示例#1
0
def adsb_decode_all(n=None):
    print("===== Decode ADS-B sample data=====")
    import csv
    f = open('tests/data/sample_data_adsb.csv', 'rt')

    msg0 = None
    msg1 = None

    for i, r in enumerate(csv.reader(f)):
        if n and i > n:
            break

        ts = r[0]
        m = r[1]
        icao = adsb.icao(m)
        tc = adsb.typecode(m)
        if 1 <= tc <= 4:
            print(ts, m, icao, tc, adsb.category(m), adsb.callsign(m))
        if tc == 19:
            print(ts, m, icao, tc, adsb.velocity(m))
        if 5 <= tc <= 18:
            if adsb.oe_flag(m):
                msg1 = m
                t1 = ts
            else:
                msg0 = m
                t0 = ts

            if msg0 and msg1:
                pos = adsb.position(msg0, msg1, t0, t1)
                alt = adsb.altitude(m)
                print(ts, m, icao, tc, pos, alt)
示例#2
0
文件: run.py 项目: aeroevan/pyModeS
def adsb_decode_all(n=None):
    print "===== Decode all ADS-B sample data====="
    import csv
    f = open('adsb.csv', 'rt')

    msg0 = None
    msg1 = None

    for i, r in enumerate(csv.reader(f)):
        if n and i > n:
            break

        ts = r[0]
        m = r[1]
        icao = adsb.icao(m)
        tc = adsb.typecode(m)
        if 1 <= tc <= 4:
            print ts, m, icao, tc, adsb.category(m), adsb.callsign(m)
        if tc == 19:
            print ts, m, icao, tc, adsb.velocity(m)
        if 5 <= tc <= 18:
            if adsb.oe_flag(m):
                msg1 = m
                t1 = ts
            else:
                msg0 = m
                t0 = ts

            if msg0 and msg1:
                pos = adsb.position(msg0, msg1, t0, t1)
                alt = adsb.altitude(m)
                print ts, m, icao, tc, pos, alt
    def createFromMessageBuffer(messageBuffer):
        info = None
        if messageBuffer.isComplete():
            latLng = adsb.position(messageBuffer.dataPositionEven[0].frame[1:29],
                                   messageBuffer.dataPositionOdd[0].frame[1:29],
                                   messageBuffer.dataPositionEven[0].timestamp,
                                   messageBuffer.dataPositionOdd[0].timestamp)
            velocity = adsb.velocity(messageBuffer.dataVelocity[0].frame[1:29])
            if latLng:
                info = ADSBInfo(
                    collector=COLLECTOR_ID,
                    modeSCode=adsb.icao(messageBuffer.dataId[0].frame[1:29]),
                    callsign=adsb.callsign(messageBuffer.dataId[0].frame[1:29]).replace("_", ""),
                    latitude=latLng[0],
                    longitude=latLng[1],
                    altitude=adsb.altitude(messageBuffer.dataPositionEven[0].frame[1:29]),
                    horizontalVelocity=velocity[0],
                    groundTrackHeading=velocity[1],
                    verticalVelocity=velocity[2],
                    messagDataId=messageBuffer.dataId[0].frame[1:29],
                    messagDataPositionEven=messageBuffer.dataId[0].frame[1:29],
                    messagDataPositionOdd=messageBuffer.dataId[0].frame[1:29],
                    messagDataVelocity=messageBuffer.dataId[0].frame[1:29],
                    timestamp=int(systemTimestamp() * 1000),
                    timestampSent=int(systemTimestamp() * 1000)
                )

        messageBuffer.clearPositionMessages()
        return info
示例#4
0
def test_adsb_position_swap_odd_even():
    pos = adsb.position(
        "8D40058B58C904A87F402D3B8C59",
        "8D40058B58C901375147EFD09357",
        1446332405,
        1446332400,
    )
    assert pos == (49.81755, 6.08442)
示例#5
0
文件: run.py 项目: aeroevan/pyModeS
def test_adsb_position():
    pos = adsb.position("8D40058B58C901375147EFD09357",
                        "8D40058B58C904A87F402D3B8C59",
                        1446332400, 1446332405)
    assert pos == (49.81755, 6.08442)