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

Module ais_msg_21

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

Classes [hide private]
  TestAidsToNavReport
Use testvalue tag text from each type to build test case the AidsToNavReport message

Functions [hide private]
BitVector encode(params, validate=False)
Create a AidsToNavReport binary message payload to pack into an AIS Msg AidsToNavReport.
dict decode(bv, validate=False)
Unpack a AidsToNavReport message
  decodeMessageID(bv, validate=False)
  decodeRepeatIndicator(bv, validate=False)
  decodeUserID(bv, validate=False)
  decodetype(bv, validate=False)
  decodename(bv, validate=False)
  decodePositionAccuracy(bv, validate=False)
  decodePosition_longitude(bv, validate=False)
  decodePosition_latitude(bv, validate=False)
  decodedim(bv, validate=False)
  decodeFixType(bv, validate=False)
  decodetimestamp(bv, validate=False)
  decodeOffPosition(bv, validate=False)
  decodeRegionalApp(bv, validate=False)
  decodeRAIM(bv, validate=False)
  decodeSpare(bv, validate=False)
  printHtml(params, out=sys.stdout)
  printKml(params, out=sys.stdout)
KML (Keyhole Markup Language) for Google Earth, but without the header/footer
stdout printFields(params, out=sys.stdout, format='std', fieldList=None)
Print a Spare message to stdout.
str sqlCreateStr(outfile=sys.stdout, fields=None, extraFields=None, addCoastGuardFields=True)
Return the SQL CREATE command for this message type
sqlhelp.create sqlCreate(fields=None, extraFields=None, addCoastGuardFields=True)
Return the sqlhelp object to create the table.
str sqlInsertStr(params, outfile=sys.stdout, extraParams=None)
Return the SQL CREATE command for this message type
sqlhelp.insert sqlInsert(params, extraParams=None)
Give the SQL insert statement
dict testParams()
Return a params file base on the testvalue tags.
  addMsgOptions(parser)

Variables [hide private]
  __date__ = '2007-02-08'
Date of last svn commit
  TrueBV = <ais.BitVector.BitVector object at 0xb3a6b70>
Why always rebuild the True bit? This should speed things up a bunch
  FalseBV = <ais.BitVector.BitVector object at 0xb3a6a50>
Why always rebuild the False bit? This should speed things up a bunch
  fieldList = ['MessageID', 'RepeatIndicator', 'UserID', 'type', '...
  RepeatIndicatorEncodeLut = {'default': '0', 'do not repeat any more': '3'}
  RepeatIndicatorDecodeLut = {'0': 'default', '3': 'do not repeat any more'}
  typeEncodeLut = {'Light, without sectors': '5', 'Safe water': '29', ...
  typeDecodeLut = {'24': 'Port hand Mark', '25': 'Starbord hand Mark',...
  PositionAccuracyEncodeLut = {'low (greater than 10 m)': '0', 'high (less than 10...
  PositionAccuracyDecodeLut = {'1': 'high (less than 10 m)', '0': 'low (greater th...
  FixTypeEncodeLut = {'Combined GPS/GLONASS': '3', 'Integrated Navigation...
  FixTypeDecodeLut = {'11': 'not used - 11', '10': 'not used - 10', '13':...
  timestampEncodeLut = {'Positioning system is in manual mode': '61', 'Posi...
  timestampDecodeLut = {'61': 'Positioning system is in manual mode', '62':...
  OffPositionEncodeLut = {'Off position': 'True', 'On position': 'False'}
  OffPositionDecodeLut = {'True': 'Off position', 'False': 'On position'}
  RAIMEncodeLut = {'in use': 'True', 'not in use': 'False'}
  RAIMDecodeLut = {'True': 'in use', 'False': 'not in use'}
  typeChoices = 'binary', 'nmeapayload', 'nmea'
  outputChoices = 'std', 'html', 'csv', 'sql', 'kml', 'kml-full'
  outfile = file(options.outputFileName, 'w')
  msgDict = {'MessageID': '21', 'RepeatIndicator': options.Repea...
  bitLen = len(bits)
  bits = bits+ BitVector(size= (6-(bitLen % 6)))
  buf = StringIO.StringIO()
  result = buf.getvalue()

Function Details [hide private]

encode(params, validate=False)

source code 

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

Fields in params:
  • MessageID(uint): AIS message number. Must be 21 aka 'F' (field automatically set to "21")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • type(uint): IALA type of aid-to-navigation
  • name(aisstr6): Name of the aid-to-navigation
  • 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
  • dim(uint): FIX: break this out.
  • FixType(uint): Type of electronic position fixing device
  • timestamp(uint): UTC second when report was generated
  • OffPosition(bool): True when the AtoN is off station
  • RegionalApp(uint): Should be set to zero (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • Spare(uint): Not Used (field automatically set to "0")
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 AidsToNavReport message

Fields in params:
  • MessageID(uint): AIS message number. Must be 21 aka 'F' (field automatically set to "21")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • type(uint): IALA type of aid-to-navigation
  • name(aisstr6): Name of the aid-to-navigation
  • 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
  • dim(uint): FIX: break this out.
  • FixType(uint): Type of electronic position fixing device
  • timestamp(uint): UTC second when report was generated
  • OffPosition(bool): True when the AtoN is off station
  • RegionalApp(uint): Should be set to zero (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • Spare(uint): Not Used (field automatically set to "0")
Parameters:
  • bv (BitVector) - Bits defining a message
  • validate - Set to true to cause checking to occur. Runs slower. FIX: not implemented.
Returns: dict
params

decodeMessageID(bv, validate=False)

source code 
None

decodeRepeatIndicator(bv, validate=False)

source code 
None

decodeUserID(bv, validate=False)

source code 
None

decodetype(bv, validate=False)

source code 
None

decodename(bv, validate=False)

source code 
None

decodePositionAccuracy(bv, validate=False)

source code 
None

decodePosition_longitude(bv, validate=False)

source code 
None

decodePosition_latitude(bv, validate=False)

source code 
None

decodedim(bv, validate=False)

source code 
None

decodeFixType(bv, validate=False)

source code 
None

decodetimestamp(bv, validate=False)

source code 
None

decodeOffPosition(bv, validate=False)

source code 
None

decodeRegionalApp(bv, validate=False)

source code 
None

decodeRAIM(bv, validate=False)

source code 
None

decodeSpare(bv, validate=False)

source code 
None

printHtml(params, out=sys.stdout)

source code 
None

printKml(params, out=sys.stdout)

source code 
KML (Keyhole Markup Language) for Google Earth, but without the header/footer

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

source code 

Print a Spare message to stdout.

Fields in params:
  • MessageID(uint): AIS message number. Must be 21 aka 'F' (field automatically set to "21")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • type(uint): IALA type of aid-to-navigation
  • name(aisstr6): Name of the aid-to-navigation
  • 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
  • dim(uint): FIX: break this out.
  • FixType(uint): Type of electronic position fixing device
  • timestamp(uint): UTC second when report was generated
  • OffPosition(bool): True when the AtoN is off station
  • RegionalApp(uint): Should be set to zero (field automatically set to "0")
  • RAIM(bool): Receiver autonomous integrity monitoring flag
  • Spare(uint): Not Used (field automatically set to "0")
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)

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
Returns: str
sql create string

See Also: sqlCreate

sqlCreate(fields=None, extraFields=None, addCoastGuardFields=True)

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
Returns: sqlhelp.create
An object that can be used to generate a return

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

source code 
Return the SQL CREATE 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)

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

addMsgOptions(parser)

source code 
None

Variables Details [hide private]

__date__

Date of last svn commit
Value:
'2007-02-08'                                                           
      

TrueBV

Why always rebuild the True bit? This should speed things up a bunch
Value:
<ais.BitVector.BitVector object at 0xb3a6b70>                          
      

FalseBV

Why always rebuild the False bit? This should speed things up a bunch
Value:
<ais.BitVector.BitVector object at 0xb3a6a50>                          
      

fieldList

None
Value:
['MessageID',
 'RepeatIndicator',
 'UserID',
 'type',
 'name',
 'PositionAccuracy',
 'Position_longitude',
 'Position_latitude',
...                                                                    
      

RepeatIndicatorEncodeLut

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

RepeatIndicatorDecodeLut

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

typeEncodeLut

None
Value:
{'Beacon, Cardinal E': '10',
 'Beacon, Cardinal N': '9',
 'Beacon, Cardinal S': '11',
 'Beacon, Cardinal W': '12',
 'Beacon, Isolated danger': '17',
 'Beacon, Port hand': '13',
 'Beacon, Preferred channel port hand': '15',
 'Beacon, Preferred channel starboard hand': '16',
...                                                                    
      

typeDecodeLut

None
Value:
{'0': 'Default, Type of A to N not specified',
 '1': 'Reference point',
 '10': 'Beacon, Cardinal E',
 '11': 'Beacon, Cardinal S',
 '12': 'Beacon, Cardinal W',
 '13': 'Beacon, Port hand',
 '14': 'Beacon, Starbord hand',
 '15': 'Beacon, Preferred channel port hand',
...                                                                    
      

PositionAccuracyEncodeLut

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

PositionAccuracyDecodeLut

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

FixTypeEncodeLut

None
Value:
{'Chayka': '5',
 'Combined GPS/GLONASS': '3',
 'GLONASS': '2',
 'GPS': '1',
 'Integrated Navigation System': '6',
 'Loran-C': '4',
 'Undefined (default)': '0',
 'not used - 10': '10',
...                                                                    
      

FixTypeDecodeLut

None
Value:
{'0': 'Undefined (default)',
 '1': 'GPS',
 '10': 'not used - 10',
 '11': 'not used - 11',
 '12': 'not used - 12',
 '13': 'not used - 13',
 '14': 'not used - 14',
 '15': 'not used - 15',
...                                                                    
      

timestampEncodeLut

None
Value:
{'Electronic position fixing system operates in estimated mode': '62',
 'Positioning system is in manual mode': '61',
 'Positioning system is inoperative': '63'}                            
      

timestampDecodeLut

None
Value:
{'61': 'Positioning system is in manual mode',
 '62': 'Electronic position fixing system operates in estimated mode',
 '63': 'Positioning system is inoperative'}                            
      

OffPositionEncodeLut

None
Value:
{'Off position': 'True', 'On position': 'False'}                       
      

OffPositionDecodeLut

None
Value:
{'True': 'Off position', 'False': 'On position'}                       
      

RAIMEncodeLut

None
Value:
{'in use': 'True', 'not in use': 'False'}                              
      

RAIMDecodeLut

None
Value:
{'True': 'in use', 'False': 'not in use'}                              
      

typeChoices

None
Value:
'binary', 'nmeapayload', 'nmea'                                        
      

outputChoices

None
Value:
'std', 'html', 'csv', 'sql', 'kml', 'kml-full'                         
      

outfile

None
Value:
file(options.outputFileName, 'w')                                      
      

msgDict

None
Value:
{'MessageID': '21', 'RepeatIndicator': options.RepeatIndicatorField, '
UserID': options.UserIDField, 'type': options.typeField, 'name': optio
ns.nameField, 'PositionAccuracy': options.PositionAccuracyField, 'Posi
tion_longitude': options.Position_longitudeField, 'Position_latitude':
 options.Position_latitudeField, 'dim': options.dimField, 'FixType': o
ptions.FixTypeField, 'timestamp': options.timestampField, 'OffPosition
': options.OffPositionField, 'RegionalApp': '0', 'RAIM': options.RAIMF
ield, 'Spare': '0',}                                                   
      

bitLen

None
Value:
len(bits)                                                              
      

bits

None
Value:
bits+ BitVector(size= (6-(bitLen % 6)))                                
      

buf

None
Value:
StringIO.StringIO()                                                    
      

result

None
Value:
buf.getvalue()