# LB2020P5.MI
#
#	PELAGIA
#
#  Retrieves waypoints from mafiles/goto_l20.ma (which is GCCS generated)
#  Retrieves envelope  from mafiles/yo20.ma (3m below surface to 3m above bottom)
#  Retrieves climb to surface controls from mafiles/surfac10.ma
#  Retrieves sampling behavior from mafiles/sample10.ma (CTD)
#                                   mafiles/sample20.ma (Optode)
#                                   mafiles/sample30.ma (Scatterometer)
#                                   mafiles/sample40.ma (BBAM)
#
#  Surfaces:
#     mission done (finished all the waypoints)
#     bad altimeter hit (yo finishes)
#     If requested by science
#     Every 300 minutes
#
# 24-May-05 hfargher@DinkumSoftware.com Initial (based on gylov001.mi)
# 30-Sep-08 hfargher@webbresearch.com Add max_wpt_distance to abend behavior
# 11-Nov-11 catherine.edwards@skio.usg.edu Customize for GCCS
# 18-Jan-12 cbc@unc.edu Add sampling behavior
# 30-Jan-12 cbc@unc.edu Change overdepth_sample_time from 10.0 to 20.0 per Ben Allsup
#

sensor: u_use_current_correction(nodim) 0   #  0 calculate, but do not use m_water_vx/y
                                            #  1 use m_water_vx/y to navigate AND aim

sensor: c_science_send_all(bool) 0  # T->send all sci_ vars from science but still log them on science.
                                    # F->just send standard subset but still log them all on science.

sensor: c_science_all_on_enabled(bool)   0  # in, non-zero enables c_science_all_on	
                                            # disable this sensor to allow for individually 
                                            # sampled science sensors ie sample11.ma and greater

behavior: abend
    b_arg: overdepth_sample_time(s)       20.0 # how often to check

                                               # MS_ABORT_OVERTIME
    b_arg: overtime(s)                    -1.0 # < 0 disables

                                                # MS_ABORT_WPT_TOOFAR
    b_arg: max_wpt_distance(m)            10000 # Maximum allowable distance to a waypoint
                                        

    b_arg: samedepth_for_sample_time(s)   30.0 # how often to check

# Come up if haven't had comms for a while, 20 minutes
#behavior: surface
#    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
#    b_arg: start_when(enum) 12     # BAW_NOCOMM_SECS 12, when have not had comms for WHEN_SECS secs
#    b_arg: when_secs(sec)   120    # 20 min, How long between surfacing, only if start_when==6,9, or 12
#    b_arg: end_action(enum) 1      # 0-quit, 1 wait for ^C quit/resume, 2 resume, 3 drift til "end_wpt_dist"
#    b_arg: keystroke_wait_time(sec) 300   # how long to wait for control-C



    # Come up when mission done
    # This is determined by no one steering in x-y plane (no waypoints)
behavior: surface
    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
    b_arg: start_when(enum)   3   # 0-immediately, 1-stack idle 2-pitch idle 3-heading idle
                                  # 6-when_secs, 7-when_wpt_dist
    b_arg: end_action(enum)  0     # 0-quit, 1 wait for ^C quit/resume, 2 resume
    b_arg: gps_wait_time(s) 300    # how long to wait for gps
    b_arg: keystroke_wait_time(s) 180   # how long to wait for control-C


    # Come up briefly if "yo" finishes
    # This happens if a bad altimeter hit causes a dive and climb to
    # complete in same cycle.  We surface and hopefully yo restarts
behavior: surface
    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
    b_arg: start_when(enum)   2   # 0-immediately, 1-stack idle 2-pitch idle 3-heading idle
                                  # 6-when_secs, 7-when_wpt_dist
    b_arg: end_action(enum)   1     # 0-quit, 1 wait for ^C quit/resume, 2 resume
    b_arg: gps_wait_time(s) 300    # how long to wait for gps
    b_arg: keystroke_wait_time(s) 15   # how long to wait for control-C



    # Come up every way point
#behavior: surface
#    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
#    b_arg: start_when(enum)    8   # 0-immediately, 1-stack idle 2-depth idle 6-when_secs
                                  # 7-when_wpt_dist 8-when hit waypoint 9-every when_secs
#    b_arg: when_wpt_dist(m)  10   # how close to waypoint before surface,

#    b_arg: end_action(enum)   1     # 0-quit, 1 wait for ^C quit/resume, 2 resume
#    # b_arg: report_all(bool)   0     # T->report all sensors once, F->just gps
#    b_arg: gps_wait_time(s) 300    # how long to wait for gps
#    b_arg: keystroke_wait_time(s) 300   # how long to wait for control-C


    # Come up when requested by science
behavior: surface
    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
    b_arg: start_when(enum)     11 # BAW_SCI_SURFACE
    b_arg: end_action(enum)   1     # 0-quit, 1 wait for ^C quit/resume, 2 resume
    b_arg: report_all(bool)   0     # T->report all sensors once, F->just gps
    b_arg: gps_wait_time(s) 300    # how long to wait for gps
    b_arg: keystroke_wait_time(s) 300   # how long to wait for control-C


    # Come up every 300 minutes
behavior: surface
    b_arg: args_from_file(enum) 10 # read from mafiles/surfac10.ma
    b_arg: start_when(enum)    9   # 0-immediately, 1-stack idle 2-depth idle 6-when_secs
                                  # 7-when_wpt_dist 8-when hit waypoint 9-every when_secs
    b_arg: when_secs(s)   18000   # How long between surfacing, only if start_when==6 or 9

    b_arg: end_action(enum)   1     # 0-quit, 1 wait for ^C quit/resume, 2 resume
    b_arg: report_all(bool)   1     # T->report all sensors once, F->just gps
    b_arg: gps_wait_time(s) 300    # how long to wait for gps
    b_arg: keystroke_wait_time(s) 300   # how long to wait for control-C



behavior: goto_list
    b_arg: args_from_file(enum) 20   # read from mafiles/goto_l20.ma
    b_arg: start_when(enum)      0   # 0-immediately, 1-stack idle 2-heading idle


behavior: yo
    b_arg: args_from_file(enum) 20   # read from mafiles/yo20.ma
    b_arg: start_when(enum) 2        #  0-immediately, 1-stack idle 2-depth idle
    b_arg: end_action(enum) 2        # 0-quit, 2 resume


# Sample CTD
behavior: sample
b_arg: args_from_file(enum)            10  # >= 0 enables reading from mafiles/sample10.ma

# Sample Optode
behavior: sample
b_arg: args_from_file(enum)            20  # >= 0 enables reading from mafiles/sample20.ma

# Sample Wetlabs custom 3-param fluorescence/scattering meter
behavior: sample
b_arg: args_from_file(enum)            30  # >= 0 enables reading from mafiles/sample30.ma

# Sample Wetlabs BBAM beam attenuation meter simulator
behavior: sample
b_arg: args_from_file(enum)            40  # >= 0 enables reading from mafiles/sample40.ma

behavior: prepare_to_dive
    b_arg: start_when(enum) 0     # 0-immediately, 1-stack idle 2-depth idle
    b_arg: wait_time(s)   720     # 12 minutes, how long to wait for gps


behavior: sensors_in       # Turn most input sensors off
