<?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
targetDepth = 40      # mission's min/max depth
depthDelta = 2        # infections can occur with delta of min/max depth
maintainCycles = 2.5*60*10 # make sure target depth is maintained for 10 minutes.     
reachedDepth = False
reachedDepthAt = -1
data = slate.read("depth")[0]
for i in range(len(data)):
  depth = abs(float(data[i].data))
  # wait to start looking for depth excursions until depth reached
  if reachedDepth == False and depth >= targetDepth:
    reachedDepth = True
    reachedDepthAt = i;
    passed = True
  # only look for depth excursions for a while
  if reachedDepthAt > 0 and i - reachedDepthAt >= maintainCycles:
    break
  # look for depth excursions
  if reachedDepth == True and not utils.withinDelta(depth, targetDepth, depthDelta):
    print("|depth(%f) - targetDepth(%f)| > depthDelta(%f)" % (depth, targetDepth, depthDelta) )
    passed = False
    break
TEST_CODE_END
-->

    <Timeout Duration="P1H"/>

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

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

    <Aggregate Id="TestAggregate">

        <Sequence/>

        <Timeout Duration="P30M30S"></Timeout>

        <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>

        <Guidance:DepthEnvelope>
            <Parallel/>
            <Setting><Guidance:DepthEnvelope.minDepth/><Units:meter/><Value>40</Value></Setting>
            <Setting><Guidance:DepthEnvelope.maxDepth/><Units:meter/><Value>40</Value></Setting>
            <Setting><Guidance:DepthEnvelope.upPitch/><Units:degree/><Value>15</Value></Setting>
            <Setting><Guidance:DepthEnvelope.downPitch/><Units:degree/><Value>-15</Value></Setting>
        </Guidance:DepthEnvelope>

    </Aggregate>

</Mission>
