static void Update(const MoreData &basic, const DerivedInfo &calculated) { const TeamInfo &teamcode_info = calculated; const TeamCodeSettings &settings = CommonInterface::GetComputerSettings().team_code; StaticString<100> buffer; if (teamcode_info.teammate_available && basic.track_available) { FormatAngleDelta(buffer.buffer(), buffer.MAX_SIZE, teamcode_info.teammate_vector.bearing - basic.track); } else { buffer = _T("---"); } SetFormValue(*wf, _T("prpRelBearing"), buffer); if (teamcode_info.teammate_available) { LoadFormProperty(*wf, _T("prpBearing"), teamcode_info.teammate_vector.bearing.Degrees()); LoadFormProperty(*wf, _T("prpRange"), UnitGroup::DISTANCE, teamcode_info.teammate_vector.distance); } SetFormValue(*wf, _T("prpOwnCode"), teamcode_info.own_teammate_code.GetCode()); SetFormValue(*wf, _T("prpMateCode"), settings.team_code.GetCode()); SetFormValue(*wf, _T("prpFlarmLock"), settings.team_flarm_id.IsDefined() ? settings.team_flarm_callsign.c_str() : _T("")); }
void TaskStatusPanel::Refresh() { if (protected_task_manager == NULL) return; const DerivedInfo &calculated = CommonInterface::Calculated(); const TaskStats &task_stats = calculated.task_stats; TCHAR Temp[80]; FormatSignedTimeHHMM(Temp, (int)protected_task_manager->GetOrderedTaskBehaviour().aat_min_time); ShowFormControl(form, _T("prpTaskTime"), task_stats.has_targets); if (task_stats.has_targets) SetFormValue(form, _T("prpTaskTime"), Temp); int ete_time(task_stats.total.time_elapsed + task_stats.total.time_remaining); FormatSignedTimeHHMM(Temp, ete_time); SetFormValue(form, _T("prpETETime"), Temp); FormatSignedTimeHHMM(Temp, (int)task_stats.total.time_remaining); SetFormValue(form, _T("prpRemainingTime"), Temp); if (task_stats.total.planned.IsDefined()) { Units::FormatUserDistanceSmart(task_stats.total.planned.get_distance(), Temp, ARRAY_SIZE(Temp)); SetFormValue(form, _T("prpTaskDistance"), Temp); } else SetFormValue(form, _T("prpTaskDistance"), _T("")); if (task_stats.total.remaining.IsDefined()) { Units::FormatUserDistanceSmart(task_stats.total.remaining.get_distance(), Temp, ARRAY_SIZE(Temp)); SetFormValue(form, _T("prpRemainingDistance"), Temp); } if (task_stats.total.planned.IsDefined()) { Units::FormatUserTaskSpeed(task_stats.total.planned.get_speed(), Temp, ARRAY_SIZE(Temp)); SetFormValue(form, _T("prpEstimatedSpeed"), Temp); } else SetFormValue(form, _T("prpEstimatedSpeed"), _T("")); if (task_stats.total.travelled.IsDefined()) { Units::FormatUserTaskSpeed(task_stats.total.travelled.get_speed(), Temp, ARRAY_SIZE(Temp)); SetFormValue(form, _T("prpAverageSpeed"), Temp); } else SetFormValue(form, _T("prpAverageSpeed"), _T("")); }
/** * Updates all the dialogs fields, that are changing frequently. * e.g. climb speed, distance, height */ static void UpdateChanging() { TCHAR tmp[20]; const FlarmTraffic* target = XCSoarInterface::Basic().flarm.traffic.FindTraffic(target_id); bool target_ok = target && target->IsDefined(); // Fill distance field if (target_ok) FormatUserDistanceSmart(target->distance, tmp, 20, fixed(1000)); else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpDistance"), tmp); // Fill horizontal direction field if (target_ok) FormatAngleDelta(tmp, ARRAY_SIZE(tmp), target->Bearing() - CommonInterface::Basic().track); else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpDirectionH"), tmp); // Fill altitude field if (target_ok && target->altitude_available) FormatUserAltitude(target->altitude, tmp, 20); else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpAltitude"), tmp); // Fill vertical direction field if (target_ok) { Angle dir = Angle::Radians((fixed)atan2(target->relative_altitude, target->distance)).AsDelta(); FormatVerticalAngleDelta(tmp, ARRAY_SIZE(tmp), dir); } else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpDirectionV"), tmp); // Fill climb speed field if (target_ok && target->climb_rate_avg30s_available) FormatUserVerticalSpeed(target->climb_rate_avg30s, tmp, 20); else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpVSpeed"), tmp); }
void TimesStatusPanel::Refresh() { const NMEAInfo &basic = CommonInterface::Basic(); const DerivedInfo &calculated = CommonInterface::Calculated(); const FlyingState &flight = calculated.flight; TCHAR Temp[64]; fixed sunsettime; int sunsethours; int sunsetmins; sunsettime = XCSoarInterface::Calculated().sunset_time; sunsethours = (int)sunsettime; sunsetmins = (int)((sunsettime - fixed(sunsethours)) * 60); _stprintf(Temp, _T("%02d:%02d"), sunsethours, sunsetmins); SetFormValue(form, _T("prpSunset"), Temp); Units::TimeToTextHHMMSigned(Temp, DetectCurrentTime(basic)); SetFormValue(form, _T("prpLocalTime"), Temp); if (positive(flight.flight_time)) { Units::TimeToTextHHMMSigned(Temp, TimeLocal((long)flight.takeoff_time)); SetFormValue(form, _T("prpTakeoffTime"), Temp); } else { SetFormValue(form, _T("prpTakeoffTime"), _T("")); } if (!flight.flying && positive(flight.flight_time)) { Units::TimeToTextHHMMSigned(Temp, TimeLocal((long)(flight.takeoff_time + flight.flight_time))); SetFormValue(form, _T("prpLandingTime"), Temp); } else { SetFormValue(form, _T("prpLandingTime"), _T("")); } if (positive(flight.flight_time)) { Units::TimeToTextHHMMSigned(Temp, (int)flight.flight_time); SetFormValue(form, _T("prpFlightTime"), Temp); } else { SetFormValue(form, _T("prpFlightTime"), _T("")); } }
void AltitudeInfoPanel::Refresh() { const DerivedInfo &calculated = CommonInterface::Calculated(); const NMEAInfo &basic = CommonInterface::Basic(); TCHAR sTmp[32]; if (!calculated.altitude_agl_valid) { SetFormValue(form, _T("prpAltAGL"), _("N/A")); } else { // Set Value Units::FormatUserAltitude(calculated.altitude_agl, sTmp, ARRAY_SIZE(sTmp)); SetFormValue(form, _T("prpAltAGL"), sTmp); } if (!basic.baro_altitude_available) { SetFormValue(form, _T("prpAltBaro"), _("N/A")); } else { // Set Value Units::FormatUserAltitude(basic.baro_altitude, sTmp, ARRAY_SIZE(sTmp)); SetFormValue(form, _T("prpAltBaro"), sTmp); } if (!basic.gps_altitude_available) { SetFormValue(form, _T("prpAltGPS"), _("N/A")); } else { // Set Value Units::FormatUserAltitude(basic.gps_altitude, sTmp, ARRAY_SIZE(sTmp)); SetFormValue(form, _T("prpAltGPS"), sTmp); } if (!calculated.terrain_valid){ SetFormValue(form, _T("prpTerrain"), _("N/A")); } else { // Set Value Units::FormatUserAltitude(calculated.terrain_altitude, sTmp, ARRAY_SIZE(sTmp)); SetFormValue(form, _T("prpTerrain"), sTmp); } }
void dlgHelpShowModal(SingleWindow &parent, const TCHAR* Caption, const TCHAR* HelpText) { if (!Caption || !HelpText) return; wf = LoadDialog(CallBackTable, parent, Layout::landscape ? _T("IDR_XML_HELP_L"): _T("IDR_XML_HELP")); if (wf == NULL) return; StaticString<100> full_caption; full_caption.Format(_T("%s: %s"), _("Help"), Caption); wf->SetCaption(full_caption); SetFormValue(*wf, _T("prpHelpText"), HelpText); wf->ShowModal(); delete wf; }
/** * Updates all the dialogs fields. * Should be called on dialog opening as it closes the dialog when the * target does not exist. */ static void Update() { TCHAR tmp[200], tmp_id[7]; // Set the dialog caption _stprintf(tmp, _T("%s (%s)"), _("FLARM Traffic Details"), target_id.Format(tmp_id)); wf->SetCaption(tmp); // Try to find the target in the FLARMnet database /// @todo: make this code a little more usable const FlarmRecord *record = FlarmDetails::LookupRecord(target_id); if (record) { // Fill the pilot name field SetFormValue(*wf, _T("prpPilot"), record->pilot); // Fill the frequency field if (!StringIsEmpty(record->frequency)) { _tcscpy(tmp, record->frequency); _tcscat(tmp, _T(" MHz")); SetFormValue(*wf, _T("prpFrequency"), tmp); } else SetFormValue(*wf, _T("prpFrequency"), _T("--")); // Fill the home airfield field SetFormValue(*wf, _T("prpAirport"), record->airfield); // Fill the plane type field SetFormValue(*wf, _T("prpPlaneType"), record->plane_type); } else { // Fill the pilot name field SetFormValue(*wf, _T("prpPilot"), _T("--")); // Fill the frequency field SetFormValue(*wf, _T("prpFrequency"), _T("--")); // Fill the home airfield field SetFormValue(*wf, _T("prpAirport"), _T("--")); // Fill the plane type field const FlarmTraffic* target = XCSoarInterface::Basic().flarm.traffic.FindTraffic(target_id); const TCHAR* actype; if (target == NULL || (actype = FlarmTraffic::GetTypeString(target->type)) == NULL) actype = _T("--"); SetFormValue(*wf, _T("prpPlaneType"), actype); } // Fill the callsign field (+ registration) // note: don't use target->Name here since it is not updated // yet if it was changed const TCHAR* cs = FlarmDetails::LookupCallsign(target_id); if (cs != NULL && cs[0] != 0) { _tcscpy(tmp, cs); if (record) { _tcscat(tmp, _T(" (")); _tcscat(tmp, record->registration); _tcscat(tmp, _T(")")); } } else _tcscpy(tmp, _T("--")); SetFormValue(*wf, _T("prpCallsign"), tmp); // Update the frequently changing fields too UpdateChanging(); }