当前位置: 首页>>代码示例>>C++>>正文


C++ TrafficList::AllocateTraffic方法代码示例

本文整理汇总了C++中TrafficList::AllocateTraffic方法的典型用法代码示例。如果您正苦于以下问题:C++ TrafficList::AllocateTraffic方法的具体用法?C++ TrafficList::AllocateTraffic怎么用?C++ TrafficList::AllocateTraffic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TrafficList的用法示例。


在下文中一共展示了TrafficList::AllocateTraffic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadBearing

void
ParsePFLAA(NMEAInputLine &line, TrafficList &flarm, double clock)
{
    flarm.modified.Update(clock);

    // PFLAA,<AlarmLevel>,<RelativeNorth>,<RelativeEast>,<RelativeVertical>,
    //   <IDType>,<ID>,<Track>,<TurnRate>,<GroundSpeed>,<ClimbRate>,<AcftType>
    FlarmTraffic traffic;
    traffic.alarm_level = (FlarmTraffic::AlarmType)
                          line.Read((int)FlarmTraffic::AlarmType::NONE);

    double value;
    bool stealth = false;

    if (!line.ReadChecked(value))
        // Relative North is required !
        return;
    traffic.relative_north = value;

    if (!line.ReadChecked(value))
        // Relative East is required !
        return;
    traffic.relative_east = value;

    if (!line.ReadChecked(value))
        // Relative Altitude is required !
        return;
    traffic.relative_altitude = value;

    line.Skip(); /* id type */

    // 5 id, 6 digit hex
    char id_string[16];
    line.Read(id_string, 16);
    traffic.id = FlarmId::Parse(id_string, nullptr);

    Angle track;
    traffic.track_received = ReadBearing(line, track);
    if (!traffic.track_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.track = Angle::Zero();
    } else
        traffic.track = track;

    traffic.turn_rate_received = line.ReadChecked(value);
    if (!traffic.turn_rate_received) {
        // Field is empty in stealth mode
        traffic.turn_rate = 0;
    } else
        traffic.turn_rate = value;

    traffic.speed_received = line.ReadChecked(value);
    if (!traffic.speed_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.speed = 0;
    } else
        traffic.speed = value;

    traffic.climb_rate_received = line.ReadChecked(value);
    if (!traffic.climb_rate_received) {
        // Field is empty in stealth mode
        stealth = true;
        traffic.climb_rate = 0;
    } else
        traffic.climb_rate = value;

    traffic.stealth = stealth;

    unsigned type = line.Read(0);
    if (type > 15 || type == 14)
        traffic.type = FlarmTraffic::AircraftType::UNKNOWN;
    else
        traffic.type = (FlarmTraffic::AircraftType)type;

    FlarmTraffic *flarm_slot = flarm.FindTraffic(traffic.id);
    if (flarm_slot == nullptr) {
        flarm_slot = flarm.AllocateTraffic();
        if (flarm_slot == nullptr)
            // no more slots available
            return;

        flarm_slot->Clear();
        flarm_slot->id = traffic.id;

        flarm.new_traffic.Update(clock);
    }

    // set time of fix to current time
    flarm_slot->valid.Update(clock);

    flarm_slot->Update(traffic);
}
开发者ID:ahsparrow,项目名称:xcsoar,代码行数:94,代码来源:StaticParser.cpp


注:本文中的TrafficList::AllocateTraffic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。