本文整理汇总了C++中MoreData类的典型用法代码示例。如果您正苦于以下问题:C++ MoreData类的具体用法?C++ MoreData怎么用?C++ MoreData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MoreData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _task
void
GlideComputerTask::ProcessBasicTask(const MoreData &basic,
const MoreData &last_basic,
DerivedInfo &calculated,
const DerivedInfo &last_calculated,
const ComputerSettings &settings_computer)
{
if (basic.HasTimeAdvancedSince(last_basic) && basic.location_available)
trace.Update(settings_computer, ToAircraftState(basic, calculated));
ProtectedTaskManager::ExclusiveLease _task(task);
_task->SetTaskBehaviour(settings_computer.task);
if (basic.HasTimeAdvancedSince(last_basic) && basic.location_available) {
const AircraftState current_as = ToAircraftState(basic, calculated);
const AircraftState last_as = ToAircraftState(last_basic, last_calculated);
_task->Update(current_as, last_as);
const fixed fallback_mc = calculated.last_thermal.IsDefined() &&
positive(calculated.last_thermal_average_smooth)
? calculated.last_thermal_average_smooth
: fixed_zero;
if (_task->UpdateAutoMC(current_as, fallback_mc))
calculated.ProvideAutoMacCready(basic.clock,
_task->GetGlidePolar().GetMC());
}
calculated.task_stats = _task->GetStats();
calculated.common_stats = _task->GetCommonStats();
calculated.glide_polar_safety = _task->GetSafetyPolar();
}
示例2:
/**
* Logs GPS fixes for stats
* @return True if valid fix (fix distance <= 200m), False otherwise
*/
bool
StatsComputer::DoLogging(const MoreData &basic,
const DerivedInfo &calculated)
{
/// @todo consider putting this sanity check inside Parser
bool location_jump = basic.location_available && last_location.IsValid() &&
basic.location.DistanceS(last_location) > 200;
last_location = basic.location_available
? basic.location : GeoPoint::Invalid();
if (location_jump || !basic.location_available)
// prevent bad fixes from being logged or added to OLC store
return false;
if (calculated.flight.flying &&
stats_clock.CheckAdvance(basic.time, PERIOD)) {
flightstats.AddAltitudeTerrain(calculated.flight.flight_time,
calculated.terrain_altitude);
if (basic.NavAltitudeAvailable())
flightstats.AddAltitude(calculated.flight.flight_time,
basic.nav_altitude);
if (calculated.task_stats.IsPirkerSpeedAvailable())
flightstats.AddTaskSpeed(calculated.flight.flight_time,
calculated.task_stats.get_pirker_speed());
}
return true;
}
示例3: Elapsed
void
GlideComputerAirData::Average30s(const MoreData &basic,
const NMEAInfo &last_basic,
DerivedInfo &calculated,
const DerivedInfo &last_calculated)
{
const bool time_advanced = basic.HasTimeAdvancedSince(last_basic);
if (!time_advanced || calculated.circling != last_calculated.circling) {
vario_30s_filter.reset();
netto_30s_filter.reset();
calculated.average = basic.brutto_vario;
calculated.netto_average = basic.netto_vario;
}
if (!time_advanced)
return;
const unsigned Elapsed(basic.time - last_basic.time);
if (Elapsed == 0)
return;
for (unsigned i = 0; i < Elapsed; ++i) {
vario_30s_filter.update(basic.brutto_vario);
netto_30s_filter.update(basic.netto_vario);
}
calculated.average = vario_30s_filter.average();
calculated.netto_average = netto_30s_filter.average();
}
示例4: fixed
/**
* Reads the current terrain height
*/
void
GlideComputerAirData::TerrainHeight(const MoreData &basic,
TerrainInfo &calculated)
{
if (!basic.location_available || terrain == NULL) {
calculated.terrain_valid = false;
calculated.terrain_altitude = fixed_zero;
calculated.altitude_agl_valid = false;
calculated.altitude_agl = fixed_zero;
return;
}
short Alt = terrain->GetTerrainHeight(basic.location);
if (RasterBuffer::IsSpecial(Alt)) {
if (RasterBuffer::IsWater(Alt))
/* assume water is 0m MSL; that's the best guess */
Alt = 0;
else {
calculated.terrain_valid = false;
calculated.terrain_altitude = fixed_zero;
calculated.altitude_agl_valid = false;
calculated.altitude_agl = fixed_zero;
return;
}
}
calculated.terrain_valid = true;
calculated.terrain_altitude = fixed(Alt);
if (basic.NavAltitudeAvailable()) {
calculated.altitude_agl = basic.nav_altitude - calculated.terrain_altitude;
calculated.altitude_agl_valid = true;
} else
calculated.altitude_agl_valid = false;
}
示例5: NearestAirspace
gcc_pure
NearestAirspace
NearestAirspace::FindHorizontal(const MoreData &basic,
const ProtectedAirspaceWarningManager &airspace_warnings,
const Airspaces &airspace_database)
{
if (!basic.location_available)
/* can't check for airspaces without a GPS fix */
return NearestAirspace();
/* find the nearest airspace */
//consider only active airspaces
const auto outside_and_active =
MakeAndPredicate(ActiveAirspacePredicate(&airspace_warnings),
OutsideAirspacePredicate(AGeoPoint(basic.location, 0)));
//if altitude is available, filter airspaces in same height as airplane
if (basic.NavAltitudeAvailable()) {
/* check altitude; hard-coded margin of 50m (for now) */
const auto outside_and_active_and_height =
MakeAndPredicate(outside_and_active,
AirspacePredicateHeightRange(basic.nav_altitude - 50,
basic.nav_altitude + 50));
const auto predicate = WrapAirspacePredicate(outside_and_active_and_height);
return ::FindHorizontal(basic.location, airspace_database, predicate);
} else {
/* only filter outside and active */
const auto predicate = WrapAirspacePredicate(outside_and_active);
return ::FindHorizontal(basic.location, airspace_database, predicate);
}
}
示例6: if
void
BasicComputer::Compute(MoreData &data,
const MoreData &last, const MoreData &last_gps,
const DerivedInfo &calculated)
{
ComputeTrack(data, last_gps);
if (data.HasTimeAdvancedSince(last_gps)) {
ComputeGroundSpeed(data, last_gps);
ComputeAirspeed(data, calculated);
}
#ifndef NDEBUG
// For testing without gps.
// When CPU load is low enough it can be done for every sample.
else if (data.dyn_pressure_available)
ComputeAirspeed(data, calculated);
#endif
ComputeHeading(data.attitude, data, calculated);
ComputeEnergyHeight(data);
ComputeGPSVario(data, last, last_gps);
ComputeBruttoVario(data);
ComputeNettoVario(data, calculated);
ComputeDynamics(data, calculated);
}
示例7: point
void
TraceComputer::Update(const ComputerSettings &settings_computer,
const MoreData &basic, const DerivedInfo &calculated)
{
/* time warps are handled by the Trace class */
if (!basic.time_available || !basic.location_available ||
!basic.NavAltitudeAvailable() ||
!calculated.flight.flying)
return;
// either olc or basic trace requires trace_full
if (settings_computer.contest.enable ||
settings_computer.task.enable_trace) {
const TracePoint point(basic);
mutex.Lock();
full.push_back(point);
mutex.Unlock();
// only olc requires trace_sprint
if (settings_computer.contest.enable)
sprint.push_back(point);
}
}
示例8: HorizontalAirspaceCondition
HorizontalAirspaceCondition(const MoreData &basic,
const DerivedInfo &calculated)
:location(basic.location),
altitude_available(basic.NavAltitudeAvailable())
{
if (altitude_available) {
altitude.altitude = basic.nav_altitude;
altitude.altitude_agl = calculated.altitude_agl;
}
}
示例9: day
void
WarningComputer::Update(const ComputerSettings &settings_computer,
const MoreData &basic, const MoreData &last_basic,
const DerivedInfo &calculated,
AirspaceWarningsInfo &result)
{
if (!basic.HasTimeAdvancedSince(last_basic) ||
!clock.check_advance(basic.time))
return;
airspaces.set_flight_levels(settings_computer.pressure);
AirspaceActivity day(calculated.date_time_local.day_of_week);
airspaces.set_activity(day);
if (!settings_computer.airspace.enable_warnings ||
!basic.location_available || !basic.NavAltitudeAvailable()) {
if (initialised) {
initialised = false;
protected_manager.clear();
}
return;
}
const AircraftState as = ToAircraftState(basic, calculated);
ProtectedAirspaceWarningManager::ExclusiveLease lease(protected_manager);
if (!initialised) {
initialised = true;
lease->Reset(as);
}
if (lease->Update(as, settings_computer.glide_polar_task,
calculated.task_stats,
calculated.circling,
uround(basic.time - last_basic.time)))
result.latest.Update(basic.clock);
}
示例10: ToAircraftState
const AircraftState
ToAircraftState(const MoreData &info, const DerivedInfo &calculated)
{
AircraftState aircraft;
/* SPEED_STATE */
aircraft.ground_speed = info.ground_speed;
aircraft.true_airspeed = info.true_airspeed;
/* ALTITUDE_STATE */
aircraft.altitude = info.NavAltitudeAvailable()
? info.nav_altitude
: 0.;
aircraft.working_band_fraction = calculated.common_stats.height_fraction_working;
aircraft.altitude_agl =
info.NavAltitudeAvailable() && calculated.terrain_valid
? calculated.altitude_agl
: 0.;
/* VARIO_INFO */
aircraft.vario = info.brutto_vario;
aircraft.netto_vario = info.netto_vario;
/* AIRCRAFT_STATE */
aircraft.time = info.time_available ? info.time : -1.;
aircraft.location = info.location_available
? info.location
: GeoPoint::Invalid();
aircraft.track = info.track;
aircraft.g_load = info.acceleration.available
? info.acceleration.g_load
: 1.;
aircraft.wind = calculated.GetWindOrZero();
aircraft.flying = calculated.flight.flying;
return aircraft;
}
示例11: Reset
void
GlideRatioComputer::Compute(const MoreData &basic,
const DerivedInfo &calculated,
VarioInfo &vario_info,
const ComputerSettings &settings)
{
if (!basic.NavAltitudeAvailable()) {
Reset();
vario_info.gr = INVALID_GR;
vario_info.average_gr = 0;
return;
}
if (!last_location_available) {
/* need two consecutive valid locations; if the previous one
wasn't valid, skip this iteration and try the next one */
Reset();
vario_info.gr = INVALID_GR;
vario_info.average_gr = 0;
last_location = basic.location;
last_location_available = basic.location_available;
last_altitude = basic.nav_altitude;
return;
}
if (!basic.location_available.Modified(last_location_available))
return;
auto DistanceFlown = basic.location.DistanceS(last_location);
// Glide ratio over ground
vario_info.gr =
UpdateGR(vario_info.gr, DistanceFlown,
last_altitude - basic.nav_altitude, 0.1);
if (calculated.flight.flying && !calculated.circling) {
if (!gr_calculator_initialised) {
gr_calculator_initialised = true;
gr_calculator.Initialize(settings);
}
gr_calculator.Add((int)DistanceFlown, (int)basic.nav_altitude);
vario_info.average_gr = gr_calculator.Calculate();
} else
gr_calculator_initialised = false;
last_location = basic.location;
last_location_available = basic.location_available;
last_altitude = basic.nav_altitude;
}
示例12: protect
void
TrackingGlue::OnTimer(const MoreData &basic, const DerivedInfo &calculated)
{
#ifdef HAVE_SKYLINES_TRACKING
skylines.Tick(basic);
#endif
#ifdef HAVE_LIVETRACK24
if (!settings.livetrack24.enabled)
/* disabled by configuration */
/* note that we are allowed to read "settings" without locking the
mutex, because the background thread never writes to this
attribute */
return;
if (!basic.time_available || !basic.gps.real || !basic.location_available)
/* can't track without a valid GPS fix */
return;
if (!clock.CheckUpdate(settings.interval * 1000))
/* later */
return;
ScopeLock protect(mutex);
if (IsBusy())
/* still running, skip this submission */
return;
date_time = basic.date_time_utc;
if (!date_time.IsDatePlausible())
/* use "today" if the GPS didn't provide a date */
(BrokenDate &)date_time = BrokenDate::TodayUTC();
location = basic.location;
/* XXX use nav_altitude? */
altitude = basic.NavAltitudeAvailable() && basic.nav_altitude > 0
? (unsigned)basic.nav_altitude
: 0u;
ground_speed = basic.ground_speed_available
? (unsigned)Units::ToUserUnit(basic.ground_speed, Unit::KILOMETER_PER_HOUR)
: 0u;
track = basic.track_available
? basic.track
: Angle::Zero();
last_flying = flying;
flying = calculated.flight.flying;
Trigger();
#endif
}
示例13: UpdateGR
void
GlideComputerAirData::GR(const MoreData &basic, const MoreData &last_basic,
const DerivedInfo &calculated, VarioInfo &vario_info)
{
if (!basic.NavAltitudeAvailable() || !last_basic.NavAltitudeAvailable()) {
vario_info.ld_vario = INVALID_GR;
vario_info.gr = INVALID_GR;
return;
}
if (basic.HasTimeRetreatedSince(last_basic)) {
vario_info.ld_vario = INVALID_GR;
vario_info.gr = INVALID_GR;
}
const bool time_advanced = basic.HasTimeAdvancedSince(last_basic);
if (time_advanced) {
fixed DistanceFlown = basic.location.Distance(last_basic.location);
// Glide ratio over ground
vario_info.gr =
UpdateGR(vario_info.gr, DistanceFlown,
last_basic.nav_altitude - basic.nav_altitude, fixed(0.1));
if (calculated.flight.flying && !calculated.circling)
gr_calculator.Add((int)DistanceFlown, (int)basic.nav_altitude);
}
// Lift / drag instantaneous from vario, updated every reading..
if (basic.total_energy_vario_available && basic.airspeed_available &&
calculated.flight.flying) {
vario_info.ld_vario =
UpdateGR(vario_info.ld_vario, basic.indicated_airspeed,
-basic.total_energy_vario, fixed(0.3));
} else {
vario_info.ld_vario = INVALID_GR;
}
}
示例14: Update
void
Update(const MoreData &basic, const FlyingState &state,
FlightTimeResult &result)
{
if (!basic.time_available || !basic.date_time_utc.IsDatePlausible())
return;
if (state.flying && !result.takeoff_time.IsPlausible()) {
result.takeoff_time = basic.GetDateTimeAt(state.takeoff_time);
result.takeoff_location = state.takeoff_location;
}
if (!state.flying && result.takeoff_time.IsPlausible() &&
!result.landing_time.IsPlausible()) {
result.landing_time = basic.GetDateTimeAt(state.landing_time);
result.landing_location = state.landing_location;
}
if (!negative(state.release_time) && !result.release_time.IsPlausible()) {
result.release_time = basic.GetDateTimeAt(state.release_time);
result.release_location = state.release_location;
}
}
示例15: day
void
WarningComputer::Update(const ComputerSettings &settings_computer,
const MoreData &basic,
const DerivedInfo &calculated,
AirspaceWarningsInfo &result)
{
if (!basic.time_available)
return;
const fixed dt = delta_time.Update(basic.time, fixed(1), fixed(20));
if (negative(dt))
/* time warp */
Reset();
if (!positive(dt))
return;
airspaces.SetFlightLevels(settings_computer.pressure);
AirspaceActivity day(calculated.date_time_local.day_of_week);
airspaces.SetActivity(day);
if (!settings_computer.airspace.enable_warnings ||
!basic.location_available || !basic.NavAltitudeAvailable()) {
if (initialised) {
initialised = false;
protected_manager.Clear();
}
return;
}
const AircraftState as = ToAircraftState(basic, calculated);
ProtectedAirspaceWarningManager::ExclusiveLease lease(protected_manager);
lease->SetConfig(settings_computer.airspace.warnings);
if (!initialised) {
initialised = true;
lease->Reset(as);
}
if (lease->Update(as, settings_computer.polar.glide_polar_task,
calculated.task_stats,
calculated.circling,
uround(dt)))
result.latest.Update(basic.clock);
}