rename functions for seleted altitudes in BDS40

This commit is contained in:
Junzi Sun 2019-08-05 10:37:17 +02:00
parent 0b7b9ad3dd
commit 6f6b50776d
4 changed files with 35 additions and 16 deletions

View File

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

View File

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

View File

@ -14,7 +14,7 @@ def bds_info(BDS, m):
info = [commb.cs20(m)]
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":
info = (commb.wind44(m), commb.temp44(m), commb.p44(m), commb.hum44(m))

View File

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