diff --git a/companion/src/simulation/telemetrysimu.cpp b/companion/src/simulation/telemetrysimu.cpp index 6c901c8dc..bb8899ba6 100644 --- a/companion/src/simulation/telemetrysimu.cpp +++ b/companion/src/simulation/telemetrysimu.cpp @@ -59,6 +59,9 @@ TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * si connect(&timer, &QTimer::timeout, this, &TelemetrySimulator::generateTelemetryFrame); connect(&logTimer, &QTimer::timeout, this, &TelemetrySimulator::onLogTimerEvent); + gpsTimer.setInterval(250); + connect(&gpsTimer, &QTimer::timeout, this, &TelemetrySimulator::onGpsRunLoop); + connect(ui->Simulate, &QCheckBox::toggled, [&](bool on) { g.currentProfile().telemSimEnabled(on); }); connect(ui->cbPauseOnHide, &QCheckBox::toggled, [&](bool on) { g.currentProfile().telemSimPauseOnHide(on); }); connect(ui->cbResetRssiOnStop, &QCheckBox::toggled, [&](bool on) { g.currentProfile().telemSimResetRssiOnStop(on); }); @@ -154,6 +157,48 @@ void TelemetrySimulator::onLogTimerEvent() logPlayback->stepForward(false); } +void TelemetrySimulator::onGpsRunLoop() +{ + int a = ui->gps_latlon->text().contains(","); + if (!a) { + QMessageBox::information(this, tr("Bad GPS Format"), tr("Must be decimal latitude,longitude")); + ui->gps_latlon->setText("000.00000000,000.00000000"); + ui->GPSpushButton->click(); + } + else + { + QStringList gpsLatLon = (ui->gps_latlon->text()).split(","); + + double b2 = gpsLatLon[0].toDouble(); + double c2 = gpsLatLon[1].toDouble(); + double d3 = ui->gps_speed->value() / 14400; + double f3 = ui->gps_course->value(); + double j2 = 6378.1; + double b3 = qRadiansToDegrees(qAsin( qSin(qDegreesToRadians(b2))*qCos(d3/j2) + qCos(qDegreesToRadians(b2))*qSin(d3/j2)*qCos(qDegreesToRadians(f3)))); + double bb3 = b3; + if (bb3 < 0) { + bb3 = bb3 * -1; + } + if (bb3 > 89.99) { + f3 = f3 + 180; + if (f3 > 360) { + f3 = f3 - 360; + } + ui->gps_course->setValue(f3); + } + double c3 = qRadiansToDegrees(qDegreesToRadians(c2) + qAtan2(qSin(qDegreesToRadians(f3))*qSin(d3/j2)*qCos(qDegreesToRadians(b2)),qCos(d3/j2)-qSin(qDegreesToRadians(b2))*qSin(qDegreesToRadians(b3)))); + if (c3 > 180) { + c3 = c3 - 360; + } + if (c3 < -180) { + c3 = c3 + 360; + } + QString lats = QString::number(b3, 'f', 8); + QString lons = QString::number(c3, 'f', 8); + QString qs = lats + "," + lons; + ui->gps_latlon->setText(qs); + } +} void TelemetrySimulator::onLoadLogFile() { onStop(); // in case we are in playback mode @@ -1098,7 +1143,7 @@ void TelemetrySimulator::on_saveTelemetryvalues_clicked() if (fldr.isEmpty()) fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QString idFileNameAndPath = QFileDialog::getSaveFileName(this, tr("Save Telemetry"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)")); + QString idFileNameAndPath = QFileDialog::getSaveFileName(this, tr("Save Telemetry"), fldr % "/telemetry.tlm", tr(".tlm Files (*.tlm)")); if (idFileNameAndPath.isEmpty()) return; @@ -1184,7 +1229,7 @@ void TelemetrySimulator::on_loadTelemetryvalues_clicked() if (fldr.isEmpty()) fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QString idFileNameAndPath = QFileDialog::getOpenFileName(this, tr("Open Telemetry File"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)")); + QString idFileNameAndPath = QFileDialog::getOpenFileName(this, tr("Open Telemetry File"), fldr % "/telemetry.tlm", tr(".tlm Files (*.tlm)")); if (idFileNameAndPath.isEmpty()) return; @@ -1323,3 +1368,26 @@ void TelemetrySimulator::on_loadTelemetryvalues_clicked() } +void TelemetrySimulator::on_GPSpushButton_clicked() +{ + if (ui->GPSpushButton->text() == "Run") { + ui->GPSpushButton->setText("Stop"); + gpsTimer.start(); + } + else + { + ui->GPSpushButton->setText("Run"); + gpsTimer.stop(); + } +} + +void TelemetrySimulator::on_gps_course_valueChanged(double arg1) +{ + if (ui->gps_course->value() > 360) { + ui->gps_course->setValue(1); + } + if (ui->gps_course->value() < 1) { + ui->gps_course->setValue(360); + } +} + diff --git a/companion/src/simulation/telemetrysimu.h b/companion/src/simulation/telemetrysimu.h index a4c33bd62..34596f755 100644 --- a/companion/src/simulation/telemetrysimu.h +++ b/companion/src/simulation/telemetrysimu.h @@ -63,6 +63,7 @@ class TelemetrySimulator : public QWidget void setupDataFields(); void onSimulateToggled(bool isChecked); void onLogTimerEvent(); + void onGpsRunLoop(); void onLoadLogFile(); void onPlay(); void onRewind(); @@ -79,6 +80,7 @@ class TelemetrySimulator : public QWidget Ui::TelemetrySimulator * ui; QTimer timer; QTimer logTimer; + QTimer gpsTimer; SimulatorInterface *simulator; bool m_simuStarted; bool m_logReplayEnable; @@ -210,6 +212,8 @@ class TelemetrySimulator : public QWidget private slots: void on_saveTelemetryvalues_clicked(); void on_loadTelemetryvalues_clicked(); + void on_GPSpushButton_clicked(); + void on_gps_course_valueChanged(double arg1); }; // TelemetrySimulator #endif // _TELEMETRYSIMU_H_ diff --git a/companion/src/simulation/telemetrysimu.ui b/companion/src/simulation/telemetrysimu.ui index 52c9ef868..1aa273773 100644 --- a/companion/src/simulation/telemetrysimu.ui +++ b/companion/src/simulation/telemetrysimu.ui @@ -136,231 +136,6 @@ 5 - - - - - 0 - 0 - - - - - 8 - - - - -16777215 - - - 16777215 - - - 1 - - - 25 - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - RAS - - - - - - - - 0 - 0 - - - - - 8 - - - - A2 - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - V / ratio - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - 30 - - - - - - - - 0 - 0 - - - - - 8 - - - - 75 - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - @@ -379,8 +154,95 @@ - - + + + + + 0 + 0 + + + + + 8 + + + + V / ratio + + + + + + + + 0 + 0 + + + + + 8 + + + + °C + + + + + + + + 0 + 0 + + + + + 8 + + + + 100000 + + + 25 + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 6.000000000000000 + + + + + 0 @@ -406,8 +268,62 @@ - - + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + 0 @@ -420,7 +336,7 @@ - V / ratio + ml @@ -479,63 +395,8 @@ - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - 999.000000000000000 - - - 0.100000000000000 - - - 5.000000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - 999.000000000000000 - - - 0.100000000000000 - - - - - - - + + 0 @@ -548,7 +409,157 @@ - RxBt + A4 + + + + + + + + 0 + 0 + + + + + 8 + + + + Fuel + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + V / ratio + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + RPM + + + + + + + + 0 + 0 + + + + + 8 + + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 5.200000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + RAS @@ -570,6 +581,54 @@ + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 125.000000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + Meters + + + @@ -597,6 +656,258 @@ + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + A3 + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + Tmp1 + + + + + + + + 0 + 0 + + + + + 8 + + + + 30 + + + + + + + + 0 + 0 + + + + + 8 + + + + 65535 + + + 50 + + + + + + + + 0 + 0 + + + + + 8 + + + + RSSI + + + + + + + + 0 + 0 + + + + + 8 + + + + °C + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + VSpd + + + + + + + + 0 + 0 + + + + + 8 + + + + -16777215 + + + 16777215 + + + 26 + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + 2147483647 + + + 5000 + + + + + + + + 0 + 0 + + + + + 8 + + + + V / ratio + + + @@ -652,10 +963,10 @@ - - + + - + 0 0 @@ -666,12 +977,39 @@ - V / ratio + Fuel Qty - - + + + + + 0 + 0 + + + + + 8 + + + + -16777215 + + + 16777215 + + + 1 + + + 25 + + + + + 0 @@ -687,12 +1025,12 @@ <html><head/><body><p><br/></p></body></html> - Tmp1 + Alt - - + + 0 @@ -705,118 +1043,122 @@ - A3 + RxBt - - + + + + + 0 + 0 + + + + + 8 + + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 5.150000000000000 + + + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + 999.000000000000000 + + + 0.100000000000000 + + + 5.000000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + 999.000000000000000 + + + 0.100000000000000 + + + + + + + 0 0 - - - 45 - 0 - - - - - 45 - 16777215 - - 8 + + m/s + - - + + 0 0 - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - 8 - A4 - - - - - - - - 0 - 0 - - - - - 8 - - - - RSSI - - - - - - - - 0 - 0 - - - - - 8 - - - - <html><head/><body><p><br/></p></body></html> - - - Tmp2 + RPM @@ -847,8 +1189,8 @@ - - + + 0 @@ -860,13 +1202,34 @@ 8 + + <html><head/><body><p><br/></p></body></html> + - RPM + Tmp2 - - + + + + + 0 + 0 + + + + + 8 + + + + 75 + + + + + 0 @@ -892,222 +1255,6 @@ - - - - - 0 - 0 - - - - - 8 - - - - 100000 - - - 25 - - - - - - - - 0 - 0 - - - - - 8 - - - - Fuel - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - °C - - - - - - - - 0 - 0 - - - - - 8 - - - - 2147483647 - - - 5000 - - - - - - - - 0 - 0 - - - - - 8 - - - - ml - - - - - - - - 0 - 0 - - - - - 8 - - - - °C - - - - - - - - 0 - 0 - - - - - 8 - - - - 65535 - - - 50 - - - - - - - - 0 - 0 - - - - - 8 - - - - RPM - - - - - - - - 0 - 0 - - - - - 8 - - - - % - - - - - - - - 0 - 0 - - - - - 8 - - - - Meters - - - @@ -1135,10 +1282,10 @@ - - + + - + 0 0 @@ -1148,25 +1295,13 @@ 8 - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - 6.000000000000000 + + % - - + + 0 @@ -1178,16 +1313,13 @@ 8 - - <html><head/><body><p><br/></p></body></html> - - Alt + A2 - - + + 0 @@ -1213,62 +1345,8 @@ - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - 125.000000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - -16777215 - - - 16777215 - - - 26 - - - - - + + 0 @@ -1294,64 +1372,7 @@ - - - - - 0 - 0 - - - - - 8 - - - - <html><head/><body><p><br/></p></body></html> - - - VSpd - - - - - - - - 0 - 0 - - - - - 8 - - - - m/s - - - - - - - - 0 - 0 - - - - - 8 - - - - Fuel Qty - - - - + Qt::Vertical @@ -1364,51 +1385,51 @@ - - + + - + 0 0 + + + 45 + 0 + + + + + 45 + 16777215 + + 8 - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 5.150000000000000 - - - - - - 0 - 0 - + + + + Run - - - 8 - + + + + + + GPS sim - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 5.200000000000000 + + + + + + Run/Stop @@ -1614,13 +1635,13 @@ hh:mm:ss 1 - -214748364.000000000000000 + 0.000000000000000 - 214748364.000000000000000 + 5000.000000000000000 - 0.100000000000000 + 1.000000000000000 40.000000000000000 @@ -2133,7 +2154,7 @@ hh:mm:ss - 25.99,-97.19 + 25.9973,-97.1572 @@ -2585,16 +2606,16 @@ hh:mm:ss 2 - -21474836.000000000000000 + 0.000000000000000 - 21474836.000000000000000 + 361.000000000000000 - 0.100000000000000 + 1.000000000000000 - 180.000000000000000 + 340.000000000000000