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

Module ais_msg_22

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.

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

Functions [hide private]
BitVector encode(params, validate=False)
Create a ChanMngmt binary message payload to pack into an AIS Msg ChanMngmt.
dict decode(bv, validate=False)
Unpack a ChanMngmt message
  decodeMessageID(bv, validate=False)
  decodeRepeatIndicator(bv, validate=False)
  decodeUserID(bv, validate=False)
  decodeChanA(bv, validate=False)
  decodeChanB(bv, validate=False)
  decodeTxRxMode(bv, validate=False)
  decodepower(bv, validate=False)
  decodecorner1_lon(bv, validate=False)
  decodecorner1_lat(bv, validate=False)
  decodecorner2_lon(bv, validate=False)
  decodecorner2_lat(bv, validate=False)
  decodeIndicatorType(bv, validate=False)
  decodeChanABandwidth(bv, validate=False)
  decodeChanBBandwidth(bv, validate=False)
  decodeTransZoneSize(bv, validate=False)
  decodeSpare(bv, validate=False)
  printHtml(params, out=sys.stdout)
stdout printFields(params, out=sys.stdout, format='std', fieldList=None, dbType='postgres')
Print a ChanMngmt message to stdout.
str sqlCreateStr(outfile=sys.stdout, fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')
Return the SQL CREATE command for this message type
sqlhelp.create sqlCreate(fields=None, extraFields=None, addCoastGuardFields=True, dbType='postgres')
Return the sqlhelp object to create the table.
str sqlInsertStr(params, outfile=sys.stdout, extraParams=None, dbType='postgres')
Return the SQL INSERT command for this message type
sqlhelp.insert sqlInsert(params, extraParams=None, dbType='postgres')
Give the SQL INSERT statement
dict testParams()
Return a params file base on the testvalue tags.
  addMsgOptions(parser)

Variables [hide private]
  __date__ = '2007-02-26'
Date of last svn commit
  TrueBV = <ais.BitVector.BitVector object at 0x2375090>
Why always rebuild the True bit? This should speed things up a bunch
  FalseBV = <ais.BitVector.BitVector object at 0x2375110>
Why always rebuild the False bit? This should speed things up a bunch
  fieldList = ('MessageID', 'RepeatIndicator', 'UserID', 'Spare', ...
  fieldListPostgres = ('MessageID', 'RepeatIndicator', 'UserID', 'Spare', ...
  toPgFields = {'corner2_lat': 'corner2', 'corner1_lon': 'corner1',...
Go to the Postgis field names from the straight field name
  fromPgFields = {'corner2': ('corner2_lon', 'corner2_lat'), 'corner1...
Go from the Postgis field names to the straight field name
  pgTypes = {'corner2': 'POINT', 'corner1': 'POINT'}
Lookup table for each postgis field name to get its type.
  RepeatIndicatorEncodeLut = {'default': '0', 'do not repeat any more': '3'}
  RepeatIndicatorDecodeLut = {'0': 'default', '3': 'do not repeat any more'}
  TxRxModeEncodeLut = {'Tx A/Tx B, Rx A/RX B': '0', 'Tx B, Rx A/Rx B': '2'...
  TxRxModeDecodeLut = {'1': 'Tx A, Rx A/Rx B', '0': 'Tx A/Tx B, Rx A/RX B'...
  powerEncodeLut = {'high': '0', 'low': '1'}
  powerDecodeLut = {'1': 'low', '0': 'high'}
  IndicatorTypeEncodeLut = {'broadcast': '0', 'addressed': '1'}
  IndicatorTypeDecodeLut = {'1': 'addressed', '0': 'broadcast'}
  ChanABandwidthEncodeLut = {'12.5kHz': '1', 'specified by channel number': '0'}
  ChanABandwidthDecodeLut = {'1': '12.5kHz', '0': 'specified by channel number'}
  ChanBBandwidthEncodeLut = {'12.5kHz': '1', 'specified by channel number': '0'}
  ChanBBandwidthDecodeLut = {'1': '12.5kHz', '0': 'specified by channel number'}
  TransZoneSizeEncodeLut = {'1': '0', '3': '2', '2': '1', '5': '4', '4': '3', '...
  TransZoneSizeDecodeLut = {'1': '2', '0': '1', '3': '4', '2': '3', '5': '6', '...
  typeChoices = 'binary', 'nmeapayload', 'nmea'
  outputChoices = 'std', 'html', 'csv', 'sql'
  dbChoices = 'sqlite', 'postgres'
  outfile = file(options.outputFileName, 'w')
  msgDict = {'MessageID': '22', '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 ChanMngmt binary message payload to pack into an AIS Msg ChanMngmt.

Fields in params:
  • MessageID(uint): AIS message number. Must be 22 (field automatically set to "22")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • ChanA(uint): Channel number from ITU-R M.1084 Annex 4
  • ChanB(uint): Channel number from ITU-R M.1084 Annex 4
  • TxRxMode(uint):
  • power(uint):
  • corner1_lon(decimal): north-east corner of area for assignment longitude of corner
  • corner1_lat(decimal): north-east corner of area for assignment latitude of corner
  • corner2_lon(decimal): south-west corner of area for assignment longitude of corner
  • corner2_lat(decimal): south-west corner of area for assignment latitude of corner
  • IndicatorType(uint):
  • ChanABandwidth(uint):
  • ChanBBandwidth(uint):
  • TransZoneSize(uint):
  • Spare(uint): Not used. Should be set to zero. (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 ChanMngmt message

Fields in params:
  • MessageID(uint): AIS message number. Must be 22 (field automatically set to "22")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • ChanA(uint): Channel number from ITU-R M.1084 Annex 4
  • ChanB(uint): Channel number from ITU-R M.1084 Annex 4
  • TxRxMode(uint):
  • power(uint):
  • corner1_lon(decimal): north-east corner of area for assignment longitude of corner
  • corner1_lat(decimal): north-east corner of area for assignment latitude of corner
  • corner2_lon(decimal): south-west corner of area for assignment longitude of corner
  • corner2_lat(decimal): south-west corner of area for assignment latitude of corner
  • IndicatorType(uint):
  • ChanABandwidth(uint):
  • ChanBBandwidth(uint):
  • TransZoneSize(uint):
  • Spare(uint): Not used. Should be set to zero. (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

decodeChanA(bv, validate=False)

source code 
None

decodeChanB(bv, validate=False)

source code 
None

decodeTxRxMode(bv, validate=False)

source code 
None

decodepower(bv, validate=False)

source code 
None

decodecorner1_lon(bv, validate=False)

source code 
None

decodecorner1_lat(bv, validate=False)

source code 
None

decodecorner2_lon(bv, validate=False)

source code 
None

decodecorner2_lat(bv, validate=False)

source code 
None

decodeIndicatorType(bv, validate=False)

source code 
None

decodeChanABandwidth(bv, validate=False)

source code 
None

decodeChanBBandwidth(bv, validate=False)

source code 
None

decodeTransZoneSize(bv, validate=False)

source code 
None

decodeSpare(bv, validate=False)

source code 
None

printHtml(params, out=sys.stdout)

source code 
None

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

source code 

Print a ChanMngmt message to stdout.

Fields in params:
  • MessageID(uint): AIS message number. Must be 22 (field automatically set to "22")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • Spare(uint): Not used. Should be set to zero. (field automatically set to "0")
  • ChanA(uint): Channel number from ITU-R M.1084 Annex 4
  • ChanB(uint): Channel number from ITU-R M.1084 Annex 4
  • TxRxMode(uint):
  • power(uint):
  • corner1_lon(decimal): north-east corner of area for assignment longitude of corner
  • corner1_lat(decimal): north-east corner of area for assignment latitude of corner
  • corner2_lon(decimal): south-west corner of area for assignment longitude of corner
  • corner2_lat(decimal): south-west corner of area for assignment latitude of corner
  • IndicatorType(uint):
  • ChanABandwidth(uint):
  • ChanBBandwidth(uint):
  • TransZoneSize(uint):
  • Spare(uint): Not used. Should be set to zero. (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, 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

addMsgOptions(parser)

source code 
None

Variables Details [hide private]

__date__

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

TrueBV

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

FalseBV

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

fieldList

None
Value:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'Spare',
 'ChanA',
 'ChanB',
 'TxRxMode',
 'power',
...                                                                    
      

fieldListPostgres

None
Value:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'Spare',
 'ChanA',
 'ChanB',
 'TxRxMode',
 'power',
...                                                                    
      

toPgFields

Go to the Postgis field names from the straight field name
Value:
{'corner1_lat': 'corner1',
 'corner1_lon': 'corner1',
 'corner2_lat': 'corner2',
 'corner2_lon': 'corner2'}                                             
      

fromPgFields

Go from the Postgis field names to the straight field name
Value:
{'corner1': ('corner1_lon', 'corner1_lat'),
 'corner2': ('corner2_lon', 'corner2_lat')}                            
      

pgTypes

Lookup table for each postgis field name to get its type.
Value:
{'corner2': 'POINT', 'corner1': 'POINT'}                               
      

RepeatIndicatorEncodeLut

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

RepeatIndicatorDecodeLut

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

TxRxModeEncodeLut

None
Value:
{'Tx A, Rx A/Rx B': '1', 'Tx A/Tx B, Rx A/RX B': '0', 'Tx B, Rx A/Rx B
': '2'}                                                                
      

TxRxModeDecodeLut

None
Value:
{'0': 'Tx A/Tx B, Rx A/RX B', '1': 'Tx A, Rx A/Rx B', '2': 'Tx B, Rx A
/Rx B'}                                                                
      

powerEncodeLut

None
Value:
{'high': '0', 'low': '1'}                                              
      

powerDecodeLut

None
Value:
{'1': 'low', '0': 'high'}                                              
      

IndicatorTypeEncodeLut

None
Value:
{'broadcast': '0', 'addressed': '1'}                                   
      

IndicatorTypeDecodeLut

None
Value:
{'1': 'addressed', '0': 'broadcast'}                                   
      

ChanABandwidthEncodeLut

None
Value:
{'12.5kHz': '1', 'specified by channel number': '0'}                   
      

ChanABandwidthDecodeLut

None
Value:
{'1': '12.5kHz', '0': 'specified by channel number'}                   
      

ChanBBandwidthEncodeLut

None
Value:
{'12.5kHz': '1', 'specified by channel number': '0'}                   
      

ChanBBandwidthDecodeLut

None
Value:
{'1': '12.5kHz', '0': 'specified by channel number'}                   
      

TransZoneSizeEncodeLut

None
Value:
{'1': '0',
 '2': '1',
 '3': '2',
 '4': '3',
 '5': '4',
 '6': '5',
 '7': '6',
 '8': '7'}                                                             
      

TransZoneSizeDecodeLut

None
Value:
{'0': '1',
 '1': '2',
 '2': '3',
 '3': '4',
 '4': '5',
 '5': '6',
 '6': '7',
 '7': '8'}                                                             
      

typeChoices

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

outputChoices

None
Value:
'std', 'html', 'csv', 'sql'                                            
      

dbChoices

None
Value:
'sqlite', 'postgres'                                                   
      

outfile

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

msgDict

None
Value:
{'MessageID': '22', 'RepeatIndicator': options.RepeatIndicatorField, '
UserID': options.UserIDField, 'Spare': '0', 'ChanA': options.ChanAFiel
d, 'ChanB': options.ChanBField, 'TxRxMode': options.TxRxModeField, 'po
wer': options.powerField, 'corner1_lon': options.corner1_lonField, 'co
rner1_lat': options.corner1_latField, 'corner2_lon': options.corner2_l
onField, 'corner2_lat': options.corner2_latField, 'IndicatorType': opt
ions.IndicatorTypeField, 'ChanABandwidth': options.ChanABandwidthField
, 'ChanBBandwidth': options.ChanBBandwidthField, 'TransZoneSize': opti
...                                                                    
      

bitLen

None
Value:
len(bits)                                                              
      

bits

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

buf

None
Value:
StringIO.StringIO()                                                    
      

result

None
Value:
buf.getvalue()