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

<!--
TEST_CODE_START

# Set passed to true because there are no post-run tests.
# If a crtical syslog is encountered in the code below, the test will fail.
passed = True

TEST_CODE_END
-->

    <Description>
        Test adding two angular values.
    </Description>

    <DefineArg Name="SearchBearing"><Description>
        Bearing to swim searching for front.
    </Description><Units:degree/><Value>270</Value></DefineArg>

    <DefineArg Name="ReturnBearing"><Description>
        (INTERNAL VARIABLE) Bearing to swim after passing front on inbound leg.
    </Description><Units:degree/><Value>NaN</Value></DefineArg>

    <Syslog Severity="Important">Search bearing: <Arg Name="SearchBearing"/><Units:degree/></Syslog>

    <Assign><Sequence/><Arg Name="ReturnBearing"/><Arg Name="SearchBearing"/><Add><Units:degree/><Value>-180</Value></Add></Assign>

    <Syslog Severity="Important">Calculated return bearing: <Arg Name="ReturnBearing"/><Units:degree/></Syslog>

    <Aggregate>

        <Sequence/>

        <Break><Arg Name="ReturnBearing"/>
            <Eq><Units:degree/><Value>90</Value></Eq>
        </Break>

        <Syslog Severity="Critical">ReturnBearing is not 90</Syslog>

    </Aggregate>

    <Assign><Sequence/><Arg Name="ReturnBearing"/><Arg Name="SearchBearing"/><Sub><Units:degree/><Value>-180</Value></Sub></Assign>

    <Syslog Severity="Important">Calculated return bearing: <Arg Name="ReturnBearing"/><Units:degree/></Syslog>

    <Aggregate>

        <Sequence/>

        <Break><Arg Name="ReturnBearing"/>
            <Eq><Units:degree/><Value>450</Value></Eq>
        </Break>

        <Syslog Severity="Critical">ReturnBearing is not 450</Syslog>

    </Aggregate>

    <Assign><Sequence/><Arg Name="ReturnBearing"/><Arg Name="SearchBearing"/><Sub><Units:degree/><Value>180</Value></Sub></Assign>

    <Syslog Severity="Important">Calculated return bearing: <Arg Name="ReturnBearing"/><Units:degree/></Syslog>

    <Aggregate>

        <Sequence/>

        <Break><Arg Name="ReturnBearing"/>
            <Eq><Units:degree/><Value>90</Value></Eq>
        </Break>

        <Syslog Severity="Critical">ReturnBearing is not 90</Syslog>

    </Aggregate>

    <Assign><Sequence/><Arg Name="ReturnBearing"/><Arg Name="SearchBearing"/><Sub><Arg Name="SearchBearing"/></Sub></Assign>

    <Syslog Severity="Important">Calculated return bearing: <Arg Name="ReturnBearing"/><Units:degree/></Syslog>

    <Aggregate>

        <Sequence/>

        <Break><Arg Name="ReturnBearing"/>
            <Eq><Units:degree/><Value>0</Value></Eq>
        </Break>

        <Syslog Severity="Critical">ReturnBearing is not 0</Syslog>

    </Aggregate>

</Mission>
