Beispiel #1
0
def writeLocationLog(imei , data):

    locationLog = LocationLog()

    utm = PacketParser.get_utm(data)
    locationLog.lat = utm[0]
    locationLog.long = utm[1]
    locationLog.timestamp = timezone.now()
    locationLog.speed = PacketParser.get_speed(data)
    locationLog.heading = PacketParser.get_heading(data)
    locationLog.car = getCarByImei(imei)
    locationLog.driver = locationLog.car.getDriverByDate(locationLog.timestamp)

    locationLog.save()

    checkAlerts(locationLog)
Beispiel #2
0
    def makeNewLocationLog(self):
        unit_collection = Unit.objects.get(imei=self.imei)
        if not unit_collection:
            print 'we got a message from unit we don\'t know, imei# %s, it said: "%s"' % self.imei, self.data  
            return
        unit = unit_collection[0] 
        car = unit.car
        utm =  PacketParser.get_utm(self.data)
        driver = car ? car.getDriverByDate(datetime.now()) : None
        
        kwargs = {  "timestamp" :  datetime.now(),
                    "lat" : utm[0],       
                    "long" : utm[1],      
                    "speed" : PacketParser.get_speed(self.data),
                    "heading" : PacketParser.get_heading(self.data)  ,               
                    "car" : car ,
                    "driver" : driver,
                  }

        logToWrite = LocationLog(**kwargs)
        logToWrite.save()
        return logToWrite