Exemplo n.º 1
0
int main(int argc, char **argv)
{
  plan_tests(11);

  Validity v;
  v.Clear();
  ok1(!v.IsValid());
  v.Update(100);
  ok1(v.IsValid());
  v.Expire(101, 5);
  ok1(v.IsValid());
  v.Expire(105, 5);
  ok1(v.IsValid());
  v.Expire(106, 5);
  ok1(!v.IsValid());

  v.Update(100);
  ok1(v.Modified(Validity(99)));
  ok1(!v.Modified(Validity(100)));
  ok1(!v.Modified(Validity(101)));
  ok1(!v.Complement(Validity(1)));

  v.Clear();
  ok1(!v.Complement(invalid()));
  ok1(v.Complement(Validity(1)));

  return exit_status();
}
Exemplo n.º 2
0
 void Reset() {
   bank_angle_available.Clear();
   bank_angle_computed = false;
   pitch_angle_available.Clear();
   pitch_angle_computed = false;
   heading_available.Clear();
   heading_computed = false;
 }
Exemplo n.º 3
0
static bool
MacCreadyProcessTimer()
{
  bool modified = false;

  static ExternalSettings last_external_settings;
  static Validity last_auto_mac_cready;

  const NMEAInfo &basic = CommonInterface::Basic();
  const DerivedInfo &calculated = CommonInterface::Calculated();

  if (last_auto_mac_cready.Modified(calculated.auto_mac_cready_available)) {
    /* time warp, reset */
    last_auto_mac_cready.Clear();
    modified = true;
  }

  if (basic.settings.mac_cready_available.Modified(last_external_settings.mac_cready_available)) {
    ActionInterface::SetMacCready(basic.settings.mac_cready, false);
    modified = true;
  } else if (calculated.auto_mac_cready_available.Modified(last_auto_mac_cready)) {
    last_auto_mac_cready = calculated.auto_mac_cready_available;
    ActionInterface::SetMacCready(calculated.auto_mac_cready);
    modified = true;
  }

  last_external_settings = basic.settings;

  return modified;
}
Exemplo n.º 4
0
static Validity
invalid()
{
  Validity v;
  v.Clear();
  return v;
}
Exemplo n.º 5
0
void
TrafficListWidget::UpdateList()
{
  assert(filter_widget != nullptr);

  items.clear();
  last_update.Clear();

  const TCHAR *callsign = filter_widget->GetValueString(CALLSIGN);
  if (!StringIsEmpty(callsign)) {
    FlarmId ids[30];
    unsigned count = FlarmDetails::FindIdsByCallSign(callsign, ids, 30);

    for (unsigned i = 0; i < count; ++i)
      AddItem(ids[i]);
  } else {
    /* if no filter was set, show a list of current traffic and known
       traffic */

    /* add live FLARM traffic */
    for (const auto &i : CommonInterface::Basic().flarm.traffic.list) {
      AddItem(i.id);
    }

    /* add FLARM peers that have a user-defined color */
    for (const auto &i : traffic_databases->flarm_colors) {
      Item &item = AddItem(i.first);
      item.color = i.second;
    }

    /* add FLARM peers that have a user-defined name */
    for (const auto &i : traffic_databases->flarm_names) {
      AddItem(i.id);
    }

#ifdef HAVE_SKYLINES_TRACKING_HANDLER
    /* show SkyLines traffic unless this is a FLARM traffic picker
       dialog (from dlgTeamCode) */
    if (action_listener == nullptr) {
      const auto &data = tracking->GetSkyLinesData();
      const ScopeLock protect(data.mutex);
      for (const auto &i : data.traffic) {
        items.emplace_back(i.first, i.second.location);
        Item &item = items.back();

        if (i.second.location.IsValid() &&
            CommonInterface::Basic().location_available)
          item.vector = GeoVector(CommonInterface::Basic().location,
                                  i.second.location);
      }
    }
#endif
  }

  GetList().SetLength(items.size());

  UpdateVolatile();
  UpdateButtons();
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{
  Args args(argc, argv, "DRIVER FILE");
  DebugReplay *replay = CreateDebugReplay(args);
  if (replay == NULL)
    return EXIT_FAILURE;

  args.ExpectEnd();

  printf("# time wind_bearing (deg) wind_speed (m/s)\n");

  GlidePolar glide_polar(fixed(0));

  CirclingSettings circling_settings;

  WindSettings wind_settings;
  wind_settings.SetDefaults();

  CirclingComputer circling_computer;
  circling_computer.Reset();

  WindComputer wind_computer;
  wind_computer.Reset();

  Validity last;
  last.Clear();

  while (replay->Next()) {
    const MoreData &basic = replay->Basic();
    const DerivedInfo &calculated = replay->Calculated();

    circling_computer.TurnRate(replay->SetCalculated(),
                               basic, calculated.flight);
    circling_computer.Turning(replay->SetCalculated(),
                              basic,
                              calculated.flight,
                              circling_settings);

    wind_computer.Compute(wind_settings, glide_polar, basic,
                          replay->SetCalculated());

    if (calculated.estimated_wind_available.Modified(last)) {
      TCHAR time_buffer[32];
      FormatTime(time_buffer, replay->Basic().time);

      _tprintf(_T("%s %d %g\n"),
               time_buffer, (int)calculated.estimated_wind.bearing.Degrees(),
               (double)calculated.estimated_wind.norm);
    }

    last = calculated.estimated_wind_available;
  }

  delete replay;
}
Exemplo n.º 7
0
void
ProcessTimer::AirspaceProcessTimer()
{
  static Validity previous;

  const AirspaceWarningsInfo &warnings =
    CommonInterface::Calculated().airspace_warnings;

  if (previous.Modified(warnings.latest))
    /* time warp, reset */
    previous.Clear();

  if (warnings.latest.Modified(previous)) {
    previous = warnings.latest;
    CommonInterface::main_window.SendAirspaceWarning();
  }
}
Exemplo n.º 8
0
 void Clear() {
   new_traffic.Clear();
   list.clear();
 }
Exemplo n.º 9
0
 void Clear() {
   available.Clear();
 }
Exemplo n.º 10
0
 /**
  * Clear the pressure altitude value if it is "weak".
  */
 void ClearWeakPressureAltitude() {
   if (pressure_altitude_available && pressure_altitude_weak)
     pressure_altitude_available.Clear();
 }
Exemplo n.º 11
0
 /**
  * Clear the barometric altitude value if it is "weak".
  */
 void ClearWeakBaroAltitude() {
   if (baro_altitude_available && baro_altitude_weak)
     baro_altitude_available.Clear();
 }
Exemplo n.º 12
0
 /**
  * Sets a fake location, and marks it as "unavailable".  This is
  * used during startup to move the glider symbol to the home
  * waypoint.
  */
 void SetFakeLocation(const GeoPoint &_location, const double _altitude) {
   location = _location;
   location_available.Clear();
   gps_altitude = _altitude;
   gps_altitude_available.Clear();
 }
Exemplo n.º 13
0
 void Clear() {
   valid.Clear();
   name.clear();
 }
Exemplo n.º 14
0
 void Reset() {
   bank_angle_available = false;
   pitch_angle_available = false;
   heading_available.Clear();
 }
Exemplo n.º 15
0
 /**
  * Create a empty flight object, used to create a flight from in-memory data
  */
 Flight()
   : keep_flight(true), flight_file(nullptr) {
   fixes = new std::vector<IGCFixEnhanced>;
   qnh = AtmosphericPressure::Standard();
   qnh_available.Clear();
 };