Exemplo n.º 1
0
    def runGPS(self):
        GPS = gps.GpsThread()
        GPS.start()
        time.sleep(5) ## wait until GPS settles
        while 1:
            st = time.time()
            (lat,lon,alt) = GPS.getCoordinates()
            try:
                DiffDegree = 4*math.pow(self.PREVIOUS[0]-lat,2)+math.pow(self.PREVIOUS[1]-lon,2)
            except:
                print "GPS is not valid FAIL to calculate difference"
            print self.PREVIOUS
            try:
                if self.PREVIOUS == None:
        	    try: 
                    	XML = self.MakeXML(alt,lat,lon,GPS.getPDOP(), GPS.getSatellites(), GPS.getSpeed(), GPS.getTime(), 10, 10)
                        self.PREVIOUS = [lat,lon]
        	    except:
        		print "GPS is not valid a"
                    GPSXMLqueue.put(XML,True,0.5)
                elif  DiffDegree > DIFF:
        	    try: 
                    	XML = self.MakeXML(alt,lat,lon,GPS.getPDOP(), GPS.getSatellites(), GPS.getSpeed(), GPS.getTime(), 10, 10)
                        self.PREVIOUS = [lat,lon]
        	    except:
        		print "GPS is not valid b"
                    GPSXMLqueue.put(XML,True,0.5)
                else:
		    print "something happens"
                    pass
            except:
                print "You're missing GPS data because QUEUE is full or not valid XML"
            ed = time.time() - st
            time.sleep(1-ed)
Exemplo n.º 2
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.gpsThread = gps.GpsThread()
     self.gpsThread.start()
     print "started gps thread"
     self.running = 1
     self.counting = 2
Exemplo n.º 3
0
    def UTCset(self):
        local = gps.GpsThread()
        local.start()
        print "Time Setting"
        counting = 2
        #for i in range(20):
        while self.running:
            tempTime = local.getTime()
            print "loop"
            if tempTime == '?':
                pass
            else:
                self.counting = self.counting - 1
                if self.counting < 1:
                    tempTime = tempTime.split(' ')
                    tempDate = tempTime[0]
                    tempTime = tempTime[1]
                    tempDate = tempDate.split('/')
                    tempTime = tempTime.split(':')
                    os.popen("/bin/date -u %s%s%s%s%s.%s" %
                             (tempDate[1], tempDate[0], tempTime[0],
                              tempTime[1], tempDate[2], tempTime[2]))
                    print "set"
                    self.running = 0
                    local.stop()
                    sys.exit(1)
                    break

                    #setting time using date
                else:
                    print tempTime
            time.sleep(1)
Exemplo n.º 4
0
 def runGPS(self):
     GPS = gps.GpsThread()
     GPS.start()
     time.sleep(5)  ## wait until GPS settles
     while 1:
         st = time.time()
         try:
             bing = os.popen("/bin/bing -c 2 -e 2 192.168.1.3 ericsson.com")
             ping = os.popen("/bin/ping -c 2 ericsson.com")
         except:
             pass
         (lat, lon, alt) = GPS.getCoordinates()
         XML = self.MakeXML(alt, lat, lon, GPS.getPDOP(), GPS.getSpeed(),
                            GPS.getTime(), netcarID, bing.read(),
                            ping.read())
         GPRSXMLqueue.put(XML, True, 0.5)
         ed = time.time() - st
         time.sleep(20 - ed)
Exemplo n.º 5
0
    def runGPS(self):
        GPS = gps.GpsThread()
        GPS.start()
        time.sleep(5)  ## wait until GPS settles
        while 1:
            (lat, lon, alt) = GPS.getCoordinates()
            print GPS.getTime()
            try:
                XML = self.MakeXML(alt, lat, lon, GPS.getPDOP(),
                                   GPS.getSatellites(), GPS.getSpeed(),
                                   GPS.getTime(), 10, 10)
            except:
                print "GPS is not valid"
#print XML
            try:
                GPSXMLqueue.put(XML, True, 0.5)
            except:
                print "You're missing GPS data"
            time.sleep(1)
Exemplo n.º 6
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(180, 280))

        # Setting up the menu
        filemenu = wx.Menu()
        filemenu.Append(ID_CONNECT, "&Connect",
                        " Connect to a live stream of data")
        filemenu.Append(ID_PLOT, "&Plot",
                        " Plot an existing stream of data from a file")
        filemenu.AppendSeparator()
        filemenu.Append(ID_EXIT, "E&xit", " Terminate the program")
        # Creating the menubar
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu, "&Menu")  # Adding the "filemenu" to menubar
        self.SetMenuBar(menuBar)  # Adding menubar to the frame content

        #Sending events on "Connect" "Plot" and "Exit"
        wx.EVT_MENU(self, ID_CONNECT, self.OnConnect)
        wx.EVT_MENU(self, ID_EXIT, self.OnExit)
        wx.EVT_MENU(self, ID_PLOT, self.OnPlot)

        sizer = wx.GridSizer(4, 1)

        self.SetSizer(sizer)

        self.panel1 = wx.Panel(self)

        self.graphs = []

        self.graphs.append(plot.PlotCanvas(self))
        self.graphs.append(plot.PlotCanvas(self))
        self.graphs.append(plot.PlotCanvas(self))
        for g in self.graphs:
            g.SetEnableLegend(True)

            sizer.Add(g, 0, wx.EXPAND)

        #add the pannel to tag the data
        panel = wx.Panel(self)
        buttonSizer = wx.GridSizer(1, 3)

        panel.SetSizer(buttonSizer)

        accels = []

        i = 1
        for e in events:
            b = wx.Button(panel, -1, str(i) + " " + e)
            self.Bind(wx.EVT_BUTTON, self.OnButtonTag, b)
            buttonSizer.Add(b, 0, wx.EXPAND)
            i += 1

        self.Bind(wx.EVT_KEY_DOWN, self.KeyPressed, self)

        sizer.Add(panel, 0, wx.EXPAND)

        self.CreateStatusBar()

        self.Show(True)
        panel.SetFocus()

        self.g = gps.GpsThread("/dev/ttyUSB3")

        self.index = 0
        self.time = 0
        self.d0 = {}
        self.d1 = {}
        self.d2 = {}
        self.file = 0
        self.gpsfile = 0
        self.dir = str(int(time.time())) + "/"
        os.mkdir(self.dir)

        EVT_RESULT(self, self.OnResult)