Exemplo n.º 1
0
    def LoadFile(self):
        """
        Re-Assemble the data into full packets
        """
        # Initialize the AIS Parser class
        ais_state = aisparser.ais_state()


        # Process the whole file
        info = os.stat( self.filename )

        dialog = wx.ProgressDialog("Loading %s" % (self.filename),
                               "Time remaining",
                               info[stat.ST_SIZE],
                               style=wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME)


        ais_file = open( self.filename, "r" )
        old_pos = 0
        while 1:
            line = ais_file.readline().strip()
            if not line:
                break
            pos = ais_file.tell()
            if pos > old_pos + 4e3:
                keepGoing = dialog.Update(pos)
                old_pos = pos

            result = aisparser.assemble_vdm( ais_state, line )
            if result == 0:
                ais_state.msgid = aisparser.get_6bit( ais_state.six_state, 6 )
                ais_state.msg = AisMessage( ais_state )
                if ais_state.msg.data:
                    self.ais_info.append( ais_state )
                # Re-start the parser, creating a new ais_state object
                ais_state = aisparser.ais_state()
        ais_file.close()
        dialog.Destroy()
Exemplo n.º 2
0
    def LoadFile(self):
        """
        Re-Assemble the data into full packets
        """
        # Initialize the AIS Parser class
        ais_state = aisparser.ais_state()

        # Process the whole file
        info = os.stat(self.filename)

        dialog = wx.ProgressDialog("Loading %s" % (self.filename),
                                   "Time remaining",
                                   info[stat.ST_SIZE],
                                   style=wx.PD_ELAPSED_TIME
                                   | wx.PD_REMAINING_TIME)

        ais_file = open(self.filename, "r")
        old_pos = 0
        while 1:
            line = ais_file.readline().strip()
            if not line:
                break
            pos = ais_file.tell()
            if pos > old_pos + 4e3:
                keepGoing = dialog.Update(pos)
                old_pos = pos

            result = aisparser.assemble_vdm(ais_state, line)
            if result == 0:
                ais_state.msgid = aisparser.get_6bit(ais_state.six_state, 6)
                ais_state.msg = AisMessage(ais_state)
                if ais_state.msg.data:
                    self.ais_info.append(ais_state)
                # Re-start the parser, creating a new ais_state object
                ais_state = aisparser.ais_state()
        ais_file.close()
        dialog.Destroy()
Exemplo n.º 3
0
#try:
#    f = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#    f.connect('192.168.2.70',1234)
#    s = f.makefile('r')
#except:
#    sys.stderr.write("Error connecting")
#    raise

with open('log_ais_vhtm.log', 'r') as f:
    s = f.readlines()

ais_state = aisparser.ais_state()

for p in s:
    result = aisparser.assemble_vdm(ais_state, p)
    #    print "%s : %s" % (result, p)
    if (result == 0):
        ais_state.msgid = aisparser.get_6bit(ais_state.six_state, 6)
        #        print "msgid = %d" % (ais_state.msgid)

        if ais_state.msgid == 1:
            msg = aisparser.aismsg_1()
            aisparser.parse_ais_1(ais_state, msg)
            (status, lat_dd,
             long_ddd) = aisparser.pos2ddd(msg.latitude, msg.longitude)

            print "%s,%d,%s,%s" % (p[0:19], msg.userid, lat_dd, long_ddd)
#            print "mmsi     : %d" % (msg.userid)
#            print "latitude : %d" % (msg.latitude)
#            print "longitude: %d" % (msg.longitude)
#!/usr/bin/python

import aisparser
import fileinput

s=fileinput.input()

#with open('log_ais_web2day.log', 'r') as f:
#	s=f.readlines()

ais_state = aisparser.ais_state()

for p in s:
    result = aisparser.assemble_vdm( ais_state, p )
#    print "%s : %s" % (result, p)
    if( result == 0):
        ais_state.msgid = aisparser.get_6bit( ais_state.six_state, 6 )
#        print "msgid = %d" % (ais_state.msgid)

        if ais_state.msgid == 1:
            msg = aisparser.aismsg_1()
            aisparser.parse_ais_1( ais_state, msg )
            (status,lat_dd,long_ddd) = aisparser.pos2ddd(msg.latitude, msg.longitude)

#            print "%s,%d,%s,%s" % (p[0:19],msg.userid,lat_dd,long_ddd)
#            print "mmsi     : %d" % (msg.userid)
#            print "latitude : %d" % (msg.latitude)
#            print "longitude: %d" % (msg.longitude)
#            print "lat_dd   : %s" % (lat_dd)
#            print "long_ddd : %s" % (long_ddd)
#            print "pos_acc  : %d" % (ord(msg.pos_acc))
Exemplo n.º 5
0
                   'long': 0.0,
                   'alt': 0.0,
                   'speed': 0.0,
                   'rssi': 0.0,
                   'mes_str': ''}
 for fileName in filesList:
     numfile += 1
     text = ''
     fid_in = open(fileName, 'r')
     for line in fid_in:
         line = line.split('\t')
         # Если плохая строка
         if line[0].find('!') != 0:
             continue
         # Строка хороша
         result = aisparser.assemble_vdm(ais_state, line[0])
         if result:
             continue
         else:
             dict_msg = dict(clear_dict_msg)
             dict_obj = dict(clear_dict_obj)
             ais_state.msgid = aisparser.get_6bit(ais_state.six_state, 6)
             dict_msg['msg_id'] = ais_state.msgid
             dict_msg['channel'] = line[0].split(',')[4]
             if ais_state.msgid == 1:
                 msg = aisparser.aismsg_1()
                 aisparser.parse_ais_1(ais_state, msg)
                 (status, lat_dd, long_ddd) = aisparser.pos2ddd(msg.latitude, msg.longitude)
                 dict_msg['mmsi'] = msg.userid
                 dict_msg['ship_lat'] = lat_dd
                 dict_msg['ship_long'] = long_ddd