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

Module ais_msg_5

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]
  Testshipdata
Use testvalue tag text from each type to build test case the shipdata message

Functions [hide private]
BitVector encode(params, validate=False)
Create a shipdata binary message payload to pack into an AIS Msg shipdata.
dict decode(bv, validate=False)
Unpack a shipdata message
  decodeMessageID(bv, validate=False)
  decodeRepeatIndicator(bv, validate=False)
  decodeUserID(bv, validate=False)
  decodeAISversion(bv, validate=False)
  decodeIMOnumber(bv, validate=False)
  decodecallsign(bv, validate=False)
  decodename(bv, validate=False)
  decodeshipandcargo(bv, validate=False)
  decodedimA(bv, validate=False)
  decodedimB(bv, validate=False)
  decodedimC(bv, validate=False)
  decodedimD(bv, validate=False)
  decodefixtype(bv, validate=False)
  decodeETA(bv, validate=False)
  decodedraught(bv, validate=False)
  decodedestination(bv, validate=False)
  decodedte(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 shipdata 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-18'
Date of last svn commit
  TrueBV = <ais.BitVector.BitVector object at 0x22aa630>
Why always rebuild the True bit? This should speed things up a bunch
  FalseBV = <ais.BitVector.BitVector object at 0x22aa6b0>
Why always rebuild the False bit? This should speed things up a bunch
  fieldList = ('MessageID', 'RepeatIndicator', 'UserID', 'AISversi...
  fieldListPostgres = ('MessageID', 'RepeatIndicator', 'UserID', 'AISversi...
  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.
  RepeatIndicatorEncodeLut = {'default': '0', 'do not repeat any more': '3'}
  RepeatIndicatorDecodeLut = {'0': 'default', '3': 'do not repeat any more'}
  fixtypeEncodeLut = {'combined GPS/GLONASS': '3', 'integrated navigation...
  fixtypeDecodeLut = {'1': 'GPS', '0': 'undefined', '3': 'combined GPS/GL...
  dteEncodeLut = {'available': '0', 'not available': '1'}
  dteDecodeLut = {'1': 'not available', '0': 'available'}
  typeChoices = 'binary', 'nmeapayload', 'nmea'
  outputChoices = 'std', 'html', 'csv', 'sql'
  dbChoices = 'sqlite', 'postgres'
  outfile = file(options.outputFileName, 'w')
  msgDict = {'MessageID': '5', 'RepeatIndicator': options.Repeat...
  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 shipdata binary message payload to pack into an AIS Msg shipdata.

Fields in params:
  • MessageID(uint): AIS message number. Must be 5 (field automatically set to "5")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • AISversion(uint): Compliant with what edition. 0 is the first edition.
  • IMOnumber(uint): vessel identification number (different than mmsi)
  • callsign(aisstr6): Ship radio call sign
  • name(aisstr6): Vessel name
  • shipandcargo(uint): what
  • dimA(uint): FIX: write a description
  • dimB(uint): FIX: write a description
  • dimC(uint): FIX: write a description
  • dimD(uint): FIX: write a description
  • fixtype(uint): Method used for positioning
  • ETA(uint): FIX: break this out
  • draught(udecimal): Maximum present static draught. 25.5 is 25.5 m or greater
  • destination(aisstr6): Where is the vessel going
  • dte(uint): Data terminal ready
  • Spare(uint): Reserved for definition by a regional authority. (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 shipdata message

Fields in params:
  • MessageID(uint): AIS message number. Must be 5 (field automatically set to "5")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • AISversion(uint): Compliant with what edition. 0 is the first edition.
  • IMOnumber(uint): vessel identification number (different than mmsi)
  • callsign(aisstr6): Ship radio call sign
  • name(aisstr6): Vessel name
  • shipandcargo(uint): what
  • dimA(uint): FIX: write a description
  • dimB(uint): FIX: write a description
  • dimC(uint): FIX: write a description
  • dimD(uint): FIX: write a description
  • fixtype(uint): Method used for positioning
  • ETA(uint): FIX: break this out
  • draught(udecimal): Maximum present static draught. 25.5 is 25.5 m or greater
  • destination(aisstr6): Where is the vessel going
  • dte(uint): Data terminal ready
  • Spare(uint): Reserved for definition by a regional authority. (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

decodeAISversion(bv, validate=False)

source code 
None

decodeIMOnumber(bv, validate=False)

source code 
None

decodecallsign(bv, validate=False)

source code 
None

decodename(bv, validate=False)

source code 
None

decodeshipandcargo(bv, validate=False)

source code 
None

decodedimA(bv, validate=False)

source code 
None

decodedimB(bv, validate=False)

source code 
None

decodedimC(bv, validate=False)

source code 
None

decodedimD(bv, validate=False)

source code 
None

decodefixtype(bv, validate=False)

source code 
None

decodeETA(bv, validate=False)

source code 
None

decodedraught(bv, validate=False)

source code 
None

decodedestination(bv, validate=False)

source code 
None

decodedte(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 shipdata message to stdout.

Fields in params:
  • MessageID(uint): AIS message number. Must be 5 (field automatically set to "5")
  • RepeatIndicator(uint): Indicated how many times a message has been repeated
  • UserID(uint): Unique ship identification number (MMSI)
  • AISversion(uint): Compliant with what edition. 0 is the first edition.
  • IMOnumber(uint): vessel identification number (different than mmsi)
  • callsign(aisstr6): Ship radio call sign
  • name(aisstr6): Vessel name
  • shipandcargo(uint): what
  • dimA(uint): FIX: write a description
  • dimB(uint): FIX: write a description
  • dimC(uint): FIX: write a description
  • dimD(uint): FIX: write a description
  • fixtype(uint): Method used for positioning
  • ETA(uint): FIX: break this out
  • draught(udecimal): Maximum present static draught. 25.5 is 25.5 m or greater
  • destination(aisstr6): Where is the vessel going
  • dte(uint): Data terminal ready
  • Spare(uint): Reserved for definition by a regional authority. (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-18'                                                           
      

TrueBV

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

FalseBV

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

fieldList

None
Value:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'AISversion',
 'IMOnumber',
 'callsign',
 'name',
 'shipandcargo',
...                                                                    
      

fieldListPostgres

None
Value:
('MessageID',
 'RepeatIndicator',
 'UserID',
 'AISversion',
 'IMOnumber',
 'callsign',
 'name',
 'shipandcargo',
...                                                                    
      

toPgFields

Go to the Postgis field names from the straight field name
Value:
{}                                                                     
      

fromPgFields

Go from the Postgis field names to the straight field name
Value:
{}                                                                     
      

pgTypes

Lookup table for each postgis field name to get its type.
Value:
{}                                                                     
      

RepeatIndicatorEncodeLut

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

RepeatIndicatorDecodeLut

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

fixtypeEncodeLut

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

fixtypeDecodeLut

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

dteEncodeLut

None
Value:
{'available': '0', 'not available': '1'}                               
      

dteDecodeLut

None
Value:
{'1': 'not available', '0': 'available'}                               
      

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': '5', 'RepeatIndicator': options.RepeatIndicatorField, 'U
serID': options.UserIDField, 'AISversion': options.AISversionField, 'I
MOnumber': options.IMOnumberField, 'callsign': options.callsignField, 
'name': options.nameField, 'shipandcargo': options.shipandcargoField, 
'dimA': options.dimAField, 'dimB': options.dimBField, 'dimC': options.
dimCField, 'dimD': options.dimDField, 'fixtype': options.fixtypeField,
 'ETA': options.ETAField, 'draught': options.draughtField, 'destinatio
n': options.destinationField, 'dte': options.dteField, '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()