Major funciton renaming in EHS for suppporting more BDS types. Bug fixes.

This commit is contained in:
Junzi Sun
2017-03-22 21:06:51 +01:00
parent cc66e2f4e4
commit ef2268127c
7 changed files with 250 additions and 99 deletions

View File

@@ -1,7 +1,6 @@
# If you get import error run with ipython
from pyModeS import adsb
from pyModeS import ehs
from pyModeS import util
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/pyModeS')
import adsb, ehs, util
# === Decode sample data file ===
@@ -54,27 +53,33 @@ def ehs_decode_all(n=None):
vBDS = ehs.BDS(m)
if vBDS:
if isinstance(vBDS, list):
print(ts, m, icao, vBDS)
if vBDS == "BDS20":
print(ts, m, icao, vBDS, ehs.callsign(m))
if vBDS == "BDS40":
print(ts, m, icao, vBDS, ehs.alt_mcp(m),
ehs.alt_fms(m), ehs.pbaro(m))
print(ts, m, icao, vBDS, ehs.alt40mcp(m),
ehs.alt40fms(m), ehs.p40baro(m))
if vBDS == "BDS44":
print(ts, m, icao, vBDS, ehs.wind(m),
ehs.temperature(m), ehs.pressure(m))
print(ts, m, icao, vBDS, ehs.wind44(m),
ehs.temp44(m), ehs.p44(m))
if vBDS == "BDS50":
print(ts, m, icao, vBDS, ehs.roll(m), ehs.track(m),
ehs.gs(m), ehs.rtrack(m), ehs.tas(m))
print(ts, m, icao, vBDS, ehs.roll50(m), ehs.trk50(m),
ehs.gs50(m), ehs.rtrk50(m), ehs.tas50(m))
if vBDS == "BDS53":
print(ts, m, icao, vBDS, ehs.hdg53(m), ehs.ias53(m),
ehs.mach53(m), ehs.tas53(m), ehs.vr53(m))
if vBDS == "BDS60":
print(ts, m, icao, vBDS, ehs.heading(m), ehs.ias(m),
ehs.mach(m), ehs.baro_vr(m), ehs.ins_vr(m))
print(ts, m, icao, vBDS, ehs.hdg60(m), ehs.ias60(m),
ehs.mach60(m), ehs.vr60baro(m), ehs.vr60ins(m))
else:
print(ts, m, icao, 'UNKNOWN')
if __name__ == '__main__':
adsb_decode_all(100)
# adsb_decode_all(100)
ehs_decode_all(100)

View File

@@ -1,5 +1,6 @@
from pyModeS import adsb
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/pyModeS')
import adsb
# === TEST ADS-B package ===

View File

@@ -1,4 +1,6 @@
from pyModeS import ehs
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/pyModeS')
import ehs
def test_ehs_icao():
@@ -12,8 +14,6 @@ def test_ehs_BDS():
assert ehs.BDS("A0001839CA3800315800007448D9") == 'BDS40'
assert ehs.BDS("A000139381951536E024D4CCF6B5") == 'BDS50'
assert ehs.BDS("A000029CFFBAA11E2004727281F1") == 'BDS60'
assert ehs.BDS("A0281838CAE9E12FA03FFF2DDDE5") == 'BDS44'
assert ehs.BDS("A00017B0C8480030A4000024512F") is None
def test_ehs_BDS20_callsign():
@@ -22,22 +22,22 @@ def test_ehs_BDS20_callsign():
def test_ehs_BDS40_functions():
assert ehs.alt_mcp("A000029C85E42F313000007047D3") == 3008
assert ehs.alt_fms("A000029C85E42F313000007047D3") == 3008
assert ehs.pbaro("A000029C85E42F313000007047D3") == 1020.0
assert ehs.alt40mcp("A000029C85E42F313000007047D3") == 3008
assert ehs.alt40fms("A000029C85E42F313000007047D3") == 3008
assert ehs.p40baro("A000029C85E42F313000007047D3") == 1020.0
def test_ehs_BDS50_functions():
assert ehs.roll("A000139381951536E024D4CCF6B5") == 2.1
assert ehs.track("A000139381951536E024D4CCF6B5") == 114.3
assert ehs.gs("A000139381951536E024D4CCF6B5") == 438
assert ehs.rtrack("A000139381951536E024D4CCF6B5") == 0.125
assert ehs.tas("A000139381951536E024D4CCF6B5") == 424
assert ehs.roll50("A000139381951536E024D4CCF6B5") == 2.1
assert ehs.trk50("A000139381951536E024D4CCF6B5") == 114.3
assert ehs.gs50("A000139381951536E024D4CCF6B5") == 438
assert ehs.rtrk50("A000139381951536E024D4CCF6B5") == 0.125
assert ehs.tas50("A000139381951536E024D4CCF6B5") == 424
def test_ehs_BDS60_functions():
assert ehs.heading("A000029CFFBAA11E2004727281F1") == 180.9
assert ehs.ias("A000029CFFBAA11E2004727281F1") == 336
assert ehs.mach("A000029CFFBAA11E2004727281F1") == 0.48
assert ehs.baro_vr("A000029CFFBAA11E2004727281F1") == 0
assert ehs.ins_vr("A000029CFFBAA11E2004727281F1") == -3648
assert ehs.hdg60("A000029CFFBAA11E2004727281F1") == 180.9
assert ehs.ias60("A000029CFFBAA11E2004727281F1") == 336
assert ehs.mach60("A000029CFFBAA11E2004727281F1") == 0.48
assert ehs.vr60baro("A000029CFFBAA11E2004727281F1") == 0
assert ehs.vr60ins("A000029CFFBAA11E2004727281F1") == -3648

View File

@@ -1,4 +1,6 @@
from pyModeS import util
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+'/pyModeS')
import util
def test_hex2bin():
@@ -12,4 +14,4 @@ def test_crc_decode():
def test_crc_encode():
parity = util.crc("8D406B902015A678D4D220AA4BDA", encode=True)
assert util.hex2bin("AA4BDA") == parity
assert util.hex2bin("AA4BDA") == parity