mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Add reading and writing of OSTC 3 Dil values
Implements reading, writing and backup/restore of OSTC 3 Dil Values (setting 0x15 to 0x19) Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com> Signed-off-by: Thiago Macieira <thiago@macieira.org>
This commit is contained in:
parent
65b0b8a64b
commit
9c032f20c0
4 changed files with 264 additions and 14 deletions
|
@ -98,6 +98,43 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai
|
|||
xml += addSettingToXML("Gas4", gas4);
|
||||
xml += addSettingToXML("Gas5", gas5);
|
||||
//
|
||||
//Add dil values
|
||||
QString dil1 = QString("%1,%2,%3,%4")
|
||||
.arg(QString::number(details->dil1().oxygen),
|
||||
QString::number(details->dil1().helium),
|
||||
QString::number(details->dil1().type),
|
||||
QString::number(details->dil1().depth)
|
||||
);
|
||||
QString dil2 = QString("%1,%2,%3,%4")
|
||||
.arg(QString::number(details->dil2().oxygen),
|
||||
QString::number(details->dil2().helium),
|
||||
QString::number(details->dil2().type),
|
||||
QString::number(details->dil2().depth)
|
||||
);
|
||||
QString dil3 = QString("%1,%2,%3,%4")
|
||||
.arg(QString::number(details->dil3().oxygen),
|
||||
QString::number(details->dil3().helium),
|
||||
QString::number(details->dil3().type),
|
||||
QString::number(details->dil3().depth)
|
||||
);
|
||||
QString dil4 = QString("%1,%2,%3,%4")
|
||||
.arg(QString::number(details->dil4().oxygen),
|
||||
QString::number(details->dil4().helium),
|
||||
QString::number(details->dil4().type),
|
||||
QString::number(details->dil4().depth)
|
||||
);
|
||||
QString dil5 = QString("%1,%2,%3,%4")
|
||||
.arg(QString::number(details->dil5().oxygen),
|
||||
QString::number(details->dil5().helium),
|
||||
QString::number(details->dil5().type),
|
||||
QString::number(details->dil5().depth)
|
||||
);
|
||||
xml += addSettingToXML("Dil1", dil1);
|
||||
xml += addSettingToXML("Dil2", dil2);
|
||||
xml += addSettingToXML("Dil3", dil3);
|
||||
xml += addSettingToXML("Dil4", dil4);
|
||||
xml += addSettingToXML("Dil5", dil5);
|
||||
//
|
||||
xml += addSettingToXML("DiveMode", details->diveMode());
|
||||
xml += addSettingToXML("Saturation", details->saturation());
|
||||
xml += addSettingToXML("Desaturation", details->desaturation());
|
||||
|
@ -216,6 +253,56 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de
|
|||
details->setGas5(gas5);
|
||||
}
|
||||
|
||||
if (settingName == "Dil1") {
|
||||
QStringList dilData = keyString.split(",");
|
||||
gas dil1;
|
||||
dil1.oxygen = dilData.at(0).toInt();
|
||||
dil1.helium = dilData.at(1).toInt();
|
||||
dil1.type = dilData.at(2).toInt();
|
||||
dil1.depth = dilData.at(3).toInt();
|
||||
details->setDil1(dil1);
|
||||
}
|
||||
|
||||
if (settingName == "Dil2") {
|
||||
QStringList dilData = keyString.split(",");
|
||||
gas dil2;
|
||||
dil2.oxygen = dilData.at(0).toInt();
|
||||
dil2.helium = dilData.at(1).toInt();
|
||||
dil2.type = dilData.at(2).toInt();
|
||||
dil2.depth = dilData.at(3).toInt();
|
||||
details->setDil1(dil2);
|
||||
}
|
||||
|
||||
if (settingName == "Dil3") {
|
||||
QStringList dilData = keyString.split(",");
|
||||
gas dil3;
|
||||
dil3.oxygen = dilData.at(0).toInt();
|
||||
dil3.helium = dilData.at(1).toInt();
|
||||
dil3.type = dilData.at(2).toInt();
|
||||
dil3.depth = dilData.at(3).toInt();
|
||||
details->setDil3(dil3);
|
||||
}
|
||||
|
||||
if (settingName == "Dil4") {
|
||||
QStringList dilData = keyString.split(",");
|
||||
gas dil4;
|
||||
dil4.oxygen = dilData.at(0).toInt();
|
||||
dil4.helium = dilData.at(1).toInt();
|
||||
dil4.type = dilData.at(2).toInt();
|
||||
dil4.depth = dilData.at(3).toInt();
|
||||
details->setDil4(dil4);
|
||||
}
|
||||
|
||||
if (settingName == "Dil5") {
|
||||
QStringList dilData = keyString.split(",");
|
||||
gas dil5;
|
||||
dil5.oxygen = dilData.at(0).toInt();
|
||||
dil5.helium = dilData.at(1).toInt();
|
||||
dil5.type = dilData.at(2).toInt();
|
||||
dil5.depth = dilData.at(3).toInt();
|
||||
details->setDil5(dil5);
|
||||
}
|
||||
|
||||
if (settingName == "Saturation")
|
||||
details->setSaturation(keyString.toInt());
|
||||
|
||||
|
|
|
@ -93,6 +93,65 @@ void ReadSettingsThread::run()
|
|||
m_deviceDetails->setGas4(gas4);
|
||||
m_deviceDetails->setGas5(gas5);
|
||||
|
||||
//Read Dil Values
|
||||
gas dil1;
|
||||
gas dil2;
|
||||
gas dil3;
|
||||
gas dil4;
|
||||
gas dil5;
|
||||
//Dil 1
|
||||
unsigned char dilData[4] = {0,0,0,0};
|
||||
rc = hw_ostc3_device_config_read(m_data->device, 0x15, dilData, sizeof(dilData));
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
//Data read successful
|
||||
dil1.depth = dilData[3];
|
||||
dil1.oxygen = dilData[0];
|
||||
dil1.helium = dilData[1];
|
||||
dil1.type = dilData[2];
|
||||
}
|
||||
//Dil 2
|
||||
rc = hw_ostc3_device_config_read(m_data->device, 0x16, dilData, sizeof(dilData));
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
//Data read successful
|
||||
dil2.depth = dilData[3];
|
||||
dil2.oxygen = dilData[0];
|
||||
dil2.helium = dilData[1];
|
||||
dil2.type = dilData[2];
|
||||
}
|
||||
//Dil 3
|
||||
rc = hw_ostc3_device_config_read(m_data->device, 0x17, dilData, sizeof(dilData));
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
//Data read successful
|
||||
dil3.depth = dilData[3];
|
||||
dil3.oxygen = dilData[0];
|
||||
dil3.helium = dilData[1];
|
||||
dil3.type = dilData[2];
|
||||
}
|
||||
//Dil 4
|
||||
rc = hw_ostc3_device_config_read(m_data->device, 0x18, dilData, sizeof(dilData));
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
//Data read successful
|
||||
dil4.depth = dilData[3];
|
||||
dil4.oxygen = dilData[0];
|
||||
dil4.helium = dilData[1];
|
||||
dil4.type = dilData[2];
|
||||
}
|
||||
//Dil 5
|
||||
rc = hw_ostc3_device_config_read(m_data->device, 0x19, dilData, sizeof(dilData));
|
||||
if (rc == DC_STATUS_SUCCESS) {
|
||||
//Data read successful
|
||||
dil5.depth = dilData[3];
|
||||
dil5.oxygen = dilData[0];
|
||||
dil5.helium = dilData[1];
|
||||
dil5.type = dilData[2];
|
||||
}
|
||||
|
||||
m_deviceDetails->setDil1(dil1);
|
||||
m_deviceDetails->setDil2(dil2);
|
||||
m_deviceDetails->setDil3(dil3);
|
||||
m_deviceDetails->setDil4(dil4);
|
||||
m_deviceDetails->setDil5(dil5);
|
||||
|
||||
//Read other settings
|
||||
unsigned char uData[1] = {0};
|
||||
//DiveMode
|
||||
|
@ -221,6 +280,42 @@ void WriteSettingsThread::run()
|
|||
//gas 5
|
||||
hw_ostc3_device_config_write(m_data->device, 0x14, gas5Data, sizeof(gas5Data));
|
||||
|
||||
//write dil values
|
||||
unsigned char dil1Data[4] = {m_deviceDetails->dil1().oxygen,
|
||||
m_deviceDetails->dil1().helium,
|
||||
m_deviceDetails->dil1().type,
|
||||
m_deviceDetails->dil1().depth};
|
||||
|
||||
unsigned char dil2Data[4] = {m_deviceDetails->dil2().oxygen,
|
||||
m_deviceDetails->dil2().helium,
|
||||
m_deviceDetails->dil2().type,
|
||||
m_deviceDetails->dil2().depth};
|
||||
|
||||
unsigned char dil3Data[4] = {m_deviceDetails->dil3().oxygen,
|
||||
m_deviceDetails->dil3().helium,
|
||||
m_deviceDetails->dil3().type,
|
||||
m_deviceDetails->dil3().depth};
|
||||
|
||||
unsigned char dil4Data[4] = {m_deviceDetails->dil4().oxygen,
|
||||
m_deviceDetails->dil4().helium,
|
||||
m_deviceDetails->dil4().type,
|
||||
m_deviceDetails->dil4().depth};
|
||||
|
||||
unsigned char dil5Data[4] = {m_deviceDetails->dil5().oxygen,
|
||||
m_deviceDetails->dil5().helium,
|
||||
m_deviceDetails->dil5().type,
|
||||
m_deviceDetails->dil5().depth};
|
||||
//dil 1
|
||||
hw_ostc3_device_config_write(m_data->device, 0x15, dil1Data, sizeof(gas1Data));
|
||||
//dil 2
|
||||
hw_ostc3_device_config_write(m_data->device, 0x16, dil2Data, sizeof(dil2Data));
|
||||
//dil 3
|
||||
hw_ostc3_device_config_write(m_data->device, 0x17, dil3Data, sizeof(dil3Data));
|
||||
//dil 4
|
||||
hw_ostc3_device_config_write(m_data->device, 0x18, dil4Data, sizeof(dil4Data));
|
||||
//dil 5
|
||||
hw_ostc3_device_config_write(m_data->device, 0x19, dil5Data, sizeof(dil5Data));
|
||||
|
||||
|
||||
//write general settings
|
||||
//custom text
|
||||
|
|
|
@ -167,6 +167,44 @@ void ConfigureDiveComputerDialog::populateDeviceDetails()
|
|||
deviceDetails->setGas3(gas3);
|
||||
deviceDetails->setGas4(gas4);
|
||||
deviceDetails->setGas5(gas5);
|
||||
|
||||
//set dil values
|
||||
gas dil1;
|
||||
gas dil2;
|
||||
gas dil3;
|
||||
gas dil4;
|
||||
gas dil5;
|
||||
|
||||
dil1.oxygen = ui->ostc3DilTable->item(0, 1)->text().toInt();
|
||||
dil1.helium = ui->ostc3DilTable->item(0, 2)->text().toInt();
|
||||
dil1.type = ui->ostc3DilTable->item(0, 3)->text().toInt();
|
||||
dil1.depth = ui->ostc3DilTable->item(0, 4)->text().toInt();
|
||||
|
||||
dil2.oxygen = ui->ostc3DilTable->item(1, 1)->text().toInt();
|
||||
dil2.helium = ui->ostc3DilTable->item(1, 2)->text().toInt();
|
||||
dil2.type = ui->ostc3DilTable->item(1, 3)->text().toInt();
|
||||
dil2.depth = ui->ostc3DilTable->item(1, 4)->text().toInt();
|
||||
|
||||
dil3.oxygen = ui->ostc3DilTable->item(2, 1)->text().toInt();
|
||||
dil3.helium = ui->ostc3DilTable->item(2, 2)->text().toInt();
|
||||
dil3.type = ui->ostc3DilTable->item(2, 3)->text().toInt();
|
||||
dil3.depth = ui->ostc3DilTable->item(2, 4)->text().toInt();
|
||||
|
||||
dil4.oxygen = ui->ostc3DilTable->item(3, 1)->text().toInt();
|
||||
dil4.helium = ui->ostc3DilTable->item(3, 2)->text().toInt();
|
||||
dil4.type = ui->ostc3DilTable->item(3, 3)->text().toInt();
|
||||
dil4.depth = ui->ostc3DilTable->item(3, 4)->text().toInt();
|
||||
|
||||
dil5.oxygen = ui->ostc3DilTable->item(4, 1)->text().toInt();
|
||||
dil5.helium = ui->ostc3DilTable->item(4, 2)->text().toInt();
|
||||
dil5.type = ui->ostc3DilTable->item(4, 3)->text().toInt();
|
||||
dil5.depth = ui->ostc3DilTable->item(4, 4)->text().toInt();
|
||||
|
||||
deviceDetails->setDil1(dil1);
|
||||
deviceDetails->setDil2(dil2);
|
||||
deviceDetails->setDil3(dil3);
|
||||
deviceDetails->setDil4(dil4);
|
||||
deviceDetails->setDil5(dil5);
|
||||
}
|
||||
|
||||
void ConfigureDiveComputerDialog::readSettings()
|
||||
|
@ -270,6 +308,36 @@ void ConfigureDiveComputerDialog::reloadValues()
|
|||
ui->ostc3GasTable->setItem(4,2, new QTableWidgetItem(QString::number(deviceDetails->gas5().helium)));
|
||||
ui->ostc3GasTable->setItem(4,3, new QTableWidgetItem(QString::number(deviceDetails->gas5().type)));
|
||||
ui->ostc3GasTable->setItem(4,4, new QTableWidgetItem(QString::number(deviceDetails->gas5().depth)));
|
||||
|
||||
//load dil 1 values
|
||||
ui->ostc3DilTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->dil1().oxygen)));
|
||||
ui->ostc3DilTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->dil1().helium)));
|
||||
ui->ostc3DilTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->dil1().type)));
|
||||
ui->ostc3DilTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->dil1().depth)));
|
||||
|
||||
//load dil 2 values
|
||||
ui->ostc3DilTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->dil2().oxygen)));
|
||||
ui->ostc3DilTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->dil2().helium)));
|
||||
ui->ostc3DilTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->dil2().type)));
|
||||
ui->ostc3DilTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->dil2().depth)));
|
||||
|
||||
//load dil 3 values
|
||||
ui->ostc3DilTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->dil3().oxygen)));
|
||||
ui->ostc3DilTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->dil3().helium)));
|
||||
ui->ostc3DilTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->dil3().type)));
|
||||
ui->ostc3DilTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->dil3().depth)));
|
||||
|
||||
//load dil 4 values
|
||||
ui->ostc3DilTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->dil4().oxygen)));
|
||||
ui->ostc3DilTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->dil4().helium)));
|
||||
ui->ostc3DilTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->dil4().type)));
|
||||
ui->ostc3DilTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->dil4().depth)));
|
||||
|
||||
//load dil 5 values
|
||||
ui->ostc3DilTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->dil5().oxygen)));
|
||||
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)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>701</width>
|
||||
<height>620</height>
|
||||
<width>699</width>
|
||||
<height>618</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -475,12 +475,7 @@
|
|||
</row>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Gas No.</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>%He</string>
|
||||
<string/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
|
@ -488,6 +483,11 @@
|
|||
<string>%O2</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>%He</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
|
@ -554,7 +554,7 @@
|
|||
</row>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Gas No.</string>
|
||||
<string/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
|
@ -579,27 +579,27 @@
|
|||
</column>
|
||||
<item row="0" column="0">
|
||||
<property name="text">
|
||||
<string>Gas 1</string>
|
||||
<string>Dil 1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<property name="text">
|
||||
<string>Gas 2</string>
|
||||
<string>Dil 2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<property name="text">
|
||||
<string>Gas 3</string>
|
||||
<string>Dil 3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<property name="text">
|
||||
<string>Gas 4</string>
|
||||
<string>Dil 4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<property name="text">
|
||||
<string>Gas 5</string>
|
||||
<string>Dil 5</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
|
Loading…
Add table
Reference in a new issue