From 8aa7fddb22cd6ab4d533082598be04649bb1ff21 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 10:22:47 +0300 Subject: [PATCH] Add read/write support for OSTC 3 SetPoint settings Implements support for reading, writing and backup/restore of set point settings for the OSTC 3. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 68 +++ configuredivecomputerthreads.cpp | 73 +++ qt-ui/configuredivecomputerdialog.cpp | 42 ++ qt-ui/configuredivecomputerdialog.ui | 812 +++++++++++++++----------- 4 files changed, 651 insertions(+), 344 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 7b86d5bb0..657f6fd10 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -135,6 +135,34 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai xml += addSettingToXML("Dil4", dil4); xml += addSettingToXML("Dil5", dil5); // + //Add set point values + QString sp1 = QString("%1,%2") + .arg(QString::number(details->sp1().sp), + QString::number(details->sp1().depth) + ); + QString sp2 = QString("%1,%2") + .arg(QString::number(details->sp2().sp), + QString::number(details->sp2().depth) + ); + QString sp3 = QString("%1,%2") + .arg(QString::number(details->sp3().sp), + QString::number(details->sp3().depth) + ); + QString sp4 = QString("%1,%2") + .arg(QString::number(details->sp4().sp), + QString::number(details->sp4().depth) + ); + QString sp5 = QString("%1,%2") + .arg(QString::number(details->sp5().sp), + QString::number(details->sp5().depth) + ); + xml += addSettingToXML("SetPoint1", sp1); + xml += addSettingToXML("SetPoint2", sp2); + xml += addSettingToXML("SetPoint3", sp3); + xml += addSettingToXML("SetPoint4", sp4); + xml += addSettingToXML("SetPoint5", sp5); + + //Other Settings xml += addSettingToXML("DiveMode", details->diveMode()); xml += addSettingToXML("Saturation", details->saturation()); xml += addSettingToXML("Desaturation", details->desaturation()); @@ -303,6 +331,46 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de details->setDil5(dil5); } + if (settingName == "SetPoint1") { + QStringList spData = keyString.split(","); + setpoint sp1; + sp1.sp = spData.at(0).toInt(); + sp1.depth = spData.at(1).toInt(); + details->setSp1(sp1); + } + + if (settingName == "SetPoint2") { + QStringList spData = keyString.split(","); + setpoint sp2; + sp2.sp = spData.at(0).toInt(); + sp2.depth = spData.at(1).toInt(); + details->setSp2(sp2); + } + + if (settingName == "SetPoint3") { + QStringList spData = keyString.split(","); + setpoint sp3; + sp3.sp = spData.at(0).toInt(); + sp3.depth = spData.at(1).toInt(); + details->setSp3(sp3); + } + + if (settingName == "SetPoint4") { + QStringList spData = keyString.split(","); + setpoint sp4; + sp4.sp = spData.at(0).toInt(); + sp4.depth = spData.at(1).toInt(); + details->setSp4(sp4); + } + + if (settingName == "SetPoint5") { + QStringList spData = keyString.split(","); + setpoint sp5; + sp5.sp = spData.at(0).toInt(); + sp5.depth = spData.at(1).toInt(); + details->setSp5(sp5); + } + if (settingName == "Saturation") details->setSaturation(keyString.toInt()); diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index c20d58a0b..66506affd 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -152,6 +152,52 @@ void ReadSettingsThread::run() m_deviceDetails->setDil4(dil4); m_deviceDetails->setDil5(dil5); + //Read set point Values + setpoint sp1; + setpoint sp2; + setpoint sp3; + setpoint sp4; + setpoint sp5; + + unsigned char spData[2] = {0,0}; + + //Sp 1 + rc = hw_ostc3_device_config_read(m_data->device, 0x1A, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp1.sp = dilData[0]; + sp1.depth = dilData[1]; + } + //Sp 2 + rc = hw_ostc3_device_config_read(m_data->device, 0x1B, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp2.sp = dilData[0]; + sp2.depth = dilData[1]; + } + //Sp 3 + rc = hw_ostc3_device_config_read(m_data->device, 0x1C, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp3.sp = dilData[0]; + sp3.depth = dilData[1]; + } + //Sp 4 + rc = hw_ostc3_device_config_read(m_data->device, 0x1D, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp4.sp = dilData[0]; + sp4.depth = dilData[1]; + } + //Sp 5 + rc = hw_ostc3_device_config_read(m_data->device, 0x1E, spData, sizeof(spData)); + if (rc == DC_STATUS_SUCCESS) { + //Data read successful + sp5.sp = dilData[0]; + sp5.depth = dilData[1]; + } + + //Read other settings unsigned char uData[1] = {0}; //DiveMode @@ -280,6 +326,33 @@ void WriteSettingsThread::run() //gas 5 hw_ostc3_device_config_write(m_data->device, 0x14, gas5Data, sizeof(gas5Data)); + //write set point values + unsigned char sp1Data[2] = {m_deviceDetails->sp1().sp, + m_deviceDetails->sp1().depth}; + + unsigned char sp2Data[2] = {m_deviceDetails->sp2().sp, + m_deviceDetails->sp2().depth}; + + unsigned char sp3Data[2] = {m_deviceDetails->sp3().sp, + m_deviceDetails->sp3().depth}; + + unsigned char sp4Data[2] = {m_deviceDetails->sp4().sp, + m_deviceDetails->sp4().depth}; + + unsigned char sp5Data[2] = {m_deviceDetails->sp5().sp, + m_deviceDetails->sp5().depth}; + + //sp 1 + hw_ostc3_device_config_write(m_data->device, 0x1A, sp1Data, sizeof(sp1Data)); + //sp 2 + hw_ostc3_device_config_write(m_data->device, 0x1B, sp2Data, sizeof(sp2Data)); + //sp 3 + hw_ostc3_device_config_write(m_data->device, 0x1C, sp3Data, sizeof(sp3Data)); + //sp 4 + hw_ostc3_device_config_write(m_data->device, 0x1D, sp4Data, sizeof(sp4Data)); + //sp 5 + hw_ostc3_device_config_write(m_data->device, 0x1E, sp5Data, sizeof(sp5Data)); + //write dil values unsigned char dil1Data[4] = {m_deviceDetails->dil1().oxygen, m_deviceDetails->dil1().helium, diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index f878ec11a..81d8f0326 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -205,6 +205,28 @@ void ConfigureDiveComputerDialog::populateDeviceDetails() deviceDetails->setDil3(dil3); deviceDetails->setDil4(dil4); deviceDetails->setDil5(dil5); + + //set set point details + setpoint sp1; + setpoint sp2; + setpoint sp3; + setpoint sp4; + setpoint sp5; + + sp1.sp = ui->ostc3SetPointTable->item(0, 1)->text().toInt(); + sp1.depth = ui->ostc3SetPointTable->item(0, 2)->text().toInt(); + + sp2.sp = ui->ostc3SetPointTable->item(1, 1)->text().toInt(); + sp2.depth = ui->ostc3SetPointTable->item(1, 2)->text().toInt(); + + sp3.sp = ui->ostc3SetPointTable->item(2, 1)->text().toInt(); + sp3.depth = ui->ostc3SetPointTable->item(2, 2)->text().toInt(); + + sp4.sp = ui->ostc3SetPointTable->item(3, 1)->text().toInt(); + sp4.depth = ui->ostc3SetPointTable->item(3, 2)->text().toInt(); + + sp5.sp = ui->ostc3SetPointTable->item(4, 1)->text().toInt(); + sp5.depth = ui->ostc3SetPointTable->item(4, 2)->text().toInt(); } void ConfigureDiveComputerDialog::readSettings() @@ -338,6 +360,26 @@ void ConfigureDiveComputerDialog::reloadValues() ui->ostc3DilTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->dil5().helium))); ui->ostc3DilTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->dil5().type))); ui->ostc3DilTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->dil5().depth))); + + //load set point 1 values + ui->ostc3SetPointTable->setItem(0, 1, new QTableWidgetItem(QString::number(deviceDetails->sp1().sp))); + ui->ostc3SetPointTable->setItem(0, 2, new QTableWidgetItem(QString::number(deviceDetails->sp1().depth))); + + //load set point 2 values + ui->ostc3SetPointTable->setItem(1, 1, new QTableWidgetItem(QString::number(deviceDetails->sp2().sp))); + ui->ostc3SetPointTable->setItem(1, 2, new QTableWidgetItem(QString::number(deviceDetails->sp2().depth))); + + //load set point 3 values + ui->ostc3SetPointTable->setItem(2, 1, new QTableWidgetItem(QString::number(deviceDetails->sp3().sp))); + ui->ostc3SetPointTable->setItem(2, 2, new QTableWidgetItem(QString::number(deviceDetails->sp3().depth))); + + //load set point 4 values + ui->ostc3SetPointTable->setItem(3, 1, new QTableWidgetItem(QString::number(deviceDetails->sp4().sp))); + ui->ostc3SetPointTable->setItem(3, 2, new QTableWidgetItem(QString::number(deviceDetails->sp4().depth))); + + //load set point 5 values + ui->ostc3SetPointTable->setItem(4, 1, new QTableWidgetItem(QString::number(deviceDetails->sp5().sp))); + ui->ostc3SetPointTable->setItem(4, 2, new QTableWidgetItem(QString::number(deviceDetails->sp5().depth))); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 0f99e597a..4274a3abe 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 699 - 618 + 787 + 672 @@ -21,6 +21,9 @@ Device or Mount Point + + device + @@ -98,31 +101,27 @@ HW OSTC 3 - - + + + + + m/°C + + + + + ft/°F + + + + + + - Serial No. + Salinity (0-5%): - - - - - - true - - - - - - - Firmware Version: - - - - - - - true + + salinitySpinBox @@ -131,22 +130,75 @@ Custom Text: - - - - - - - 1 - 0 - + + customTextLlineEdit - - + + + + % + + + + + + + % + + + + + + + % + + + 5 + + + + + + + m + + + + + - Language: + Last Deco: + + + lastDecoSpinBox + + + + + + + + Eco + + + + + Medium + + + + + High + + + + + + + + true @@ -174,225 +226,23 @@ - - + + - Dive Mode: + Language: + + + languageComboBox - - - - - OC - - - - - CC - - - - - Gauge - - - - - Apnea - - - - - - - - Saturation: - - - - - - - % - - - - - - - Desaturation: - - - - - - - % - - - - - - - Last Deco: - - - - - - - m - - - - - - - Brightness: - - - - - - - - Eco - - - - - Medium - - - - - High - - - - - - - - Date Format: - - - - - - - - MMDDYY - - - - - DDMMYY - - - - - YYMMDD - - - - - - - - Units: - - - - - - - - m/°C - - - - - ft/°F - - - - - - - - Sampling Rate: - - - - - - - - 2s - - - - - 10s - - - - - - - - Salinity (0-5%): - - - - - - - % - - - 5 - - - - - - - Dive Mode Colour: - - - - - - - - Standard - - - - - Red - - - - - Green - - - - - Blue - - - - - - - - Compass Gain: + + + + + 1 + 0 + @@ -446,87 +296,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %O2 - - - - - %He - - - - - Type - - - - - Change Depth - - - - - Gas 1 - - - - - Gas 2 - - - - - Gas 3 - - - - - Gas 4 - - - - - Gas 5 - - + + + + Compass Gain: + + + compassGainComboBox + + + + + + + Dive Mode: + + + diveModeComboBox + + + + 0 + 2 + + @@ -604,25 +401,350 @@ - + + + + Units: + + + unitsComboBox + + + + + + + Desaturation: + + + desaturationSpinBox + + + + + + + + OC + + + + + CC + + + + + Gauge + + + + + Apnea + + + + + + + + Serial No. + + + serialNoLineEdit + + + + + + + Brightness: + + + brightnessComboBox + + + + + + + Saturation: + + + saturationSpinBox + + + + + + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %O2 + + + + + %He + + + + + Type + + + + + Change Depth + + + + + Gas 1 + + + + + Gas 2 + + + + + Gas 3 + + + + + Gas 4 + + + + + Gas 5 + + + + + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + + + + + + + true + + + + + + + Firmware Version: + + + firmwareVersionLineEdit + + + + + + + Date Format: + + + dateFormatComboBox + + + + + + + + Standard + + + + + Red + + + + + Green + + + + + Blue + + + + + + + + Sampling Rate: + + + samplingRateComboBox + + + + Sync dive computer time with PC - - - - Qt::Vertical + + + + + 2s + + + + + 10s + + + + + + + + Dive Mode Colour: - - - 20 - 40 - + + diveModeColour - + + + + + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Set Point [cbar] + + + + + Change Depth [m] + + + + + SP 1 + + + + + SP 2 + + + + + SP 3 + + + + + SP 4 + + + + + SP 5 + + + @@ -684,17 +806,19 @@ customTextLlineEdit languageComboBox diveModeComboBox + dateFormatComboBox saturationSpinBox desaturationSpinBox lastDecoSpinBox brightnessComboBox - dateFormatComboBox - unitsComboBox samplingRateComboBox - salinitySpinBox + unitsComboBox diveModeColour - compassGainComboBox + salinitySpinBox dateTimeSyncCheckBox + compassGainComboBox + ostc3GasTable + ostc3DilTable cancel