<?xml version="1.0" encoding="UTF-8"?>
<Mission xmlns="Tethys"
       xmlns:Control="Tethys/Control"
       xmlns:Guidance="Tethys/Guidance" 
       xmlns:Units="Tethys/Units"
       xmlns:Universal="Tethys/Universal"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="Tethys http://okeanids.mbari.org/tethys/Xml/Tethys.xsd
                           Tethys/Control http://okeanids.mbari.org/tethys/Xml/Control.xsd
                           Tethys/Guidance http://okeanids.mbari.org/tethys/Xml/Guidance.xsd
                           Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                           Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd"
       Id="TestMission">

<!--
TEST_CODE_START
tindex = 0
tdepths = [5, 10, 15, 20, 15, 10, 5]
timer = None
depthDelta = 1
data = slate.read("depth")[0]
for i in range(len(data)):
  depth = abs(float(data[i].data)) 

  # have we reached our target depth, if yes start the timer
  if utils.withinDelta(depth, tdepths[tindex], depthDelta) and timer == None:
    timer = data[i].timestamp

  # did we fall out of our target depth, or 
  # have we reached the end of our data
  if (not utils.withinDelta(depth, tdepths[tindex], depthDelta) \
      or i == len(data) - 1) and timer != None:
    # calculate how long we stayed at the target depth
    diff = utils.timeDelta2Secs(data[i].timestamp - timer)
    timer = None
    if diff < 300:
      # didn't stay at depth for at least 5 minutes
      continue
    # everything is ok move on to the next target depth
    tindex = tindex + 1 
    # did we reach all of our target depths?
    if tindex == len(tdepths):
      # yes, we passed the test
      passed = True
      break
TEST_CODE_END
-->

    <Timeout Duration="P5H"/>

    <Insert Filename="RegressionTests/InsertHighPriority.xml"/>

    <Insert Filename="RegressionTests/InsertSurfaceOps.xml"/>

    <Aggregate Id="Ops">

        <Sequence/>

        <Guidance:SetSpeed>
            <Parallel/>
            <Setting><Guidance:SetSpeed.speed/><Units:meter_per_second/><Value>1</Value></Setting>
        </Guidance:SetSpeed>

        <Guidance:Point>
            <Parallel/>
            <Setting><Guidance:Point.heading/><Units:degree/><Value>-135</Value></Setting>
        </Guidance:Point>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>5</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>10</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>15</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>20</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>15</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>10</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

        <Aggregate>

            <Sequence/>

            <Timeout Duration="P10M"/>

            <Guidance:Pitch>
                <Parallel/>
                <Setting><Guidance:Pitch.depth/><Units:meter/><Value>5</Value></Setting>
            </Guidance:Pitch>

        </Aggregate>

    </Aggregate>

</Mission>
