| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import argparse |
| 7 |
|
| 8 |
import mlat.client.version |
| 9 |
from flightaware.client.adeptclient import AdeptConnection, UdpServerConnection |
| 10 |
from mlat.client.coordinator import Coordinator |
| 11 |
from mlat.client.util import log, log_exc |
| 12 |
from mlat.client import options |
| 13 |
|
| 14 |
|
| 15 |
def main(): |
| 16 |
|
| 17 |
mlat.client.util.suppress_log_timestamps = True |
| 18 |
|
| 19 |
parser = argparse.ArgumentParser(description="Client for multilateration.") |
| 20 |
|
| 21 |
options.make_inputs_group(parser) |
| 22 |
options.make_results_group(parser) |
| 23 |
|
| 24 |
parser.add_argument('--udp-transport', |
| 25 |
help="Provide UDP transport information. Expects an IP:port:key argument.", |
| 26 |
required=True) |
| 27 |
|
| 28 |
args = parser.parse_args() |
| 29 |
|
| 30 |
log("fa-mlat-client {version} starting up", version=mlat.client.version.CLIENT_VERSION) |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
parts = args.udp_transport.split(':') |
| 35 |
udp_key = int(parts[-1]) |
| 36 |
udp_port = int(parts[-2]) |
| 37 |
udp_host = ':'.join(parts[:-2]) |
| 38 |
udp_transport = UdpServerConnection(udp_host, udp_port, udp_key) |
| 39 |
log("Using UDP transport to {host} port {port}", host=udp_host, port=udp_port) |
| 40 |
|
| 41 |
receiver = options.build_receiver_connection(args) |
| 42 |
adept = AdeptConnection(udp_transport, allow_anon=args.allow_anon_results, allow_modeac=args.allow_modeac_results) |
| 43 |
outputs = options.build_outputs(args) |
| 44 |
|
| 45 |
coordinator = Coordinator(receiver=receiver, server=adept, outputs=outputs, freq=options.clock_frequency(args), |
| 46 |
allow_anon=args.allow_anon_results, allow_modeac=args.allow_modeac_results) |
| 47 |
adept.start(coordinator) |
| 48 |
coordinator.run_until(lambda: adept.closed) |
| 49 |
|
| 50 |
|
| 51 |
if __name__ == '__main__': |
| 52 |
try: |
| 53 |
main() |
| 54 |
except KeyboardInterrupt: |
| 55 |
log("Exiting on SIGINT") |
| 56 |
except Exception: |
| 57 |
log_exc("Exiting on exception") |
| 58 |
else: |
| 59 |
log("Exiting on connection loss") |