示例#1
0
def infer(msg):
    """Estimate the most likely BDS code of an message

    Args:
        msg (String): 28 bytes hexadecimal message string

    Returns:
        String or None: BDS version, or possible versions, or None if nothing matches.
    """

    df = common.df(msg)

    if common.allzeros(msg):
        return 'EMPTY'

    # For ADS-B / Mode-S extended squitter
    if df == 17:
        tc = common.typecode(msg)

        if 1 <= tc <= 4:
            return 'BDS08'  # indentification and category
        if 5 <= tc <= 8:
            return 'BDS06'  # surface movement
        if 9 <= tc <= 18:
            return 'BDS05'  # airborne position, baro-alt
        if tc == 19:
            return 'BDS09'  # airborne velocity
        if 20 <= tc <= 22:
            return 'BDS05'  # airborne position, gnss-alt
        if tc == 28:
            return 'BDS61'  # aircraft status
        if tc == 29:
            return 'BDS62'  # target state and status
        if tc == 31:
            return 'BDS65'  # operational status

    # For Comm-B replies, ELS + EHS only
    IS10 = bds10.is10(msg)
    IS17 = bds17.is17(msg)
    IS20 = bds20.is20(msg)
    IS30 = bds30.is30(msg)
    IS40 = bds40.is40(msg)
    IS50 = bds50.is50(msg)
    IS60 = bds60.is60(msg)

    allbds = np.array(
        ["BDS10", "BDS17", "BDS20", "BDS30", "BDS40", "BDS50", "BDS60"])

    mask = [IS10, IS17, IS20, IS30, IS40, IS50, IS60]

    bds = ','.join(sorted(allbds[mask]))

    if len(bds) == 0:
        return None
    else:
        return bds
示例#2
0
def infer(msg, mrar=False):
    """Estimate the most likely BDS code of an message.

    Args:
        msg (str): 28 hexdigits string
        mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False.

    Returns:
        String or None: BDS version, or possible versions, or None if nothing matches.

    """
    df = common.df(msg)

    if common.allzeros(msg):
        return "EMPTY"

    # For ADS-B / Mode-S extended squitter
    if df == 17:
        tc = common.typecode(msg)

        if 1 <= tc <= 4:
            return "BDS08"  # identification and category
        if 5 <= tc <= 8:
            return "BDS06"  # surface movement
        if 9 <= tc <= 18:
            return "BDS05"  # airborne position, baro-alt
        if tc == 19:
            return "BDS09"  # airborne velocity
        if 20 <= tc <= 22:
            return "BDS05"  # airborne position, gnss-alt
        if tc == 28:
            return "BDS61"  # aircraft status
        if tc == 29:
            return "BDS62"  # target state and status
        if tc == 31:
            return "BDS65"  # operational status

    # For Comm-B replies
    IS10 = bds10.is10(msg)
    IS17 = bds17.is17(msg)
    IS20 = bds20.is20(msg)
    IS30 = bds30.is30(msg)
    IS40 = bds40.is40(msg)
    IS50 = bds50.is50(msg)
    IS60 = bds60.is60(msg)
    IS44 = bds44.is44(msg)
    IS45 = bds45.is45(msg)

    if mrar:
        allbds = np.array([
            "BDS10",
            "BDS17",
            "BDS20",
            "BDS30",
            "BDS40",
            "BDS44",
            "BDS45",
            "BDS50",
            "BDS60",
        ])
        mask = [IS10, IS17, IS20, IS30, IS40, IS44, IS45, IS50, IS60]
    else:
        allbds = np.array(
            ["BDS10", "BDS17", "BDS20", "BDS30", "BDS40", "BDS50", "BDS60"])
        mask = [IS10, IS17, IS20, IS30, IS40, IS50, IS60]

    bds = ",".join(sorted(allbds[mask]))

    if len(bds) == 0:
        return None
    else:
        return bds