rename functions for seleted altitudes in BDS40

pull/45/head
Junzi Sun 5 years ago
parent 0b7b9ad3dd
commit 6f6b50776d

@ -225,8 +225,8 @@ Mode-S Enhanced Surveillance (EHS)
.. code:: python .. code:: python
# BDS 4,0 # BDS 4,0
pms.commb.alt40mcp(msg) # MCP/FCU selected altitude (ft) pms.commb.selalt40mcp(msg) # MCP/FCU selected altitude (ft)
pms.commb.alt40fms(msg) # FMS selected altitude (ft) pms.commb.selalt40fms(msg) # FMS selected altitude (ft)
pms.commb.p40baro(msg) # Barometric pressure (mb) pms.commb.p40baro(msg) # Barometric pressure (mb)
# BDS 5,0 # BDS 5,0

@ -18,10 +18,11 @@
# Selected vertical intention # Selected vertical intention
# ------------------------------------------ # ------------------------------------------
from __future__ import absolute_import, print_function, division from __future__ import absolute_import, print_function, division
import warnings
from pyModeS.decoder.common import hex2bin, bin2int, data, allzeros, wrongstatus from pyModeS.decoder.common import hex2bin, bin2int, data, allzeros, wrongstatus
def is40(msg): def is40(msg):
"""Check if a message is likely to be BDS code 4,0 """Check if a message is likely to be BDS code 4,0
@ -65,7 +66,7 @@ def is40(msg):
return True return True
def alt40mcp(msg): def selalt40mcp(msg):
"""Selected altitude, MCP/FCU """Selected altitude, MCP/FCU
Args: Args:
@ -76,14 +77,14 @@ def alt40mcp(msg):
""" """
d = hex2bin(data(msg)) d = hex2bin(data(msg))
if d[0] == '0': if d[0] == "0":
return None return None
alt = bin2int(d[1:13]) * 16 # ft alt = bin2int(d[1:13]) * 16 # ft
return alt return alt
def alt40fms(msg): def selalt40fms(msg):
"""Selected altitude, FMS """Selected altitude, FMS
Args: Args:
@ -94,10 +95,10 @@ def alt40fms(msg):
""" """
d = hex2bin(data(msg)) d = hex2bin(data(msg))
if d[13] == '0': if d[13] == "0":
return None return None
alt = bin2int(d[14:26]) * 16 # ft alt = bin2int(d[14:26]) * 16 # ft
return alt return alt
@ -112,8 +113,26 @@ def p40baro(msg):
""" """
d = hex2bin(data(msg)) d = hex2bin(data(msg))
if d[26] == '0': if d[26] == "0":
return None return None
p = bin2int(d[27:39]) * 0.1 + 800 # millibar p = bin2int(d[27:39]) * 0.1 + 800 # millibar
return p return p
def alt40mcp(msg):
warnings.simplefilter("once", DeprecationWarning)
warnings.warn(
"alt40mcp() has been renamed to selalt40mcp(). It will be removed in the future.",
DeprecationWarning,
)
return selalt40mcp(msg)
def alt40fms(msg):
warnings.simplefilter("once", DeprecationWarning)
warnings.warn(
"alt40fms() has been renamed to selalt40fms(). It will be removed in the future.",
DeprecationWarning,
)
return selalt40mcp(msg)

@ -14,7 +14,7 @@ def bds_info(BDS, m):
info = [commb.cs20(m)] info = [commb.cs20(m)]
elif BDS == "BDS40": elif BDS == "BDS40":
info = (commb.alt40mcp(m), commb.alt40fms(m), commb.p40baro(m)) info = (commb.selalt40mcp(m), commb.selalt40fms(m), commb.p40baro(m))
elif BDS == "BDS44": elif BDS == "BDS44":
info = (commb.wind44(m), commb.temp44(m), commb.p44(m), commb.hum44(m)) info = (commb.wind44(m), commb.temp44(m), commb.p44(m), commb.hum44(m))

@ -10,12 +10,12 @@ def test_bds20_callsign():
def test_bds40_functions(): def test_bds40_functions():
assert bds.bds40.alt40mcp("A000029C85E42F313000007047D3") == 3008 assert bds.bds40.selalt40mcp("A000029C85E42F313000007047D3") == 3008
assert bds.bds40.alt40fms("A000029C85E42F313000007047D3") == 3008 assert bds.bds40.selalt40fms("A000029C85E42F313000007047D3") == 3008
assert bds.bds40.p40baro("A000029C85E42F313000007047D3") == 1020.0 assert bds.bds40.p40baro("A000029C85E42F313000007047D3") == 1020.0
assert commb.alt40mcp("A000029C85E42F313000007047D3") == 3008 assert commb.selalt40mcp("A000029C85E42F313000007047D3") == 3008
assert commb.alt40fms("A000029C85E42F313000007047D3") == 3008 assert commb.selalt40fms("A000029C85E42F313000007047D3") == 3008
assert commb.p40baro("A000029C85E42F313000007047D3") == 1020.0 assert commb.p40baro("A000029C85E42F313000007047D3") == 1020.0

Loading…
Cancel
Save