#! /bin/bash 
#
# PURPOSE: 
#
# AUTHORS: 1. Rob McEwen, July 18, 2018
# 
#missionList="SimWCakeSimple.cfg Flat4c.cfg PortOALow2.cfg"
#echo "QNX bash script executing."
#cd $AUV/../offboard
#pwd
#missionList=`cat missionList.txt`
#
# if [ $# -ne 1 ]
# then
#     echo " "
#     echo " Please provide a mission file including the .cfg suffix."
#     echo " Pre-setup missions are:"
#     for mission in $missionList
#     do
# 	echo "    $mission"
#     done
#     echo " "
#     exit -1
# fi
#missionList=$*;
#missionList="${@:2}"
#echo $missionList
#recognized=false
#
#cd $AUV/missions
#pwd
#
if [ -a "$1" ] 
then
    echo " "
    if [ -n $2 ]
    then
	echo "QNX:  Starting the simulation in 2 seconds with option $2."
    else
	echo "QNX:  Starting the simulation in 2 seconds:"
    fi
    echo " "
    sleep 2
    cd $AUV/bin
    #../../offboard memscript &
    #supervisor -fastsim -plan $1 > /dev/null >& /dev/null
    supervisor -fastsim -plan $1 $2 -abort abortSimPlan.cfg
    #supervisor -sim -plan $1 $2 -abort abortSimPlan.cfg
    ls -l $AUV_LOG_DIR/latest
else
    echo "Can't find $1"
    exit -1
fi
