# Path: mlat/profile.py
# def trackcpu(f, **kwargs):
# def dump_cpu_profiles(tofile=None):
# def trackcpu(f, name=None, **kwargs):
#     def cpu_measurement_wrapper(*args, **kwargs):
# def dump_cpu_profiles(tofile=sys.stderr):
# 
# Path: mlat/server/kalman.py
# class KalmanState(object):
# class KalmanStateCV(KalmanState):
# class KalmanStateCA(KalmanState):
#     def __init__(self, icao):
#     def _reset(self):
#     def observation_function_without_altitude(self, state, *, positions):
#     def observation_function_with_altitude(self, state, *, positions):
#     def _update_derived(self):
#     def update(self, position_time, measurements, altitude, altitude_error,
#                leastsquares_position, leastsquares_cov, distinct, dof):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#         C = numpy.array([[-math.sin(lon_r), math.cos(lon_r), 0],
#                          [math.sin(-lat_r) * math.cos(lon_r), math.sin(-lat_r) * math.sin(lon_r), math.cos(-lat_r)],
#                          [math.cos(-lat_r) * math.cos(lon_r), math.cos(-lat_r) * math.sin(lon_r), -math.sin(-lat_r)]])


import asyncio
from mlat import profile
from mlat.server import kalman
        # set of receivers who want to use this aircraft for multilateration.
        # this aircraft is interesting if this set has at least three receivers.
        # invariant: r.mlat_interest.contains(a) iff a.mlat_interest.contains(r)
        self.mlat_interest = set()

        # set of receivers that have contributed to at least one multilateration
        # result. This is used to decide who to forward results to.
        self.successful_mlat = set()

        # number of mlat message resolves attempted
        self.mlat_message_count = 0
        # number of mlat messages that produced valid least-squares results
        self.mlat_result_count = 0
        # number of mlat messages that produced valid kalman state updates
        self.mlat_kalman_count = 0

        # last reported altitude (for multilaterated aircraft)
        self.altitude = None
        # time of last altitude (time.monotonic())
        self.last_altitude_time = None

        # last multilateration, time (monotonic)
        self.last_result_time = None
        # last multilateration, ECEF position
        self.last_result_position = None
        # last multilateration, variance
        self.last_result_var = None
        # last multilateration, distinct receivers
        self.last_result_distinct = None
        # kalman filter state

# Path: mlat/profile.py
# def trackcpu(f, **kwargs):
# def dump_cpu_profiles(tofile=None):
# def trackcpu(f, name=None, **kwargs):
#     def cpu_measurement_wrapper(*args, **kwargs):
# def dump_cpu_profiles(tofile=sys.stderr):
# 
# Path: mlat/server/kalman.py
# class KalmanState(object):
# class KalmanStateCV(KalmanState):
# class KalmanStateCA(KalmanState):
#     def __init__(self, icao):
#     def _reset(self):
#     def observation_function_without_altitude(self, state, *, positions):
#     def observation_function_with_altitude(self, state, *, positions):
#     def _update_derived(self):
#     def update(self, position_time, measurements, altitude, altitude_error,
#                leastsquares_position, leastsquares_cov, distinct, dof):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#     def set_initial_state(self, leastsquares_position, leastsquares_cov):
#     def transition_function(self, state, *, dt):
#     def transition_covariance(self, dt):
#         C = numpy.array([[-math.sin(lon_r), math.cos(lon_r), 0],
#                          [math.sin(-lat_r) * math.cos(lon_r), math.sin(-lat_r) * math.sin(lon_r), math.cos(-lat_r)],
#                          [math.cos(-lat_r) * math.cos(lon_r), math.cos(-lat_r) * math.sin(lon_r), -math.sin(-lat_r)]])


# Path: mlat/server/tracker.py
import asyncio
from mlat import profile
from mlat.server import kalman

        # set of receivers who want to use this aircraft for multilateration.
        # this aircraft is interesting if this set has at least three receivers.
        # invariant: r.mlat_interest.contains(a) iff a.mlat_interest.contains(r)
        self.mlat_interest = set()

        # set of receivers that have contributed to at least one multilateration
        # result. This is used to decide who to forward results to.
        self.successful_mlat = set()

        # number of mlat message resolves attempted
        self.mlat_message_count = 0
        # number of mlat messages that produced valid least-squares results
        self.mlat_result_count = 0
        # number of mlat messages that produced valid kalman state updates
        self.mlat_kalman_count = 0

        # last reported altitude (for multilaterated aircraft)
        self.altitude = None
        # time of last altitude (time.monotonic())
        self.last_altitude_time = None

        # last multilateration, time (monotonic)
        self.last_result_time = None
        # last multilateration, ECEF position
        self.last_result_position = None
        # last multilateration, variance
        self.last_result_var = None
        # last multilateration, distinct receivers
        self.last_result_distinct = None
        # kalman filter state

        self.kalman = kalman.KalmanStateCA(self.icao)