Ejemplo n.º 1
0
def udp_listener_summary_callback(data):
    ''' Handle a Payload Summary Message from UDPListener '''
    # Extract the fields we need.

    # Convert to something generic we can pass onwards.
    output = {}
    output['lat'] = data['latitude']
    output['lon'] = data['longitude']
    output['alt'] = data['altitude']
    output['callsign'] = data['callsign']

    logging.info("Horus UDP Data: %.5f, %.5f, %.1f" % (output['lat'], output['lon'], output['alt']))

    # Process the 'short time' value if we have been provided it.
    if 'time' in data.keys():
        output['time_dt'] = fix_datetime(data['time'])
        #_full_time = datetime.utcnow().strftime("%Y-%m-%dT") + data['time'] + "Z"
        #output['time_dt'] = parse(_full_time)
    else:
        # Otherwise use the current UTC time.
        
        output['time_dt'] = pytz.utc.localize(datetime.utcnow())

    # Copy out any extra fields that we want to pass on to the GUI.
    for _field in EXTRA_FIELDS:
        if _field in data:
            output[_field] = data[_field]

    try:
        handle_new_payload_position(output)
    except Exception as e:
        logging.error("Error Handling Payload Position - %s" % str(e))
Ejemplo n.º 2
0
def udp_listener_summary_callback(data):
    """ Handle a Payload Summary Message from UDPListener """

    # Modem stats messages are also passed in via this callback.
    # handle them separately.
    if data["type"] == "MODEM_STATS":
        handle_modem_stats(data)
        return

    # Otherwise, we have a PAYLOAD_SUMMARY message.

    # Extract the fields we need.
    # Convert to something generic we can pass onwards.
    output = {}
    output["lat"] = float(data["latitude"])
    output["lon"] = float(data["longitude"])
    output["alt"] = float(data["altitude"])
    output["callsign"] = data["callsign"]

    if "time" in data.keys():
        _time = data["time"]
    else:
        _time = "??:??:??"

    logging.info(
        "Horus UDP Data: %s, %s, %.5f, %.5f, %.1f"
        % (output["callsign"], _time, output["lat"], output["lon"], output["alt"])
    )

    # Process the 'short time' value if we have been provided it.
    if "time" in data.keys():
        output["time_dt"] = fix_datetime(data["time"])
        # _full_time = datetime.utcnow().strftime("%Y-%m-%dT") + data['time'] + "Z"
        # output['time_dt'] = parse(_full_time)
    else:
        # Otherwise use the current UTC time.

        output["time_dt"] = pytz.utc.localize(datetime.utcnow())

    # Copy out any extra fields that we want to pass on to the GUI.
    for _field in EXTRA_FIELDS:
        if _field in data:
            output[_field] = data[_field]

    try:
        handle_new_payload_position(output)
    except Exception as e:
        logging.error("Error Handling Payload Position - %s" % str(e))