Script 1_py
[hide private]
[frames] | no frames]

Script 1_py

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

Date: 2007-01-05

Classes [hide private]
  Testposition
Use testvalue tag text from each type to build test case the position message
Functions [hide private]
BitVector
encode(params, validate=False)
Create a position binary message payload to pack into an AIS Msg position.
source code
dict
decode(bv, validate=False)
Unpack a position message
source code
 
decodeMessageID(bv, validate=False) source code
 
decodeRepeatIndicator(bv, validate=False) source code
 
decodeUserID(bv, validate=False) source code
 
decodeNavigationStatus(bv, validate=False) source code
 
decodeROT(bv, validate=False) source code
 
decodeSOG(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
 
decodeCOG(bv, validate=False) source code
 
decodeTrueHeading(bv, validate=False) source code
 
decodeTimeStamp(bv, validate=False) source code
 
decodeRegionalReserved(bv, validate=False) source code
 
decodeSpare(bv, validate=False) source code
 
decodeRAIM(bv, validate=False) source code
 
decodesyncstate(bv, validate=False) source code
 
decodeslotoffset(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')
Print a position message to stdout.
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
  RepeatIndicatorEncodeLut = {'default': '0', 'do not repeat any...
  RepeatIndicatorDecodeLut = {'0': 'default', '3': 'do not repea...
  NavigationStatusEncodeLut = {'aground': '6', 'at anchor': '1',...
  NavigationStatusDecodeLut = {'0': 'under way using engine', '1...
  SOGEncodeLut = {'102.2 knots or higher': '102.2'}
  SOGDecodeLut = {'102.2': '102.2 knots or higher'}
  PositionAccuracyEncodeLut = {'high (greater than 10 m)': '1', ...
  PositionAccuracyDecodeLut = {'0': 'low (greater than 10 m)', '...
  TimeStampEncodeLut = {'dead reckoning': '62', 'inoperative': '...
  TimeStampDecodeLut = {'60': 'not available/default', '61': 'ma...
  RAIMEncodeLut = {'in use': 'True', 'not in use': 'False'}
  RAIMDecodeLut = {'False': 'not in use', 'True': 'in use'}
  syncstateEncodeLut = {'UTC direct': '0', 'UTC indirect': '1', ...
  syncstateDecodeLut = {'0': 'UTC direct', '1': 'UTC indirect', ...
Function Details [hide private]

encode(params, validate=False)

source code 

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

Fields in params:
  • MessageID(uint): AIS message number. Must be 1 (field automatically set to "1")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • NavigationStatus(uint): What is the vessel doing
  • ROT(int): RateOfTurn
  • SOG(udecimal): Speed over ground
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of the vessel East West location
  • Position_latitude(decimal): Location of the vessel North South location
  • COG(udecimal): Course over ground
  • TrueHeading(uint): True heading (relative to true North)
  • TimeStamp(uint): UTC second when the report was generated
  • RegionalReserved(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • syncstate(uint): Sycronization state
  • slotoffset(uint): 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 position message

Fields in params:
  • MessageID(uint): AIS message number. Must be 1 (field automatically set to "1")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • NavigationStatus(uint): What is the vessel doing
  • ROT(int): RateOfTurn
  • SOG(udecimal): Speed over ground
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of the vessel East West location
  • Position_latitude(decimal): Location of the vessel North South location
  • COG(udecimal): Course over ground
  • TrueHeading(uint): True heading (relative to true North)
  • TimeStamp(uint): UTC second when the report was generated
  • RegionalReserved(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • syncstate(uint): Sycronization state
  • slotoffset(uint): 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')

source code 

Print a position message to stdout.

Fields in params:
  • MessageID(uint): AIS message number. Must be 1 (field automatically set to "1")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • NavigationStatus(uint): What is the vessel doing
  • ROT(int): RateOfTurn
  • SOG(udecimal): Speed over ground
  • PositionAccuracy(uint): Accuracy of positioning fixes
  • Position_longitude(decimal): Location of the vessel East West location
  • Position_latitude(decimal): Location of the vessel North South location
  • COG(udecimal): Course over ground
  • TrueHeading(uint): True heading (relative to true North)
  • TimeStamp(uint): UTC second when the report was generated
  • RegionalReserved(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • Spare(uint): Reserved for definition by a regional authority. (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • syncstate(uint): Sycronization state
  • slotoffset(uint): 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

testParams()

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

Variables Details [hide private]

RepeatIndicatorEncodeLut

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

RepeatIndicatorDecodeLut

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

NavigationStatusEncodeLut

Value:
{'aground': '6',
 'at anchor': '1',
 'constrained by her draught': '4',
 'engaged in fishing': '7',
 'moored': '5',
 'not defined = default': '15',
 'not under command': '2',
 'reserved for future use': '14',
...

NavigationStatusDecodeLut

Value:
{'0': 'under way using engine',
 '1': 'at anchor',
 '10': 'reserved for future use',
 '11': 'reserved for future use',
 '12': 'reserved for future use',
 '13': 'reserved for future use',
 '14': 'reserved for future use',
 '15': 'not defined = default',
...

PositionAccuracyEncodeLut

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

PositionAccuracyDecodeLut

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

TimeStampEncodeLut

Value:
{'dead reckoning': '62',
 'inoperative': '63',
 'manual input': '61',
 'not available/default': '60'}

TimeStampDecodeLut

Value:
{'60': 'not available/default',
 '61': 'manual input',
 '62': 'dead reckoning',
 '63': 'inoperative'}

syncstateEncodeLut

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

syncstateDecodeLut

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