コード例 #1
0
def velocity(msg, rtn_sources=False):
    """Calculate the speed, heading, and vertical rate
    (handles both airborne or surface message)

    Args:
        msg (string): 28 bytes hexadecimal message string
        rtn_source (boolean): If the function will return
            the sources for direction of travel and vertical
            rate. This will change the return value from a four
            element array to a six element array.

    Returns:
        (int, float, int, string, string, string): speed (kt),
            ground track or heading (degree),
            rate of climb/descent (ft/min), speed type
            ('GS' for ground speed, 'AS' for airspeed),
            direction source ('true_north' for ground track / true north
            as refrence, 'mag_north' for magnetic north as reference),
            rate of climb/descent source ('Baro' for barometer, 'GNSS'
            for GNSS constellation).
            
            In the case of surface messages, None will be put in place
            for vertical rate and its respective sources.
    """

    if 5 <= typecode(msg) <= 8:
        return surface_velocity(msg, rtn_sources)

    elif typecode(msg) == 19:
        return airborne_velocity(msg, rtn_sources)

    else:
        raise RuntimeError(
            "incorrect or inconsistant message types, expecting 4<TC<9 or TC=19"
        )
コード例 #2
0
ファイル: adsb.py プロジェクト: wrobell/pyModeS
def velocity(msg, source=False):
    """Calculate the speed, heading, and vertical rate (handles both airborne or surface message).

    Args:
        msg (str): 28 hexdigits string
        source (boolean): Include direction and vertical rate sources in return. Default to False.
            If set to True, the function will return six value instead of four.

    Returns:
        int, float, int, string, [string], [string]: Four or six parameters, including:
            - Speed (kt)
            - Angle (degree), either ground track or heading
            - Vertical rate (ft/min)
            - Speed type ('GS' for ground speed, 'AS' for airspeed)
            - [Optional] Direction source ('TRUE_NORTH' or 'MAGENTIC_NORTH')
            - [Optional] Vertical rate source ('BARO' or 'GNSS')

        For surface messages, vertical rate and its respective sources are set to None.

    """
    if 5 <= typecode(msg) <= 8:
        return surface_velocity(msg, source)

    elif typecode(msg) == 19:
        return airborne_velocity(msg, source)

    else:
        raise RuntimeError(
            "incorrect or inconsistent message types, expecting 4<TC<9 or TC=19"
        )
コード例 #3
0
def velocity(msg):
    """Calculate the speed, heading, and vertical rate
    (handles both airborne or surface message)

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

    Returns:
        (int, float, int, string): speed (kt), ground track or heading (degree),
            rate of climb/descend (ft/min), and speed type
            ('GS' for ground speed, 'AS' for airspeed)
    """

    if 5 <= typecode(msg) <= 8:
        return surface_velocity(msg)

    elif typecode(msg) == 19:
        return airborne_velocity(msg)

    else:
        raise RuntimeError(
            "incorrect or inconsistant message types, expecting 4<TC<9 or TC=19"
        )