Package ais :: Module waterlevel
[hide private]
[frames] | no frames]

Module waterlevel

source code

Autogenerated python functions to serialize/deserialize binary messages.

Generated by: ./aisxmlbinmsg2py.py

Need to then wrap these functions with the outer AIS packet and then convert the whole binary blob to a NMEA string. Those functions are not currently provided in this file.

serialize: python to ais binary deserialize: ais binary to python

The generated code uses translators.py, binary.py, and aisstring.py which should be packaged with the resulting files.


Requires:

Author: xmlbinmsg

Version: 4791

Status: under development

License: Generated code has no license

To Do: FIX: put in a description of the message here with fields and types.

Date: 2007-03-03

Classes [hide private]
  Testwaterlevel
Use testvalue tag text from each type to build test case the waterlevel message
Functions [hide private]
BitVector
encode(params, validate=False)
Create a waterlevel binary message payload to pack into an AIS Msg waterlevel.
source code
dict
decode(bv, validate=False)
Unpack a waterlevel message
source code
 
decodedac(bv, validate=False) source code
 
decodefid(bv, validate=False) source code
 
decodeefid(bv, validate=False) source code
 
decodetimetag_month(bv, validate=False) source code
 
decodetimetag_day(bv, validate=False) source code
 
decodetimetag_hour(bv, validate=False) source code
 
decodetimetag_min(bv, validate=False) source code
 
decodetimetag_sec(bv, validate=False) source code
 
decodestationid(bv, validate=False) source code
 
decodestationloc_longitude(bv, validate=False) source code
 
decodestationloc_latitude(bv, validate=False) source code
 
decodewaterlevel(bv, validate=False) source code
 
decodedatum(bv, validate=False) source code
 
decodesigma(bv, validate=False) source code
 
decodeo(bv, validate=False) source code
 
decodelevelinferred(bv, validate=False) source code
 
decodeflat_tolerance_exceeded(bv, validate=False) source code
 
decoderate_tolerance_exceeded(bv, validate=False) source code
 
decodetemp_tolerance_exceeded(bv, validate=False) source code
 
decodeexpected_height_exceeded(bv, validate=False) source code
 
decodelink_down(bv, validate=False) source code
 
decodetimeLastMeasured_month(bv, validate=False) source code
 
decodetimeLastMeasured_day(bv, validate=False) source code
 
decodetimeLastMeasured_hour(bv, validate=False) source code
 
decodetimeLastMeasured_min(bv, validate=False) source code
 
decodetimeLastMeasured_sec(bv, validate=False) source code
 
printHtml(params, out=sys.stdout) source code
 
printKml(params, out=sys.stdout)
KML (Keyhole Markup Language) for Google Earth, but without the header/footer
source code
stdout
printFields(params, out=sys.stdout, format='std', fieldList=None, dbType='postgres')
Print a waterlevel message to stdout.
source code
str
sqlCreateStr(outfile=sys.stdout, fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')
Return the SQL CREATE command for this message type
source code
sqlhelp.create
sqlCreate(fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')
Return the sqlhelp object to create the table.
source code
str
sqlInsertStr(params, outfile=sys.stdout, extraParams=None, dbType='postgres')
Return the SQL INSERT command for this message type
source code
sqlhelp.insert
sqlInsert(params, extraParams=None, dbType='postgres')
Give the SQL INSERT statement
source code
dict
testParams()
Return a params file base on the testvalue tags.
source code
 
addMsgOptions(parser) source code
Variables [hide private]
  TrueBV = BitVector(bitstring= "1")
Why always rebuild the True bit? This should speed things up a bunch
  FalseBV = BitVector(bitstring= "0")
Why always rebuild the False bit? This should speed things up a bunch
  fieldList = ('dac', 'fid', 'efid', 'timetag_month', 'timetag_d...
  fieldListPostgres = ('dac', 'fid', 'efid', 'timetag_month', 't...
  toPgFields = {}
Go to the Postgis field names from the straight field name
  fromPgFields = {}
Go from the Postgis field names to the straight field name
  pgTypes = {}
Lookup table for each postgis field name to get its type.
  datumEncodeLut = {'IGLD-85': '1', 'LAT': '9', 'MHW': '4', 'MLL...
  datumDecodeLut = {'0': 'MLLW', '1': 'IGLD-85', '2': 'WaterDept...
Function Details [hide private]

encode(params, validate=False)

source code 

Create a waterlevel binary message payload to pack into an AIS Msg waterlevel.

Fields in params:
  • dac(uint): Designated Area Code (field automatically set to "366")
  • fid(uint): Functional Identifier (field automatically set to "1")
  • efid(uint): extended functional identifier (field automatically set to "1")
  • timetag_month(uint): Time the measurement represents month 1..12
  • timetag_day(uint): Time the measurement represents day of the month 1..31
  • timetag_hour(uint): Time the measurement represents UTC hours 0..23
  • timetag_min(uint): Time the measurement represents minutes
  • timetag_sec(uint): Time the measurement represents seconds
  • stationid(aisstr6): Character identifier of the station. Usually a number.
  • stationloc_longitude(decimal): Location of the sensor taking the water level measurement or position of prediction East West location
  • stationloc_latitude(decimal): Location of the sensor taking the water level measurement or position of prediction North South location
  • waterlevel(int): Water level in centimeters
  • datum(uint): What reference datum applies to the value
  • sigma(float): Standard deviation of 1 second samples used to compute the water level height
  • o(uint): Count of number of samples that fall outside a 3-sigma band about the mean
  • levelinferred(bool): indicates that the water level value has been inferred
  • flat_tolerance_exceeded(bool): flat tolerance limit was exceeded. Need better descr
  • rate_tolerance_exceeded(bool): rate of change tolerance limit was exceeded
  • temp_tolerance_exceeded(bool): temperature difference tolerance limit was exceeded
  • expected_height_exceeded(bool): either the maximum or minimum expected water level height limit was exceeded
  • link_down(bool): Unable to communicate with the tide system. All data invalid
  • timeLastMeasured_month(uint): Time since last measured value was available month 1..12
  • timeLastMeasured_day(uint): Time since last measured value was available day of the month 1..31
  • timeLastMeasured_hour(uint): Time since last measured value was available UTC hours 0..23
  • timeLastMeasured_min(uint): Time since last measured value was available minutes
  • timeLastMeasured_sec(uint): Time since last measured value was available seconds
Parameters:
  • params - Dictionary of field names/values. Throws a ValueError exception if required is missing
  • validate - Set to true to cause checking to occur. Runs slower. FIX: not implemented.
Returns: BitVector
encoded binary message (for binary messages, this needs to be wrapped in a msg 8

Note: The returned bits may not be 6 bit aligned. It is up to you to pad out the bits.

decode(bv, validate=False)

source code 

Unpack a waterlevel message

Fields in params:
  • dac(uint): Designated Area Code (field automatically set to "366")
  • fid(uint): Functional Identifier (field automatically set to "1")
  • efid(uint): extended functional identifier (field automatically set to "1")
  • timetag_month(uint): Time the measurement represents month 1..12
  • timetag_day(uint): Time the measurement represents day of the month 1..31
  • timetag_hour(uint): Time the measurement represents UTC hours 0..23
  • timetag_min(uint): Time the measurement represents minutes
  • timetag_sec(uint): Time the measurement represents seconds
  • stationid(aisstr6): Character identifier of the station. Usually a number.
  • stationloc_longitude(decimal): Location of the sensor taking the water level measurement or position of prediction East West location
  • stationloc_latitude(decimal): Location of the sensor taking the water level measurement or position of prediction North South location
  • waterlevel(int): Water level in centimeters
  • datum(uint): What reference datum applies to the value
  • sigma(float): Standard deviation of 1 second samples used to compute the water level height
  • o(uint): Count of number of samples that fall outside a 3-sigma band about the mean
  • levelinferred(bool): indicates that the water level value has been inferred
  • flat_tolerance_exceeded(bool): flat tolerance limit was exceeded. Need better descr
  • rate_tolerance_exceeded(bool): rate of change tolerance limit was exceeded
  • temp_tolerance_exceeded(bool): temperature difference tolerance limit was exceeded
  • expected_height_exceeded(bool): either the maximum or minimum expected water level height limit was exceeded
  • link_down(bool): Unable to communicate with the tide system. All data invalid
  • timeLastMeasured_month(uint): Time since last measured value was available month 1..12
  • timeLastMeasured_day(uint): Time since last measured value was available day of the month 1..31
  • timeLastMeasured_hour(uint): Time since last measured value was available UTC hours 0..23
  • timeLastMeasured_min(uint): Time since last measured value was available minutes
  • timeLastMeasured_sec(uint): Time since last measured value was available seconds
Parameters:
  • bv (BitVector) - Bits defining a message
  • validate - Set to true to cause checking to occur. Runs slower. FIX: not implemented.
Returns: dict
params

printFields(params, out=sys.stdout, format='std', fieldList=None, dbType='postgres')

source code 

Print a waterlevel message to stdout.

Fields in params:
  • dac(uint): Designated Area Code (field automatically set to "366")
  • fid(uint): Functional Identifier (field automatically set to "1")
  • efid(uint): extended functional identifier (field automatically set to "1")
  • timetag_month(uint): Time the measurement represents month 1..12
  • timetag_day(uint): Time the measurement represents day of the month 1..31
  • timetag_hour(uint): Time the measurement represents UTC hours 0..23
  • timetag_min(uint): Time the measurement represents minutes
  • timetag_sec(uint): Time the measurement represents seconds
  • stationid(aisstr6): Character identifier of the station. Usually a number.
  • stationloc_longitude(decimal): Location of the sensor taking the water level measurement or position of prediction East West location
  • stationloc_latitude(decimal): Location of the sensor taking the water level measurement or position of prediction North South location
  • waterlevel(int): Water level in centimeters
  • datum(uint): What reference datum applies to the value
  • sigma(float): Standard deviation of 1 second samples used to compute the water level height
  • o(uint): Count of number of samples that fall outside a 3-sigma band about the mean
  • levelinferred(bool): indicates that the water level value has been inferred
  • flat_tolerance_exceeded(bool): flat tolerance limit was exceeded. Need better descr
  • rate_tolerance_exceeded(bool): rate of change tolerance limit was exceeded
  • temp_tolerance_exceeded(bool): temperature difference tolerance limit was exceeded
  • expected_height_exceeded(bool): either the maximum or minimum expected water level height limit was exceeded
  • link_down(bool): Unable to communicate with the tide system. All data invalid
  • timeLastMeasured_month(uint): Time since last measured value was available month 1..12
  • timeLastMeasured_day(uint): Time since last measured value was available day of the month 1..31
  • timeLastMeasured_hour(uint): Time since last measured value was available UTC hours 0..23
  • timeLastMeasured_min(uint): Time since last measured value was available minutes
  • timeLastMeasured_sec(uint): Time since last measured value was available seconds
Parameters:
  • params - Dictionary of field names/values.
  • out - File like object to write to
Returns: stdout
text to out

sqlCreateStr(outfile=sys.stdout, fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')

source code 
Return the SQL CREATE command for this message type
Parameters:
  • outfile - file like object to print to.
  • fields - which fields to put in the create. Defaults to all.
  • extraFields - A sequence of tuples containing (name,sql type) for additional fields
  • addCoastGuardFields (bool) - Add the extra fields that come after the NMEA check some from the USCG N-AIS format
  • dbType - Which flavor of database we are using so that the create is tailored ('sqlite' or 'postgres')
Returns: str
sql create string

See Also: sqlCreate

sqlCreate(fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')

source code 
Return the sqlhelp object to create the table.
Parameters:
  • fields - which fields to put in the create. Defaults to all.
  • extraFields - A sequence of tuples containing (name,sql type) for additional fields
  • addCoastGuardFields (bool) - Add the extra fields that come after the NMEA check some from the USCG N-AIS format
  • dbType - Which flavor of database we are using so that the create is tailored ('sqlite' or 'postgres')
Returns: sqlhelp.create
An object that can be used to generate a return

sqlInsertStr(params, outfile=sys.stdout, extraParams=None, dbType='postgres')

source code 
Return the SQL INSERT command for this message type
Parameters:
  • params - dictionary of values keyed by field name
  • outfile - file like object to print to.
  • extraParams - A sequence of tuples containing (name,sql type) for additional fields
Returns: str
sql create string

See Also: sqlCreate

sqlInsert(params, extraParams=None, dbType='postgres')

source code 
Give the SQL INSERT statement
Parameters:
  • params - dict keyed by field name of values
  • extraParams - any extra fields that you have created beyond the normal ais message fields
Returns: sqlhelp.insert
insert class instance

To Do: allow optional type checking of params?

Warning: this will take invalid keys happily and do what???

testParams()

source code 
Return a params file base on the testvalue tags.
Returns: dict
params based on testvalue tags

Variables Details [hide private]

fieldList

Value:
('dac',
 'fid',
 'efid',
 'timetag_month',
 'timetag_day',
 'timetag_hour',
 'timetag_min',
 'timetag_sec',
...

fieldListPostgres

Value:
('dac',
 'fid',
 'efid',
 'timetag_month',
 'timetag_day',
 'timetag_hour',
 'timetag_min',
 'timetag_sec',
...

datumEncodeLut

Value:
{'IGLD-85': '1',
 'LAT': '9',
 'MHW': '4',
 'MLLW': '0',
 'MLS': '5',
 'NAVD': '7',
 'NGVD': '6',
 'STND': '3',
...

datumDecodeLut

Value:
{'0': 'MLLW',
 '1': 'IGLD-85',
 '2': 'WaterDepth',
 '3': 'STND',
 '4': 'MHW',
 '5': 'MLS',
 '6': 'NGVD',
 '7': 'NAVD',
...