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

    <Description>
        Minimum working example to demostrate a bug with setting a timeout from
        a config variable.
    </Description>

    <DefineArg Name="ArgTimeout"><Units:second/><Value>30</Value></DefineArg>

    <DefineArg Name="ConfigTimeout"><Description>
        How long to wait for an ESP sample to complete.
    </Description><Science:ESPComponent.sampleTimeout/></DefineArg>

    <Aggregate>

        <Sequence/>

        <Syslog Severity="Important">Trying hard-coded timeout.</Syslog>

        <ReadDatum>
            <Timeout Duration="P10S"/>
            <Science:ESPComponent.sample_number/>
        </ReadDatum>

        <Syslog Severity="Important">Used hard-coded timeout.</Syslog>

    </Aggregate>

    <Aggregate>

        <Sequence/>

        <Syslog Severity="Important">Trying timeout argument with default specified in mission. (<Arg Name="ArgTimeout"/><Units:second/>)</Syslog>

        <ReadDatum>
            <Timeout Duration="ArgTimeout"/>
            <Science:ESPComponent.sample_number/>
        </ReadDatum>

        <Syslog Severity="Important">Used argument timeout.</Syslog>

    </Aggregate>

    <Aggregate Id="Callable">

        <DefineArg Name="Timeout"><Units:second/><Value>30</Value></DefineArg>

        <When>
            <Called/>
        </When>

        <Syslog Severity="Important">Trying config value as timeout passed to arg of another aggregate. (<Arg Name="Timeout"/><Units:second/>)</Syslog>

        <ReadDatum>
            <Timeout Duration="Timeout"/>
            <Science:ESPComponent.sample_number/>
        </ReadDatum>

        <Syslog Severity="Important">Used config timeout passed to another aggregate.</Syslog>

    </Aggregate>

    <Assign><Sequence/><Arg Name="Callable:Timeout"/><Arg Name="ConfigTimeout"/></Assign>

    <Call Id="Called" RefId="Callable"/>

    <Aggregate>

        <Sequence/>

        <Syslog Severity="Important">Trying argument timeout defaulted to config value. (<Arg Name="ConfigTimeout"/><Units:second/>)</Syslog>

        <ReadDatum>
            <Timeout Duration="ConfigTimeout"/>
            <Science:ESPComponent.sample_number/>
        </ReadDatum>

        <Syslog Severity="Important">Used arg timeout defaulted to config value.</Syslog>

    </Aggregate>

</Mission>
