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

    <Description>
        Rotate the sampler 1x at a specified depth
    </Description>

    <DefineArg Name="MissionTimeout"><Description>
        Maximum duration of mission
    </Description><Units:hour/><Value>1</Value></DefineArg>

    <DefineArg Name="BuoyancyNeutral"><Description>
        Buoyancy bladder position while performing the YoYo behavior. Defaults
        to buoyancyNeutral setting in the Config/Control.cfg file. Set to NaN cc
        for active buoyancy
    </Description><Control:VerticalControl.buoyancyNeutral/></DefineArg>

    <DefineArg Name="MassDefault"><Description>
        Static setting for mass during the mission. Set to NaN mm for active
        mass position
    </Description><Control:VerticalControl.massDefault/></DefineArg>

    <DefineArg Name="Rotate"><Units:bool/><Value>1</Value></DefineArg>

    <DefineArg Name="Depth01"><Description>
        Depth of sample 1.
    </Description><Units:meter/><Value>40</Value></DefineArg>

    <DefineArg Name="SettleTime"><Description>
        How long to wait after reaching target depth before triggering sample.
    </Description><Units:second/><Value>0</Value></DefineArg>

    <DefineArg Name="RudderAngle"><Description>
        Rudder angle to use while performing the spiral cast.
    </Description><Units:degree/><Value>13</Value></DefineArg>

    <DefineArg Name="Speed"><Description>
        Speed while performing the spiral cast.
    </Description><Units:meter_per_second/><Value>1</Value></DefineArg>

    <DefineArg Name="MinAltitude"><Description>
        Minimum altitude for the entire mission.
    </Description><Units:meter/><Value>5</Value></DefineArg>

    <DefineArg Name="MaxDepth"><Description>
        Maximum depth for the entire mission.
    </Description><Units:meter/><Value>225</Value></DefineArg>

    <Timeout Duration="MissionTimeout"/>

    <Insert Filename="Insert/Science.xml">
        <RedefineArg Name="PeakDetectChlActive"><True/></RedefineArg>
    </Insert>

    <Insert Filename="Insert/NeedComms.xml" Id="NeedComms"/>

    <Assign><Sequence/><Arg Name="NeedComms:DiveInterval"/><Arg Name="MissionTimeout"/></Assign>

    <Assign><Sequence/><Arg Name="NeedComms:SurfaceSpeed"/><Arg Name="Speed"/></Assign>

    <Insert Filename="Insert/StandardEnvelopes.xml"/>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MinAltitude"/><Arg Name="MinAltitude"/></Assign>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MaxDepth"/><Arg Name="MaxDepth"/></Assign>

    <Call Id="StartingMission" RefId="NeedComms"/>

    <Guidance:Pitch>
        <Parallel/>
        <Setting><Guidance:Pitch.massPosition/><Arg Name="MassDefault"/></Setting>
    </Guidance:Pitch>

    <Guidance:Buoyancy>
        <Parallel/>
        <Setting><Guidance:Buoyancy.position/><Arg Name="BuoyancyNeutral"/></Setting>
    </Guidance:Buoyancy>

    <Guidance:SetSpeed>
        <Parallel/>
        <Setting><Guidance:SetSpeed.speed/><Arg Name="Speed"/></Setting>
    </Guidance:SetSpeed>

    <Assign><Sequence/><Arg Name="NeedComms:DiveInterval"/><Arg Name="MissionTimeout"/></Assign>

    <Guidance:Point>
        <Parallel/>
        <Setting><Guidance:Point.rudderAngle/><Arg Name="RudderAngle"/></Setting>
    </Guidance:Point>

    <Insert Filename="Insert/SampleAtDepth.xml"/>

    <Assign><Sequence/><Arg Name="SampleAtDepth:SettleTime"/><Arg Name="SettleTime"/></Assign>

    <Assign><Sequence/><Arg Name="SampleAtDepth:RotateOnly"/><Arg Name="Rotate"/></Assign>

    <Aggregate Id="SampleWithinEnvelopesWrapper">

        <DefineArg Name="TargetDepth"><Units:meter/><Value>1</Value></DefineArg>

        <When>
            <Called/>
        </When>

        <Break>
            <Universal:depth/>
            <Ge><Arg Name="MaxDepth"/></Ge>
            <And><Arg Name="TargetDepth"/><Ge><Arg Name="MaxDepth"/></Ge></And>
            <Or><Universal:height_above_sea_floor/><Le><Arg Name="MinAltitude"/></Le><And><Arg Name="TargetDepth"/><Ge><Universal:depth/></Ge></And></Or>
        </Break>

        <Assign><Sequence/><Arg Name="SampleAtDepth:TargetDepth"/><Arg Name="TargetDepth"/></Assign>

        <Call Id="SampleWithinEnvelopes" RefId="SampleAtDepth"/>

    </Aggregate>

    <Aggregate Id="Cast">

        <Sequence/>

        <Assign><Sequence/><Arg Name="SampleWithinEnvelopesWrapper:TargetDepth"/><Arg Name="Depth01"/></Assign>

        <Call Id="Depth01" RefId="SampleWithinEnvelopesWrapper"/>

    </Aggregate>

    <Call Id="CastComplete" RefId="NeedComms"/>

</Mission>
