static void SetPolar(Port &port, OperationEnvironment &env) { fixed a, b, c; if (!ReadFixed("polar coefficient a", a) || !ReadFixed("polar coefficient b", b) || !ReadFixed("polar coefficient c", c)) return; if (LX1600::SetPolar(port, env, a, b, c)) fprintf(stdout, "Polar coefficients set to \"%.2f, %.2f, %.2f\"\n", (double)a, (double)b, (double)c); else fprintf(stdout, "Operation failed!\n"); }
static void SetFilters(Port &port, OperationEnvironment &env) { fixed vario_filter, te_filter; unsigned te_level; if (!ReadFixed("the Vario filter (sec, default = 1)", vario_filter) || !ReadFixed("the TE filter (0.1 - 2.0, default = 1.5)", te_filter) || !ReadUnsigned("the TE level (50 - 150 %, default = 0 = off)", te_level)) return; if (LX1600::SetFilters(port, env, vario_filter, te_filter, te_level)) fprintf(stdout, "Filters set to \"%.1f, %.1f, %u\"\n", (double)vario_filter, (double)te_filter, te_level); else fprintf(stdout, "Operation failed!\n"); }
static bool ReadFixed(const char *setting, fixed &value) { PrintInputRequest(setting); if (ReadFixed(value)) return true; fprintf(stdout, "Invalid input\n"); return false; }
static void SetSCSettings(Port &port, OperationEnvironment &env) { unsigned mode, control_mode; fixed deadband, threshold_speed; if (!ReadUnsigned("the SC Mode (EXTERNAL = 0, default = ON_CIRCLING = 1, AUTO_IAS = 2)", mode) || !ReadFixed("the SC deadband (0 - 10.0 m/s, default=1)", deadband) || !ReadUnsigned("the SC switch mode (NORMAL = 0, default = INVERTED = 1, TASTER = 2)", control_mode)) return; if (mode != 2u) threshold_speed = fixed(0); else if (!ReadFixed("the SC threshold speed (50 - 150 km/h, default=110)", threshold_speed)) return; if (LX1600::SetSCSettings(port, env, (LX1600::SCMode)mode, deadband, (LX1600::SCControlMode)control_mode, threshold_speed)) fprintf(stdout, "SC settings changed!\n"); else fprintf(stdout, "Operation failed!\n"); }
static void SetMC(Port &port, OperationEnvironment &env) { fixed mc; if (!ReadFixed("the MC setting (0.0 - 5.0)", mc)) return; fprintf(stdout, "Setting MC to \"%.1f\" ...\n", (double)mc); if (LX1600::SetMacCready(port, env, mc)) fprintf(stdout, "MC set to \"%.1f\"\n", (double)mc); else fprintf(stdout, "Operation failed!\n"); }
static void SetBallast(Port &port, OperationEnvironment &env) { fixed ballast; if (!ReadFixed("the Ballast setting (1.0 - 1.5)", ballast)) return; fprintf(stdout, "Setting Ballast to \"%.1f\" ...\n", (double)ballast); if (LX1600::SetBallast(port, env, ballast)) fprintf(stdout, "Ballast set to \"%.1f\"\n", (double)ballast); else fprintf(stdout, "Operation failed!\n"); }
static void SetQNH(Port &port, OperationEnvironment &env) { fixed qnh; if (!ReadFixed("the QNH setting (hPa)", qnh)) return; fprintf(stdout, "Setting QNH to \"%.1f hPa\" ...\n", (double)qnh); if (LX1600::SetQNH(port, env, AtmosphericPressure::HectoPascal(qnh))) fprintf(stdout, "QNH set to \"%.1f hPa\"\n", (double)qnh); else fprintf(stdout, "Operation failed!\n"); }
static void SetAltitudeOffset(Port &port, OperationEnvironment &env) { fixed altitude_offset; if (!ReadFixed("the altitude offset setting (m)", altitude_offset)) return; fprintf(stdout, "Setting altitude offset to \"%.1f m\" ...\n", (double)altitude_offset); if (LX1600::SetAltitudeOffset(port, env, Units::ToUserUnit(altitude_offset, Unit::FEET))) fprintf(stdout, "Altitude offset set to \"%.1f m\"\n", (double)altitude_offset); else fprintf(stdout, "Operation failed!\n"); }
bool PlaneGlue::Read(Plane &plane, KeyValueFileReader &reader) { bool has_registration = false; bool has_competition_id = false; bool has_type = false; bool has_polar_name = false; bool has_polar = false; bool has_reference_mass = false; bool has_dry_mass = false; bool has_handicap = false; bool has_max_ballast = false; bool has_dump_time = false; bool has_max_speed = false; bool has_wing_area = false; KeyValuePair pair; while (reader.Read(pair)) { if (!has_registration && StringIsEqual(pair.key, "Registration")) { plane.registration.SetUTF8(pair.value); has_registration = true; } else if (!has_competition_id && StringIsEqual(pair.key, "CompetitionID")) { plane.competition_id.SetUTF8(pair.value); has_competition_id = true; } else if (!has_type && StringIsEqual(pair.key, "Type")) { plane.type.SetUTF8(pair.value); has_type = true; } else if (!has_handicap && StringIsEqual(pair.key, "Handicap")) { has_handicap = ReadUnsigned(pair.value, plane.handicap); } else if (!has_polar_name && StringIsEqual(pair.key, "PolarName")) { plane.polar_name.SetUTF8(pair.value); has_polar_name = true; } else if (!has_polar && StringIsEqual(pair.key, "PolarInformation")) { has_polar = ReadPolar(pair.value, plane); } else if (!has_reference_mass && StringIsEqual(pair.key, "PolarReferenceMass")) { has_reference_mass = ReadFixed(pair.value, plane.reference_mass); } else if (!has_dry_mass && StringIsEqual(pair.key, "PolarDryMass")) { has_dry_mass = ReadFixed(pair.value, plane.dry_mass); } else if (!has_max_ballast && StringIsEqual(pair.key, "MaxBallast")) { has_max_ballast = ReadFixed(pair.value, plane.max_ballast); } else if (!has_dump_time && StringIsEqual(pair.key, "DumpTime")) { has_dump_time = ReadUnsigned(pair.value, plane.dump_time); } else if (!has_max_speed && StringIsEqual(pair.key, "MaxSpeed")) { has_max_speed = ReadFixed(pair.value, plane.max_speed); } else if (!has_wing_area && StringIsEqual(pair.key, "WingArea")) { has_wing_area = ReadFixed(pair.value, plane.wing_area); } } if (!has_polar || !has_reference_mass) return false; if (!has_registration) plane.registration.clear(); if (!has_competition_id) plane.competition_id.clear(); if (!has_type) plane.type.clear(); if (!has_polar_name) plane.polar_name.clear(); if (!has_dry_mass) plane.dry_mass = plane.reference_mass; if (!has_handicap) plane.handicap = 100; if (!has_max_ballast) plane.max_ballast = fixed(0); if (!has_dump_time) plane.dump_time = 0; if (!has_max_speed) plane.max_speed = fixed(55.555); if (!has_wing_area) plane.wing_area = fixed(0); return true; }