From 6f139d4ae91b45caea580e8e168300604a692d45 Mon Sep 17 00:00:00 2001 From: Junzi Sun Date: Wed, 4 Jul 2018 21:20:23 +0200 Subject: [PATCH] make modeslive uncertanty values optional --- README.rst | 1 + pyModeS/streamer/modeslive | 5 +++-- pyModeS/streamer/screen.py | 15 +++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 211591f..9c7fccd 100644 --- a/README.rst +++ b/README.rst @@ -80,6 +80,7 @@ Supports **Mode-S Beast** and **AVR** raw stream --port PORT raw data port --rawtype RAWTYPE beast or avr --latlon LAT LON receiver position + --show-uncertainty display uncertaint values, default off If you have a RTL-SDR receiver or Mode-S Beast, use modesmixer2 (http://xdeco.org/?page_id=48) to create raw beast TCP stream: diff --git a/pyModeS/streamer/modeslive b/pyModeS/streamer/modeslive index 9db9980..1447e05 100644 --- a/pyModeS/streamer/modeslive +++ b/pyModeS/streamer/modeslive @@ -22,7 +22,7 @@ parser.add_argument('--server', help='server address or IP', required=True) parser.add_argument('--port', help='raw data port', required=True) parser.add_argument('--rawtype', help='beast or avr', required=True) parser.add_argument('--latlon', help='receiver position', nargs=2, metavar=('LAT', 'LON'), required=True) -parser.add_argument('--show-uncertainty', help='display uncertainty indicators', required=False) +parser.add_argument('--show-uncertainty', dest='uncertainty', help='display uncertaint values, default off', action='store_true', required=False, default=False) args = parser.parse_args() SERVER = args.server @@ -30,6 +30,7 @@ PORT = int(args.port) RAWTYPE = args.rawtype LAT0 = float(args.latlon[0]) LON0 = float(args.latlon[1]) +UNCERTAINTY = args.uncertainty class ModesClient(BaseClient): @@ -76,7 +77,7 @@ client.start() stream = Stream(lat0=LAT0, lon0=LON0) try: - screen = Screen() + screen = Screen(uncertainty=UNCERTAINTY) screen.daemon = True screen.start() diff --git a/pyModeS/streamer/screen.py b/pyModeS/streamer/screen.py index b2951c9..093d032 100644 --- a/pyModeS/streamer/screen.py +++ b/pyModeS/streamer/screen.py @@ -17,6 +17,10 @@ COLUMNS = [ ('trk', 10), ('hdg', 10), ('ver', 4), + ('live', 6), +] + +UNCERTAINTY_COLUMNS = [ ('HPL', 5), ('RCu', 5), ('RCv', 5), @@ -30,11 +34,10 @@ COLUMNS = [ ('VFOMr', 7), ('PE_RCu', 8), ('PE_VPL', 8), - ('live', 6), ] class Screen(Thread): - def __init__(self): + def __init__(self, uncertainty=False): Thread.__init__(self) self.screen = curses.initscr() curses.noecho() @@ -46,6 +49,10 @@ class Screen(Thread): self.acs = {} self.lock_icao = None + self.columns = COLUMNS + if uncertainty: + self.columns.extend(UNCERTAINTY_COLUMNS) + def reset_cursor_pos(self): self.screen.move(self.y, self.x) @@ -73,7 +80,7 @@ class Screen(Thread): row = 1 header = ' icao' - for c, cw in COLUMNS: + for c, cw in self.columns: header += (cw-len(c))*' ' + c # fill end with spaces @@ -105,7 +112,7 @@ class Screen(Thread): line += icao - for c, cw in COLUMNS: + for c, cw in self.columns: if c=='live': val = int(time.time() - ac[c]) elif ac[c] is None: