GlidePolar AbortTask::get_safety_polar() const { const fixed mc_safety = task_behaviour.get_safety_mc(glide_polar.get_mc()); GlidePolar polar = glide_polar; polar.set_mc(mc_safety); return polar; }
void MapWindow::DrawWaypoints(Canvas &canvas) { GlidePolar polar = get_glide_polar(); polar.set_mc(min(Calculated().common_stats.current_risk_mc, SettingsComputer().safety_mc)); way_point_renderer.render(canvas, label_block, render_projection, SettingsMap(), SettingsComputer(), polar, ToAircraftState(Basic()), task); }
/** * Loads calculated values from the persistent memory file * @param Calculated DERIVED_INFO the values should be loaded into */ void LoadCalculationsPersist(DERIVED_INFO *Calculated, ProtectedTaskManager &protected_task_manager, GlideComputer &glide_computer) { return; // do nothing, this is broken for CommonStats // Get the persistent memory filename if (szCalculationsPersistFileName[0] == 0) { if (is_altair()) { LocalPath(szCalculationsPersistFileName, _T("persist/xcsoar-persist.log")); LocalPath(szCalculationsPersistDirectory, _T("persist")); } else { LocalPath(szCalculationsPersistFileName, _T("xcsoar-persist.log")); _tcscpy(szCalculationsPersistDirectory, GetPrimaryDataPath()); } } // Debug Log LogStartUp(_T("LoadCalculationsPersist")); unsigned sizein; // Try to open the persistent memory file FILE *file = _tfopen(szCalculationsPersistFileName, _T("rb")); if (file == NULL) { LogStartUp(_T("LoadCalculationsPersist file not found")); return; } fread(&sizein, sizeof(sizein), 1, file); if (sizein != sizeof(*Calculated)) { fclose(file); return; } // Read persistent memory into Calculated fread(Calculated, sizeof(*Calculated), 1, file); fread(&sizein, sizeof(sizein), 1, file); if (sizein != sizeof(glide_computer.GetFlightStats())) { glide_computer.ResetFlight(); fclose(file); return; } // Read persistent memory into FlightStats fread(&glide_computer.GetFlightStats(), sizeof(glide_computer.GetFlightStats()), 1, file); /// @todo persistence for OLC data fread(&sizein, sizeof(sizein), 1, file); if (sizein != 4 * sizeof(double)) { fclose(file); return; } GlidePolar polar = glide_computer.SettingsComputer().glide_polar_task; double MACCREADY = polar.get_mc(); double BUGS = polar.get_bugs(); double BALLAST = polar.get_ballast(); // Read persistent memory into MacCready, QNH, bugs, ballast and temperature fread(&MACCREADY, sizeof(double), 1, file); fread(&BUGS, sizeof(double), 1, file); fread(&BALLAST, sizeof(double), 1, file); fread(&CuSonde::maxGroundTemperature, sizeof(CuSonde::maxGroundTemperature), 1, file); // ReadFile(hFile,&CRUISE_EFFICIENCY, // size,&dwBytesWritten,(OVERLAPPED*)NULL); MACCREADY = min(10.0, max(MACCREADY, 0.0)); BUGS = min(1.0, max(BUGS, 0.0)); BALLAST = min(1.0, max(BALLAST, 0.0)); // CRUISE_EFFICIENCY = min(1.5, max(CRUISE_EFFICIENCY,0.75)); polar.set_mc(fixed(MACCREADY)); polar.set_bugs(fixed(BUGS)); polar.set_ballast(fixed(BALLAST)); protected_task_manager.set_glide_polar(polar); LogStartUp(_T("LoadCalculationsPersist OK")); fclose(file); }