<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: waterlevel.xml 4839 2006-10-02 17:07:03Z schwehr $ -->
<!-- $Revision: 4839 $ -->
<!-- $Date: 2006-10-02 13:07:03 -0400 (Mon, 02 Oct 2006) $ -->

<!-- Example by Kurt Schwehr for the Hampton Roads/Elizabeth River demonstration -->

<ais-binary-message version="1.0">

  <struct name="position2d">
    <description>Generic representation of position on the WGS84 sphereoid</description>
    <field name="longitude" numberofbits="28" type="udecimal">
      <description>East West location</description>
      <range min="-180" max="180"/>
      <unavailable>181</unavailable>
      <units>degrees</units>
      <scale>600000</scale>
      <decimalplaces>5</decimalplaces>
    </field>
    
    <field name="latitude" numberofbits="27" type="udecimal">
      <description>North South location</description>
      <range min="-90" max="90"/>
      <unavailable>91</unavailable>
      <units>degrees</units>
      <scale>600000</scale>
      <decimalplaces>5</decimalplaces>
    </field>
  </struct>

  <struct name="utcdatetime">
    <description>Time stamp in UTC</description>
    <field name="month" numberofbits="4" type="uint">
      <description>month 1..12</description>
    </field>
 	
    <field name="day" numberofbits="5" type="uint">
      <description>day of the month 1..31</description>
    </field>
    <field name="hour" numberofbits="5" type="uint">
      <description>UTC hours 0..23</description>
    </field>
    <field name="min" numberofbits="6" type="uint">
      <description>minutes</description>
    </field>
    <field name="sec" numberofbits="6" type="uint">
      <description>seconds</description>
    </field>
  </struct> <!-- utcdatetime -->


  <!-- ============================================================ -->

  <message name="waterlevel" aismsgnum="8" dac="366" fid="63" efid="1">
    <description>Water level report.  In this case from the NOAA Co-Ops 6 minute raw data</description>
    <note>Prototype only for the Hampton Roads/Elizabeth River 2007 demonstration project</note>
    <see-also>http://opendap.co-ops.nos.noaa.gov/axis/</see-also>
    <!-- <see-also>http://opendap.co-ops.nos.noaa.gov/axis/doc.html</see-also> -->

    <!-- header -->

    <field name="dac" numberofbits="16" type="uint">
      <description>Designated Area Code</description>
      <required>366</required>
    </field>
    <field name="fid" numberofbits="4" type="uint">
      <description>Functional Identifier</description>
      <required>1</required>
    </field>
    <field name="efid" numberofbits="12" type="uint">
      <description>extended functional identifier</description>
      <required>12</required>
    </field>


    <!-- body -->

    <include-struct name="timetag" struct="utcdatetime">
      <description>Time the measurement represents</description>
    </include-struct>
    
    <!-- number of bits of station id is just to match St. Lawrence Seaway -->
    <field name="stationid" numberofbits="6" arraylength="7" type="aisstr6">
      <description>Character identifier of the station.  Usually a number.</description>
      <note>station name should be taken from an external lookup table based on stationid</note>
      <unavailable>@@@@@@@</unavailable>
    </field>

    <include-struct name="stationloc" struct="position2d">
      <description>Location of the sensor taking the water level measurement or position of prediction</description>
    </include-struct>

    <field name="waterlevel" numberofbits="16" type="sdecimal">
      <description>Water level in centimeters</description>
      <unavailable>-32768</unavailable>
    </field>

    <field name="datum" numberofbits="5" type="uint">
      <description>What reference datum applies to the value</description>
      <note>Tries to match the first 2 along with the St. Lawrence Seaway.  2 is for Water Level Type of 1?!?</note>
      <note>Need a good reference to the definition of each</note>
      <lookuptable>
	<entry key="0">MLLW</entry>
	<entry key="1">IGLD-85</entry>
	<entry key="2">WaterDepth</entry>
	<entry key="3">STND</entry>
	<entry key="4">MHW</entry>
	<entry key="5">MLS</entry>
	<entry key="6">NGVD</entry>
	<entry key="7">NAVD</entry>
      </lookuptable>
      <unavailable>31</unavailable>
    </field>

    <field name="sigma" numberofbits="32" type="float">
      <description>Standard deviation of 1 second samples used to compute the water level height</description>
      <note>could easily be make a more compact decimal</note>
      <units>m</units>
    </field>

    <field name="o" numberofbits="8" type="uint">
      <description>Count of number of samples that fall outside a 3-sigma band about the mean</description>
      <unavailable>255</unavailable>
    </field>

    <!-- FLAGS Based on NOAA Co-ops format -->

    <field name="levelinferred" numberofbits="1" type="bool">
      <description>indicates that the water level value has been inferred</description>
      <note>NOAA Co-Ops I flag</note>
    </field>

    <field name="flat_tolerance_exceeded" numberofbits="1" type="bool">
      <description>flat tolerance limit was exceeded.  Need better descr</description>
      <note>NOAA Co-Ops F flag</note>
    </field>

    <field name="rate_tolerance_exceeded" numberofbits="1" type="bool">
      <description>rate of change tolerance limit was exceeded</description>
      <note>NOAA Co-Ops R flag</note>
    </field>

    <field name="temp_tolerance_exceeded" numberofbits="1" type="bool">
      <description>temperature difference tolerance limit was exceeded</description>
      <note>NOAA Co-Ops T flag</note>
    </field>

    <field name="expected_height_exceeded" numberofbits="1" type="bool">
      <description>either the maximum or minimum expected water level height limit was exceeded</description>
      <note>NOAA Co-Ops L flag</note>
    </field>

    <field name="link_down" numberofbits="1" type="bool">
      <description>Unable to communicate with the tide system.  All data invalid</description>
    </field>

    <include-struct name="timeSinceLastMeasured" struct="utcdatetime">
      <description>Time since last measured value was available</description>
      <note>If the system has never seen a valid measurement for the station, set the date to WHAT?  1972?</note>
    </include-struct>

  </message> <!-- waterlevel -->

</ais-binary-message>
