Package ais
[hide private]
[frames] | no frames]

Source Code for Package ais

  1  __version__ = '0.32' 
  2  '''The version of ais-py''' 
  3  __docformat__ = 'epytext en' 
  4  __author__ = 'Kurt Schwehr <kurt@ccom.unh.edu>' 
  5  '''The primary author of ais-py''' 
  6  __url__ = 'http://vislab-ccom.unh.edu/~schwehr/src/noaadata/' 
  7  '''The ais-py homepage''' 
  8   
  9  __doc__=''' 
 10  Python module for Automatic Indentification System (AIS).  This is 
 11  the 3rd iteration of creating an AIS codec package in python.  This 
 12  version is more a compiler so that it could be altered to emit 
 13  something other than python if need be.  The focus this time is on 
 14  building a simple distributable batch of code that only requires the 
 15  python lxml package when it builds the python.  After that, the only 
 16  requirement is the BitVector package by Avi Kak.  BitVector is included 
 17  with permission for your convenience, but it is best if you install 
 18  BitVector yourself from the original distribution. 
 19   
 20  @see: NMEA strings at U{http://gpsd.berlios.de/NMEA.txt} 
 21  @see: Wikipedia at U{http://en.wikipedia.org/wiki/Automatic_Identification_System} 
 22   
 23  @author: Kurt Schwehr U{email<mailto:kurt@ccom.unh.edu>} U{homepage<http://schwehr.org>} 
 24  @requires: U{Python<http://python.org/>} >= 2.4 
 25  @requires: U{lxml<http://codespeak.net/lxml/>} >= 1.1.2 
 26  @requires: U{libxml2<http://xmlsoft.org/>} for xmllint 
 27  @requires: U{BitVector<http://cobweb.ecn.purdue.edu/~kak/dist/>} >= 1.2 
 28  @requires: U{epydoc<http://epydoc.sourceforge.net>} >= 3.0alpha3 
 29  @version: '''+__version__+''' 
 30   
 31  @license: GPL version 2 
 32  @copyright: (C) 2006-2007 Kurt Schwehr/UNH 
 33   
 34  @undocumented: __doc__ 
 35  @undocumented: __version__ __author__ __url__ 
 36  @todo: the msgName variable should be generated from the XML 
 37  ''' 
 38   
 39  msgNames = { 
 40      1:'Position, Class A' # FIX: explain difference in 1..3 
 41      ,2:'Position, Class A' 
 42      ,3:'Position, Class A' 
 43      ,4:'Base station report' 
 44      ,5:'Ship and Cargo' 
 45      ,6:'Addressed binary message' 
 46      ,7:'ACK for addressed binary message' 
 47      ,8:'Binary broadcast message (BBM)' 
 48      ,9:'SAR Position' 
 49      ,10:'UTC query' 
 50      ,11:'?' 
 51      ,12:'ASRM' 
 52      ,13:'?' 
 53      ,14:'SRBM' 
 54      ,15:'Interrogation' 
 55      ,16:'?' 
 56      ,17:'?' 
 57      ,18:'Position, Class B' 
 58      ,19:'Position and ship, Class B' 
 59      ,20:'Data link management' 
 60      ,21:'Aids to navigation report' 
 61      ,22:'?' 
 62      ,23:'Group Assignment Command' 
 63      ,24:'Static data report' 
 64      ,25:'Single slit binary message - addressed or broadcast' 
 65      ,26:'Multi slot binary message with comm state' 
 66      } 
 67  ''' 
 68  Messages in the main AIS name space 
 69  ''' 
 70   
 71  # FIX: is this really the right way to do things?  Definitely helps with tab completion and less user code 
 72   
 73  import ais_msg_1 
 74  import ais_msg_2 
 75  import ais_msg_3 
 76  import ais_msg_4 
 77  import ais_msg_5 
 78  import ais_msg_6 
 79  import ais_msg_7 
 80  import ais_msg_8 
 81  import ais_msg_9 
 82  import ais_msg_10 
 83  #import ais_msg_11 
 84  import ais_msg_12 
 85  #import ais_msg_13 
 86  import ais_msg_14 
 87  import ais_msg_15 
 88  #import ais_msg_16 
 89  #import ais_msg_17 
 90  import ais_msg_18 
 91  import ais_msg_19 
 92  import ais_msg_20 
 93  import ais_msg_21 
 94  import ais_msg_22 
 95  #import ais_msg_23 
 96  #import ais_msg_24 
 97  #import ais_msg_25 
 98  #import ais_msg_26 
 99   
100  import binary 
101   
102  msgModByNumber={ 
103       1: ais_msg_1 
104       ,2: ais_msg_2 
105       ,3: ais_msg_3 
106       ,4: ais_msg_4 
107       ,5: ais_msg_5 
108       ,6: ais_msg_6 
109       ,7: ais_msg_7 
110       ,8: ais_msg_8 
111       ,9: ais_msg_9 
112       ,10: ais_msg_10 
113  #     ,11: ais_msg_11 
114       ,12: ais_msg_12 
115  #     ,13: ais_msg_13 
116       ,14: ais_msg_14 
117       ,15: ais_msg_15 
118  #     ,16: ais_msg_16 
119  #     ,17: ais_msg_17 
120       ,18: ais_msg_18 
121       ,19: ais_msg_19 
122       ,20: ais_msg_20 
123       ,21: ais_msg_21 
124       ,22: ais_msg_22 
125  #     ,23: ais_msg_23 
126  #     ,24: ais_msg_24 
127  #     ,25: ais_msg_25 
128  #     ,26: ais_msg_26 
129   
130      } 
131  ''' 
132  Allows easier decoding of messages without having to write as much code 
133  ''' 
134   
135  msgModByFirstChar={ 
136         '1': ais_msg_1 
137      ,  '2': ais_msg_2 
138      ,  '3': ais_msg_3 
139      ,  '4': ais_msg_4 
140      ,  '5': ais_msg_5 
141      ,  '6': ais_msg_6 
142      ,  '7': ais_msg_7 
143      ,  '8': ais_msg_8 
144      ,  '9': ais_msg_9 
145      ,  ':': ais_msg_10 
146  #    ,  ';': ais_msg_11 
147      ,  '<': ais_msg_12 
148  #    ,  '=': ais_msg_13 
149      ,  '>': ais_msg_14 
150      ,  '?': ais_msg_15 
151  #    ,  '@': ais_msg_16 
152  #    ,  'A': ais_msg_17 
153      ,  'B': ais_msg_18 
154      ,  'C': ais_msg_19 
155      ,  'D': ais_msg_20 
156      ,  'E': ais_msg_21 
157      ,  'F': ais_msg_22 
158  #    ,  'G': ais_msg_23 
159  #    ,  'H': ais_msg_24 
160  #    ,  'I': ais_msg_25 
161  #    ,  'J': ais_msg_26 
162  } 
163