void CaiLNavDevice::OnCalculatedUpdate(const MoreData &basic, const DerivedInfo &calculated) { NullOperationEnvironment env; char buffer[100]; const GeoPoint here = basic.location_available ? basic.location : GeoPoint::Invalid(); const ElementStat ¤t_leg = calculated.task_stats.current_leg; AGeoPoint destination = AGeoPoint(current_leg.location_remaining, current_leg.solution_planned.min_arrival_altitude); if (FormatGPRMC(buffer, sizeof(buffer), basic)) PortWriteNMEA(port, buffer, env); if (FormatGPRMB(buffer, sizeof(buffer), here, destination)) PortWriteNMEA(port, buffer, env); if (FormatPCAIB(buffer, sizeof(buffer), destination)) PortWriteNMEANoChecksum(port, buffer, env); }
bool DeviceDescriptor::WriteNMEA(const char *line) { assert(line != NULL); return port != NULL && PortWriteNMEA(*port, line); }
/** * Set the MC setting of the V7 vario * @param mc in m/s */ static inline bool SetMacCready(Port &port, OperationEnvironment &env, fixed mc) { char buffer[32]; sprintf(buffer, "PLXV0,MC,W,%.1f", (double)mc); return PortWriteNMEA(port, buffer, env); }
bool DeviceDescriptor::WriteNMEA(const char *line, OperationEnvironment &env) { assert(line != nullptr); return port != nullptr && PortWriteNMEA(*port, line, env); }
bool VegaDevice::RequestSetting(const char *name, OperationEnvironment &env) { char buffer[64]; sprintf(buffer, "PDVSC,R,%s", name); return PortWriteNMEA(port, buffer, env); }
bool FlymasterF1Device::EnableNMEA(OperationEnvironment &env) { /* this command initiates NMEA mode according to the "Flymaster F1 Commands" document */ return PortWriteNMEA(port, "$PFMNAV,", env); }
bool LXDevice::PutMacCready(fixed mac_cready, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; char tmp[32]; sprintf(tmp, "PFLX2,%1.1f,,,,,,", (double)mac_cready); PortWriteNMEA(port, tmp, env); // LXNAV V7 variant: sprintf(tmp, "PLXV0,MC,W,%.1f", (double)mac_cready); PortWriteNMEA(port, tmp, env); return true; }
/** * Set the ballast setting of the V7 vario * @param overload 1.0 - 1.4 (100 - 140%) */ static inline bool SetBallast(Port &port, OperationEnvironment &env, fixed overload) { char buffer[100]; sprintf(buffer, "PLXV0,BAL,W,%.2f", (double)overload); return PortWriteNMEA(port, buffer, env); }
/** * Set the bugs setting of the V7 vario * @param bugs 0 - 30 % */ static inline bool SetBugs(Port &port, OperationEnvironment &env, unsigned bugs) { char buffer[100]; sprintf(buffer, "PLXV0,BUGS,W,%u", bugs); return PortWriteNMEA(port, buffer, env); }
bool Vega::VolatileData::SendTo(Port &port, OperationEnvironment &env) const { char buffer[100]; sprintf(buffer, "PDVMC,%u,%u,%u,%d,%u", mc, stf, circling, terrain_altitude, qnh); return PortWriteNMEA(port, buffer, env); }
/** * Set the QNH setting of the V7 vario */ static inline bool SetQNH(Port &port, OperationEnvironment &env, const AtmosphericPressure &qnh) { char buffer[100]; unsigned QNHinPascal = uround(qnh.GetPascal()); sprintf(buffer, "PLXV0,QNH,W,%u", QNHinPascal); return PortWriteNMEA(port, buffer, env); }
bool LXDevice::PutMacCready(fixed MacCready) { char szTmp[32]; sprintf(szTmp, "PFLX2,%1.1f,,,,,,", (double)MacCready); PortWriteNMEA(port, szTmp); return true; }
void devWriteNMEAString(DeviceDescriptor &d, const TCHAR *text) { if (d.Com == NULL) return; PortWriteNMEA(d.Com, text); }
void VarioWriteNMEA(const TCHAR *text) { for (int i = 0; i < NUMDEV; i++) if (DeviceList[i].IsVega()) if (DeviceList[i].Com) PortWriteNMEA(DeviceList[i].Com, text); }
bool VaulterDevice::PutMacCready(fixed mc, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; char buffer[30]; sprintf(buffer,"PITV1,MC=%0.2f", (double)mc); return PortWriteNMEA(port, buffer, env); }
bool VaulterDevice::PutBallast(fixed fraction, fixed overload, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; char buffer[30]; sprintf(buffer,"PITV1,WL=%0.2f", (double)overload); return PortWriteNMEA(port, buffer, env); }
static bool RequestLogbookContents(Port &port, unsigned start, unsigned end, OperationEnvironment &env) { char buffer[32]; sprintf(buffer, "PLXVC,LOGBOOK,R,%u,%u,", start, end); return PortWriteNMEA(port, buffer, env); }
static bool SetupNMEA(Port &port, OperationEnvironment &env) { /* This line initiates the Color Vario to send out LXWP2 and LXWP3 LXWP0 once started, is repeated every second. This is a copy of the initiation done in LK8000, realized by LX Navigation developers We have no documentation and so we do not know what this exactly means. */ return PortWriteNMEA(port, "PFLX0,LXWP0,1,LXWP2,3,LXWP3,4", env); }
bool LXDevice::PutQNH(const AtmosphericPressure &pres) { fixed altitude_offset = pres.StaticPressureToQNHAltitude(AtmosphericPressure::Standard()); char buffer[100]; sprintf(buffer, "PFLX3,%.2f,,,,,,,,,,,,", (double)altitude_offset / 0.3048); PortWriteNMEA(port, buffer); return true; }
bool LXDevice::PutQNH(const AtmosphericPressure &pres, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; double altitude_offset = (double)pres.StaticPressureToQNHAltitude(AtmosphericPressure::Standard()) / 0.3048; char buffer[100]; sprintf(buffer, "PFLX3,%.2f,,,,,,,,,,,,", altitude_offset); PortWriteNMEA(port, buffer, env); // LXNAV V7 variant: sprintf(buffer, "PLXV0,QNH,W,%.2f", altitude_offset); PortWriteNMEA(port, buffer, env); return true; }
static bool RequestFlight(Port &port, const char *filename, unsigned start_row, unsigned end_row, OperationEnvironment &env) { char buffer[64]; sprintf(buffer, "PLXVC,FLIGHT,R,%s,%u,%u,", filename, start_row, end_row); return PortWriteNMEA(port, buffer, env); }
bool BlueFlyDevice::RequestSettings(OperationEnvironment &env) { { const ScopeLock lock(mutex_settings); settings_ready = false; } return PortWriteNMEA(port, "BST", env); }
bool LXDevice::PutBugs(fixed bugs, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; // This is a copy of the routine done in LK8000 for LX MiniMap, realized // by Lx developers. char tmp[100]; int transformed_bugs_value = 100 - (int)(bugs*100); sprintf(tmp, "PFLX2,,,%d,,,", transformed_bugs_value); PortWriteNMEA(port, tmp, env); // LXNAV V7 variant: sprintf(tmp, "PLXV0,BUGS,W,%d", transformed_bugs_value); PortWriteNMEA(port, tmp, env); return true; }
bool BlueFlyDevice::WriteDeviceSetting(const char *name, int value, OperationEnvironment &env) { char buffer[64]; assert(strlen(name) == 3); sprintf(buffer, "%s %d", name, value); return PortWriteNMEA(port, buffer, env); }
bool LXDevice::PutBallast(gcc_unused fixed fraction, fixed overload, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; // This is a copy of the routine done in LK8000 for LX MiniMap, realized // by Lx developers. char tmp[100]; sprintf(tmp, "PFLX2,,%.2f,,,,", (double)overload); PortWriteNMEA(port, tmp, env); // LXNAV V7 variant: sprintf(tmp, "PLXV0,BAL,W,%.2f", (double)overload); PortWriteNMEA(port, tmp, env); return true; }
bool LXDevice::Open(gcc_unused OperationEnvironment &env) { // This line initiates the Color Vario to send out LXWP2 and LXWP3 // LXWP0 once started, is repeated every second // This is a copy of the initiation done in LK8000, realized by Lx developers // We have no documentation and so we do not know what this exactly means char tmp[100]; sprintf(tmp, "PFLX0,LXWP0,1,LXWP2,3,LXWP3,4"); PortWriteNMEA(port, tmp); return true; }
static void PortWriteNMEA(Port *port, const TCHAR *line) { assert(port != NULL); assert(line != NULL); char buffer[_tcslen(line) * 4 + 1]; if (::WideCharToMultiByte(CP_ACP, 0, line, -1, buffer, sizeof(buffer), NULL, NULL) <= 0) return; PortWriteNMEA(port, buffer); }
bool VegaDevice::SendSetting(const char *name, int value, OperationEnvironment &env) { /* erase the old value from the settings map, because we expect to receive the new one now */ settings.Lock(); settings.erase(name); settings.Unlock(); char buffer[64]; sprintf(buffer, "PDVSC,S,%s,%d", name, value); return PortWriteNMEA(port, buffer, env); }
void PDVSC_S(NMEAInputLine &line) { char name[64], value[256]; line.read(name, ARRAY_SIZE(name)); line.read(value, ARRAY_SIZE(value)); settings[name] = value; ConsoleOperationEnvironment env; char buffer[512]; snprintf(buffer, ARRAY_SIZE(buffer), "PDVSC,A,%s,%s", name, value); PortWriteNMEA(*port, buffer, env); }
bool LXDevice::RequestV7Setting(const char *name, OperationEnvironment &env) { if (!EnableNMEA(env)) return false; v7_settings.Lock(); v7_settings.MarkOld(name); v7_settings.Unlock(); char buffer[256]; sprintf(buffer, "PLXV0,%s,R", name); return PortWriteNMEA(port, buffer, env); }