##############################################################
#
# PURPOSE: Convert binary files generated by the flight code into
#          Matlab-readable ASCII files.  COMPLETE CONVERSION
# AUTHOR:  rsm
# DATE:    99/12/20
# NOTES:   See the companion Matlab script loadData.m
#          00/1/11: The -a option, which supposedly checks file existance
#                   doesn't appear to work.  -f determines regularity.
#
#
##############################################################
#
  if [ -f simulation.log ]
  then
    echo "Converting simulation.log"
    #
    # If an argument exists, skip that many records.
    #
    if [ $1 ]
    then
      logToMatlab -skip $1 simulation.log > dataS.m
    else
      logToMatlab simulation.log > dataS.m
    fi
  fi

  if [ -f navigation.log ]
  then
    echo "Converting navigation.log"
    if [ $1 ]
    then
      logToMatlab -skip $1 navigation.log > dataN.m
    else
      logToMatlab navigation.log > dataN.m
    fi
  fi

  if [ -f dynamicControl.log ]
  then
    echo "Converting dynamicControl.log"
    if [ $1 ]
    then
      logToMatlab -skip $1 dynamicControl.log > dataD.m
    else
      logToMatlab dynamicControl.log > dataD.m
    fi
  fi

  if [ -f ctdlog.log ]
  then
    echo "Converting ctdlog.log"
    if [ $1 ]
    then
      logToMatlab -skip $1 ctdlog.log > dataCTD.m
    else
      logToMatlab ctdlog.log > dataCTD.m
    fi
  fi

  if [ -f parosci.log ]
  then
    echo "Converting parosci.log"
    if [ $1 ]
    then
      logToMatlab -skip $1 parosci.log > dataPS.m
    else
      logToMatlab parosci.log > dataPS.m
    fi
  fi


  if [ -f psa916.log ]
  then
    echo "Converting psa916.log"
    if [ $1 ]
    then
      logToMatlab -skip $1 psa916.log > dataPSA.m
    else
      logToMatlab psa916.log > dataPSA.m
    fi
  fi

  if [ -f gps.log ]
  then
   echo "Converting gps.log"
   logToMatlab gps.log > dataGPS.m
  fi

  if [ -f kvhInclinometer.log ]
  then
    echo "Converting kvhInclinometer"
    if [ $1 ]
    then
      logToMatlab -skip $1 kvhInclinometer.log > dataINC.m
    else
      logToMatlab kvhInclinometer.log > dataINC.m
    fi
  fi

  if [ -f kvhCompass.log ]
  then
    echo "Converting kvhCompass"
    if [ $1 ]
    then
      logToMatlab -skip $1 kvhCompass.log > dataCOM.m
    else
      logToMatlab kvhCompass.log > dataCOM.m
    fi
  fi

  if [ -f crossbow.log ]
  then
    echo "Converting Crossbow data"
    if [ $1 ]
    then
      let nlines=$1
      logToMatlab -skip $nlines crossbow.log > dataCrossB.m
    else
      logToMatlab crossbow.log > dataCrossB.m
    fi
  fi


