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

    <Timeout Duration="P5H"/>

<!-- some high priority behaviors -->

    <Guidance:AltitudeEnvelope>
        <Parallel/>
        <Setting><Guidance:AltitudeEnvelope.minAltitude/><Units:meter/><Value>20</Value></Setting>
    </Guidance:AltitudeEnvelope>

    <Guidance:OffshoreEnvelope>
        <Parallel/>
        <Setting><Guidance:OffshoreEnvelope.minOffshore/><Units:kilometer/><Value>1</Value></Setting>
        <Setting><Guidance:OffshoreEnvelope.maxOffshore/><Units:kilometer/><Value>50</Value></Setting>
    </Guidance:OffshoreEnvelope>

    <Guidance:DepthEnvelope>
        <Parallel/>
        <Setting><Guidance:DepthEnvelope.minDepth/><Units:meter/><Value>0</Value></Setting>
        <Setting><Guidance:DepthEnvelope.maxDepth/><Units:meter/><Value>300</Value></Setting>
    </Guidance:DepthEnvelope>

<!-- Initial GPS (and Iridium) Update -->

    <Aggregate Id="SurfaceOps">

        <Sequence/>

        <Guidance:GoToSurface>
            <Parallel/>
        </Guidance:GoToSurface>

        <Guidance:GoToSurface>
            <Sequence/>
        </Guidance:GoToSurface>

        <ReadDatum>
            <Universal:latitude_fix/>
        </ReadDatum>

    </Aggregate>

    <Aggregate Id="NeedSatFix">

        <When>
            <Elapsed><Universal:time_fix/></Elapsed>
            <Gt><Units:minute/><Value>10</Value></Gt>
        </When>

        <Guidance:GoToSurface>
            <Parallel/>
        </Guidance:GoToSurface>

        <Guidance:GoToSurface>
            <Sequence/>
        </Guidance:GoToSurface>

        <Aggregate Id="SurfOps">

            <Sequence/>

            <Preemptive>
                <True/>
            </Preemptive>

            <ReadDatum>
                <Universal:latitude_fix/>
            </ReadDatum>

        </Aggregate>

    </Aggregate>

    <Aggregate Id="TestAggregate">

        <Sequence/>

        <Guidance:KeepStation>
            <Parallel/>
            <Setting><Guidance:KeepStation.longitude/><Units:degree/><Value>-121.89</Value></Setting>
            <Setting><Guidance:KeepStation.radius/><Units:meter/><Value>500</Value></Setting>
        </Guidance:KeepStation>

        <Guidance:DepthEnvelope>
            <Parallel/>
            <Setting><Guidance:DepthEnvelope.minDepth/><Units:meter/><Value>15</Value></Setting>
            <Setting><Guidance:DepthEnvelope.maxDepth/><Units:meter/><Value>15</Value></Setting>
        </Guidance:DepthEnvelope>

        <Guidance:Wait>
            <Sequence/>
            <Setting><Guidance:Wait.duration/><Units:minute/><Value>120</Value></Setting>
        </Guidance:Wait>

    </Aggregate>

</Mission>
