diff --git a/companion/src/simulation/telemetrysimu.cpp b/companion/src/simulation/telemetrysimu.cpp index 6fc9f04c4..6c901c8dc 100644 --- a/companion/src/simulation/telemetrysimu.cpp +++ b/companion/src/simulation/telemetrysimu.cpp @@ -28,6 +28,8 @@ #include #include +#include // + TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * simulator): QWidget(parent), ui(new Ui::TelemetrySimulator), @@ -1089,3 +1091,235 @@ void TelemetrySimulator::LogPlaybackController::setUiDataValues() } } } + +void TelemetrySimulator::on_saveTelemetryvalues_clicked() +{ + QString fldr = g.backupDir().trimmed(); + if (fldr.isEmpty()) + fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + + QString idFileNameAndPath = QFileDialog::getSaveFileName(this, tr("Save Telemetry"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)")); + if (idFileNameAndPath.isEmpty()) + return; + + QFile file(idFileNameAndPath); + if (!file.open(QIODevice::WriteOnly)){ + QMessageBox::critical(this, CPN_STR_APP_NAME, tr("Unable to open file for writing.\n%1").arg(file.errorString())); + return; + } + QTextStream out(&file); + + out<< ui -> rxbt -> text(); + out<<"\r\n"; + out<< ui -> Rssi -> text(); + out<<"\r\n"; + out<< ui -> Swr -> text(); + out<<"\r\n"; + out << ui -> A1 -> text(); + out<<"\r\n"; + out<< ui -> A2 -> text(); + out<<"\r\n"; + out<< ui -> A3 -> text(); + out<<"\r\n"; + out << ui -> A4 -> text(); + out<<"\r\n"; + out << ui -> T1 -> text(); + out<<"\r\n"; + out << ui -> T2 -> text(); + out<<"\r\n"; + out << ui -> rpm -> text(); + out<<"\r\n"; + out << ui -> fuel -> text(); + out<<"\r\n"; + out << ui -> fuel_qty -> text(); + out<<"\r\n"; + out << ui -> vspeed -> text(); + out<<"\r\n"; + out << ui -> valt -> text(); + out<<"\r\n"; + out << ui -> vfas -> text(); + out<<"\r\n"; + out << ui -> curr -> text(); + out<<"\r\n"; + out << ui -> cell1 -> text(); + out<<"\r\n"; + out << ui -> cell2 -> text(); + out<<"\r\n"; + out << ui -> cell3 -> text(); + out<<"\r\n"; + out << ui -> cell4 -> text(); + out<<"\r\n"; + out << ui -> cell5 -> text(); + out<<"\r\n"; + out << ui -> cell6 -> text(); + out<<"\r\n"; + out << ui -> aspeed -> text(); + out<<"\r\n"; + out << ui -> gps_alt -> text(); + out<<"\r\n"; + out << ui -> gps_speed -> text(); + out<<"\r\n"; + out << ui -> gps_course -> text(); + out<<"\r\n"; + out << ui -> gps_time -> text(); + out<<"\r\n"; + out << ui -> gps_latlon -> text(); + out<<"\r\n"; + out << ui -> accx -> text(); + out<<"\r\n"; + out << ui -> accy -> text(); + out<<"\r\n"; + out << ui -> accz -> text(); + out<<"\r\n"; + file.flush(); + + file.close(); + +} + + +void TelemetrySimulator::on_loadTelemetryvalues_clicked() +{ + QString fldr = g.backupDir().trimmed(); + if (fldr.isEmpty()) + fldr = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + + QString idFileNameAndPath = QFileDialog::getOpenFileName(this, tr("Open Telemetry File"), fldr % "/telemetry.txt", tr(".txt Files (*.txt)")); + if (idFileNameAndPath.isEmpty()) + return; + + QFile file(idFileNameAndPath); + + if (!file.open(QIODevice::ReadOnly)){ + QMessageBox::critical(this, CPN_STR_APP_NAME, tr("Unable to open file for reading.\n%1").arg(file.errorString())); + return; + } + + QTextStream in(&file); + + QString n = in.readLine(); + double ns = n.toDouble(); + ui -> rxbt -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> Rssi -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> Swr -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> A1 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> A2 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> A3 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> A4 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> T1 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> T2 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> rpm -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> fuel -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> fuel_qty -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> vspeed -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> valt -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> vfas -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> curr -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell1 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell2 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell3 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell4 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell5 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> cell6 -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> aspeed -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> gps_alt -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> gps_speed -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> gps_course -> setValue(ns); + + n = in.readLine(); + ui -> gps_time -> setText(n); + + n = in.readLine(); + ui -> gps_latlon -> setText(n); + + n = in.readLine(); + ns = n.toDouble(); + ui -> accx -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> accy -> setValue(ns); + + n = in.readLine(); + ns = n.toDouble(); + ui -> accz -> setValue(ns); + + file.close(); + +} + diff --git a/companion/src/simulation/telemetrysimu.h b/companion/src/simulation/telemetrysimu.h index c317e2fb5..a4c33bd62 100644 --- a/companion/src/simulation/telemetrysimu.h +++ b/companion/src/simulation/telemetrysimu.h @@ -207,6 +207,9 @@ class TelemetrySimulator : public QWidget uint32_t encodeLatLon(double latLon, bool isLat); uint32_t encodeDateTime(uint8_t yearOrHour, uint8_t monthOrMinute, uint8_t dayOrSecond, bool isDate); }; // GPSEmulator +private slots: + void on_saveTelemetryvalues_clicked(); + void on_loadTelemetryvalues_clicked(); }; // TelemetrySimulator #endif // _TELEMETRYSIMU_H_ diff --git a/companion/src/simulation/telemetrysimu.ui b/companion/src/simulation/telemetrysimu.ui index d7f9951e5..52c9ef868 100644 --- a/companion/src/simulation/telemetrysimu.ui +++ b/companion/src/simulation/telemetrysimu.ui @@ -158,6 +158,9 @@ 1 + + 25 + @@ -500,6 +503,9 @@ 0.100000000000000 + + 5.000000000000000 + @@ -615,6 +621,9 @@ 0.100000000000000 + + 5.100000000000000 + @@ -899,6 +908,9 @@ 100000 + + 25 + @@ -980,6 +992,9 @@ 2147483647 + + 5000 + @@ -1034,6 +1049,9 @@ 65535 + + 50 + @@ -1142,6 +1160,9 @@ 0.100000000000000 + + 6.000000000000000 + @@ -1217,6 +1238,9 @@ 0.100000000000000 + + 125.000000000000000 + @@ -1238,6 +1262,9 @@ 16777215 + + 26 + @@ -1356,6 +1383,9 @@ 21474836.000000000000000 + + 5.150000000000000 + @@ -1377,6 +1407,9 @@ 21474836.000000000000000 + + 5.200000000000000 + @@ -1437,8 +1470,38 @@ 5 - - + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 + + + + + 0 @@ -1451,12 +1514,34 @@ - km/h + G - - + + + + + 0 + 0 + + + + + 8 + + + + dd-MM-yyyy +hh:mm:ss + + + false + + + + + 0 @@ -1468,31 +1553,25 @@ 8 - - - - - - - 0 - 0 - + + 2 - - - 8 - + + -21474836.000000000000000 - - <html><head/><body><p><br/></p></body></html> + + 21474836.000000000000000 - - VFAS + + 0.100000000000000 + + + -0.100000000000000 - - + + 0 @@ -1518,6 +1597,66 @@ + + + + + 0 + 0 + + + + + 8 + + + + 1 + + + -214748364.000000000000000 + + + 214748364.000000000000000 + + + 0.100000000000000 + + + 40.000000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 1125.000000000000000 + + + @@ -1539,35 +1678,21 @@ - - - - - 0 - 0 - + + + + Qt::Vertical - + - 45 - 0 + 20 + 40 - - - 45 - 16777215 - - - - - 8 - - - + - - + + 0 @@ -1583,14 +1708,14 @@ <html><head/><body><p><br/></p></body></html> - ASpd + VFAS - - + + - + 0 0 @@ -1600,13 +1725,16 @@ 8 + + <html><head/><body><p><br/></p></body></html> + - G + GPS - - + + 0 @@ -1659,26 +1787,8 @@ - - - - - 0 - 0 - - - - - 8 - - - - km/h - - - - - + + 0 @@ -1694,7 +1804,64 @@ <html><head/><body><p><br/></p></body></html> - GPS + GAlt + + + + + + + + 0 + 0 + + + + + 8 + + + + Meters + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + GSpd + + + + + + + + 0 + 0 + + + + + 8 + + + + AccZ @@ -1725,230 +1892,6 @@ - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - Lat,Lon -(dec.deg.) - - - false - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - AccX - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - dd-MM-yyyy -hh:mm:ss - - - false - - - @@ -1976,71 +1919,8 @@ hh:mm:ss - - - - - 0 - 0 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 45 - 0 - - - - - 45 - 16777215 - - - - - 8 - - - - - - - - - 0 - 0 - - - - - 8 - - - - <html><head/><body><p><br/></p></body></html> - - - Date - - - - - + + 0 @@ -2053,118 +1933,21 @@ hh:mm:ss - Amps + Volts - - - - - 0 - 0 - - - - - 8 - - + + - G + Load Telemetry Values - - - - - 0 - 0 - - - - - 8 - - + + - AccZ - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - <html><head/><body><p><br/></p></body></html> - - - GAlt - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 + Save Telemetry Values @@ -2195,35 +1978,8 @@ hh:mm:ss - - - - - 0 - 0 - - - - - 8 - - - - 1 - - - -214748364.000000000000000 - - - 214748364.000000000000000 - - - 0.100000000000000 - - - - - + + 0 @@ -2236,14 +1992,41 @@ hh:mm:ss - Volts + km/h - - + + - + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + 0 0 @@ -2253,140 +2036,28 @@ hh:mm:ss 8 - - <html><head/><body><p><br/></p></body></html> - - Cels + Amps - - - - - - - 0 - 0 - - - - - 8 - - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 8.190000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 8.190000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 8.190000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 8.190000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - 8.190000000000000 - - - 0.100000000000000 - - - - + + + + + 0 + 0 + + + + + 8 + + + + km/h + + @@ -2409,6 +2080,244 @@ hh:mm:ss + + + + + 0 + 0 + + + + + 8 + + + + Volts + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + ASpd + + + + + + + + 0 + 0 + + + + + 8 + + + + 25.99,-97.19 + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + Lat,Lon +(dec.deg.) + + + false + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + + + + + + + + + 0 + 0 + + + + + 8 + + + + G + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + Date + + + + + + + + 0 + 0 + + + + + 8 + + + + AccY + + + + + + + + 0 + 0 + + + + + 8 + + + + * + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 23.699999999999999 + + + @@ -2436,10 +2345,10 @@ hh:mm:ss - - + + - + 0 0 @@ -2449,13 +2358,55 @@ hh:mm:ss 8 - - Volts + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 0.200000000000000 - - + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 35.000000000000000 + + + + + 0 @@ -2468,12 +2419,208 @@ hh:mm:ss - AccY + AccX - - + + + + + + + 0 + 0 + + + + + 8 + + + + 0.100000000000000 + + + 3.700000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 8.190000000000000 + + + 0.100000000000000 + + + 3.800000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 8.190000000000000 + + + 0.100000000000000 + + + 3.900000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 8.190000000000000 + + + 0.100000000000000 + + + 4.000000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 8.190000000000000 + + + 0.100000000000000 + + + 4.100000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + 8.190000000000000 + + + 0.100000000000000 + + + 4.200000000000000 + + + + + + + + + + 0 + 0 + + + + + 8 + + + + 2 + + + -21474836.000000000000000 + + + 21474836.000000000000000 + + + 0.100000000000000 + + + 180.000000000000000 + + + + + + + + 0 + 0 + + + + + 8 + + + + <html><head/><body><p><br/></p></body></html> + + + Cels + + + + + 0 @@ -2486,7 +2633,82 @@ hh:mm:ss - Meters + Degrees + + + + + + + + 0 + 0 + + + + + 8 + + + + G + + + + + + + + 0 + 0 + + + + + 8 + + + + 1 + + + -214748364.000000000000000 + + + 214748364.000000000000000 + + + 0.100000000000000 + + + 0.100000000000000 + + + + + + + + 0 + 0 + + + + + 45 + 0 + + + + + 45 + 16777215 + + + + + 8 + @@ -2517,129 +2739,12 @@ hh:mm:ss - - - - - 0 - 0 - - - - - 8 - - - - 1 - - - -214748364.000000000000000 - - - 214748364.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - <html><head/><body><p><br/></p></body></html> - - - GSpd - - - - - - - - 0 - 0 - - - - - 8 - - - - Degrees - - - - - - - - 0 - 0 - - - - - 8 - - - - 2 - - - -21474836.000000000000000 - - - 21474836.000000000000000 - - - 0.100000000000000 - - - - - - - - 0 - 0 - - - - - 8 - - - - G - - - - - + + - Qt::Vertical + Qt::Horizontal - - - 20 - 40 - - - +