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
#import os,sys,socket
import aisparser
#import fileinput

#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)
#!/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))