<?xml version="1.0" encoding="UTF-8"?>
<Mission xmlns="Tethys"
       xmlns:Control="Tethys/Control"
       xmlns:Guidance="Tethys/Guidance" 
       xmlns:Trigger="Tethys/Trigger" 
       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/Trigger http://okeanids.mbari.org/tethys/Xml/Trigger.xsd
                           Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                           Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd"
       Id="CallTest">

<!-- some high priority behaviors -->

    <Guidance:AltitudeEnvelope>
        <Parallel/>
        <Setting><Guidance:AltitudeEnvelope.minAltitude/><Units:meter/><Value>5</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.maxDepth/><Units:meter/><Value>300</Value></Setting>
    </Guidance:DepthEnvelope>

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

    <Insert Filename="Insert/Surface.xml" Id="SurfaceOps" />

    <Insert Filename="Demo/CallTestScience.xml"/>

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

    <Aggregate Id="CalledAggregate">

        <When>
            <Called/>
        </When>

        <Guidance:Point>
            <Parallel/>
            <Setting><Guidance:Point.rudderAngle/><Units:degree/><Value>20</Value></Setting>
        </Guidance:Point>

        <Guidance:Execute>
            <Sequence/>
            <Setting><Guidance:Execute.command/><String>show stack</String></Setting>
        </Guidance:Execute>

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

    </Aggregate>

    <Call Id="CallThere1" PriorityHere="false" RefId="CalledAggregate"/>

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

    <Aggregate Id="Ops">

        <Sequence/>

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

        <Call Id="CallHere" PriorityHere="true" RefId="CalledAggregate"/>

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

        <Call Id="CallThere2" PriorityHere="false" RefId="CalledAggregate"/>

        <Call Id="CallScience" PriorityHere="false" RefId="Science"/>

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

    </Aggregate>

    <Aggregate Id="Final">

        <Sequence/>

        <Guidance:GoToSurface>
            <Progression/>
        </Guidance:GoToSurface>

        <Guidance:Wait>
            <Sequence/>
            <Timeout Duration="P1M"/>
        </Guidance:Wait>

    </Aggregate>

</Mission>
