# Path: mlat/geodesy.py
# WGS84_A = 6378137.0
# WGS84_F = 1.0/298.257223563
# WGS84_B = WGS84_A * (1 - WGS84_F)
# WGS84_ECC_SQ = 1 - WGS84_B * WGS84_B / (WGS84_A * WGS84_A)
# WGS84_ECC = math.sqrt(WGS84_ECC_SQ)
# SPHERICAL_R = 6371e3
#     N = WGS84_A / math.sqrt(1 - WGS84_ECC_SQ * math.sin(lat)**2)
# def llh2ecef(llh):
# def ecef2llh(ecef):
# def greatcircle(p0, p1):
# def ecef_distance(p0, p1):
# 
# Path: mlat/server/net.py
# class MonitoringListener(object):
# class MonitoringConnector(object):
#     def __init__(self, host, port, factory, logger=glogger, description=None):
#     def start(self):
#     def _start(self):
#     def _new_client(self, r, w):
#     def _close(self):
#     def start_client(self, r, w):
#     def monitor_client(self, client):
#     def close(self):
#     def wait_closed(self):
#     def __init__(self, host, port, reconnect_interval, factory):
#     def start(self):
#     def reconnect(self):
#     def close(self):
#     def wait_closed(self):
# 
# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):
# 
# Path: mlat/server/connection.py
# class Connection(object):
#     def request_traffic(self, receiver, icao_set):
#     def report_mlat_position(self, receiver,
#                              receive_timestamp, address, ecef, ecef_cov, receivers, distinct):
# 
# Path: mlat/server/config.py
# MIN_NUC = 6
# MAX_RANGE = 500e3
# MAX_INTERMESSAGE_RANGE = 10e3
# MAX_ALT = 50000 * constants.FTOM
# MLAT_DELAY = 2.5
# SOLVER_MAXFEV = 50


import asyncio
import zlib
import logging
import json
import struct
import time
import random
import socket
import inspect
import sys
import math
from mlat import constants, geodesy
from mlat.server import net, util, connection, config
        elif 'heartbeat' in msg:
            self.process_heartbeat_message(msg['heartbeat'])
        elif 'rate_report' in msg:
            self.process_rate_report_message(msg['rate_report'])
        elif 'quine' in msg:
            self.process_quine_message(msg['quine'])
        else:
            self.logger.info('Received an unexpected message: %s', msg)

    def process_sync(self, et, ot, em, om):
        self.coordinator.receiver_sync(self.receiver, et, ot, em, om)

    def process_mlat_gps(self, t, m, now):
        # extract UTC receive time from Radarcape timestamps
        start_of_day = now - math.fmod(now, 86400)
        day_seconds = t / self.receiver.clock.freq
        utc = start_of_day + day_seconds

        # off by one error?
        utc -= 1

        # handle values close to rollover
        if day_seconds > 86000 and (utc - now) > 85000:
            # it's a value from yesterday that arrived after rollover
            utc -= 86400
            glogger.info('{0} GPS midnight rollover server={1:.3f} message={2:.3f}'.format(
                self.receiver,
                now,
                utc))


# Path: mlat/geodesy.py
# WGS84_A = 6378137.0
# WGS84_F = 1.0/298.257223563
# WGS84_B = WGS84_A * (1 - WGS84_F)
# WGS84_ECC_SQ = 1 - WGS84_B * WGS84_B / (WGS84_A * WGS84_A)
# WGS84_ECC = math.sqrt(WGS84_ECC_SQ)
# SPHERICAL_R = 6371e3
#     N = WGS84_A / math.sqrt(1 - WGS84_ECC_SQ * math.sin(lat)**2)
# def llh2ecef(llh):
# def ecef2llh(ecef):
# def greatcircle(p0, p1):
# def ecef_distance(p0, p1):
# 
# Path: mlat/server/net.py
# class MonitoringListener(object):
# class MonitoringConnector(object):
#     def __init__(self, host, port, factory, logger=glogger, description=None):
#     def start(self):
#     def _start(self):
#     def _new_client(self, r, w):
#     def _close(self):
#     def start_client(self, r, w):
#     def monitor_client(self, client):
#     def close(self):
#     def wait_closed(self):
#     def __init__(self, host, port, reconnect_interval, factory):
#     def start(self):
#     def reconnect(self):
#     def close(self):
#     def wait_closed(self):
# 
# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):
# 
# Path: mlat/server/connection.py
# class Connection(object):
#     def request_traffic(self, receiver, icao_set):
#     def report_mlat_position(self, receiver,
#                              receive_timestamp, address, ecef, ecef_cov, receivers, distinct):
# 
# Path: mlat/server/config.py
# MIN_NUC = 6
# MAX_RANGE = 500e3
# MAX_INTERMESSAGE_RANGE = 10e3
# MAX_ALT = 50000 * constants.FTOM
# MLAT_DELAY = 2.5
# SOLVER_MAXFEV = 50


# Path: mlat/server/jsonclient.py
import asyncio
import zlib
import logging
import json
import struct
import time
import random
import socket
import inspect
import sys
import math
from mlat import constants, geodesy
from mlat.server import net, util, connection, config

        elif 'heartbeat' in msg:
            self.process_heartbeat_message(msg['heartbeat'])
        elif 'rate_report' in msg:
            self.process_rate_report_message(msg['rate_report'])
        elif 'quine' in msg:
            self.process_quine_message(msg['quine'])
        else:
            self.logger.info('Received an unexpected message: %s', msg)

    def process_sync(self, et, ot, em, om):
        self.coordinator.receiver_sync(self.receiver, et, ot, em, om)

    def process_mlat_gps(self, t, m, now):
        # extract UTC receive time from Radarcape timestamps
        start_of_day = now - math.fmod(now, 86400)
        day_seconds = t / self.receiver.clock.freq
        utc = start_of_day + day_seconds

        # off by one error?
        utc -= 1

        # handle values close to rollover
        if day_seconds > 86000 and (utc - now) > 85000:
            # it's a value from yesterday that arrived after rollover
            utc -= 86400
            glogger.info('{0} GPS midnight rollover server={1:.3f} message={2:.3f}'.format(
                self.receiver,
                now,
                utc))


        if utc > now or (now - utc) > config.MLAT_DELAY: