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

Module ais_msg_4

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: 2008-01-09

Classes [hide private]
  Testbsreport
Use testvalue tag text from each type to build test case the bsreport message
Functions [hide private]
BitVector
encode(params, validate=False)
Create a bsreport binary message payload to pack into an AIS Msg bsreport.
source code
dict
decode(bv, validate=False)
Unpack a bsreport message
source code
 
decodeMessageID(bv, validate=False) source code
 
decodeRepeatIndicator(bv, validate=False) source code
 
decodeUserID(bv, validate=False) source code
 
decodeTime_year(bv, validate=False) source code
 
decodeTime_month(bv, validate=False) source code
 
decodeTime_day(bv, validate=False) source code
 
decodeTime_hour(bv, validate=False) source code
 
decodeTime_min(bv, validate=False) source code
 
decodeTime_sec(bv, validate=False) source code
 
decodePositionAccuracy(bv, validate=False) source code
 
decodePosition_longitude(bv, validate=False) source code
 
decodePosition_latitude(bv, validate=False) source code
 
decodefixtype(bv, validate=False) source code
 
decodeSpare(bv, validate=False) source code
 
decodeRAIM(bv, validate=False) source code
 
decodestate_syncstate(bv, validate=False) source code
 
decodestate_slottimeout(bv, validate=False) source code
 
decodestate_slotoffset(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 bsreport 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
str
latexDefinitionTable(outfile=sys.stdout)
Return the LaTeX definition table for this message type
source code
str
textDefinitionTable(outfile=sys.stdout, delim='\t')
Return the text definition table for this message type
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 = ('MessageID', 'RepeatIndicator', 'UserID', 'Time_y...
  fieldListPostgres = ('MessageID', 'RepeatIndicator', 'UserID',...
  toPgFields = {'Position_latitude': 'Position', 'Position_longi...
Go to the Postgis field names from the straight field name
  fromPgFields = {'Position': ('Position_longitude', 'Position_l...
Go from the Postgis field names to the straight field name
  pgTypes = {'Position': 'POINT'}
Lookup table for each postgis field name to get its type.
  RepeatIndicatorEncodeLut = {'default': '0', 'do not repeat any...
  RepeatIndicatorDecodeLut = {'0': 'default', '3': 'do not repea...
  PositionAccuracyEncodeLut = {'high (less than 10 m)': '1', 'lo...
  PositionAccuracyDecodeLut = {'0': 'low (greater than 10 m)', '...
  fixtypeEncodeLut = {'Chayka': '5', 'GLONASS': '2', 'GPS': '1',...
  fixtypeDecodeLut = {'0': 'undefined', '1': 'GPS', '2': 'GLONAS...
  RAIMEncodeLut = {'in use': 'True', 'not in use': 'False'}
  RAIMDecodeLut = {'False': 'not in use', 'True': 'in use'}
  state_syncstateEncodeLut = {'UTC direct': '0', 'UTC indirect':...
  state_syncstateDecodeLut = {'0': 'UTC direct', '1': 'UTC indir...
  state_slottimeoutEncodeLut = {'1 frames left': '1', '2 frames ...
  state_slottimeoutDecodeLut = {'0': 'Last frame in this slot', ...
  dbTableName = 'bsreport'
Database table name
Function Details [hide private]

encode(params, validate=False)

source code 

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

Fields in params:
  • MessageID(uint): AIS message number. Must be 4 (field automatically set to "4")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Time_year(uint): Current time stamp year 1-9999
  • Time_month(uint): Current time stamp month 1..12
  • Time_day(uint): Current time stamp day of the month 1..31
  • Time_hour(uint): Current time stamp UTC hours 0..23
  • Time_min(uint): Current time stamp minutes
  • Time_sec(uint): Current time stamp seconds
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of base station East West location
  • Position_latitude(decimal): Location of base station North South location
  • fixtype(uint): Method used for positioning
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • state_syncstate(uint): Communications State - SOTDMA Sycronization state
  • state_slottimeout(uint): Communications State - SOTDMA Frames remaining until a new slot is selected
  • state_slotoffset(uint): Communications State - SOTDMA In what slot will the next transmission occur. BROKEN
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 bsreport message

Fields in params:
  • MessageID(uint): AIS message number. Must be 4 (field automatically set to "4")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Time_year(uint): Current time stamp year 1-9999
  • Time_month(uint): Current time stamp month 1..12
  • Time_day(uint): Current time stamp day of the month 1..31
  • Time_hour(uint): Current time stamp UTC hours 0..23
  • Time_min(uint): Current time stamp minutes
  • Time_sec(uint): Current time stamp seconds
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of base station East West location
  • Position_latitude(decimal): Location of base station North South location
  • fixtype(uint): Method used for positioning
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • state_syncstate(uint): Communications State - SOTDMA Sycronization state
  • state_slottimeout(uint): Communications State - SOTDMA Frames remaining until a new slot is selected
  • state_slotoffset(uint): Communications State - SOTDMA In what slot will the next transmission occur. BROKEN
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 bsreport message to stdout.

Fields in params:
  • MessageID(uint): AIS message number. Must be 4 (field automatically set to "4")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Time_year(uint): Current time stamp year 1-9999
  • Time_month(uint): Current time stamp month 1..12
  • Time_day(uint): Current time stamp day of the month 1..31
  • Time_hour(uint): Current time stamp UTC hours 0..23
  • Time_min(uint): Current time stamp minutes
  • Time_sec(uint): Current time stamp seconds
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of base station East West location
  • Position_latitude(decimal): Location of base station North South location
  • fixtype(uint): Method used for positioning
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • state_syncstate(uint): Communications State - SOTDMA Sycronization state
  • state_slottimeout(uint): Communications State - SOTDMA Frames remaining until a new slot is selected
  • state_slotoffset(uint): Communications State - SOTDMA In what slot will the next transmission occur. BROKEN
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???

latexDefinitionTable(outfile=sys.stdout)

source code 
Return the LaTeX definition table for this message type
Parameters:
  • outfile (file obj) - file like object to print to.
Returns: str
LaTeX table string via the outfile

textDefinitionTable(outfile=sys.stdout, delim='\t')

source code 
Return the text definition table for this message type
Parameters:
  • outfile (file obj) - file like object to print to.
Returns: str
text table string via the outfile

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:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'Time_year',
 'Time_month',
 'Time_day',
 'Time_hour',
 'Time_min',
...

fieldListPostgres

Value:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'Time_year',
 'Time_month',
 'Time_day',
 'Time_hour',
 'Time_min',
...

toPgFields

Go to the Postgis field names from the straight field name
Value:
{'Position_latitude': 'Position', 'Position_longitude': 'Position'}

fromPgFields

Go from the Postgis field names to the straight field name
Value:
{'Position': ('Position_longitude', 'Position_latitude')}

RepeatIndicatorEncodeLut

Value:
{'default': '0', 'do not repeat any more': '3'}

RepeatIndicatorDecodeLut

Value:
{'0': 'default', '3': 'do not repeat any more'}

PositionAccuracyEncodeLut

Value:
{'high (less than 10 m)': '1', 'low (greater than 10 m)': '0'}

PositionAccuracyDecodeLut

Value:
{'0': 'low (greater than 10 m)', '1': 'high (less than 10 m)'}

fixtypeEncodeLut

Value:
{'Chayka': '5',
 'GLONASS': '2',
 'GPS': '1',
 'Loran-C': '4',
 'combined GPS/GLONASS': '3',
 'integrated navigation system': '6',
 'surveyed': '7',
 'undefined': '0'}

fixtypeDecodeLut

Value:
{'0': 'undefined',
 '1': 'GPS',
 '2': 'GLONASS',
 '3': 'combined GPS/GLONASS',
 '4': 'Loran-C',
 '5': 'Chayka',
 '6': 'integrated navigation system',
 '7': 'surveyed'}

state_syncstateEncodeLut

Value:
{'UTC direct': '0',
 'UTC indirect': '1',
 'synchronized to a base station': '2',
 'synchronized to another station': '3'}

state_syncstateDecodeLut

Value:
{'0': 'UTC direct',
 '1': 'UTC indirect',
 '2': 'synchronized to a base station',
 '3': 'synchronized to another station'}

state_slottimeoutEncodeLut

Value:
{'1 frames left': '1',
 '2 frames left': '2',
 '3 frames left': '3',
 '4 frames left': '4',
 '5 frames left': '5',
 '6 frames left': '6',
 '7 frames left': '7',
 'Last frame in this slot': '0'}

state_slottimeoutDecodeLut

Value:
{'0': 'Last frame in this slot',
 '1': '1 frames left',
 '2': '2 frames left',
 '3': '3 frames left',
 '4': '4 frames left',
 '5': '5 frames left',
 '6': '6 frames left',
 '7': '7 frames left'}