def __init__(self, sbs1Message): log.debug("%s appeared" % sbs1Message.icao24) self.messageType = sbs1Message.messageType self.transmissionType = sbs1Message.transmissionType self.sessionID = sbs1Message.sessionID self.aircraftID = sbs1Message.aircraftID self.icao24 = sbs1Message.icao24 self.loggedDate = sbs1Message.loggedDate self.callsign = sbs1Message.callsign self.altitude = sbs1Message.altitude self.groundSpeed = sbs1Message.groundSpeed self.track = sbs1Message.track self.lat = sbs1Message.lat self.lon = sbs1Message.lon self.verticalRate = sbs1Message.verticalRate self.device = getenv('RESIN_DEVICE_NAME_AT_INIT') self.operator = None self.registration = None self.type = None self.lost = False self.updated = True if args.pdb_host: plane = planedb.lookup_aircraft(self.icao24) if plane: self.registration = plane['registration'] self.type = plane['manufacturer'] + " " + plane['model'] self.operator = plane['operator'] else: log.debug("icao24 %s not found in the database" % (self.icao24))
def __init__(self, sbs1msg): logging.info("%s appeared" % sbs1msg["icao24"]) self.__icao24 = sbs1msg["icao24"] self.__loggedDate = datetime.utcnow() # sbs1msg["loggedDate"] self.__callsign = sbs1msg["callsign"] self.__altitude = sbs1msg["altitude"] self.__altitudeTime = datetime.utcnow() self.__groundSpeed = sbs1msg["groundSpeed"] self.__track = sbs1msg["track"] self.__lat = sbs1msg["lat"] self.__lon = sbs1msg["lon"] self.__latLonTime = datetime.utcnow() self.__verticalRate = sbs1msg["verticalRate"] self.__operator = None self.__registration = None self.__type = None self.__updated = True if args.pdb_host: plane = planedb.lookup_aircraft(self.__icao24) if plane: self.__registration = plane["registration"] self.__type = plane["manufacturer"] + " " + plane["model"] self.__operator = plane["operator"] self.__image_url = plane["image"] if self.__image_url is None: self.__image_url = utils.image_search(self.__icao24, self.__operator, self.__type, self.__registration) else: if not self.__planedb_nagged: self.__planedb_nagged = True logging.error("icao24 %s not found in the database" % (self.__icao24))
def update(self, sbs1Message): self.loggedDate = sbs1Message.loggedDate oldData = dict(self.__dict__) if sbs1Message.icao24: self.icao24 = sbs1Message.icao24 if sbs1Message.callsign and self.callsign != sbs1Message.callsign: self.callsign = sbs1Message.callsign if sbs1Message.altitude: self.altitude = sbs1Message.altitude if sbs1Message.groundSpeed: self.groundSpeed = sbs1Message.groundSpeed if sbs1Message.track: self.track = sbs1Message.track if sbs1Message.lat: self.lat = sbs1Message.lat if sbs1Message.lon: self.lon = sbs1Message.lon if sbs1Message.verticalRate: self.verticalRate = sbs1Message.verticalRate if not self.verticalRate: self.verticalRate = 0 if args.pdb_host: plane = planedb.lookup_aircraft(self.icao24) if plane: self.registration = plane['registration'] self.type = plane['manufacturer'] + " " + plane['model'] self.operator = plane['operator'] else: log.debug("icao24 %s not found in any data base" % (self.icao24)) # Check if observation was updated newData = dict(self.__dict__) del oldData["loggedDate"] del newData["loggedDate"] d = DictDiffer(oldData, newData) self.updated = len(d.changed()) > 0
def update(self, sbs1msg): oldData = dict(self.__dict__) self.__loggedDate = datetime.utcnow() if sbs1msg["icao24"]: self.__icao24 = sbs1msg["icao24"] if sbs1msg["callsign"] and self.__callsign != sbs1msg["callsign"]: self.__callsign = sbs1msg["callsign"].rstrip() if sbs1msg["altitude"]: self.__altitude = sbs1msg["altitude"] self.__altitudeTime = datetime.utcnow() if sbs1msg["groundSpeed"]: self.__groundSpeed = sbs1msg["groundSpeed"] if sbs1msg["track"]: self.__track = sbs1msg["track"] if sbs1msg["lat"]: self.__lat = sbs1msg["lat"] self.__latLonTime = datetime.utcnow() if sbs1msg["lon"]: self.__lon = sbs1msg["lon"] self.__latLonTime = datetime.utcnow() if sbs1msg["verticalRate"]: self.__verticalRate = sbs1msg["verticalRate"] if not self.__verticalRate: self.__verticalRate = 0 if sbs1msg["generatedDate"]: self.__generatedDate = sbs1msg["generatedDate"] #if sbs1msg["loggedDate"]: # self.__loggedDate = sbs1msg["loggedDate"] if args.pdb_host: plane = planedb.lookup_aircraft(self.__icao24) if plane: self.__registration = plane['registration'] self.__type = plane['manufacturer'] + " " + plane['model'] self.__operator = plane['operator'] else: if not self.__planedb_nagged: self.__planedb_nagged = True logging.error("icao24 %s not found in the database" % (self.__icao24)) if self.__callsign and not self.__route: route = planedb.lookup_route(self.__callsign) if route: src = planedb.lookup_airport(route['src_iata']) dst = planedb.lookup_airport(route['dst_iata']) if src and dst: src.pop('id', None) src.pop('added_on', None) src.pop('updated_on', None) dst.pop('id', None) dst.pop('added_on', None) dst.pop('updated_on', None) self.__route = {'origin' : src, 'destination' : dst} else: self.__route = {} else: self.__route = {} # Check if observation was updated newData = dict(self.__dict__) del oldData["_Observation__loggedDate"] del newData["_Observation__loggedDate"] d = DictDiffer(oldData, newData) self.__updated = len(d.changed()) > 0
def proxyCheck(bridge, data): global min_receiver_distance global max_receiver_distance global cur_tracking_distance global cur_icao24 global args global blacklisted global cur_route if not data: return lat = data["lat"] lon = data["lon"] if lat and lon: altitude = data["altitude"] icao24 = data["icao24"] lost = data["lost"] distance = receiverDistance(lat, lon, altitude) bearing = receiverBearing(lat, lon) data["distance"] = distance data["bearing"] = bearing # Is this the plane we're tracking or is it one that is closer? if icao24 == cur_icao24 or distance < cur_tracking_distance: plane = planedb.lookup_aircraft(icao24) if not plane: return img_url = plane['image'] if not img_url and blacklisted != cur_icao24: if data["operator"] and data["type"] and data["registration"]: img_url = image_search(data) if not img_url: # Don't try again for this plane blacklisted = icao24 if img_url: # Only track planes with images data["image"] = img_url if icao24 != cur_icao24: log.info("Giving up %s (%d), tracking %s (%d)", cur_icao24, cur_tracking_distance, icao24, distance) cur_route = None cur_icao24 = icao24 cur_tracking_distance = distance log.info("%s: pos:%2f, %2f @ %dft distance:%d bearing:%d" % (icao24, lat, lon, altitude, distance, bearing)) if not cur_route: route = planedb.lookup_route(data['callsign']) if route: src = planedb.lookup_airport(route['src_iata']) dst = planedb.lookup_airport(route['dst_iata']) if src and dst: src.pop('id', None) src.pop('added_on', None) src.pop('updated_on', None) dst.pop('id', None) dst.pop('added_on', None) dst.pop('updated_on', None) cur_route = {'origin': src, 'destination': dst} if cur_route: data['route'] = cur_route sendProx(bridge, data) if distance < min_receiver_distance: log.info("New min range for %s at %d", icao24, distance) min_receiver_distance = distance if distance > max_receiver_distance: log.info("New max range for %s at %d", icao24, distance) max_receiver_distance = distance