<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2008 Monterey Bay Aquarium Research Institute (MBARI)
    MBARI Proprietary Information. All Rights Reserved
-->
<Aggregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="Tethys"
           xmlns:Units="Tethys/Units"
           xmlns:Estimation="Tethys/Estimation"
           xmlns:Science="Tethys/Science"
           xmlns:Universal="Tethys/Universal"
           xmlns:Trigger="Tethys/Trigger"
           xsi:schemaLocation="Tethys http://okeanids.mbari.org/tethys/Xml/Tethys.xsd
                               Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                               Tethys/Estimation http://okeanids.mbari.org/tethys/Xml/Estimation.xsd
                               Tethys/Science http://okeanids.mbari.org/tethys/Xml/Science.xsd
                               Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd
                               Tethys/Trigger http://okeanids.mbari.org/tethys/Xml/Trigger.xsd"
       Id="Science">

    <DefineArg Name="PeakDetectChlActive"><Description>
        Turns on peak detection of Cholorphyll.
    </Description><False/></DefineArg>

    <DefineArg Name="TimeWindowPeakReport"><Description>
        If greater than zero, report a peak every window. If NaN or zero, this
        variable is ignored.
    </Description><Units:minute/><Value>NaN</Value></DefineArg>

    <DefineArg Name="HighestChlPeakReportActive"><Description>
        Turns on reporting of the highest peak value of chlorophyll on yo-yo
        profiles in a horizontal sliding window (of length
        numProfilesSlidingwindow)
    </Description><False/></DefineArg>

    <DefineArg Name="HighestSaltPeakReportActive"><Description>
        Turns on reporting of the highest peak value of salinity on yo-yo
        profiles in a horizontal sliding window (of length
        numProfilesSlidingwindow)
    </Description><False/></DefineArg>

    <DefineArg Name="HighestOilPeakReportActive"><Description>
        Turns on reporting of the highest peak value of oil on yo-yo profiles in
        a horizontal sliding window (of length numProfilesSlidingwindow)
    </Description><False/></DefineArg>

    <DefineArg Name="PatchTracking"><Description>
        If tracking a patch
    </Description><False/></DefineArg>

    <DefineArg Name="DetectTrough"><Description>
        Whether to track a trough. If false, track peak; if true, track trough.
        Default is false.
    </Description><False/></DefineArg>

<!--debug    
    </Description><True/></DefineArg>
-->

    <DefineArg Name="FilterWidthHorizontal"><Description>
        Width of boxcar filter applied to yoyo-wise chl peaks to pick out the
        highest peak.
    </Description><Units:count/><Value>3</Value></DefineArg>

    <DefineArg Name="NumProfilesSlidingwindow"><Description>
        Length of horizontal sliding window. The highest yoyo-wise chl peak
        (after low-pass filtering by a filter of length FilterWidthHorizontal)
        within this window.
    </Description><Units:count/><Value>100</Value></DefineArg>

    <DefineArg Name="OffPeakFractionHorizontal"><Description>
        When filtered horizontal value is this fraction of the peak, consider it
        outside the patch.
    </Description><Units:percent/><Value>80</Value></DefineArg>

    <DefineArg Name="PeakDetectNO3Active"><Description>
        Turns on peak detection of Nitrate (and turns on ISUS).
    </Description><False/></DefineArg>

    <DefineArg Name="PeakDetectOilActive"><Description>
        Turns on peak detection of Dissolved Oil.
    </Description><False/></DefineArg>

    <DefineArg Name="PeakDetectFDOMActive"><Description>
        Turns on peak detection of
        concentration_of_colored_dissolved_organic_matter_in_sea_water from FDOM
        sensor.
    </Description><False/></DefineArg>

    <DefineArg Name="PeakDetectSalinityActive"><Description>
        Turns on peak detection of salinity.
    </Description><False/></DefineArg>

    <DefineArg Name="UpwardDerivativeOfTemperatureActive"><Description>
        Turns on seawater temperature derivative.
    </Description><False/></DefineArg>

    <DefineArg Name="EnabledAanderaaO2"><Description>
        Automatically set to True if the Aanderaa O2 sensor is installed. Set to
        false to disable reading Aandera O2.
    </Description><Science:Aanderaa_O2.loadAtStartup/></DefineArg>

    <DefineArg Name="EnabledNeilBrown"><Description>
        Automatically set to true if the Neil Brown CTD is enabled. Set to false
        to disable reading from the Neil Brown.
    </Description><Science:CTD_NeilBrown.loadAtStartup/></DefineArg>

    <DefineArg Name="EnabledSeabird"><Description>
        Automatically set to true if the CTD is enabled. Set to false to disable
        reading from the CTD.
    </Description><Science:CTD_Seabird.loadAtStartup/></DefineArg>

    <DefineArg Name="EnabledWetLabsBB2FL"><Description>
        Automatically set to true if the the WetLabs BB2FL is enabled. Set to
        false to disable the WetLabs BB2FL.
    </Description><Science:WetLabsBB2FL.loadAtStartup/></DefineArg>

    <DefineArg Name="EnabledWetLabsSeaOWL_UV_A"><Description>
        Automatically set to true if the the WetLabs SeaOWL UV-A is enabled. Set
        to false to disable the WetLabs SeaOWL UV-A.
    </Description><Science:WetLabsSeaOWL_UV_A.loadAtStartup/></DefineArg>

    <DefineArg Name="EnabledWetLabsUBAT"><Description>
        Automatically set to true if the the WetLabs UBAT is enabled. Set to
        false to disable the WetLabs UBAT.
    </Description><Science:WetLabsUBAT.loadAtStartup/></DefineArg>

    <DefineArg Name="LowPassWindowLength"><Description>
        Low-pass window length (based on depth sensor sampling interval 0.4
        second) for low-pass filtering.
    </Description><Units:count/><Value>20</Value></DefineArg>

    <DefineArg Name="MedianFilterLen"><Description>
        Median filter length (only for chlorophyll fluorescence which tends to
        have spikes)
    </Description><Units:count/><Value>5</Value></DefineArg>

    <DefineArg Name="PeakShallowBound"><Description>
        Shallow depth bound for detecting any peak on each descent or ascent
        profile.
    </Description><Units:meter/><Value>NaN</Value></DefineArg>

    <DefineArg Name="PeakDeepBound"><Description>
        Deep depth bound for detecting any peak on each descent or ascent
        profile.
    </Description><Units:meter/><Value>NaN</Value></DefineArg>

    <DefineArg Name="DepChangeThreshForAttitudeFlip"><Description>
        Depth change threshold for determining vehicle attitude flip.
    </Description><Units:meter/><Value>2.0</Value></DefineArg>

    <DefineArg Name="ChlThreshTriggerActive"><Description>
        Turns on chlorophyll threshold trigger.
    </Description><False/></DefineArg>

    <DefineArg Name="ChlLowerThresh"><Description>
        Used only when ChlThreshTriggerActive is True. Triggered when
        chlorophyll falls in [ChlLowerThresh ChlUpperThresh]. ChlLowerThresh is
        ignored if NaN.
    </Description><Units:microgram_per_liter/><Value>NaN</Value></DefineArg>

    <DefineArg Name="ChlUpperThresh"><Description>
        Used only when ChlThreshTriggerActive is True. Triggered when
        chlorophyll falls in [ChlLowerThresh ChlUpperThresh]. ChlUpperThresh is
        ignored if NaN.
    </Description><Units:microgram_per_liter/><Value>NaN</Value></DefineArg>

    <DefineOutput Name="PeakChl"><Units:microgram_per_liter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakChlDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakChlTemperature"><Units:celsius/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakChlLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakChlLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakNO3"><Units:micromole_per_liter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakNO3Depth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakNO3Latitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakNO3Longitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakOil"><Units:kilogram_per_cubic_meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakOilDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakOilLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakOilLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakFDOM"><Units:part_per_billion/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakFDOMDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakFDOMTemperature"><Units:celsius/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakFDOMLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakFDOMLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchFDOMDistance"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakSalt"><Units:psu/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakSaltDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakSaltTemperature"><Units:celsius/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakSaltLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PeakSaltLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchChl"><Units:microgram_per_liter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchChlDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchChlLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchChlLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchChlDistance"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchSalt"><Units:psu/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchSaltDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchSaltLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchSaltLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchSaltDistance"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchOil"><Units:psu/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchOilDepth"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchOilLatitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchOilLongitude"><Units:degree/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="PatchOilDistance"><Units:meter/><Value>NaN</Value></DefineOutput>

    <DefineOutput Name="TriggeredOnChl"><False/></DefineOutput>

    <DefineOutput Name="ChlTriggering"><Units:microgram_per_liter/><Value>NaN</Value></DefineOutput>

    <Parallel/>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledAanderaaO2"/>
        </While>
        <Universal:mass_concentration_of_oxygen_in_sea_water/>
    </ReadData>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledNeilBrown"/>
            <Or><Arg Name="EnabledSeabird"/></Or>
        </While>
        <Universal:sea_water_temperature/>
        <Universal:sea_water_salinity/>
    </ReadData>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledSeabird"/>
        </While>
        <Science:CTD_Seabird.sea_water_temperature/>
        <Science:CTD_Seabird.sea_water_salinity/>
    </ReadData>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledNeilBrown"/>
            <Or><Arg Name="EnabledSeabird"/></Or>
            <And><Arg Name="UpwardDerivativeOfTemperatureActive"/></And>
        </While>
        <Universal:upward_derivative_of_sea_water_temperature/>
    </ReadData>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledWetLabsBB2FL"/>
            <Or><Arg Name="PeakDetectChlActive"/></Or>
        </While>
        <Universal:mass_concentration_of_chlorophyll_in_sea_water/>
    </ReadData>

    <ReadData Strategy="MinError">
        <While>
            <Arg Name="EnabledWetLabsUBAT"/>
        </While>
        <Science:WetLabsUBAT.average_bioluminescence/>
    </ReadData>

    <ReadData Id="Read_Oil" Strategy="MinError">
        <While>
            <Arg Name="EnabledWetLabsSeaOWL_UV_A"/>
            <Or><Arg Name="PeakDetectOilActive"/></Or>
        </While>
        <Universal:mass_concentration_of_petroleum_hydrocarbons_in_sea_water/>
    </ReadData>

    <Aggregate Id="OceanCurrent">

        <Sequence/>

        <Estimation:CurrentEstimator>
            <Parallel/>
        </Estimation:CurrentEstimator>

    </Aggregate>

    <Aggregate Id="PeakDetectChl">

        <While>
            <Arg Name="PeakDetectChlActive"/>
        </While>

        <Trigger:PeakDetectVsDepth>
            <Sequence/>
            <Setting><Trigger:PeakDetectVsDepth.detect/><Universal:mass_concentration_of_chlorophyll_in_sea_water/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.timeWindowPeakReport/><Arg Name="TimeWindowPeakReport"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.windowLength/><Arg Name="LowPassWindowLength"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.medianFilterLength/><Arg Name="MedianFilterLen"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.shallowBound/><Arg Name="PeakShallowBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.deepBound/><Arg Name="PeakDeepBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.depthChangeThresh/><Arg Name="DepChangeThreshForAttitudeFlip"/></Setting>
            <OutputArg Name="PeakChl"><Trigger:PeakDetectVsDepth.peakDetect/></OutputArg>
            <OutputArg Name="PeakChlDepth"><Trigger:PeakDetectVsDepth.peakDepth/></OutputArg>
            <OutputArg Name="PeakChlTemperature"><Trigger:PeakDetectVsDepth.peakTemperature/></OutputArg>
            <OutputArg Name="PeakChlLatitude"><Trigger:PeakDetectVsDepth.peakLatitude/></OutputArg>
            <OutputArg Name="PeakChlLongitude"><Trigger:PeakDetectVsDepth.peakLongitude/></OutputArg>
        </Trigger:PeakDetectVsDepth>

<!--debug
        <Syslog Severity="Important">PeakChl, PeakChlLatitude, PeakChlLongitude = <Arg Name="PeakChl"/><Units:microgram_per_liter/>, <Arg Name="PeakChlLatitude"/><Units:degree/>, <Arg Name="PeakChlLongitude"/><Units:degree/></Syslog>
-->

        <SendData Service="Express"><Arg Name="PeakChl"/><Arg Name="PeakChlDepth"/>
        </SendData>

    </Aggregate>

    <Aggregate Id="HighestChlPeakReport">

        <While>
            <Arg Name="HighestChlPeakReportActive"/>
        </While>

        <Trigger:PeakDetectHorizontal>
            <Sequence/>
            <Setting><Trigger:PeakDetectHorizontal.detectFrom/><Arg Name="PeakChl"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.depthFrom/><Arg Name="PeakChlDepth"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.latitudeFrom/><Arg Name="PeakChlLatitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.longitudeFrom/><Arg Name="PeakChlLongitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.patchTracking/><Arg Name="PatchTracking"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.filterWidth/><Arg Name="FilterWidthHorizontal"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.numProfilesSlidingwindow/><Arg Name="NumProfilesSlidingwindow"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.offPeakFraction/><Arg Name="OffPeakFractionHorizontal"/></Setting>
            <OutputArg Name="PatchChl"><Trigger:PeakDetectHorizontal.peakDetect/></OutputArg>
            <OutputArg Name="PatchChlDepth"><Trigger:PeakDetectHorizontal.peakDepth/></OutputArg>
            <OutputArg Name="PatchChlLatitude"><Trigger:PeakDetectHorizontal.peakLatitude/></OutputArg>
            <OutputArg Name="PatchChlLongitude"><Trigger:PeakDetectHorizontal.peakLongitude/></OutputArg>
            <OutputArg Name="PatchChlDistance"><Trigger:PeakDetectHorizontal.peakDistance/></OutputArg>
        </Trigger:PeakDetectHorizontal>

    </Aggregate>

    <Aggregate Id="PeakDetectNO3">

        <While>
            <Arg Name="PeakDetectNO3Active"/>
        </While>

        <Trigger:PeakDetectVsDepth>
            <Sequence/>
            <Setting><Trigger:PeakDetectVsDepth.detect/><Universal:mole_concentration_of_nitrate_in_sea_water/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.timeWindowPeakReport/><Arg Name="TimeWindowPeakReport"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.windowLength/><Arg Name="LowPassWindowLength"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.shallowBound/><Arg Name="PeakShallowBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.deepBound/><Arg Name="PeakDeepBound"/></Setting>
            <OutputArg Name="PeakNO3"><Trigger:PeakDetectVsDepth.peakDetect/></OutputArg>
            <OutputArg Name="PeakNO3Depth"><Trigger:PeakDetectVsDepth.peakDepth/></OutputArg>
            <OutputArg Name="PeakNO3Latitude"><Trigger:PeakDetectVsDepth.peakLatitude/></OutputArg>
            <OutputArg Name="PeakNO3Longitude"><Trigger:PeakDetectVsDepth.peakLongitude/></OutputArg>
        </Trigger:PeakDetectVsDepth>

        <SendData Service="Express"><Arg Name="PeakNO3"/><Arg Name="PeakNO3Depth"/>
        </SendData>

    </Aggregate>

    <Aggregate Id="PeakDetectOil">

        <While>
            <Arg Name="PeakDetectOilActive"/>
        </While>

        <Trigger:PeakDetectVsDepth>
            <Sequence/>
            <Setting><Trigger:PeakDetectVsDepth.detect/><Universal:mass_concentration_of_petroleum_hydrocarbons_in_sea_water/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.timeWindowPeakReport/><Arg Name="TimeWindowPeakReport"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.windowLength/><Arg Name="LowPassWindowLength"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.shallowBound/><Arg Name="PeakShallowBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.deepBound/><Arg Name="PeakDeepBound"/></Setting>
            <OutputArg Name="PeakOil"><Trigger:PeakDetectVsDepth.peakDetect/></OutputArg>
            <OutputArg Name="PeakOilDepth"><Trigger:PeakDetectVsDepth.peakDepth/></OutputArg>
            <OutputArg Name="PeakOilLatitude"><Trigger:PeakDetectVsDepth.peakLatitude/></OutputArg>
            <OutputArg Name="PeakOilLongitude"><Trigger:PeakDetectVsDepth.peakLongitude/></OutputArg>
        </Trigger:PeakDetectVsDepth>

<!--debug
        <Syslog Severity="Important">PeakOil, PeakOilDepth, PeakOilTemperature, PeakOilLatitude, PeakOilLongitude = <Arg Name="PeakOil"/><Units:kilogram_per_cubic_meter/>, <Arg Name="PeakOilDepth"/><Units:meter/>, <Arg Name="PeakOilTemperature"/><Units:celsius/>, <Arg Name="PeakOilLatitude"/><Units:degree/>, <Arg Name="PeakOilLongitude"/><Units:degree/></Syslog>
-->

        <SendData Service="Express"><Arg Name="PeakOil"/><Arg Name="PeakOilDepth"/>
        </SendData>

    </Aggregate>

    <Aggregate Id="HighestOilPeakReport">

        <While>
            <Arg Name="HighestOilPeakReportActive"/>
        </While>

        <Trigger:PeakDetectHorizontal>
            <Sequence/>
            <Setting><Trigger:PeakDetectHorizontal.detectFrom/><Arg Name="PeakOil"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.depthFrom/><Arg Name="PeakOilDepth"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.latitudeFrom/><Arg Name="PeakOilLatitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.longitudeFrom/><Arg Name="PeakOilLongitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.patchTracking/><Arg Name="PatchTracking"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.filterWidth/><Arg Name="FilterWidthHorizontal"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.numProfilesSlidingwindow/><Arg Name="NumProfilesSlidingwindow"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.offPeakFraction/><Arg Name="OffPeakFractionHorizontal"/></Setting>
            <OutputArg Name="PatchOil"><Trigger:PeakDetectHorizontal.peakDetect/></OutputArg>
            <OutputArg Name="PatchOilDepth"><Trigger:PeakDetectHorizontal.peakDepth/></OutputArg>
            <OutputArg Name="PatchOilLatitude"><Trigger:PeakDetectHorizontal.peakLatitude/></OutputArg>
            <OutputArg Name="PatchOilLongitude"><Trigger:PeakDetectHorizontal.peakLongitude/></OutputArg>
            <OutputArg Name="PatchOilDistance"><Trigger:PeakDetectHorizontal.peakDistance/></OutputArg>
        </Trigger:PeakDetectHorizontal>

    </Aggregate>

    <Aggregate Id="PeakDetectFDOM">

        <While>
            <Arg Name="PeakDetectFDOMActive"/>
        </While>

        <Trigger:PeakDetectVsDepth>
            <Sequence/>
            <Setting><Trigger:PeakDetectVsDepth.detect/><Universal:concentration_of_colored_dissolved_organic_matter_in_sea_water/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.timeWindowPeakReport/><Arg Name="TimeWindowPeakReport"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.windowLength/><Arg Name="LowPassWindowLength"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.shallowBound/><Arg Name="PeakShallowBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.deepBound/><Arg Name="PeakDeepBound"/></Setting>
            <OutputArg Name="PeakFDOM"><Trigger:PeakDetectVsDepth.peakDetect/></OutputArg>
            <OutputArg Name="PeakFDOMDepth"><Trigger:PeakDetectVsDepth.peakDepth/></OutputArg>
            <OutputArg Name="PeakFDOMTemperature"><Trigger:PeakDetectVsDepth.peakTemperature/></OutputArg>
            <OutputArg Name="PeakFDOMLatitude"><Trigger:PeakDetectVsDepth.peakLatitude/></OutputArg>
            <OutputArg Name="PeakFDOMLongitude"><Trigger:PeakDetectVsDepth.peakLongitude/></OutputArg>
        </Trigger:PeakDetectVsDepth>

        <SendData Service="Express"><Arg Name="PeakFDOM"/><Arg Name="PeakFDOMDepth"/>
        </SendData>

    </Aggregate>

    <Aggregate Id="PeakDetectSalinity">

        <While>
            <Arg Name="PeakDetectSalinityActive"/>
        </While>

        <Trigger:PeakDetectVsDepth>
            <Sequence/>
            <Setting><Trigger:PeakDetectVsDepth.detect/><Universal:sea_water_salinity/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.timeWindowPeakReport/><Arg Name="TimeWindowPeakReport"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.windowLength/><Arg Name="LowPassWindowLength"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.medianFilterLength/><Arg Name="MedianFilterLen"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.shallowBound/><Arg Name="PeakShallowBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.deepBound/><Arg Name="PeakDeepBound"/></Setting>
            <Setting><Trigger:PeakDetectVsDepth.depthChangeThresh/><Arg Name="DepChangeThreshForAttitudeFlip"/></Setting>
            <OutputArg Name="PeakSalt"><Trigger:PeakDetectVsDepth.peakDetect/></OutputArg>
            <OutputArg Name="PeakSaltDepth"><Trigger:PeakDetectVsDepth.peakDepth/></OutputArg>
            <OutputArg Name="PeakSaltTemperature"><Trigger:PeakDetectVsDepth.peakTemperature/></OutputArg>
            <OutputArg Name="PeakSaltLatitude"><Trigger:PeakDetectVsDepth.peakLatitude/></OutputArg>
            <OutputArg Name="PeakSaltLongitude"><Trigger:PeakDetectVsDepth.peakLongitude/></OutputArg>
        </Trigger:PeakDetectVsDepth>

<!--debug
        <Syslog Severity="Important">PeakSalt, PeakSaltDepth, PeakSaltTemperature, PeakSaltLatitude, PeakSaltLongitude = <Arg Name="PeakSalt"/><Units:psu/>, <Arg Name="PeakSaltDepth"/><Units:meter/>, <Arg Name="PeakSaltTemperature"/><Units:celsius/>, <Arg Name="PeakSaltLatitude"/><Units:degree/>, <Arg Name="PeakSaltLongitude"/><Units:degree/></Syslog>
-->

        <SendData Service="Express"><Arg Name="PeakSalt"/><Arg Name="PeakSaltDepth"/>
        </SendData>

    </Aggregate>

    <Aggregate Id="HighestSaltPeakReport">

        <While>
            <Arg Name="HighestSaltPeakReportActive"/>
        </While>

        <Trigger:PeakDetectHorizontal>
            <Sequence/>
            <Setting><Trigger:PeakDetectHorizontal.detectFrom/><Arg Name="PeakSalt"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.depthFrom/><Arg Name="PeakSaltDepth"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.latitudeFrom/><Arg Name="PeakSaltLatitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.longitudeFrom/><Arg Name="PeakSaltLongitude"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.patchTracking/><Arg Name="PatchTracking"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.filterWidth/><Arg Name="FilterWidthHorizontal"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.numProfilesSlidingwindow/><Arg Name="NumProfilesSlidingwindow"/></Setting>
            <Setting><Trigger:PeakDetectHorizontal.offPeakFraction/><Arg Name="OffPeakFractionHorizontal"/></Setting>
            <OutputArg Name="PatchSalt"><Trigger:PeakDetectHorizontal.peakDetect/></OutputArg>
            <OutputArg Name="PatchSaltDepth"><Trigger:PeakDetectHorizontal.peakDepth/></OutputArg>
            <OutputArg Name="PatchSaltLatitude"><Trigger:PeakDetectHorizontal.peakLatitude/></OutputArg>
            <OutputArg Name="PatchSaltLongitude"><Trigger:PeakDetectHorizontal.peakLongitude/></OutputArg>
            <OutputArg Name="PatchSaltDistance"><Trigger:PeakDetectHorizontal.peakDistance/></OutputArg>
        </Trigger:PeakDetectHorizontal>

    </Aggregate>

    <Aggregate Id="ChlThreshTrigger">

        <While>
            <Arg Name="ChlThreshTriggerActive"/>
        </While>

        <Trigger:ValueDetect>
            <Sequence/>
            <Setting><Trigger:ValueDetect.detect/><Arg Name="PeakChl"/></Setting>
            <Setting><Trigger:ValueDetect.lowerThreshold/><Arg Name="ChlLowerThresh"/></Setting>
            <Setting><Trigger:ValueDetect.upperThreshold/><Arg Name="ChlUpperThresh"/></Setting>
            <OutputArg Name="ChlTriggering"><Trigger:ValueDetect.outputValue/></OutputArg>
        </Trigger:ValueDetect>

        <Assign><Sequence/><Arg Name="TriggeredOnChl"/><True/></Assign>

    </Aggregate>

</Aggregate>
