add VDS check in ACAS decoding

This commit is contained in:
Junzi Sun 2020-12-02 22:29:42 +01:00
parent 2e9833148b
commit 46ffb79234
3 changed files with 37 additions and 4 deletions

View File

@ -3,6 +3,24 @@ Decoding Air-Air Surveillance (ACAS) DF=0/16
""" """
from pyModeS import common from pyModeS import common
import warnings
warnings.simplefilter("always", UserWarning)
def isACAS(msg: str) -> bool:
"""Check if the message is an ACAS coordination message.
:param msg: 28 hexdigits string
:return: if VDS is 3,1
"""
mv = common.hex2bin(common.data(msg))
vds = mv[0:8]
if vds == "00110000":
return True
else:
return False
def rac(msg: str) -> str: def rac(msg: str) -> str:
@ -11,10 +29,14 @@ def rac(msg: str) -> str:
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
:return: RACs :return: RACs
""" """
mv = common.hex2bin(common.data(msg)) if not isACAS(msg):
warnings.warn("Not an ACAS coordination message.")
return None
RAC = [] RAC = []
mv = common.hex2bin(common.data(msg))
if mv[22] == "1": if mv[22] == "1":
RAC.append("do not pass below") RAC.append("do not pass below")
@ -39,6 +61,10 @@ def rat(msg: str) -> bool:
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
:return: if RA has been terminated :return: if RA has been terminated
""" """
if not isACAS(msg):
warnings.warn("Not an ACAS coordination message.")
return None
mv = common.hex2bin(common.data(msg)) mv = common.hex2bin(common.data(msg))
mte = int(mv[26]) mte = int(mv[26])
return mte return mte
@ -50,6 +76,10 @@ def mte(msg: str) -> bool:
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
:return: if there are multiple threats :return: if there are multiple threats
""" """
if not isACAS(msg):
warnings.warn("Not an ACAS coordination message.")
return None
mv = common.hex2bin(common.data(msg)) mv = common.hex2bin(common.data(msg))
mte = int(mv[27]) mte = int(mv[27])
return mte return mte
@ -61,6 +91,9 @@ def ara(msg: str) -> str:
:param msg: 28 bytes hexadecimal message string :param msg: 28 bytes hexadecimal message string
:return: RA charactristics :return: RA charactristics
""" """
if not isACAS(msg):
warnings.warn("Not an ACAS coordination message.")
return None
mv = common.hex2bin(common.data(msg)) mv = common.hex2bin(common.data(msg))
mte = int(mv[27]) mte = int(mv[27])

View File

@ -60,7 +60,7 @@ def threat_location(msg: str) -> Tuple:
def has_multiple_threats(msg: str) -> bool: def has_multiple_threats(msg: str) -> bool:
""" Indicate if the ACAS is processing multiple threats simultaneously. """Indicate if the ACAS is processing multiple threats simultaneously.
:param msg: 28 hexdigits string :param msg: 28 hexdigits string
:return: if there are multiple threats :return: if there are multiple threats
@ -76,7 +76,7 @@ def active_resolution_advisories(msg: str) -> str:
:param msg: 28 bytes hexadecimal message string :param msg: 28 bytes hexadecimal message string
:return: RA charactristics :return: RA charactristics
""" """
return acars.ara(msg) return acas.ara(msg)
def is_ra_terminated(msg: str) -> bool: def is_ra_terminated(msg: str) -> bool:

View File

@ -25,7 +25,7 @@ msgs = [
"8526D57E4D963C92CDEE1B6C7C49", "8526D57E4D963C92CDEE1B6C7C49",
"802A613C93F65A7FF803A51B5ADB", "802A613C93F65A7FF803A51B5ADB",
"85B6C54279B67BE2A0001998FFDA", "85B6C54279B67BE2A0001998FFDA",
"851944F15881648338D1AF4B7A27", "851944F1 5881648338D1AF 4B7A27",
"8321014858208000787905B0E800", "8321014858208000787905B0E800",
"866DD078EDEBD330404FFFAE9BA5", "866DD078EDEBD330404FFFAE9BA5",
"80E196905AB503260E835D849E35", "80E196905AB503260E835D849E35",