From ec02737eda780284562692168569d9dd3837a1a9 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 29 May 2014 18:54:19 +0300 Subject: [PATCH 01/33] Create Dive Computer configuration dialog Create a dialog for reading and writing settings to and from dive computers, with a menu entry in MainWindow to open the dialog. I will build up on this dialog and change it as needed. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 14 +++ qt-ui/configuredivecomputerdialog.h | 22 +++++ qt-ui/configuredivecomputerdialog.ui | 125 ++++++++++++++++++++++++++ qt-ui/mainwindow.cpp | 7 ++ qt-ui/mainwindow.h | 2 + qt-ui/mainwindow.ui | 7 ++ subsurface.pro | 9 +- 7 files changed, 183 insertions(+), 3 deletions(-) create mode 100644 qt-ui/configuredivecomputerdialog.cpp create mode 100644 qt-ui/configuredivecomputerdialog.h create mode 100644 qt-ui/configuredivecomputerdialog.ui diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp new file mode 100644 index 000000000..9aa2cfb94 --- /dev/null +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -0,0 +1,14 @@ +#include "configuredivecomputerdialog.h" +#include "ui_configuredivecomputerdialog.h" + +ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConfigureDiveComputerDialog) +{ + ui->setupUi(this); +} + +ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() +{ + delete ui; +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h new file mode 100644 index 000000000..b1f3924cf --- /dev/null +++ b/qt-ui/configuredivecomputerdialog.h @@ -0,0 +1,22 @@ +#ifndef CONFIGUREDIVECOMPUTERDIALOG_H +#define CONFIGUREDIVECOMPUTERDIALOG_H + +#include + +namespace Ui { +class ConfigureDiveComputerDialog; +} + +class ConfigureDiveComputerDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConfigureDiveComputerDialog(QWidget *parent = 0); + ~ConfigureDiveComputerDialog(); + +private: + Ui::ConfigureDiveComputerDialog *ui; +}; + +#endif // CONFIGUREDIVECOMPUTERDIALOG_H diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui new file mode 100644 index 000000000..25d63007f --- /dev/null +++ b/qt-ui/configuredivecomputerdialog.ui @@ -0,0 +1,125 @@ + + + ConfigureDiveComputerDialog + + + + 0 + 0 + 362 + 375 + + + + Configure Dive Computer + + + + + + + + Vendor + + + + + + + Dive Computer + + + + + + + + + + + + + + + + + Device or Mount Point + + + + + + + + + true + + + + + + + ... + + + + + + + + + + + + + Retrieve available details: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + + + + diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1a4594bab..85b31608c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -41,6 +41,7 @@ #include "worldmap-save.h" #include "updatemanager.h" #include "planner.h" +#include "configuredivecomputerdialog.h" #ifndef NO_PRINTING #include #include "printdialog.h" @@ -1287,6 +1288,12 @@ void MainWindow::on_actionExport_triggered() diveLogExport.exec(); } +void MainWindow::on_actionConfigure_Dive_Computer_triggered() +{ + ConfigureDiveComputerDialog *dcConfig = new ConfigureDiveComputerDialog(this); + dcConfig->show(); +} + void MainWindow::setEnabledToolbar(bool arg1) { QList toolBar; toolBar << ui.profCalcAllTissues << ui.profCalcCeiling diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 5c0ec8efa..b9c8e4682 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -143,6 +143,8 @@ slots: void on_profTogglePicture_clicked(bool triggered); void on_actionExport_triggered(); + void on_actionConfigure_Dive_Computer_triggered(); + protected: void closeEvent(QCloseEvent *); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index ac72673c8..bd5581f64 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -681,6 +681,8 @@ p, li { white-space: pre-wrap; } + + @@ -1023,6 +1025,11 @@ p, li { white-space: pre-wrap; } Ctrl+E + + + Configure Dive Computer + + diff --git a/subsurface.pro b/subsurface.pro index 1857f8405..ca3c8abdf 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -86,7 +86,8 @@ HEADERS = \ qt-ui/updatemanager.h \ qt-ui/divelogexportdialog.h \ qt-ui/usersurvey.h \ - subsurfacesysinfo.h + subsurfacesysinfo.h \ + qt-ui/configuredivecomputerdialog.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -165,7 +166,8 @@ SOURCES = \ qt-ui/updatemanager.cpp \ qt-ui/divelogexportdialog.cpp \ qt-ui/usersurvey.cpp \ - subsurfacesysinfo.cpp + subsurfacesysinfo.cpp \ + qt-ui/configuredivecomputerdialog.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c @@ -196,7 +198,8 @@ FORMS = \ qt-ui/searchbar.ui \ qt-ui/divelogexportdialog.ui \ qt-ui/plannerSettings.ui \ - qt-ui/usersurvey.ui + qt-ui/usersurvey.ui \ + qt-ui/configuredivecomputerdialog.ui # Nether usermanual or printing is supported on android right now android: FORMS -= qt-ui/printoptions.ui From 791fbee260b3b0884963b8ff0e2e2968ef130792 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 29 May 2014 19:16:34 +0300 Subject: [PATCH 02/33] Load vendor list and product list Using code from 'downloadfromdivecomputer' class, this code loads the vendors and products to the respective comboboxes. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 127 +++++++++++++++++++++++++- qt-ui/configuredivecomputerdialog.h | 17 +++- 2 files changed, 142 insertions(+), 2 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 9aa2cfb94..0af50b755 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -1,14 +1,139 @@ #include "configuredivecomputerdialog.h" #include "ui_configuredivecomputerdialog.h" +#include "../divecomputer.h" +#include "../libdivecomputer.h" +#include "../helpers.h" +#include "../display.h" +#include "../divelist.h" +struct product { + const char *product; + dc_descriptor_t *descriptor; + struct product *next; +}; + +struct vendor { + const char *vendor; + struct product *productlist; + struct vendor *next; +}; + +struct mydescriptor { + const char *vendor; + const char *product; + dc_family_t type; + unsigned int model; +}; + ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::ConfigureDiveComputerDialog) + ui(new Ui::ConfigureDiveComputerDialog), + vendorModel(0), + productModel(0) { ui->setupUi(this); + + fill_computer_list(); + + vendorModel = new QStringListModel(vendorList); + ui->vendor->setModel(vendorModel); + if (default_dive_computer_vendor) { + ui->vendor->setCurrentIndex(ui->vendor->findText(default_dive_computer_vendor)); + productModel = new QStringListModel(productList[default_dive_computer_vendor]); + ui->product->setModel(productModel); + if (default_dive_computer_product) + ui->product->setCurrentIndex(ui->product->findText(default_dive_computer_product)); + } + if (default_dive_computer_device) + ui->device->setEditText(default_dive_computer_device); } ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() { delete ui; } + +void ConfigureDiveComputerDialog::fill_computer_list() +{ + dc_iterator_t *iterator = NULL; + dc_descriptor_t *descriptor = NULL; + + struct mydescriptor *mydescriptor; + + QStringList computer; + dc_descriptor_iterator(&iterator); + while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) { + const char *vendor = dc_descriptor_get_vendor(descriptor); + const char *product = dc_descriptor_get_product(descriptor); + + if (!vendorList.contains(vendor)) + vendorList.append(vendor); + + if (!productList[vendor].contains(product)) + productList[vendor].push_back(product); + + descriptorLookup[QString(vendor) + QString(product)] = descriptor; + } + dc_iterator_free(iterator); + + mydescriptor = (struct mydescriptor *)malloc(sizeof(struct mydescriptor)); + mydescriptor->vendor = "Uemis"; + mydescriptor->product = "Zurich"; + mydescriptor->type = DC_FAMILY_NULL; + mydescriptor->model = 0; + + if (!vendorList.contains("Uemis")) + vendorList.append("Uemis"); + + if (!productList["Uemis"].contains("Zurich")) + productList["Uemis"].push_back("Zurich"); + + descriptorLookup["UemisZurich"] = (dc_descriptor_t *)mydescriptor; + + qSort(vendorList); +} + +static void fillDeviceList(const char *name, void *data) +{ + QComboBox *comboBox = (QComboBox *)data; + comboBox->addItem(name); +} + +void ConfigureDiveComputerDialog::fill_device_list(int dc_type) +{ + int deviceIndex; + ui->device->clear(); + deviceIndex = enumerate_devices(fillDeviceList, ui->device, dc_type); + if (deviceIndex >= 0) + ui->device->setCurrentIndex(deviceIndex); +} + +void ConfigureDiveComputerDialog::on_vendor_currentIndexChanged(const QString &vendor) +{ + int dcType = DC_TYPE_SERIAL; + QAbstractItemModel *currentModel = ui->product->model(); + if (!currentModel) + return; + + productModel = new QStringListModel(productList[vendor]); + ui->product->setModel(productModel); + + if (vendor == QString("Uemis")) + dcType = DC_TYPE_UEMIS; + fill_device_list(dcType); +} + +void ConfigureDiveComputerDialog::on_product_currentIndexChanged(const QString &product) +{ + dc_descriptor_t *descriptor = NULL; + descriptor = descriptorLookup[ui->vendor->currentText() + product]; + + // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL + if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) { + // if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box. + ui->device->setEnabled(true); + } else { + // otherwise disable the device node box + ui->device->setEnabled(false); + } +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index b1f3924cf..4f4fbb36c 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -2,7 +2,8 @@ #define CONFIGUREDIVECOMPUTERDIALOG_H #include - +#include +#include "../libdivecomputer.h" namespace Ui { class ConfigureDiveComputerDialog; } @@ -15,8 +16,22 @@ public: explicit ConfigureDiveComputerDialog(QWidget *parent = 0); ~ConfigureDiveComputerDialog(); +private slots: + void on_vendor_currentIndexChanged(const QString &vendor); + + void on_product_currentIndexChanged(const QString &product); + private: Ui::ConfigureDiveComputerDialog *ui; + + QStringList vendorList; + QHash productList; + QHash descriptorLookup; + + QStringListModel *vendorModel; + QStringListModel *productModel; + void fill_computer_list(); + void fill_device_list(int dc_type); }; #endif // CONFIGUREDIVECOMPUTERDIALOG_H From a7c9b25b053ee77a816e1555f1c00c3e4b996396 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 30 May 2014 09:56:27 +0300 Subject: [PATCH 03/33] Read basic details from dive computer Added classes for reading data from dive computer. This is at the basic level and I will expand it as I go along. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 74 +++++++++++++++++++++++++++ qt-ui/configuredivecomputer.h | 58 +++++++++++++++++++++ qt-ui/configuredivecomputerdialog.cpp | 48 +++++++++++++++++ qt-ui/configuredivecomputerdialog.h | 11 ++++ qt-ui/configuredivecomputerdialog.ui | 17 ++++++ subsurface.pro | 6 ++- 6 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 qt-ui/configuredivecomputer.cpp create mode 100644 qt-ui/configuredivecomputer.h diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp new file mode 100644 index 000000000..d02ceffb7 --- /dev/null +++ b/qt-ui/configuredivecomputer.cpp @@ -0,0 +1,74 @@ +#include "configuredivecomputer.h" +#include "libdivecomputer/hw.h" +#include +ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : + QObject(parent), + readThread(0) +{ + setState(INITIAL); +} + +void ConfigureDiveComputer::readSettings(device_data_t *data) +{ + setState(READING); + + if (readThread) + readThread->deleteLater(); + + readThread = new ReadSettingsThread(this, data); + connect (readThread, SIGNAL(finished()), + this, SLOT(readThreadFinished()), Qt::QueuedConnection); + connect (readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + + readThread->start(); +} + +void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) +{ + currentState = newState; + emit stateChanged(currentState); +} + +void ConfigureDiveComputer::setError(QString err) +{ + lastError = err; + emit error(err); +} + +void ConfigureDiveComputer::readHWSettings(device_data_t *data) +{ + +} + +void ConfigureDiveComputer::readThreadFinished() +{ + setState(DONE); + emit deviceSettings(readThread->result); +} + +ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) + : QThread(parent), data(data) +{ + +} + +void ReadSettingsThread::run() +{ + QString vendor = data->vendor; + dc_status_t rc; + rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); + if (rc == DC_STATUS_SUCCESS) { + if (vendor.trimmed() == "Heinrichs Weikamp") { + unsigned char hw_data[10]; + hw_frog_device_version(data->device, hw_data, 10); + QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this + } else { + lastError = tr("This feature is not yet available for the selected dive computer."); + emit error(lastError); + } + dc_device_close(data->device); + } else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } +} diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h new file mode 100644 index 000000000..8441c0cec --- /dev/null +++ b/qt-ui/configuredivecomputer.h @@ -0,0 +1,58 @@ +#ifndef CONFIGUREDIVECOMPUTER_H +#define CONFIGUREDIVECOMPUTER_H + +#include +#include +#include "libdivecomputer.h" + +class ReadSettingsThread : public QThread { + Q_OBJECT +public: + ReadSettingsThread(QObject *parent, device_data_t *data); + virtual void run(); + QString result; + QString lastError; +signals: + void error(QString err); +private: + device_data_t *data; +}; + +class ConfigureDiveComputer : public QObject +{ + Q_OBJECT +public: + explicit ConfigureDiveComputer(QObject *parent = 0); + void readSettings(device_data_t *data); + + enum states { + INITIAL, + READING, + WRITING, + CANCELLING, + CANCELLED, + ERROR, + DONE, + }; + + QString lastError; + states currentState; +signals: + void deviceSettings(QString settings); + void message(QString msg); + void error(QString err); + void readFinished(); + void writeFinished(); + void stateChanged(states newState); +private: + ReadSettingsThread *readThread; + void setState(states newState); + + + void readHWSettings(device_data_t *data); +private slots: + void readThreadFinished(); + void setError(QString err); +}; + +#endif // CONFIGUREDIVECOMPUTER_H diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 0af50b755..53544575c 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -6,6 +6,7 @@ #include "../helpers.h" #include "../display.h" #include "../divelist.h" +#include "configuredivecomputer.h" struct product { const char *product; dc_descriptor_t *descriptor; @@ -28,11 +29,17 @@ struct mydescriptor { ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigureDiveComputerDialog), + config(0), vendorModel(0), productModel(0) { ui->setupUi(this); + config = new ConfigureDiveComputer(this); + connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); + connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); + connect (config, SIGNAL(deviceSettings(QString)), ui->availableDetails, SLOT(setText(QString))); + fill_computer_list(); vendorModel = new QStringListModel(vendorList); @@ -46,6 +53,10 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : } if (default_dive_computer_device) ui->device->setEditText(default_dive_computer_device); + + memset(&device_data, 0, sizeof(device_data)); + + connect (ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); } ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() @@ -137,3 +148,40 @@ void ConfigureDiveComputerDialog::on_product_currentIndexChanged(const QString & ui->device->setEnabled(false); } } + +void ConfigureDiveComputerDialog::readSettings() +{ + ui->statusLabel->clear(); + ui->errorLabel->clear(); + + getDeviceData(); + config->readSettings(&device_data); +} + +void ConfigureDiveComputerDialog::configMessage(QString msg) +{ + ui->statusLabel->setText(msg); +} + +void ConfigureDiveComputerDialog::configError(QString err) +{ + ui->errorLabel->setText(err); +} + +void ConfigureDiveComputerDialog::getDeviceData() +{ + device_data.devname = strdup(ui->device->currentText().toUtf8().data()); + device_data.vendor = strdup(ui->vendor->currentText().toUtf8().data()); + device_data.product = strdup(ui->product->currentText().toUtf8().data()); + + device_data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()]; + device_data.deviceid = device_data.diveid = 0; + + set_default_dive_computer(device_data.vendor, device_data.product); + set_default_dive_computer_device(device_data.devname); +} + +void ConfigureDiveComputerDialog::on_cancel_clicked() +{ + this->close(); +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 4f4fbb36c..116968b79 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -4,6 +4,9 @@ #include #include #include "../libdivecomputer.h" + +class ConfigureDiveComputer; + namespace Ui { class ConfigureDiveComputerDialog; } @@ -21,9 +24,17 @@ private slots: void on_product_currentIndexChanged(const QString &product); + void readSettings(); + void configMessage(QString msg); + void configError(QString err); + void on_cancel_clicked(); private: Ui::ConfigureDiveComputerDialog *ui; + ConfigureDiveComputer *config; + device_data_t device_data; + void getDeviceData(); + QStringList vendorList; QHash productList; QHash descriptorLookup; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 25d63007f..fe36512b2 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -94,6 +94,23 @@ + + + + color: rgb(242, 19, 25); + + + + + + + + + + + + + diff --git a/subsurface.pro b/subsurface.pro index ca3c8abdf..b532e3c99 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -87,7 +87,8 @@ HEADERS = \ qt-ui/divelogexportdialog.h \ qt-ui/usersurvey.h \ subsurfacesysinfo.h \ - qt-ui/configuredivecomputerdialog.h + qt-ui/configuredivecomputerdialog.h \ + qt-ui/configuredivecomputer.h \ android: HEADERS -= \ qt-ui/usermanual.h \ @@ -167,7 +168,8 @@ SOURCES = \ qt-ui/divelogexportdialog.cpp \ qt-ui/usersurvey.cpp \ subsurfacesysinfo.cpp \ - qt-ui/configuredivecomputerdialog.cpp + qt-ui/configuredivecomputerdialog.cpp \ + qt-ui/configuredivecomputer.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c From 3e127a059f598a30e9cfd71411783d71f40b315f Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 30 May 2014 10:49:58 +0300 Subject: [PATCH 04/33] Create class to write settings to dive computer Adds a class to write settings to dive computer, and modifies the existing ones to integrate it. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 92 +++++++++++++++++++++++++-- qt-ui/configuredivecomputer.h | 26 +++++++- qt-ui/configuredivecomputerdialog.cpp | 25 ++++++++ qt-ui/configuredivecomputerdialog.h | 4 ++ qt-ui/configuredivecomputerdialog.ui | 18 ++++++ 5 files changed, 156 insertions(+), 9 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index d02ceffb7..fcd8fbc80 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -3,7 +3,8 @@ #include ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), - readThread(0) + readThread(0), + writeThread(0) { setState(INITIAL); } @@ -23,29 +24,57 @@ void ConfigureDiveComputer::readSettings(device_data_t *data) readThread->start(); } +void ConfigureDiveComputer::setDeviceName(device_data_t *data, QString newName) +{ + writeSettingToDevice(data, "Name", newName); +} + +void ConfigureDiveComputer::setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime) +{ + writeSettingToDevice(data, "DateAndTime", dateAndTime); +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; emit stateChanged(currentState); } +void ConfigureDiveComputer::writeSettingToDevice(device_data_t *data, QString settingName, QVariant settingValue) +{ + setState(READING); + + if (writeThread) + writeThread->deleteLater(); + + writeThread = new WriteSettingsThread(this, data, settingName, settingValue); + connect (writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + connect (writeThread, SIGNAL(finished()), this, SLOT(writeThreadFinished())); + + writeThread->start(); +} + void ConfigureDiveComputer::setError(QString err) { lastError = err; emit error(err); } -void ConfigureDiveComputer::readHWSettings(device_data_t *data) -{ - -} - void ConfigureDiveComputer::readThreadFinished() { setState(DONE); emit deviceSettings(readThread->result); } +void ConfigureDiveComputer::writeThreadFinished() +{ + setState(DONE); + if (writeThread->lastError.isEmpty()) { + //No error + emit message(tr("Setting successfully written to device")); + } +} + ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), data(data) { @@ -72,3 +101,54 @@ void ReadSettingsThread::run() emit error(lastError); } } + +WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data, QString settingName, QVariant settingValue) + : QThread(parent), data(data), m_settingName(settingName), m_settingValue(settingValue) +{ + +} + +void WriteSettingsThread::run() +{ + bool supported = false; + dc_status_t rc; + QString product = data->product; + QString vendor = data->vendor; + rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); + if (rc == DC_STATUS_SUCCESS) { + dc_status_t result; + if (product.trimmed() == "OSTC 3") { + if (m_settingName == "Name") { + supported = true; + result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data()); + } + } + if (vendor.trimmed() == "Heinrichs Weikamp" && m_settingName == "DateAndTime") { + supported = true; + QDateTime timeToSet = m_settingValue.toDateTime(); + dc_datetime_t time; + time.year = timeToSet.date().year(); + time.month = timeToSet.date().month(); + time.day = timeToSet.date().day(); + time.hour = timeToSet.time().hour(); + time.minute = timeToSet.time().minute(); + time.second = timeToSet.time().second(); + result = hw_ostc_device_clock(data->device, &time); //Toto fix error here + } + if (result != DC_STATUS_SUCCESS) { + qDebug() << result; + lastError = tr("An error occurred while sending data to the dive computer."); + //Todo Update this message to change depending on actual result. + + emit error(lastError); + } + dc_device_close(data->device); + } else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } + if (!supported) { + lastError = tr("This feature is not yet available for the selected dive computer."); + emit error(lastError); + } +} diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index 8441c0cec..8b1c4b4c7 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -3,8 +3,9 @@ #include #include +#include #include "libdivecomputer.h" - +#include class ReadSettingsThread : public QThread { Q_OBJECT public: @@ -18,6 +19,21 @@ private: device_data_t *data; }; +class WriteSettingsThread : public QThread { + Q_OBJECT +public: + WriteSettingsThread(QObject *parent, device_data_t *data, QString settingName, QVariant settingValue); + virtual void run(); + QString result; + QString lastError; +signals: + void error(QString err); +private: + device_data_t *data; + QString m_settingName; + QVariant m_settingValue; +}; + class ConfigureDiveComputer : public QObject { Q_OBJECT @@ -37,6 +53,9 @@ public: QString lastError; states currentState; + + void setDeviceName(device_data_t *data, QString newName); + void setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime); signals: void deviceSettings(QString settings); void message(QString msg); @@ -46,12 +65,13 @@ signals: void stateChanged(states newState); private: ReadSettingsThread *readThread; + WriteSettingsThread *writeThread; void setState(states newState); - - void readHWSettings(device_data_t *data); + void writeSettingToDevice(device_data_t *data, QString settingName, QVariant settingValue); private slots: void readThreadFinished(); + void writeThreadFinished(); void setError(QString err); }; diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 53544575c..b88715fc9 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -7,6 +7,8 @@ #include "../display.h" #include "../divelist.h" #include "configuredivecomputer.h" +#include + struct product { const char *product; dc_descriptor_t *descriptor; @@ -185,3 +187,26 @@ void ConfigureDiveComputerDialog::on_cancel_clicked() { this->close(); } + +void ConfigureDiveComputerDialog::on_setDeviceName_clicked() +{ + ui->statusLabel->clear(); + ui->errorLabel->clear(); + ui->availableDetails->clear(); + + QString newDeviceName = QInputDialog::getText(this, tr("Set device name"), tr("Enter the new name for this device:")); + if (newDeviceName.length() > 0) { + getDeviceData(); + config->setDeviceName(&device_data, newDeviceName); + } +} + +void ConfigureDiveComputerDialog::on_setDateAndTime_clicked() +{ + ui->statusLabel->clear(); + ui->errorLabel->clear(); + ui->availableDetails->clear(); + + getDeviceData(); + config->setDeviceDateAndTime(&device_data, QDateTime::currentDateTime()); +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 116968b79..4c63c8c8f 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -28,6 +28,10 @@ private slots: void configMessage(QString msg); void configError(QString err); void on_cancel_clicked(); + void on_setDeviceName_clicked(); + + void on_setDateAndTime_clicked(); + private: Ui::ConfigureDiveComputerDialog *ui; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index fe36512b2..71fa541c3 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -94,6 +94,24 @@ + + + + + + Set Device Name + + + + + + + Set Date && Time + + + + + From a08d239af598632eec5a8bb951aeda4cfc441fc8 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 4 Jun 2014 07:25:41 +0300 Subject: [PATCH 05/33] Change dive computer family detection Following suggestions on the mailing list, this changes the method used to detect the dive computer family. Detection is now done using: dc_device_get_type. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index fcd8fbc80..ae71ea627 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -83,13 +83,12 @@ ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) void ReadSettingsThread::run() { - QString vendor = data->vendor; dc_status_t rc; rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); if (rc == DC_STATUS_SUCCESS) { - if (vendor.trimmed() == "Heinrichs Weikamp") { + if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) { unsigned char hw_data[10]; - hw_frog_device_version(data->device, hw_data, 10); + hw_ostc3_device_version(data->device, hw_data, 10); QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this } else { lastError = tr("This feature is not yet available for the selected dive computer."); @@ -112,18 +111,21 @@ void WriteSettingsThread::run() { bool supported = false; dc_status_t rc; - QString product = data->product; - QString vendor = data->vendor; rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); if (rc == DC_STATUS_SUCCESS) { dc_status_t result; - if (product.trimmed() == "OSTC 3") { + if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) { if (m_settingName == "Name") { supported = true; result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data()); } + } else if ( dc_device_get_type(data->device) == DC_FAMILY_HW_FROG ) { + if (m_settingName == "Name") { + supported = true; + result = hw_frog_device_customtext(data->device, m_settingValue.toByteArray().data()); + } } - if (vendor.trimmed() == "Heinrichs Weikamp" && m_settingName == "DateAndTime") { + if ( dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3 && m_settingName == "DateTime" ) { supported = true; QDateTime timeToSet = m_settingValue.toDateTime(); dc_datetime_t time; From ee2403d63c282cbf7ef6b155013ae2cc42278ee7 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 5 Jun 2014 12:41:23 +0300 Subject: [PATCH 06/33] Improve writing of date and time to dive computer Improves writing of date and time to the dive computer. This has been tested using the Heinrichs Weikamp OSTC-3. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index ae71ea627..2d7008b81 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -125,8 +125,7 @@ void WriteSettingsThread::run() result = hw_frog_device_customtext(data->device, m_settingValue.toByteArray().data()); } } - if ( dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3 && m_settingName == "DateTime" ) { - supported = true; + if (m_settingName == "DateAndTime") { QDateTime timeToSet = m_settingValue.toDateTime(); dc_datetime_t time; time.year = timeToSet.date().year(); @@ -135,7 +134,21 @@ void WriteSettingsThread::run() time.hour = timeToSet.time().hour(); time.minute = timeToSet.time().minute(); time.second = timeToSet.time().second(); - result = hw_ostc_device_clock(data->device, &time); //Toto fix error here + + switch (dc_device_get_type(data->device)) { + case DC_FAMILY_HW_OSTC3: + supported = true; + result = hw_ostc3_device_clock(data->device, &time); + break; + case DC_FAMILY_HW_OSTC: + supported = true; + result = hw_ostc_device_clock(data->device, &time); + break; + case DC_FAMILY_HW_FROG: + supported = true; + result = hw_frog_device_clock(data->device, &time); + break; + } } if (result != DC_STATUS_SUCCESS) { qDebug() << result; From a7a74ae9a630dba8ba29afb3fece6c9f5bf3639d Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 5 Jun 2014 12:58:16 +0300 Subject: [PATCH 07/33] Improve writing of device name to dive computers. Improves the writing of device name to the dive computer. The code has been updated to use a switch statement. This will make it easier to add new devices in the future. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index 2d7008b81..f591efffa 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -114,15 +114,16 @@ void WriteSettingsThread::run() rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); if (rc == DC_STATUS_SUCCESS) { dc_status_t result; - if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) { - if (m_settingName == "Name") { + if (m_settingName == "Name") { + switch (dc_device_get_type(data->device)) { + case DC_FAMILY_HW_OSTC3: supported = true; result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data()); - } - } else if ( dc_device_get_type(data->device) == DC_FAMILY_HW_FROG ) { - if (m_settingName == "Name") { + break; + case DC_FAMILY_HW_FROG: supported = true; result = hw_frog_device_customtext(data->device, m_settingValue.toByteArray().data()); + break; } } if (m_settingName == "DateAndTime") { From 2432350064c6a9109501b3df21f56a9fe41aa686 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 7 Jun 2014 21:56:44 +0300 Subject: [PATCH 08/33] Add brightness setting Adds a setting to control the device's brightness. Currently I have only the OSTC 3. Will add more afterwards. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 16 +++++++++++++ qt-ui/configuredivecomputer.h | 1 + qt-ui/configuredivecomputerdialog.cpp | 6 +++++ qt-ui/configuredivecomputerdialog.h | 2 ++ qt-ui/configuredivecomputerdialog.ui | 33 +++++++++++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index f591efffa..8cc3a6953 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -34,6 +34,11 @@ void ConfigureDiveComputer::setDeviceDateAndTime(device_data_t *data, QDateTime writeSettingToDevice(data, "DateAndTime", dateAndTime); } +void ConfigureDiveComputer::setDeviceBrightness(device_data_t *data, int brighnessLevel) +{ + writeSettingToDevice(data, "Brightness", brighnessLevel); +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; @@ -151,6 +156,17 @@ void WriteSettingsThread::run() break; } } + if (m_settingName == "Brightness") { + switch (dc_device_get_type(data->device)) { + case DC_FAMILY_HW_OSTC3: + qDebug() << "Brightness"; + supported = true; + unsigned char packet[1] = { m_settingValue.toInt() }; + result = hw_ostc3_device_config_write(data->device, 0x2D, packet, sizeof (packet)); + break; + } + } + qDebug() << result; if (result != DC_STATUS_SUCCESS) { qDebug() << result; lastError = tr("An error occurred while sending data to the dive computer."); diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index 8b1c4b4c7..08c4e190f 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -56,6 +56,7 @@ public: void setDeviceName(device_data_t *data, QString newName); void setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime); + void setDeviceBrightness(device_data_t *data, int brighnessLevel); signals: void deviceSettings(QString settings); void message(QString msg); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index b88715fc9..1d5b1d7f8 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -210,3 +210,9 @@ void ConfigureDiveComputerDialog::on_setDateAndTime_clicked() getDeviceData(); config->setDeviceDateAndTime(&device_data, QDateTime::currentDateTime()); } + +void ConfigureDiveComputerDialog::on_setBrightnessButton_clicked() +{ + getDeviceData(); + config->setDeviceBrightness(&device_data, ui->brightnessComboBox->currentIndex()); +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 4c63c8c8f..7c4243ab8 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -32,6 +32,8 @@ private slots: void on_setDateAndTime_clicked(); + void on_setBrightnessButton_clicked(); + private: Ui::ConfigureDiveComputerDialog *ui; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 71fa541c3..cb4dacb23 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -110,6 +110,39 @@ + + + + Brightness: + + + + + + + + Eco + + + + + Medium + + + + + High + + + + + + + + ... + + + From 4fc16b16749a73b8c06d41cb7cb22b78c77ab29e Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 15:03:26 +0300 Subject: [PATCH 09/33] Move divecomputer configuration code to different files This splits the code in configuredivecomputer.cpp into multiple files. The read and write threads are moved to configuredivecomputerthreads.h/cpp, and the device details class is moved to devicedetails.h/.cpp Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 141 ++----------------------- qt-ui/configuredivecomputer.h | 40 ++----- qt-ui/configuredivecomputerdialog.cpp | 36 ++----- qt-ui/configuredivecomputerdialog.h | 13 +-- qt-ui/configuredivecomputerdialog.ui | 127 +++++++++++++++++----- qt-ui/configuredivecomputerthreads.cpp | 81 ++++++++++++++ qt-ui/configuredivecomputerthreads.h | 42 ++++++++ qt-ui/devicedetails.cpp | 88 +++++++++++++++ qt-ui/devicedetails.h | 54 ++++++++++ subsurface.pro | 6 +- 10 files changed, 403 insertions(+), 225 deletions(-) create mode 100644 qt-ui/configuredivecomputerthreads.cpp create mode 100644 qt-ui/configuredivecomputerthreads.h create mode 100644 qt-ui/devicedetails.cpp create mode 100644 qt-ui/devicedetails.h diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index 8cc3a6953..d24c8905d 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -4,19 +4,21 @@ ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), readThread(0), - writeThread(0) + writeThread(0), + m_deviceDetails(0) { setState(INITIAL); } -void ConfigureDiveComputer::readSettings(device_data_t *data) +void ConfigureDiveComputer::readSettings(DeviceDetails *deviceDetails, device_data_t *data) { setState(READING); + m_deviceDetails = deviceDetails; if (readThread) readThread->deleteLater(); - readThread = new ReadSettingsThread(this, data); + readThread = new ReadSettingsThread(this, deviceDetails, data); connect (readThread, SIGNAL(finished()), this, SLOT(readThreadFinished()), Qt::QueuedConnection); connect (readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); @@ -24,19 +26,9 @@ void ConfigureDiveComputer::readSettings(device_data_t *data) readThread->start(); } -void ConfigureDiveComputer::setDeviceName(device_data_t *data, QString newName) +void ConfigureDiveComputer::saveDeviceDetails() { - writeSettingToDevice(data, "Name", newName); -} -void ConfigureDiveComputer::setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime) -{ - writeSettingToDevice(data, "DateAndTime", dateAndTime); -} - -void ConfigureDiveComputer::setDeviceBrightness(device_data_t *data, int brighnessLevel) -{ - writeSettingToDevice(data, "Brightness", brighnessLevel); } void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) @@ -45,20 +37,6 @@ void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) emit stateChanged(currentState); } -void ConfigureDiveComputer::writeSettingToDevice(device_data_t *data, QString settingName, QVariant settingValue) -{ - setState(READING); - - if (writeThread) - writeThread->deleteLater(); - - writeThread = new WriteSettingsThread(this, data, settingName, settingValue); - connect (writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); - connect (writeThread, SIGNAL(finished()), this, SLOT(writeThreadFinished())); - - writeThread->start(); -} - void ConfigureDiveComputer::setError(QString err) { lastError = err; @@ -68,7 +46,7 @@ void ConfigureDiveComputer::setError(QString err) void ConfigureDiveComputer::readThreadFinished() { setState(DONE); - emit deviceSettings(readThread->result); + emit readFinished(); } void ConfigureDiveComputer::writeThreadFinished() @@ -79,108 +57,3 @@ void ConfigureDiveComputer::writeThreadFinished() emit message(tr("Setting successfully written to device")); } } - -ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) - : QThread(parent), data(data) -{ - -} - -void ReadSettingsThread::run() -{ - dc_status_t rc; - rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); - if (rc == DC_STATUS_SUCCESS) { - if (dc_device_get_type(data->device) == DC_FAMILY_HW_OSTC3) { - unsigned char hw_data[10]; - hw_ostc3_device_version(data->device, hw_data, 10); - QTextStream (&result) << "Device Version: " << hw_data; //just a test. I will work on decoding this - } else { - lastError = tr("This feature is not yet available for the selected dive computer."); - emit error(lastError); - } - dc_device_close(data->device); - } else { - lastError = tr("Could not a establish connection to the dive computer."); - emit error(lastError); - } -} - -WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data, QString settingName, QVariant settingValue) - : QThread(parent), data(data), m_settingName(settingName), m_settingValue(settingValue) -{ - -} - -void WriteSettingsThread::run() -{ - bool supported = false; - dc_status_t rc; - rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); - if (rc == DC_STATUS_SUCCESS) { - dc_status_t result; - if (m_settingName == "Name") { - switch (dc_device_get_type(data->device)) { - case DC_FAMILY_HW_OSTC3: - supported = true; - result = hw_ostc3_device_customtext(data->device, m_settingValue.toByteArray().data()); - break; - case DC_FAMILY_HW_FROG: - supported = true; - result = hw_frog_device_customtext(data->device, m_settingValue.toByteArray().data()); - break; - } - } - if (m_settingName == "DateAndTime") { - QDateTime timeToSet = m_settingValue.toDateTime(); - dc_datetime_t time; - time.year = timeToSet.date().year(); - time.month = timeToSet.date().month(); - time.day = timeToSet.date().day(); - time.hour = timeToSet.time().hour(); - time.minute = timeToSet.time().minute(); - time.second = timeToSet.time().second(); - - switch (dc_device_get_type(data->device)) { - case DC_FAMILY_HW_OSTC3: - supported = true; - result = hw_ostc3_device_clock(data->device, &time); - break; - case DC_FAMILY_HW_OSTC: - supported = true; - result = hw_ostc_device_clock(data->device, &time); - break; - case DC_FAMILY_HW_FROG: - supported = true; - result = hw_frog_device_clock(data->device, &time); - break; - } - } - if (m_settingName == "Brightness") { - switch (dc_device_get_type(data->device)) { - case DC_FAMILY_HW_OSTC3: - qDebug() << "Brightness"; - supported = true; - unsigned char packet[1] = { m_settingValue.toInt() }; - result = hw_ostc3_device_config_write(data->device, 0x2D, packet, sizeof (packet)); - break; - } - } - qDebug() << result; - if (result != DC_STATUS_SUCCESS) { - qDebug() << result; - lastError = tr("An error occurred while sending data to the dive computer."); - //Todo Update this message to change depending on actual result. - - emit error(lastError); - } - dc_device_close(data->device); - } else { - lastError = tr("Could not a establish connection to the dive computer."); - emit error(lastError); - } - if (!supported) { - lastError = tr("This feature is not yet available for the selected dive computer."); - emit error(lastError); - } -} diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index 08c4e190f..65ceaa780 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -5,41 +5,15 @@ #include #include #include "libdivecomputer.h" +#include "configuredivecomputerthreads.h" #include -class ReadSettingsThread : public QThread { - Q_OBJECT -public: - ReadSettingsThread(QObject *parent, device_data_t *data); - virtual void run(); - QString result; - QString lastError; -signals: - void error(QString err); -private: - device_data_t *data; -}; - -class WriteSettingsThread : public QThread { - Q_OBJECT -public: - WriteSettingsThread(QObject *parent, device_data_t *data, QString settingName, QVariant settingValue); - virtual void run(); - QString result; - QString lastError; -signals: - void error(QString err); -private: - device_data_t *data; - QString m_settingName; - QVariant m_settingValue; -}; class ConfigureDiveComputer : public QObject { Q_OBJECT public: explicit ConfigureDiveComputer(QObject *parent = 0); - void readSettings(device_data_t *data); + void readSettings(DeviceDetails *deviceDetails, device_data_t *data); enum states { INITIAL, @@ -53,23 +27,23 @@ public: QString lastError; states currentState; + DeviceDetails *m_deviceDetails; + device_data_t *m_data; + void saveDeviceDetails(); + void fetchDeviceDetails(); - void setDeviceName(device_data_t *data, QString newName); - void setDeviceDateAndTime(device_data_t *data, QDateTime dateAndTime); - void setDeviceBrightness(device_data_t *data, int brighnessLevel); signals: - void deviceSettings(QString settings); void message(QString msg); void error(QString err); void readFinished(); void writeFinished(); void stateChanged(states newState); + private: ReadSettingsThread *readThread; WriteSettingsThread *writeThread; void setState(states newState); - void writeSettingToDevice(device_data_t *data, QString settingName, QVariant settingValue); private slots: void readThreadFinished(); void writeThreadFinished(); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 1d5b1d7f8..8ae250468 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -33,14 +33,16 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : ui(new Ui::ConfigureDiveComputerDialog), config(0), vendorModel(0), - productModel(0) + productModel(0), + deviceDetails(0) { ui->setupUi(this); + deviceDetails = new DeviceDetails(this); config = new ConfigureDiveComputer(this); connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); - connect (config, SIGNAL(deviceSettings(QString)), ui->availableDetails, SLOT(setText(QString))); + connect (config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); fill_computer_list(); @@ -157,7 +159,7 @@ void ConfigureDiveComputerDialog::readSettings() ui->errorLabel->clear(); getDeviceData(); - config->readSettings(&device_data); + config->readSettings(deviceDetails, &device_data); } void ConfigureDiveComputerDialog::configMessage(QString msg) @@ -181,6 +183,8 @@ void ConfigureDiveComputerDialog::getDeviceData() set_default_dive_computer(device_data.vendor, device_data.product); set_default_dive_computer_device(device_data.devname); + + //deviceDetails->setData(&device_data); } void ConfigureDiveComputerDialog::on_cancel_clicked() @@ -188,31 +192,13 @@ void ConfigureDiveComputerDialog::on_cancel_clicked() this->close(); } -void ConfigureDiveComputerDialog::on_setDeviceName_clicked() +void ConfigureDiveComputerDialog::deviceReadFinished() { - ui->statusLabel->clear(); - ui->errorLabel->clear(); - ui->availableDetails->clear(); - - QString newDeviceName = QInputDialog::getText(this, tr("Set device name"), tr("Enter the new name for this device:")); - if (newDeviceName.length() > 0) { - getDeviceData(); - config->setDeviceName(&device_data, newDeviceName); - } + ui->brightnessComboBox->setCurrentIndex(config->m_deviceDetails->brightness()); } -void ConfigureDiveComputerDialog::on_setDateAndTime_clicked() +void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() { - ui->statusLabel->clear(); - ui->errorLabel->clear(); - ui->availableDetails->clear(); - - getDeviceData(); - config->setDeviceDateAndTime(&device_data, QDateTime::currentDateTime()); + config->saveDeviceDetails(); } -void ConfigureDiveComputerDialog::on_setBrightnessButton_clicked() -{ - getDeviceData(); - config->setDeviceBrightness(&device_data, ui->brightnessComboBox->currentIndex()); -} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 7c4243ab8..5a8bf63e1 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -4,8 +4,7 @@ #include #include #include "../libdivecomputer.h" - -class ConfigureDiveComputer; +#include "configuredivecomputer.h" namespace Ui { class ConfigureDiveComputerDialog; @@ -28,12 +27,8 @@ private slots: void configMessage(QString msg); void configError(QString err); void on_cancel_clicked(); - void on_setDeviceName_clicked(); - - void on_setDateAndTime_clicked(); - - void on_setBrightnessButton_clicked(); - + void deviceReadFinished(); + void on_saveSettingsPushButton_clicked(); private: Ui::ConfigureDiveComputerDialog *ui; @@ -49,6 +44,8 @@ private: QStringListModel *productModel; void fill_computer_list(); void fill_device_list(int dc_type); + + DeviceDetails *deviceDetails; }; #endif // CONFIGUREDIVECOMPUTERDIALOG_H diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index cb4dacb23..d7c584e0c 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 362 - 375 + 343 + 365 @@ -91,33 +91,16 @@ - - - - - - - Set Device Name - - - - - - - Set Date && Time - - - - + Brightness: - + @@ -136,15 +119,90 @@ - - + + + + true + + + + + + + + English + + + + + German + + + + + French + + + + + Italian + + + + + + + + + - ... + Language: + + + + + + + Serial No. + + + + + + + Custom Text: + + + + + + + Firmware Version: + + + + + + + true + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -164,6 +222,13 @@ + + + + Save Chages to Device + + + @@ -188,6 +253,20 @@ + + vendor + product + device + search + retrieveDetails + serialNoLineEdit + firmwareVersionLineEdit + customTextLlineEdit + brightnessComboBox + languageComboBox + saveSettingsPushButton + cancel + diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp new file mode 100644 index 000000000..f1ac3b5d9 --- /dev/null +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -0,0 +1,81 @@ +#include "configuredivecomputerthreads.h" +#include "libdivecomputer/hw.h" +#include + +ReadSettingsThread::ReadSettingsThread(QObject *parent, DeviceDetails *deviceDetails, device_data_t *data) + : QThread(parent), m_deviceDetails(deviceDetails), m_data(data) +{ + +} + +void ReadSettingsThread::run() +{ + bool supported = false; + dc_status_t rc; + rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); + if (rc == DC_STATUS_SUCCESS) { + switch (dc_device_get_type(m_data->device)) { + case DC_FAMILY_HW_OSTC3: + supported = true; + m_deviceDetails->setBrightness(0); + m_deviceDetails->setCustomText(""); + m_deviceDetails->setDateFormat(0); + m_deviceDetails->setDiveModeColor(0); + m_deviceDetails->setFirmwareVersion(""); + m_deviceDetails->setLanguage(0); + m_deviceDetails->setLastDeco(0); + m_deviceDetails->setSerialNo(""); + unsigned char uData[1]; + rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setBrightness(uData[0]); + rc = hw_ostc3_device_config_read(m_data->device, 0x32, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setLanguage(uData[0]); + rc = hw_ostc3_device_config_read(m_data->device, 0x33, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setDateFormat(uData[0]); + break; + + } + dc_device_close(m_data->device); + + if (!supported) { + lastError = tr("This feature is not yet available for the selected dive computer."); + emit error(lastError); + } + } + else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } +} + +WriteSettingsThread::WriteSettingsThread(QObject *parent, DeviceDetails *deviceDetails, QString settingName, QVariant settingValue) + : QThread(parent), m_deviceDetails(deviceDetails), m_settingName(settingName), m_settingValue(settingValue) +{ + +} + +void WriteSettingsThread::run() +{ + bool supported = false; + dc_status_t rc; + + switch (dc_device_get_type(data->device)) { + case DC_FAMILY_HW_OSTC3: + rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); + if (rc == DC_STATUS_SUCCESS) { + + } else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } + break; + + if (!supported) { + lastError = tr("This feature is not yet available for the selected dive computer."); + emit error(lastError); + } + } +} diff --git a/qt-ui/configuredivecomputerthreads.h b/qt-ui/configuredivecomputerthreads.h new file mode 100644 index 000000000..c684cddaa --- /dev/null +++ b/qt-ui/configuredivecomputerthreads.h @@ -0,0 +1,42 @@ +#ifndef CONFIGUREDIVECOMPUTERTHREADS_H +#define CONFIGUREDIVECOMPUTERTHREADS_H + +#include +#include +#include +#include "libdivecomputer.h" +#include +#include "devicedetails.h" + +class ReadSettingsThread : public QThread { + Q_OBJECT +public: + ReadSettingsThread(QObject *parent, DeviceDetails *deviceDetails, device_data_t *data); + virtual void run(); + QString result; + QString lastError; +signals: + void error(QString err); +private: + DeviceDetails *m_deviceDetails; + device_data_t *m_data; +}; + +class WriteSettingsThread : public QThread { + Q_OBJECT +public: + WriteSettingsThread(QObject *parent, DeviceDetails *deviceDetails, QString settingName, QVariant settingValue); + virtual void run(); + QString result; + QString lastError; +signals: + void error(QString err); +private: + device_data_t *data; + QString m_settingName; + QVariant m_settingValue; + + DeviceDetails *m_deviceDetails; +}; + +#endif // CONFIGUREDIVECOMPUTERTHREADS_H diff --git a/qt-ui/devicedetails.cpp b/qt-ui/devicedetails.cpp new file mode 100644 index 000000000..e5a90b9da --- /dev/null +++ b/qt-ui/devicedetails.cpp @@ -0,0 +1,88 @@ +#include "devicedetails.h" + +DeviceDetails::DeviceDetails(QObject *parent) : + QObject(parent) +{ + +} +device_data_t *DeviceDetails::data() const +{ + return m_data; +} + +void DeviceDetails::setData(device_data_t *data) +{ + m_data = data; +} +QString DeviceDetails::serialNo() const +{ + return m_serialNo; +} + +void DeviceDetails::setSerialNo(const QString &serialNo) +{ + m_serialNo = serialNo; +} +QString DeviceDetails::firmwareVersion() const +{ + return m_firmwareVersion; +} + +void DeviceDetails::setFirmwareVersion(const QString &firmwareVersion) +{ + m_firmwareVersion = firmwareVersion; +} +QString DeviceDetails::customText() const +{ + return m_customText; +} + +void DeviceDetails::setCustomText(const QString &customText) +{ + m_customText = customText; +} +int DeviceDetails::brightness() const +{ + return m_brightness; +} + +void DeviceDetails::setBrightness(int brightness) +{ + m_brightness = brightness; +} +int DeviceDetails::diveModeColor() const +{ + return m_diveModeColor; +} + +void DeviceDetails::setDiveModeColor(int diveModeColor) +{ + m_diveModeColor = diveModeColor; +} +int DeviceDetails::language() const +{ + return m_language; +} + +void DeviceDetails::setLanguage(int language) +{ + m_language = language; +} +int DeviceDetails::dateFormat() const +{ + return m_dateFormat; +} + +void DeviceDetails::setDateFormat(int dateFormat) +{ + m_dateFormat = dateFormat; +} +int DeviceDetails::lastDeco() const +{ + return m_lastDeco; +} + +void DeviceDetails::setLastDeco(int lastDeco) +{ + m_lastDeco = lastDeco; +} diff --git a/qt-ui/devicedetails.h b/qt-ui/devicedetails.h new file mode 100644 index 000000000..9f5e7c1dd --- /dev/null +++ b/qt-ui/devicedetails.h @@ -0,0 +1,54 @@ +#ifndef DEVICEDETAILS_H +#define DEVICEDETAILS_H + +#include +#include +#include "libdivecomputer.h" + +class DeviceDetails : public QObject +{ + Q_OBJECT +public: + explicit DeviceDetails(QObject *parent = 0); + + device_data_t *data() const; + void setData(device_data_t *data); + + QString serialNo() const; + void setSerialNo(const QString &serialNo); + + QString firmwareVersion() const; + void setFirmwareVersion(const QString &firmwareVersion); + + QString customText() const; + void setCustomText(const QString &customText); + + int brightness() const; + void setBrightness(int brightness); + + int diveModeColor() const; + void setDiveModeColor(int diveModeColor); + + int language() const; + void setLanguage(int language); + + int dateFormat() const; + void setDateFormat(int dateFormat); + + int lastDeco() const; + void setLastDeco(int lastDeco); + +private: + device_data_t *m_data; + QString m_serialNo; + QString m_firmwareVersion; + QString m_customText; + int m_brightness; + int m_diveModeColor; + int m_language; + int m_dateFormat; + int m_lastDeco; +}; + + +#endif // DEVICEDETAILS_H diff --git a/subsurface.pro b/subsurface.pro index b532e3c99..8711ab505 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -89,6 +89,8 @@ HEADERS = \ subsurfacesysinfo.h \ qt-ui/configuredivecomputerdialog.h \ qt-ui/configuredivecomputer.h \ + qt-ui/configuredivecomputerthreads.h \ + qt-ui/devicedetails.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -169,7 +171,9 @@ SOURCES = \ qt-ui/usersurvey.cpp \ subsurfacesysinfo.cpp \ qt-ui/configuredivecomputerdialog.cpp \ - qt-ui/configuredivecomputer.cpp + qt-ui/configuredivecomputer.cpp \ + qt-ui/configuredivecomputerthreads.cpp \ + qt-ui/devicedetails.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c From 20eb62a98a70c1773ff99ece05f1c69e6ca8ce15 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 18:25:25 +0300 Subject: [PATCH 10/33] Polish up on classes This patch polishes up on all classes added for dive computer configuration to give a clean workflow. The classes can now write and read data from the OSTC 3. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 23 +++++--- qt-ui/configuredivecomputer.h | 6 +-- qt-ui/configuredivecomputerdialog.cpp | 32 +++++++++-- qt-ui/configuredivecomputerdialog.h | 2 + qt-ui/configuredivecomputerdialog.ui | 74 +++++++++++++++++--------- qt-ui/configuredivecomputerthreads.cpp | 61 +++++++++++++++------ qt-ui/configuredivecomputerthreads.h | 12 ++--- 7 files changed, 150 insertions(+), 60 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index d24c8905d..ad431eefe 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -4,31 +4,42 @@ ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), readThread(0), - writeThread(0), - m_deviceDetails(0) + writeThread(0) { setState(INITIAL); } -void ConfigureDiveComputer::readSettings(DeviceDetails *deviceDetails, device_data_t *data) +void ConfigureDiveComputer::readSettings(device_data_t *data) { setState(READING); - m_deviceDetails = deviceDetails; if (readThread) readThread->deleteLater(); - readThread = new ReadSettingsThread(this, deviceDetails, data); + readThread = new ReadSettingsThread(this, data); connect (readThread, SIGNAL(finished()), this, SLOT(readThreadFinished()), Qt::QueuedConnection); connect (readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + connect (readThread, SIGNAL(devicedetails(DeviceDetails*)), this, + SIGNAL(deviceDetailsChanged(DeviceDetails*))); readThread->start(); } -void ConfigureDiveComputer::saveDeviceDetails() +void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_data_t *data) { + setState(WRITING); + if (writeThread) + writeThread->deleteLater(); + + writeThread = new WriteSettingsThread(this, data); + connect (writeThread, SIGNAL(finished()), + this, SLOT(writeThreadFinished()), Qt::QueuedConnection); + connect (writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + + writeThread->setDeviceDetails(details); + writeThread->start(); } void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index 65ceaa780..f21f02910 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -13,7 +13,7 @@ class ConfigureDiveComputer : public QObject Q_OBJECT public: explicit ConfigureDiveComputer(QObject *parent = 0); - void readSettings(DeviceDetails *deviceDetails, device_data_t *data); + void readSettings(device_data_t *data); enum states { INITIAL, @@ -27,9 +27,8 @@ public: QString lastError; states currentState; - DeviceDetails *m_deviceDetails; device_data_t *m_data; - void saveDeviceDetails(); + void saveDeviceDetails(DeviceDetails *details, device_data_t *data); void fetchDeviceDetails(); signals: @@ -38,6 +37,7 @@ signals: void readFinished(); void writeFinished(); void stateChanged(states newState); + void deviceDetailsChanged(DeviceDetails *newDetails); private: ReadSettingsThread *readThread; diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 8ae250468..ea5e764dc 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -8,6 +8,7 @@ #include "../divelist.h" #include "configuredivecomputer.h" #include +#include struct product { const char *product; @@ -43,6 +44,8 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); connect (config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); + connect (config, SIGNAL(deviceDetailsChanged(DeviceDetails*)), + this, SLOT(deviceDetailsReceived(DeviceDetails*))); fill_computer_list(); @@ -159,7 +162,7 @@ void ConfigureDiveComputerDialog::readSettings() ui->errorLabel->clear(); getDeviceData(); - config->readSettings(deviceDetails, &device_data); + config->readSettings(&device_data); } void ConfigureDiveComputerDialog::configMessage(QString msg) @@ -183,8 +186,6 @@ void ConfigureDiveComputerDialog::getDeviceData() set_default_dive_computer(device_data.vendor, device_data.product); set_default_dive_computer_device(device_data.devname); - - //deviceDetails->setData(&device_data); } void ConfigureDiveComputerDialog::on_cancel_clicked() @@ -194,11 +195,32 @@ void ConfigureDiveComputerDialog::on_cancel_clicked() void ConfigureDiveComputerDialog::deviceReadFinished() { - ui->brightnessComboBox->setCurrentIndex(config->m_deviceDetails->brightness()); + } void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() { - config->saveDeviceDetails(); + deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); + deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); + deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); + deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + getDeviceData(); + config->saveDeviceDetails(deviceDetails, &device_data); +} + +void ConfigureDiveComputerDialog::deviceDetailsReceived(DeviceDetails *newDeviceDetails) +{ + deviceDetails = newDeviceDetails; + reloadValues(); +} + +void ConfigureDiveComputerDialog::reloadValues() +{ + ui->serialNoLineEdit->setText(deviceDetails->serialNo()); + ui->firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion()); + ui->customTextLlineEdit->setText(deviceDetails->customText()); + ui->brightnessComboBox->setCurrentIndex(deviceDetails->brightness()); + ui->languageComboBox->setCurrentIndex(deviceDetails->language()); + ui->dateFormatComboBox->setCurrentIndex(deviceDetails->dateFormat()); } diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 5a8bf63e1..e8c941fcf 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -29,6 +29,8 @@ private slots: void on_cancel_clicked(); void deviceReadFinished(); void on_saveSettingsPushButton_clicked(); + void deviceDetailsReceived(DeviceDetails *newDeviceDetails); + void reloadValues(); private: Ui::ConfigureDiveComputerDialog *ui; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index d7c584e0c..4f1c7a8af 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -7,7 +7,7 @@ 0 0 343 - 365 + 390 @@ -93,12 +93,8 @@ - - - - Brightness: - - + + @@ -119,10 +115,10 @@ - - - - true + + + + Firmware Version: @@ -150,20 +146,17 @@ - - - - - + + - Language: + Brightness: - - - - Serial No. + + + + true @@ -174,10 +167,17 @@ - - + + - Firmware Version: + Serial No. + + + + + + + Language: @@ -188,6 +188,32 @@ + + + + Date Format: + + + + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + + + diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index f1ac3b5d9..5d9f0e8b0 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -2,8 +2,8 @@ #include "libdivecomputer/hw.h" #include -ReadSettingsThread::ReadSettingsThread(QObject *parent, DeviceDetails *deviceDetails, device_data_t *data) - : QThread(parent), m_deviceDetails(deviceDetails), m_data(data) +ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) + : QThread(parent), m_data(data) { } @@ -14,6 +14,7 @@ void ReadSettingsThread::run() dc_status_t rc; rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); if (rc == DC_STATUS_SUCCESS) { + DeviceDetails *m_deviceDetails = new DeviceDetails(0); switch (dc_device_get_type(m_data->device)) { case DC_FAMILY_HW_OSTC3: supported = true; @@ -25,7 +26,8 @@ void ReadSettingsThread::run() m_deviceDetails->setLanguage(0); m_deviceDetails->setLastDeco(0); m_deviceDetails->setSerialNo(""); - unsigned char uData[1]; + //Read general settings + unsigned char uData[1] = {0}; rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setBrightness(uData[0]); @@ -35,6 +37,20 @@ void ReadSettingsThread::run() rc = hw_ostc3_device_config_read(m_data->device, 0x33, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setDateFormat(uData[0]); + + //read firmware settings + unsigned char fData[64] = {0}; + rc = hw_ostc3_device_version (m_data->device, fData, sizeof (fData)); + if (rc == DC_STATUS_SUCCESS) { + int serial = fData[0] + (fData[1] << 8); + m_deviceDetails->setSerialNo(QString::number(serial)); + int fw = (fData[2] << 8) + fData[3]; + m_deviceDetails->setFirmwareVersion(QString::number(fw)); + QByteArray ar((char *)fData + 4, 60); + m_deviceDetails->setCustomText(ar.trimmed()); + } + + emit devicedetails(m_deviceDetails); break; } @@ -51,31 +67,46 @@ void ReadSettingsThread::run() } } -WriteSettingsThread::WriteSettingsThread(QObject *parent, DeviceDetails *deviceDetails, QString settingName, QVariant settingValue) - : QThread(parent), m_deviceDetails(deviceDetails), m_settingName(settingName), m_settingValue(settingValue) -{ +WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) + : QThread(parent), m_data(data) { } +void WriteSettingsThread::setDeviceDetails(DeviceDetails *details) +{ + m_deviceDetails = details; +} + void WriteSettingsThread::run() { bool supported = false; dc_status_t rc; + rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); + if (rc == DC_STATUS_SUCCESS) { + switch (dc_device_get_type(m_data->device)) { + case DC_FAMILY_HW_OSTC3: + supported = true; + //write general settings + hw_ostc3_device_customtext(m_data->device, m_deviceDetails->customText().toUtf8().data()); + unsigned char data[1] = {0}; + data[0] = m_deviceDetails->brightness(); + hw_ostc3_device_config_write(m_data->device, 0x2D, data, sizeof(data)); + data[0] = m_deviceDetails->language(); + hw_ostc3_device_config_write(m_data->device, 0x32, data, sizeof(data)); + data[0] = m_deviceDetails->dateFormat(); + hw_ostc3_device_config_write(m_data->device, 0x33, data, sizeof(data)); + break; - switch (dc_device_get_type(data->device)) { - case DC_FAMILY_HW_OSTC3: - rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname); - if (rc == DC_STATUS_SUCCESS) { - - } else { - lastError = tr("Could not a establish connection to the dive computer."); - emit error(lastError); } - break; + dc_device_close(m_data->device); if (!supported) { lastError = tr("This feature is not yet available for the selected dive computer."); emit error(lastError); } } + else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } } diff --git a/qt-ui/configuredivecomputerthreads.h b/qt-ui/configuredivecomputerthreads.h index c684cddaa..db54db460 100644 --- a/qt-ui/configuredivecomputerthreads.h +++ b/qt-ui/configuredivecomputerthreads.h @@ -11,31 +11,29 @@ class ReadSettingsThread : public QThread { Q_OBJECT public: - ReadSettingsThread(QObject *parent, DeviceDetails *deviceDetails, device_data_t *data); + ReadSettingsThread(QObject *parent, device_data_t *data); virtual void run(); QString result; QString lastError; signals: void error(QString err); + void devicedetails(DeviceDetails *newDeviceDetails); private: - DeviceDetails *m_deviceDetails; device_data_t *m_data; }; class WriteSettingsThread : public QThread { Q_OBJECT public: - WriteSettingsThread(QObject *parent, DeviceDetails *deviceDetails, QString settingName, QVariant settingValue); + WriteSettingsThread(QObject *parent, device_data_t *data); + void setDeviceDetails(DeviceDetails *details); virtual void run(); QString result; QString lastError; signals: void error(QString err); private: - device_data_t *data; - QString m_settingName; - QVariant m_settingValue; - + device_data_t *m_data; DeviceDetails *m_deviceDetails; }; From 3534e29ae2165aab491c2e0cdecd667dd8cf50e8 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 18:37:37 +0300 Subject: [PATCH 11/33] Port writing of date and time to new classes After splitting dive computer configuration classes, the date/time setting had not been ported. This adds the same to the classes. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 1 + qt-ui/configuredivecomputerdialog.ui | 95 ++++++++++++++------------ qt-ui/configuredivecomputerthreads.cpp | 15 ++++ qt-ui/devicedetails.cpp | 10 +++ qt-ui/devicedetails.h | 4 ++ 5 files changed, 81 insertions(+), 44 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index ea5e764dc..973243af7 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -204,6 +204,7 @@ void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); getDeviceData(); config->saveDeviceDetails(deviceDetails, &device_data); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 4f1c7a8af..580f86159 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 343 - 390 + 364 + 416 @@ -93,6 +93,41 @@ + + + + Brightness: + + + + + + + Serial No. + + + + + + + Custom Text: + + + + + + + true + + + + + + + Language: + + + @@ -146,48 +181,6 @@ - - - - Brightness: - - - - - - - true - - - - - - - Custom Text: - - - - - - - Serial No. - - - - - - - Language: - - - - - - - true - - - @@ -214,6 +207,20 @@ + + + + true + + + + + + + Sync dive computer time with PC + + + diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index 5d9f0e8b0..bddced474 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -1,6 +1,7 @@ #include "configuredivecomputerthreads.h" #include "libdivecomputer/hw.h" #include +#include ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) @@ -95,6 +96,20 @@ void WriteSettingsThread::run() hw_ostc3_device_config_write(m_data->device, 0x32, data, sizeof(data)); data[0] = m_deviceDetails->dateFormat(); hw_ostc3_device_config_write(m_data->device, 0x33, data, sizeof(data)); + + //sync date and time + if (m_deviceDetails->syncTime()) { + QDateTime timeToSet = QDateTime::currentDateTime(); + dc_datetime_t time; + time.year = timeToSet.date().year(); + time.month = timeToSet.date().month(); + time.day = timeToSet.date().day(); + time.hour = timeToSet.time().hour(); + time.minute = timeToSet.time().minute(); + time.second = timeToSet.time().second(); + hw_ostc3_device_clock(m_data->device, &time); + } + break; } diff --git a/qt-ui/devicedetails.cpp b/qt-ui/devicedetails.cpp index e5a90b9da..7d6212f18 100644 --- a/qt-ui/devicedetails.cpp +++ b/qt-ui/devicedetails.cpp @@ -86,3 +86,13 @@ void DeviceDetails::setLastDeco(int lastDeco) { m_lastDeco = lastDeco; } +bool DeviceDetails::syncTime() const +{ + return m_syncTime; +} + +void DeviceDetails::setSyncTime(bool syncTime) +{ + m_syncTime = syncTime; +} + diff --git a/qt-ui/devicedetails.h b/qt-ui/devicedetails.h index 9f5e7c1dd..a0d0f18c2 100644 --- a/qt-ui/devicedetails.h +++ b/qt-ui/devicedetails.h @@ -38,6 +38,9 @@ public: int lastDeco() const; void setLastDeco(int lastDeco); + bool syncTime() const; + void setSyncTime(bool syncTime); + private: device_data_t *m_data; QString m_serialNo; @@ -48,6 +51,7 @@ private: int m_language; int m_dateFormat; int m_lastDeco; + bool m_syncTime; }; From e54d7d9178fc159f068587a59244340bec068efb Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 19:19:28 +0300 Subject: [PATCH 12/33] Backup basic settings as XML This patch enables XML backup. We can now save the settings to an XML file. Currently this backs up just the basic stuff such as custom text, language and brightness. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 32 +++++++++++++++++++ qt-ui/configuredivecomputer.h | 2 +- qt-ui/configuredivecomputerdialog.cpp | 46 ++++++++++++++++++++++----- qt-ui/configuredivecomputerdialog.h | 3 ++ qt-ui/configuredivecomputerdialog.ui | 18 +++++++++-- 5 files changed, 90 insertions(+), 11 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index ad431eefe..0d602c8e8 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -1,6 +1,8 @@ #include "configuredivecomputer.h" #include "libdivecomputer/hw.h" #include +#include + ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), readThread(0), @@ -42,6 +44,36 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat writeThread->start(); } +bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText) +{ + QString xml = ""; + QString vendor = data->vendor; + QString product = data->product; + xml += ""; + xml += "\n"; + xml += "\n"; + xml += "\n"; + xml += "\n"; + xml += "\n"; + xml += "\n"; + xml += "\n"; + xml += "\n"; + QFile file(fileName); + if (!file.open(QIODevice::WriteOnly)) { + errorText = tr("Could not save the backup file %1. Error Message: %2") + .arg(fileName, file.errorString()); + return false; + } + //file open successful. write data and save. + QTextStream out(&file); + out << xml; + + file.close(); + return true; +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index f21f02910..ca072e148 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -30,7 +30,7 @@ public: device_data_t *m_data; void saveDeviceDetails(DeviceDetails *details, device_data_t *data); void fetchDeviceDetails(); - + bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText); signals: void message(QString msg); void error(QString err); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 973243af7..71960b6f2 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -7,9 +7,8 @@ #include "../display.h" #include "../divelist.h" #include "configuredivecomputer.h" -#include -#include - +#include +#include struct product { const char *product; dc_descriptor_t *descriptor; @@ -126,6 +125,15 @@ void ConfigureDiveComputerDialog::fill_device_list(int dc_type) ui->device->setCurrentIndex(deviceIndex); } +void ConfigureDiveComputerDialog::populateDeviceDetails() +{ + deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); + deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); + deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); + deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); +} + void ConfigureDiveComputerDialog::on_vendor_currentIndexChanged(const QString &vendor) { int dcType = DC_TYPE_SERIAL; @@ -200,11 +208,7 @@ void ConfigureDiveComputerDialog::deviceReadFinished() void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() { - deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); - deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); - deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); - deviceDetails->setCustomText(ui->customTextLlineEdit->text()); - deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); + populateDeviceDetails(); getDeviceData(); config->saveDeviceDetails(deviceDetails, &device_data); } @@ -225,3 +229,29 @@ void ConfigureDiveComputerDialog::reloadValues() ui->dateFormatComboBox->setCurrentIndex(deviceDetails->dateFormat()); } + +void ConfigureDiveComputerDialog::on_backupButton_clicked() +{ + QString filename = existing_filename ?: prefs.default_filename; + QFileInfo fi(filename); + filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml"); + QString backupPath = QFileDialog::getSaveFileName(this, tr("Backup Dive Computer Settings"), + filename, tr("Backup files (*.xml)") + ); + if (!backupPath.isEmpty()) { + populateDeviceDetails(); + getDeviceData(); + QString errorText = ""; + if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) { + QMessageBox::critical(this, tr("XML Backup Error"), + tr("An eror occurred while saving the backup file.\n%1") + .arg(errorText) + ); + } else { + QMessageBox::information(this, tr("Backup succeeded"), + tr("Your settings have been saved to: %1") + .arg(filename) + ); + } + } +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index e8c941fcf..7312deec7 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -31,6 +31,8 @@ private slots: void on_saveSettingsPushButton_clicked(); void deviceDetailsReceived(DeviceDetails *newDeviceDetails); void reloadValues(); + void on_backupButton_clicked(); + private: Ui::ConfigureDiveComputerDialog *ui; @@ -48,6 +50,7 @@ private: void fill_device_list(int dc_type); DeviceDetails *deviceDetails; + void populateDeviceDetails(); }; #endif // CONFIGUREDIVECOMPUTERDIALOG_H diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 580f86159..4fb731a3c 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 364 - 416 + 472 + 472 @@ -89,6 +89,20 @@ + + + + Backup + + + + + + + Restore Backup + + + From aad60ef6da3308960767a47cb750c2ba9aab54bd Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 09:37:27 +0300 Subject: [PATCH 13/33] Working XML Backup and Restore The ConfigureDiveComputer class now has functions for complete XML backup and restore. These dump the loaded settings on a dive computer to an XML file, and there is an option to restore them. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 93 +++++++++++++++++++++++---- qt-ui/configuredivecomputer.h | 5 +- qt-ui/configuredivecomputerdialog.cpp | 28 +++++++- qt-ui/configuredivecomputerdialog.h | 2 + 4 files changed, 115 insertions(+), 13 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index 0d602c8e8..72f2427d4 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -2,6 +2,11 @@ #include "libdivecomputer/hw.h" #include #include +#include +#include +#include +#include +#include ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), @@ -49,17 +54,18 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai QString xml = ""; QString vendor = data->vendor; QString product = data->product; - xml += ""; - xml += "\n"; - xml += "\n"; - xml += "\n"; - xml += "\n"; - xml += "\n"; - xml += "\n"; - xml += "\n"; - xml += "\n"; + xml += ""; + xml += "\n"; + xml += addSettingToXML("Vendor", vendor); + xml += addSettingToXML("Product", product); + xml += "\n"; + xml += "\n"; + xml += addSettingToXML("CustomText", details->customText()); + xml += addSettingToXML("Brightness", details->brightness()); + xml += addSettingToXML("Language", details->language()); + xml += addSettingToXML("DateFormat", details->dateFormat()); + xml += "\n"; + xml += "\n"; QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { errorText = tr("Could not save the backup file %1. Error Message: %2") @@ -74,12 +80,77 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai return true; } +bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText) +{ + xmlDocPtr doc; + xmlNodePtr node; + xmlChar *key; + + doc = xmlParseFile(fileName.toUtf8().data()); + + if (doc == NULL) { + errorText = tr("Could not read the backup file."); + return false; + } + + node = xmlDocGetRootElement(doc); + if (node == NULL) { + errorText = tr("The specified file is invalid."); + xmlFreeDoc(doc); + return false; + } + + if (xmlStrcmp(node->name, (const xmlChar *) "DiveComputerSettingsBackup")) { + errorText = tr("The specified file does not contain a valid backup."); + xmlFreeDoc(doc); + return false; + } + + xmlNodePtr child = node->children; + + while (child != NULL) { + QString nodeName = (char *)child->name; + if (nodeName == "Settings") { + xmlNodePtr settingNode = child->children; + while (settingNode != NULL) { + QString settingName = (char *)settingNode->name; + key = xmlNodeListGetString(doc, settingNode->xmlChildrenNode, 1); + QString keyString = (char *)key; + if (settingName != "text") { + if (settingName == "CustomText") + details->setCustomText(keyString); + + if (settingName == "Brightness") + details->setBrightness(keyString.toInt()); + + if (settingName == "Language") + details->setLanguage(keyString.toInt()); + + if (settingName == "DateFormat") + details->setDateFormat(keyString.toInt()); + } + + settingNode = settingNode->next; + } + } + child = child->next; + } + + return true; +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; emit stateChanged(currentState); } + +QString ConfigureDiveComputer::addSettingToXML(QString settingName, QVariant value) +{ + return "\n<" + settingName + ">" + value.toString() + ""; +} + void ConfigureDiveComputer::setError(QString err) { lastError = err; diff --git a/qt-ui/configuredivecomputer.h b/qt-ui/configuredivecomputer.h index ca072e148..31c0cb756 100644 --- a/qt-ui/configuredivecomputer.h +++ b/qt-ui/configuredivecomputer.h @@ -8,6 +8,8 @@ #include "configuredivecomputerthreads.h" #include +#include "libxml/xmlreader.h" + class ConfigureDiveComputer : public QObject { Q_OBJECT @@ -31,6 +33,7 @@ public: void saveDeviceDetails(DeviceDetails *details, device_data_t *data); void fetchDeviceDetails(); bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText); + bool restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText); signals: void message(QString msg); void error(QString err); @@ -43,7 +46,7 @@ private: ReadSettingsThread *readThread; WriteSettingsThread *writeThread; void setState(states newState); - + QString addSettingToXML(QString settingName, QVariant value); private slots: void readThreadFinished(); void writeThreadFinished(); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 71960b6f2..2f8771ed7 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -244,7 +244,7 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked() QString errorText = ""; if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) { QMessageBox::critical(this, tr("XML Backup Error"), - tr("An eror occurred while saving the backup file.\n%1") + tr("An error occurred while saving the backup file.\n%1") .arg(errorText) ); } else { @@ -255,3 +255,29 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked() } } } + +void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked() +{ + QString filename = existing_filename ?: prefs.default_filename; + QFileInfo fi(filename); + filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml"); + QString restorePath = QFileDialog::getOpenFileName(this, tr("Restore Dive Computer Settings"), + filename, tr("Backup files (*.xml)") + ); + if (!restorePath.isEmpty()) { + QString errorText = ""; + if (!config->restoreXMLBackup(restorePath, deviceDetails, errorText)) { + QMessageBox::critical(this, tr("XML Restore Error"), + tr("An error occurred while restoring the backup file.\n%1") + .arg(errorText) + ); + } else { + reloadValues(); + //getDeviceData(); + //config->saveDeviceDetails(deviceDetails, &device_data); + QMessageBox::information(this, tr("Restore succeeded"), + tr("Your settings have been restored successfully.") + ); + } + } +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 7312deec7..ee1eb4c99 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -33,6 +33,8 @@ private slots: void reloadValues(); void on_backupButton_clicked(); + void on_restoreBackupButton_clicked(); + private: Ui::ConfigureDiveComputerDialog *ui; From 09ec8a44e5c48b6b6a2e4ebb1253fd3cd94154ae Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 11:09:01 +0300 Subject: [PATCH 14/33] Add Support for more OSTC 3 Settings Adds support for more OSTC 3 Settings to the reading, writing, backup and restore functions. These settings are: last deco, units, sampling rate, salinity, dive mode colour and compass gain. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 24 ++ qt-ui/configuredivecomputerdialog.cpp | 14 +- qt-ui/configuredivecomputerdialog.ui | 291 ++++++++++++++---- qt-ui/configuredivecomputerthreads.cpp | 61 ++++ qt-ui/devicedetails.cpp | 389 +++++++++++++++++++++++++ qt-ui/devicedetails.h | 148 +++++++++- 6 files changed, 867 insertions(+), 60 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index 72f2427d4..c88534e9f 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -61,9 +61,15 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai xml += "\n"; xml += "\n"; xml += addSettingToXML("CustomText", details->customText()); + xml += addSettingToXML("LastDeco", details->lastDeco()); xml += addSettingToXML("Brightness", details->brightness()); + xml += addSettingToXML("Units", details->units()); + xml += addSettingToXML("SamplingRate", details->samplingRate()); + xml += addSettingToXML("Salinity", details->salinity()); + xml += addSettingToXML("DiveModeColor", details->diveModeColor()); xml += addSettingToXML("Language", details->language()); xml += addSettingToXML("DateFormat", details->dateFormat()); + xml += addSettingToXML("CompassGain", details->compassGain()); xml += "\n"; xml += "\n"; QFile file(fileName); @@ -120,14 +126,32 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de if (settingName == "CustomText") details->setCustomText(keyString); + if (settingName == "LastDeco") + details->setLastDeco(keyString.toInt()); + if (settingName == "Brightness") details->setBrightness(keyString.toInt()); + if (settingName == "Units") + details->setUnits(keyString.toInt()); + + if (settingName == "SamplingRate") + details->setSamplingRate(keyString.toInt()); + + if (settingName == "Salinity") + details->setSalinity(keyString.toInt()); + + if (settingName == "DiveModeColour") + details->setDiveModeColor(keyString.toInt()); + if (settingName == "Language") details->setLanguage(keyString.toInt()); if (settingName == "DateFormat") details->setDateFormat(keyString.toInt()); + + if (settingName == "CompassGain") + details->setCompassGain(keyString.toInt()); } settingNode = settingNode->next; diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 2f8771ed7..c50306f1a 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -127,10 +127,16 @@ void ConfigureDiveComputerDialog::fill_device_list(int dc_type) void ConfigureDiveComputerDialog::populateDeviceDetails() { + deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setLastDeco(ui->lastDecoSpinBox->value()); deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); + deviceDetails->setUnits(ui->unitsComboBox->currentIndex()); + deviceDetails->setSamplingRate(ui->samplingRateComboBox->currentIndex()); + deviceDetails->setSalinity(ui->salinitySpinBox->value()); + deviceDetails->setDiveModeColor(ui->diveModeColour->currentIndex()); deviceDetails->setLanguage(ui->languageComboBox->currentIndex()); deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); - deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setCompassGain(ui->compassGainComboBox->currentIndex()); deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); } @@ -224,9 +230,15 @@ void ConfigureDiveComputerDialog::reloadValues() ui->serialNoLineEdit->setText(deviceDetails->serialNo()); ui->firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion()); ui->customTextLlineEdit->setText(deviceDetails->customText()); + ui->lastDecoSpinBox->setValue(deviceDetails->lastDeco()); ui->brightnessComboBox->setCurrentIndex(deviceDetails->brightness()); + ui->unitsComboBox->setCurrentIndex(deviceDetails->units()); + ui->samplingRateComboBox->setCurrentIndex(deviceDetails->samplingRate()); + ui->salinitySpinBox->setValue(deviceDetails->salinity()); + ui->diveModeColour->setCurrentIndex(deviceDetails->diveModeColor()); ui->languageComboBox->setCurrentIndex(deviceDetails->language()); ui->dateFormatComboBox->setCurrentIndex(deviceDetails->dateFormat()); + ui->compassGainComboBox->setCurrentIndex(deviceDetails->compassGain()); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 4fb731a3c..e117db644 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 472 - 472 + 629 + 496 @@ -76,6 +76,13 @@ + + + + Save Chages to Device + + + @@ -107,24 +114,55 @@ - + + + + Custom Text: + + + + + + + Sampling Rate: + + + + Brightness: - - + + - Serial No. + Salinity (0-5%): - - + + - Custom Text: + Sync dive computer time with PC + + + + + + + % + + + 5 + + + + + + + m @@ -135,17 +173,42 @@ - + + + + Last Deco: + + + + + + + Serial No. + + + + Language: - - + + + + + m/°C + + + + + ft/°F + + + - + @@ -164,14 +227,26 @@ - - - - Firmware Version: - + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + - + @@ -195,32 +270,6 @@ - - - - Date Format: - - - - - - - - MMDDYY - - - - - DDMMYY - - - - - YYMMDD - - - - @@ -228,13 +277,139 @@ - - + + - Sync dive computer time with PC + Date Format: + + + + Firmware Version: + + + + + + + + 1 + 0 + + + + + + + + Units: + + + + + + + + 2s + + + + + 10s + + + + + + + + Dive Mode Colour: + + + + + + + + Standard + + + + + Red + + + + + Green + + + + + Blue + + + + + + + + Compass Gain: + + + + + + + + 1 + 0 + + + + + 230LSB/Gauss + + + + + 330LSB/Gauss + + + + + 390LSB/Gauss + + + + + 440LSB/Gauss + + + + + 660LSB/Gauss + + + + + 820LSB/Gauss + + + + + 1090LSB/Gauss + + + + + 1370LSB/Gauss + + + + @@ -269,13 +444,6 @@ - - - - Save Chages to Device - - - @@ -306,12 +474,21 @@ device search retrieveDetails + backupButton + restoreBackupButton serialNoLineEdit firmwareVersionLineEdit customTextLlineEdit - brightnessComboBox languageComboBox - saveSettingsPushButton + lastDecoSpinBox + brightnessComboBox + dateFormatComboBox + unitsComboBox + samplingRateComboBox + salinitySpinBox + diveModeColour + compassGainComboBox + dateTimeSyncCheckBox cancel diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index bddced474..369640459 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -27,18 +27,47 @@ void ReadSettingsThread::run() m_deviceDetails->setLanguage(0); m_deviceDetails->setLastDeco(0); m_deviceDetails->setSerialNo(""); + m_deviceDetails->setCompassGain(0); + m_deviceDetails->setSalinity(0); + m_deviceDetails->setSamplingRate(0); + m_deviceDetails->setUnits(0); + //Read general settings unsigned char uData[1] = {0}; + //LastDeco + rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setLastDeco(uData[0]); + //Brightness rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setBrightness(uData[0]); + //Units + rc = hw_ostc3_device_config_read(m_data->device, 0x2E, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setUnits(uData[0]); + //Sampling Rate + rc = hw_ostc3_device_config_read(m_data->device, 0x2F, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setSamplingRate(uData[0]); + //Salinity + rc = hw_ostc3_device_config_read(m_data->device, 0x30, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setSalinity(uData[0]); + //Dive mode colour + rc = hw_ostc3_device_config_read(m_data->device, 0x31, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setDiveModeColor(uData[0]); + //Language rc = hw_ostc3_device_config_read(m_data->device, 0x32, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setLanguage(uData[0]); + //Date Format rc = hw_ostc3_device_config_read(m_data->device, 0x33, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setDateFormat(uData[0]); + //read firmware settings unsigned char fData[64] = {0}; rc = hw_ostc3_device_version (m_data->device, fData, sizeof (fData)); @@ -88,15 +117,47 @@ void WriteSettingsThread::run() case DC_FAMILY_HW_OSTC3: supported = true; //write general settings + + //custom text hw_ostc3_device_customtext(m_data->device, m_deviceDetails->customText().toUtf8().data()); unsigned char data[1] = {0}; + + //last deco + data[0] = m_deviceDetails->lastDeco(); + hw_ostc3_device_config_write(m_data->device, 0x2C, data, sizeof(data)); + + //brightness data[0] = m_deviceDetails->brightness(); hw_ostc3_device_config_write(m_data->device, 0x2D, data, sizeof(data)); + + //units + data[0] = m_deviceDetails->units(); + hw_ostc3_device_config_write(m_data->device, 0x2E, data, sizeof(data)); + + //sampling rate + data[0] = m_deviceDetails->samplingRate(); + hw_ostc3_device_config_write(m_data->device, 0x2F, data, sizeof(data)); + + //salinity + data[0] = m_deviceDetails->salinity(); + hw_ostc3_device_config_write(m_data->device, 0x30, data, sizeof(data)); + + //dive mode colour + data[0] = m_deviceDetails->diveModeColor(); + hw_ostc3_device_config_write(m_data->device, 0x31, data, sizeof(data)); + + //language data[0] = m_deviceDetails->language(); hw_ostc3_device_config_write(m_data->device, 0x32, data, sizeof(data)); + + //date format data[0] = m_deviceDetails->dateFormat(); hw_ostc3_device_config_write(m_data->device, 0x33, data, sizeof(data)); + //compass gain + data[0] = m_deviceDetails->compassGain(); + hw_ostc3_device_config_write(m_data->device, 0x34, data, sizeof(data)); + //sync date and time if (m_deviceDetails->syncTime()) { QDateTime timeToSet = QDateTime::currentDateTime(); diff --git a/qt-ui/devicedetails.cpp b/qt-ui/devicedetails.cpp index 7d6212f18..db95cfd41 100644 --- a/qt-ui/devicedetails.cpp +++ b/qt-ui/devicedetails.cpp @@ -5,6 +5,7 @@ DeviceDetails::DeviceDetails(QObject *parent) : { } + device_data_t *DeviceDetails::data() const { return m_data; @@ -14,6 +15,7 @@ void DeviceDetails::setData(device_data_t *data) { m_data = data; } + QString DeviceDetails::serialNo() const { return m_serialNo; @@ -23,6 +25,7 @@ void DeviceDetails::setSerialNo(const QString &serialNo) { m_serialNo = serialNo; } + QString DeviceDetails::firmwareVersion() const { return m_firmwareVersion; @@ -32,6 +35,7 @@ void DeviceDetails::setFirmwareVersion(const QString &firmwareVersion) { m_firmwareVersion = firmwareVersion; } + QString DeviceDetails::customText() const { return m_customText; @@ -41,6 +45,7 @@ void DeviceDetails::setCustomText(const QString &customText) { m_customText = customText; } + int DeviceDetails::brightness() const { return m_brightness; @@ -50,6 +55,7 @@ void DeviceDetails::setBrightness(int brightness) { m_brightness = brightness; } + int DeviceDetails::diveModeColor() const { return m_diveModeColor; @@ -59,6 +65,7 @@ void DeviceDetails::setDiveModeColor(int diveModeColor) { m_diveModeColor = diveModeColor; } + int DeviceDetails::language() const { return m_language; @@ -68,6 +75,7 @@ void DeviceDetails::setLanguage(int language) { m_language = language; } + int DeviceDetails::dateFormat() const { return m_dateFormat; @@ -77,6 +85,7 @@ void DeviceDetails::setDateFormat(int dateFormat) { m_dateFormat = dateFormat; } + int DeviceDetails::lastDeco() const { return m_lastDeco; @@ -86,6 +95,7 @@ void DeviceDetails::setLastDeco(int lastDeco) { m_lastDeco = lastDeco; } + bool DeviceDetails::syncTime() const { return m_syncTime; @@ -95,4 +105,383 @@ void DeviceDetails::setSyncTime(bool syncTime) { m_syncTime = syncTime; } + +gas DeviceDetails::gas1() const +{ + return m_gas1; +} + +void DeviceDetails::setGas1(const gas &gas1) +{ + m_gas1 = gas1; +} + +gas DeviceDetails::gas2() const +{ + return m_gas2; +} + +void DeviceDetails::setGas2(const gas &gas2) +{ + m_gas2 = gas2; +} + +gas DeviceDetails::gas3() const +{ + return m_gas3; +} + +void DeviceDetails::setGas3(const gas &gas3) +{ + m_gas3 = gas3; +} + +gas DeviceDetails::gas4() const +{ + return m_gas4; +} + +void DeviceDetails::setGas4(const gas &gas4) +{ + m_gas4 = gas4; +} + +gas DeviceDetails::gas5() const +{ + return m_gas5; +} + +void DeviceDetails::setGas5(const gas &gas5) +{ + m_gas5 = gas5; +} + +gas DeviceDetails::dil1() const +{ + return m_dil1; +} + +void DeviceDetails::setDil1(const gas &dil1) +{ + m_dil1 = dil1; +} + +gas DeviceDetails::dil2() const +{ + return m_dil2; +} + +void DeviceDetails::setDil2(const gas &dil2) +{ + m_dil2 = dil2; +} + +gas DeviceDetails::dil3() const +{ + return m_dil3; +} + +void DeviceDetails::setDil3(const gas &dil3) +{ + m_dil3 = dil3; +} + +gas DeviceDetails::dil4() const +{ + return m_dil4; +} + +void DeviceDetails::setDil4(const gas &dil4) +{ + m_dil4 = dil4; +} + +gas DeviceDetails::dil5() const +{ + return m_dil5; +} + +void DeviceDetails::setDil5(const gas &dil5) +{ + m_dil5 = dil5; +} + +setpoint DeviceDetails::sp1() const +{ + return m_sp1; +} + +void DeviceDetails::setSp1(const setpoint &sp1) +{ + m_sp1 = sp1; +} + +setpoint DeviceDetails::sp2() const +{ + return m_sp2; +} + +void DeviceDetails::setSp2(const setpoint &sp2) +{ + m_sp2 = sp2; +} + +setpoint DeviceDetails::sp3() const +{ + return m_sp3; +} + +void DeviceDetails::setSp3(const setpoint &sp3) +{ + m_sp3 = sp3; +} + +setpoint DeviceDetails::sp4() const +{ + return m_sp4; +} + +void DeviceDetails::setSp4(const setpoint &sp4) +{ + m_sp4 = sp4; +} + +setpoint DeviceDetails::sp5() const +{ + return m_sp5; +} + +void DeviceDetails::setSp5(const setpoint &sp5) +{ + m_sp5 = sp5; +} + +int DeviceDetails::ccrMode() const +{ + return m_ccrMode; +} + +void DeviceDetails::setCcrMode(int ccrMode) +{ + m_ccrMode = ccrMode; +} + +int DeviceDetails::diveMode() const +{ + return m_diveMode; +} + +void DeviceDetails::setDiveMode(int diveMode) +{ + m_diveMode = diveMode; +} + +int DeviceDetails::decoType() const +{ + return m_decoType; +} + +void DeviceDetails::setDecoType(int decoType) +{ + m_decoType = decoType; +} + +int DeviceDetails::pp02Max() const +{ + return m_pp02Max; +} + +void DeviceDetails::setPp02Max(int pp02Max) +{ + m_pp02Max = pp02Max; +} + +int DeviceDetails::pp02Min() const +{ + return m_pp02Min; +} + +void DeviceDetails::setPp02Min(int pp02Min) +{ + m_pp02Min = pp02Min; +} + +int DeviceDetails::futureTTS() const +{ + return m_futureTTS; +} + +void DeviceDetails::setFutureTTS(int futureTTS) +{ + m_futureTTS = futureTTS; +} + +int DeviceDetails::gfLow() const +{ + return m_gfLow; +} + +void DeviceDetails::setGfLow(int gfLow) +{ + m_gfLow = gfLow; +} + +int DeviceDetails::gfHigh() const +{ + return m_gfHigh; +} + +void DeviceDetails::setGfHigh(int gfHigh) +{ + m_gfHigh = gfHigh; +} + +int DeviceDetails::aGFLow() const +{ + return m_aGFLow; +} + +void DeviceDetails::setAGFLow(int aGFLow) +{ + m_aGFLow = aGFLow; +} + +int DeviceDetails::aGFHigh() const +{ + return m_aGFHigh; +} + +void DeviceDetails::setAGFHigh(int aGFHigh) +{ + m_aGFHigh = aGFHigh; +} + +int DeviceDetails::aGFSelectable() const +{ + return m_aGFSelectable; +} + +void DeviceDetails::setAGFSelectable(int aGFSelectable) +{ + m_aGFSelectable = aGFSelectable; +} + +int DeviceDetails::saturation() const +{ + return m_saturation; +} + +void DeviceDetails::setSaturation(int saturation) +{ + m_saturation = saturation; +} + +int DeviceDetails::desaturation() const +{ + return m_desaturation; +} + +void DeviceDetails::setDesaturation(int desaturation) +{ + m_desaturation = desaturation; +} + +int DeviceDetails::units() const +{ + return m_units; +} + +void DeviceDetails::setUnits(int units) +{ + m_units = units; +} + +int DeviceDetails::samplingRate() const +{ + return m_samplingRate; +} + +void DeviceDetails::setSamplingRate(int samplingRate) +{ + m_samplingRate = samplingRate; +} + +int DeviceDetails::salinity() const +{ + return m_salinity; +} + +void DeviceDetails::setSalinity(int salinity) +{ + m_salinity = salinity; +} + +int DeviceDetails::compassGain() const +{ + return m_compassGain; +} + +void DeviceDetails::setCompassGain(int compassGain) +{ + m_compassGain = compassGain; +} + +int DeviceDetails::pressureSensorOffset() const +{ + return m_pressureSensorOffset; +} + +void DeviceDetails::setPressureSensorOffset(int pressureSensorOffset) +{ + m_pressureSensorOffset = pressureSensorOffset; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt-ui/devicedetails.h b/qt-ui/devicedetails.h index a0d0f18c2..d754e9774 100644 --- a/qt-ui/devicedetails.h +++ b/qt-ui/devicedetails.h @@ -5,6 +5,18 @@ #include #include "libdivecomputer.h" +struct gas { + int oxygen; + int helium; + int type; + int depth; +}; + +struct setpoint { + int sp; + int depth; +}; + class DeviceDetails : public QObject { Q_OBJECT @@ -41,17 +53,149 @@ public: bool syncTime() const; void setSyncTime(bool syncTime); + gas gas1() const; + void setGas1(const gas &gas1); + + gas gas2() const; + void setGas2(const gas &gas2); + + gas gas3() const; + void setGas3(const gas &gas3); + + gas gas4() const; + void setGas4(const gas &gas4); + + gas gas5() const; + void setGas5(const gas &gas5); + + gas dil1() const; + void setDil1(const gas &dil1); + + gas dil2() const; + void setDil2(const gas &dil2); + + gas dil3() const; + void setDil3(const gas &dil3); + + gas dil4() const; + void setDil4(const gas &dil4); + + gas dil5() const; + void setDil5(const gas &dil5); + + setpoint sp1() const; + void setSp1(const setpoint &sp1); + + setpoint sp2() const; + void setSp2(const setpoint &sp2); + + setpoint sp3() const; + void setSp3(const setpoint &sp3); + + setpoint sp4() const; + void setSp4(const setpoint &sp4); + + setpoint sp5() const; + void setSp5(const setpoint &sp5); + + int ccrMode() const; + void setCcrMode(int ccrMode); + + int diveMode() const; + void setDiveMode(int diveMode); + + int decoType() const; + void setDecoType(int decoType); + + int pp02Max() const; + void setPp02Max(int pp02Max); + + int pp02Min() const; + void setPp02Min(int pp02Min); + + int futureTTS() const; + void setFutureTTS(int futureTTS); + + int gfLow() const; + void setGfLow(int gfLow); + + int gfHigh() const; + void setGfHigh(int gfHigh); + + int aGFLow() const; + void setAGFLow(int aGFLow); + + int aGFHigh() const; + void setAGFHigh(int aGFHigh); + + int aGFSelectable() const; + void setAGFSelectable(int aGFSelectable); + + int saturation() const; + void setSaturation(int saturation); + + int desaturation() const; + void setDesaturation(int desaturation); + + int units() const; + void setUnits(int units); + + int samplingRate() const; + void setSamplingRate(int samplingRate); + + int salinity() const; + void setSalinity(int salinity); + + int compassGain() const; + void setCompassGain(int compassGain); + + int pressureSensorOffset() const; + void setPressureSensorOffset(int pressureSensorOffset); + private: device_data_t *m_data; QString m_serialNo; QString m_firmwareVersion; QString m_customText; + bool m_syncTime; + gas m_gas1; + gas m_gas2; + gas m_gas3; + gas m_gas4; + gas m_gas5; + gas m_dil1; + gas m_dil2; + gas m_dil3; + gas m_dil4; + gas m_dil5; + setpoint m_sp1; + setpoint m_sp2; + setpoint m_sp3; + setpoint m_sp4; + setpoint m_sp5; + int m_ccrMode; + int m_diveMode; + int m_decoType; + int m_pp02Max; + int m_pp02Min; + int m_futureTTS; + int m_gfLow; + int m_gfHigh; + int m_aGFLow; + int m_aGFHigh; + int m_aGFSelectable; + int m_saturation; + int m_desaturation; + int m_lastDeco; int m_brightness; + int m_units; + int m_samplingRate; + int m_salinity; int m_diveModeColor; int m_language; int m_dateFormat; - int m_lastDeco; - bool m_syncTime; + int m_compassGain; + int m_pressureSensorOffset; }; From 8ccf2e8f1d05fb34854ce5f5de935d523484e163 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 11:47:25 +0300 Subject: [PATCH 15/33] Change ConfigureDiveComputerDialog to use tabbed interface Changes the dive computer configuration dialog to use a tabbed interface. This will make it easier to add new dive computer models to the interface. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 108 ++--- qt-ui/configuredivecomputerdialog.h | 19 +- qt-ui/configuredivecomputerdialog.ui | 662 +++++++++++++------------- 3 files changed, 374 insertions(+), 415 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index c50306f1a..d9cee9229 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -32,8 +32,6 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigureDiveComputerDialog), config(0), - vendorModel(0), - productModel(0), deviceDetails(0) { ui->setupUi(this); @@ -45,24 +43,14 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : connect (config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); connect (config, SIGNAL(deviceDetailsChanged(DeviceDetails*)), this, SLOT(deviceDetailsReceived(DeviceDetails*))); + connect (ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); + memset(&device_data, 0, sizeof(device_data)); fill_computer_list(); - - vendorModel = new QStringListModel(vendorList); - ui->vendor->setModel(vendorModel); - if (default_dive_computer_vendor) { - ui->vendor->setCurrentIndex(ui->vendor->findText(default_dive_computer_vendor)); - productModel = new QStringListModel(productList[default_dive_computer_vendor]); - ui->product->setModel(productModel); - if (default_dive_computer_product) - ui->product->setCurrentIndex(ui->product->findText(default_dive_computer_product)); - } if (default_dive_computer_device) ui->device->setEditText(default_dive_computer_device); - memset(&device_data, 0, sizeof(device_data)); - - connect (ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); + on_tabWidget_currentChanged(0); } ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() @@ -70,6 +58,22 @@ ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() delete ui; } + +static void fillDeviceList(const char *name, void *data) +{ + QComboBox *comboBox = (QComboBox *)data; + comboBox->addItem(name); +} + +void ConfigureDiveComputerDialog::fill_device_list(int dc_type) +{ + int deviceIndex; + ui->device->clear(); + deviceIndex = enumerate_devices(fillDeviceList, ui->device, dc_type); + if (deviceIndex >= 0) + ui->device->setCurrentIndex(deviceIndex); +} + void ConfigureDiveComputerDialog::fill_computer_list() { dc_iterator_t *iterator = NULL; @@ -77,7 +81,6 @@ void ConfigureDiveComputerDialog::fill_computer_list() struct mydescriptor *mydescriptor; - QStringList computer; dc_descriptor_iterator(&iterator); while (dc_iterator_next(iterator, &descriptor) == DC_STATUS_SUCCESS) { const char *vendor = dc_descriptor_get_vendor(descriptor); @@ -110,21 +113,6 @@ void ConfigureDiveComputerDialog::fill_computer_list() qSort(vendorList); } -static void fillDeviceList(const char *name, void *data) -{ - QComboBox *comboBox = (QComboBox *)data; - comboBox->addItem(name); -} - -void ConfigureDiveComputerDialog::fill_device_list(int dc_type) -{ - int deviceIndex; - ui->device->clear(); - deviceIndex = enumerate_devices(fillDeviceList, ui->device, dc_type); - if (deviceIndex >= 0) - ui->device->setCurrentIndex(deviceIndex); -} - void ConfigureDiveComputerDialog::populateDeviceDetails() { deviceDetails->setCustomText(ui->customTextLlineEdit->text()); @@ -140,36 +128,6 @@ void ConfigureDiveComputerDialog::populateDeviceDetails() deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); } -void ConfigureDiveComputerDialog::on_vendor_currentIndexChanged(const QString &vendor) -{ - int dcType = DC_TYPE_SERIAL; - QAbstractItemModel *currentModel = ui->product->model(); - if (!currentModel) - return; - - productModel = new QStringListModel(productList[vendor]); - ui->product->setModel(productModel); - - if (vendor == QString("Uemis")) - dcType = DC_TYPE_UEMIS; - fill_device_list(dcType); -} - -void ConfigureDiveComputerDialog::on_product_currentIndexChanged(const QString &product) -{ - dc_descriptor_t *descriptor = NULL; - descriptor = descriptorLookup[ui->vendor->currentText() + product]; - - // call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL - if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) { - // if the dc_transport_t is DC_TRANSPORT_SERIAL, then enable the device node box. - ui->device->setEnabled(true); - } else { - // otherwise disable the device node box - ui->device->setEnabled(false); - } -} - void ConfigureDiveComputerDialog::readSettings() { ui->statusLabel->clear(); @@ -192,13 +150,12 @@ void ConfigureDiveComputerDialog::configError(QString err) void ConfigureDiveComputerDialog::getDeviceData() { device_data.devname = strdup(ui->device->currentText().toUtf8().data()); - device_data.vendor = strdup(ui->vendor->currentText().toUtf8().data()); - device_data.product = strdup(ui->product->currentText().toUtf8().data()); + device_data.vendor = strdup(selected_vendor.toUtf8().data()); + device_data.product = strdup(selected_product.toUtf8().data()); - device_data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()]; + device_data.descriptor = descriptorLookup[selected_vendor + selected_product]; device_data.deviceid = device_data.diveid = 0; - set_default_dive_computer(device_data.vendor, device_data.product); set_default_dive_computer_device(device_data.devname); } @@ -248,8 +205,8 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked() QFileInfo fi(filename); filename = fi.absolutePath().append(QDir::separator()).append("Backup.xml"); QString backupPath = QFileDialog::getSaveFileName(this, tr("Backup Dive Computer Settings"), - filename, tr("Backup files (*.xml)") - ); + filename, tr("Backup files (*.xml)") + ); if (!backupPath.isEmpty()) { populateDeviceDetails(); getDeviceData(); @@ -293,3 +250,20 @@ void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked() } } } + +void ConfigureDiveComputerDialog::on_tabWidget_currentChanged(int index) +{ + switch (index) { + case 0: + selected_vendor = "Heinrichs Weikamp"; + selected_product = "OSTC 3"; + break; + } + + int dcType = DC_TYPE_SERIAL; + + + if (selected_vendor == QString("Uemis")) + dcType = DC_TYPE_UEMIS; + fill_device_list(dcType); +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index ee1eb4c99..de068c609 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -19,10 +19,6 @@ public: ~ConfigureDiveComputerDialog(); private slots: - void on_vendor_currentIndexChanged(const QString &vendor); - - void on_product_currentIndexChanged(const QString &product); - void readSettings(); void configMessage(QString msg); void configError(QString err); @@ -35,24 +31,27 @@ private slots: void on_restoreBackupButton_clicked(); + void on_tabWidget_currentChanged(int index); + private: Ui::ConfigureDiveComputerDialog *ui; + QStringList vendorList; + QHash productList; + ConfigureDiveComputer *config; device_data_t device_data; void getDeviceData(); - QStringList vendorList; - QHash productList; QHash descriptorLookup; - - QStringListModel *vendorModel; - QStringListModel *productModel; - void fill_computer_list(); void fill_device_list(int dc_type); + void fill_computer_list(); DeviceDetails *deviceDetails; void populateDeviceDetails(); + + QString selected_vendor; + QString selected_product; }; #endif // CONFIGUREDIVECOMPUTERDIALOG_H diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index e117db644..22bd9b563 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,38 +6,14 @@ 0 0 - 629 - 496 + 594 + 509 Configure Dive Computer - - - - - - Vendor - - - - - - - Dive Computer - - - - - - - - - - - @@ -113,317 +89,327 @@ - - - - - Custom Text: - - - - - - - Sampling Rate: - - - - - - - Brightness: - - - - - - - Salinity (0-5%): - - - - - - - Sync dive computer time with PC - - - - - - - % - - - 5 - - - - - - - m - - - - - - - true - - - - - - - Last Deco: - - - - - - - Serial No. - - - - - - - Language: - - - - - - - - m/°C - - - - - ft/°F - - - - - - - - - Eco - - - - - Medium - - - - - High - - - - - - - - - MMDDYY - - - - - DDMMYY - - - - - YYMMDD - - - - - - - - - English - - - - - German - - - - - French - - - - - Italian - - - - - - - - true - - - - - - - Date Format: - - - - - - - Firmware Version: - - - - - - - - 1 - 0 - - - - - - - - Units: - - - - - - - - 2s - - - - - 10s - - - - - - - - Dive Mode Colour: - - - - - - - - Standard - - - - - Red - - - - - Green - - - - - Blue - - - - - - - - Compass Gain: - - - - - - - - 1 - 0 - - - - - 230LSB/Gauss - - - - - 330LSB/Gauss - - - - - 390LSB/Gauss - - - - - 440LSB/Gauss - - - - - 660LSB/Gauss - - - - - 820LSB/Gauss - - - - - 1090LSB/Gauss - - - - - 1370LSB/Gauss - - - - - - - - - - Qt::Vertical + + + 0 - - - 20 - 40 - - - + + + HW OSTC 3 + + + + + + m + + + + + + + Sync dive computer time with PC + + + + + + + Units: + + + + + + + Salinity (0-5%): + + + + + + + Language: + + + + + + + Custom Text: + + + + + + + + 1 + 0 + + + + + + + + Date Format: + + + + + + + Compass Gain: + + + + + + + true + + + + + + + Last Deco: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + true + + + + + + + + Standard + + + + + Red + + + + + Green + + + + + Blue + + + + + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + + + + + + + + m/°C + + + + + ft/°F + + + + + + + + + English + + + + + German + + + + + French + + + + + Italian + + + + + + + + Brightness: + + + + + + + Serial No. + + + + + + + Dive Mode Colour: + + + + + + + Sampling Rate: + + + + + + + + Eco + + + + + Medium + + + + + High + + + + + + + + + 2s + + + + + 10s + + + + + + + + Firmware Version: + + + + + + + % + + + 5 + + + + + + + + 1 + 0 + + + + + 230LSB/Gauss + + + + + 330LSB/Gauss + + + + + 390LSB/Gauss + + + + + 440LSB/Gauss + + + + + 660LSB/Gauss + + + + + 820LSB/Gauss + + + + + 1090LSB/Gauss + + + + + 1370LSB/Gauss + + + + + + + @@ -469,13 +455,13 @@ - vendor - product device search retrieveDetails + saveSettingsPushButton backupButton restoreBackupButton + tabWidget serialNoLineEdit firmwareVersionLineEdit customTextLlineEdit From 5292bcbf2134901e3120fb15e2f85626b2ceb1ad Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 13 Jun 2014 17:10:10 +0300 Subject: [PATCH 16/33] Add more OSTC 3 settings I am adding more OSTC 3 settings as I go along. Here, I have added dive mode and saturation. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 8 +++ qt-ui/configuredivecomputerdialog.cpp | 4 ++ qt-ui/configuredivecomputerdialog.ui | 87 ++++++++++++++++++++------ qt-ui/configuredivecomputerthreads.cpp | 16 +++++ 4 files changed, 95 insertions(+), 20 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index c88534e9f..a91a48d25 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -61,6 +61,8 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai xml += "\n"; xml += "\n"; xml += addSettingToXML("CustomText", details->customText()); + xml += addSettingToXML("DiveMode", details->diveMode()); + xml += addSettingToXML("Saturation", details->saturation()); xml += addSettingToXML("LastDeco", details->lastDeco()); xml += addSettingToXML("Brightness", details->brightness()); xml += addSettingToXML("Units", details->units()); @@ -126,6 +128,12 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de if (settingName == "CustomText") details->setCustomText(keyString); + if (settingName == "Saturation") + details->setSaturation(keyString.toInt()); + + if (settingName == "DiveMode") + details->setDiveMode(keyString.toInt()); + if (settingName == "LastDeco") details->setLastDeco(keyString.toInt()); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index d9cee9229..769f2cdc8 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -116,6 +116,8 @@ void ConfigureDiveComputerDialog::fill_computer_list() void ConfigureDiveComputerDialog::populateDeviceDetails() { deviceDetails->setCustomText(ui->customTextLlineEdit->text()); + deviceDetails->setDiveMode(ui->diveModeComboBox->currentIndex()); + deviceDetails->setSaturation(ui->saturationSpinBox->value()); deviceDetails->setLastDeco(ui->lastDecoSpinBox->value()); deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); deviceDetails->setUnits(ui->unitsComboBox->currentIndex()); @@ -187,6 +189,8 @@ void ConfigureDiveComputerDialog::reloadValues() ui->serialNoLineEdit->setText(deviceDetails->serialNo()); ui->firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion()); ui->customTextLlineEdit->setText(deviceDetails->customText()); + ui->diveModeComboBox->setCurrentIndex(deviceDetails->diveMode()); + ui->saturationSpinBox->setValue(deviceDetails->saturation()); ui->lastDecoSpinBox->setValue(deviceDetails->lastDeco()); ui->brightnessComboBox->setCurrentIndex(deviceDetails->brightness()); ui->unitsComboBox->setCurrentIndex(deviceDetails->units()); diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 22bd9b563..2d8825847 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -98,28 +98,28 @@ HW OSTC 3 - + m - + Sync dive computer time with PC - + Units: - + Salinity (0-5%): @@ -150,14 +150,14 @@ - + Date Format: - + Compass Gain: @@ -171,14 +171,14 @@ - + Last Deco: - + Qt::Vertical @@ -198,7 +198,7 @@ - + @@ -222,7 +222,7 @@ - + @@ -241,7 +241,7 @@ - + @@ -279,7 +279,7 @@ - + Brightness: @@ -293,21 +293,21 @@ - + Dive Mode Colour: - + Sampling Rate: - + @@ -326,7 +326,7 @@ - + @@ -347,7 +347,7 @@ - + % @@ -357,7 +357,7 @@ - + @@ -407,6 +407,51 @@ + + + + Dive Mode: + + + + + + + + OC + + + + + CC + + + + + Gauge + + + + + Apnea + + + + + + + + Saturation: + + + + + + + % + + + @@ -455,7 +500,7 @@ - device + cancel search retrieveDetails saveSettingsPushButton @@ -466,6 +511,8 @@ firmwareVersionLineEdit customTextLlineEdit languageComboBox + diveModeComboBox + saturationSpinBox lastDecoSpinBox brightnessComboBox dateFormatComboBox @@ -475,7 +522,7 @@ diveModeColour compassGainComboBox dateTimeSyncCheckBox - cancel + device diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index 369640459..f0e2bde6e 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -34,6 +34,14 @@ void ReadSettingsThread::run() //Read general settings unsigned char uData[1] = {0}; + //DiveMode + rc = hw_ostc3_device_config_read(m_data->device, 0x20, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setDiveMode(uData[0]); + //Saturation + rc = hw_ostc3_device_config_read(m_data->device, 0x2A, uData, sizeof(uData)); + if (rc == DC_STATUS_SUCCESS) + m_deviceDetails->setSaturation(uData[0]); //LastDeco rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) @@ -122,6 +130,14 @@ void WriteSettingsThread::run() hw_ostc3_device_customtext(m_data->device, m_deviceDetails->customText().toUtf8().data()); unsigned char data[1] = {0}; + //dive mode + data[0] = m_deviceDetails->diveMode(); + hw_ostc3_device_config_write(m_data->device, 0x20, data, sizeof(data)); + + //saturation + data[0] = m_deviceDetails->saturation(); + hw_ostc3_device_config_write(m_data->device, 0x2A, data, sizeof(data)); + //last deco data[0] = m_deviceDetails->lastDeco(); hw_ostc3_device_config_write(m_data->device, 0x2C, data, sizeof(data)); From d76881cb012903a1855e53b796571e1c5e849c1a Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Mon, 16 Jun 2014 21:28:27 +0300 Subject: [PATCH 17/33] THIS COMMIT NEEDS A COMMIT MESSAGE I've moved the .pro file fixes to where it happened, so the rest of the changes need explanation now. -Thiago Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.ui | 207 ++++++++++++++------------- 1 file changed, 111 insertions(+), 96 deletions(-) diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 2d8825847..076b66fd1 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 594 - 509 + 592 + 507 @@ -98,34 +98,51 @@ HW OSTC 3 - + m - + + + + Dive Mode Colour: + + + + Sync dive computer time with PC - + Units: - + Salinity (0-5%): + + + + % + + + 5 + + + @@ -133,10 +150,10 @@ - - + + - Custom Text: + Date Format: @@ -150,14 +167,14 @@ - - + + - Date Format: + Custom Text: - + Compass Gain: @@ -171,26 +188,13 @@ - + Last Deco: - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -198,7 +202,7 @@ - + @@ -222,7 +226,20 @@ - + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -241,20 +258,6 @@ - - - - - m/°C - - - - - ft/°F - - - - @@ -279,7 +282,21 @@ - + + + + + m/°C + + + + + ft/°F + + + + + Brightness: @@ -294,20 +311,13 @@ - - - Dive Mode Colour: - - - - Sampling Rate: - + @@ -326,7 +336,7 @@ - + @@ -347,17 +357,38 @@ - - - - % - - - 5 + + + + Dive Mode: - + + + + + OC + + + + + CC + + + + + Gauge + + + + + Apnea + + + + + @@ -407,51 +438,34 @@ - - - - Dive Mode: - - - - - - - - OC - - - - - CC - - - - - Gauge - - - - - Apnea - - - - - + Saturation: - + % + + + + Desaturation: + + + + + + + % + + + @@ -500,7 +514,7 @@ - cancel + device search retrieveDetails saveSettingsPushButton @@ -513,6 +527,7 @@ languageComboBox diveModeComboBox saturationSpinBox + desaturationSpinBox lastDecoSpinBox brightnessComboBox dateFormatComboBox @@ -522,7 +537,7 @@ diveModeColour compassGainComboBox dateTimeSyncCheckBox - device + cancel From 045a6fb6b16ae402588484fb8361f15f8978bdd3 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 20 Jun 2014 07:51:32 +0300 Subject: [PATCH 18/33] Start working on GAS and DIL tables Start work for gas1-5 and dil1-5. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputer.cpp | 4 + qt-ui/configuredivecomputerdialog.cpp | 10 +- qt-ui/configuredivecomputerdialog.ui | 622 ++++++++++++++++--------- qt-ui/configuredivecomputerthreads.cpp | 25 + 4 files changed, 428 insertions(+), 233 deletions(-) diff --git a/qt-ui/configuredivecomputer.cpp b/qt-ui/configuredivecomputer.cpp index a91a48d25..01df1c744 100644 --- a/qt-ui/configuredivecomputer.cpp +++ b/qt-ui/configuredivecomputer.cpp @@ -63,6 +63,7 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai xml += addSettingToXML("CustomText", details->customText()); xml += addSettingToXML("DiveMode", details->diveMode()); xml += addSettingToXML("Saturation", details->saturation()); + xml += addSettingToXML("Desaturation", details->desaturation()); xml += addSettingToXML("LastDeco", details->lastDeco()); xml += addSettingToXML("Brightness", details->brightness()); xml += addSettingToXML("Units", details->units()); @@ -131,6 +132,9 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de if (settingName == "Saturation") details->setSaturation(keyString.toInt()); + if (settingName == "Desaturation") + details->setDesaturation(keyString.toInt()); + if (settingName == "DiveMode") details->setDiveMode(keyString.toInt()); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 769f2cdc8..ece02a3d0 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -118,6 +118,7 @@ void ConfigureDiveComputerDialog::populateDeviceDetails() deviceDetails->setCustomText(ui->customTextLlineEdit->text()); deviceDetails->setDiveMode(ui->diveModeComboBox->currentIndex()); deviceDetails->setSaturation(ui->saturationSpinBox->value()); + deviceDetails->setDesaturation(ui->desaturationSpinBox->value()); deviceDetails->setLastDeco(ui->lastDecoSpinBox->value()); deviceDetails->setBrightness(ui->brightnessComboBox->currentIndex()); deviceDetails->setUnits(ui->unitsComboBox->currentIndex()); @@ -168,7 +169,7 @@ void ConfigureDiveComputerDialog::on_cancel_clicked() void ConfigureDiveComputerDialog::deviceReadFinished() { - + ui->statusLabel->setText(tr("Dive computer details read successfully.")); } void ConfigureDiveComputerDialog::on_saveSettingsPushButton_clicked() @@ -191,6 +192,7 @@ void ConfigureDiveComputerDialog::reloadValues() ui->customTextLlineEdit->setText(deviceDetails->customText()); ui->diveModeComboBox->setCurrentIndex(deviceDetails->diveMode()); ui->saturationSpinBox->setValue(deviceDetails->saturation()); + ui->desaturationSpinBox->setValue(deviceDetails->desaturation()); ui->lastDecoSpinBox->setValue(deviceDetails->lastDeco()); ui->brightnessComboBox->setCurrentIndex(deviceDetails->brightness()); ui->unitsComboBox->setCurrentIndex(deviceDetails->units()); @@ -200,6 +202,12 @@ void ConfigureDiveComputerDialog::reloadValues() ui->languageComboBox->setCurrentIndex(deviceDetails->language()); ui->dateFormatComboBox->setCurrentIndex(deviceDetails->dateFormat()); ui->compassGainComboBox->setCurrentIndex(deviceDetails->compassGain()); + + //load gas 1 values + ui->ostc3GasTable->setItem(0,1, new QTableWidgetItem(QString::number(deviceDetails->gas1().oxygen))); + ui->ostc3GasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); + ui->ostc3GasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); + ui->ostc3GasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 076b66fd1..6099535e8 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 592 - 507 + 701 + 620 @@ -98,62 +98,38 @@ HW OSTC 3 - - - - m - - - - - + + - Dive Mode Colour: + Serial No. - - + + + + true + + + + + - Sync dive computer time with PC + Firmware Version: - - + + + + true + + + + + - Units: - - - - - - - Salinity (0-5%): - - - - - - - % - - - 5 - - - - - - - Language: - - - - - - - Date Format: + Custom Text: @@ -167,97 +143,13 @@ - - + + - Custom Text: + Language: - - - - Compass Gain: - - - - - - - true - - - - - - - Last Deco: - - - - - - - true - - - - - - - - Standard - - - - - Red - - - - - Green - - - - - Blue - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - MMDDYY - - - - - DDMMYY - - - - - YYMMDD - - - - @@ -282,81 +174,6 @@ - - - - - m/°C - - - - - ft/°F - - - - - - - - Brightness: - - - - - - - Serial No. - - - - - - - Sampling Rate: - - - - - - - - Eco - - - - - Medium - - - - - High - - - - - - - - - 2s - - - - - 10s - - - - - - - - Firmware Version: - - - @@ -388,6 +205,197 @@ + + + + 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: + + + @@ -438,33 +446,183 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gas No. + + + + + %He + + + + + %O2 + + + + + Type + + + + + Change Depth + + + + + Gas 1 + + + + + Gas 2 + + + + + Gas 3 + + + + + Gas 4 + + + + + Gas 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gas No. + + + + + %He + + + + + %O2 + + + + + Type + + + + + Change Depth + + + + + Gas 1 + + + + + Gas 2 + + + + + Gas 3 + + + + + Gas 4 + + + + + Gas 5 + + + + + + - Saturation: + Sync dive computer time with PC - - - - % + + + + Qt::Vertical - - - - - - Desaturation: + + + 20 + 40 + - - - - - - % - - + diff --git a/qt-ui/configuredivecomputerthreads.cpp b/qt-ui/configuredivecomputerthreads.cpp index f0e2bde6e..3afb11bc5 100644 --- a/qt-ui/configuredivecomputerthreads.cpp +++ b/qt-ui/configuredivecomputerthreads.cpp @@ -32,6 +32,31 @@ void ReadSettingsThread::run() m_deviceDetails->setSamplingRate(0); m_deviceDetails->setUnits(0); + + //Gread gas mixes + gas gas1; + gas gas2; + gas gas3; + gas gas4; + gas gas5; + //Gas 1 + unsigned char gasData[4] = {0,0,0,0}; + rc = hw_ostc3_device_config_read(m_data->device, 0x10, gasData, sizeof(gasData)); + if (rc == DC_STATUS_SUCCESS) { + //Gas 1 read successful + gas gas1; + gas1.depth = gasData[3]; + gas1.oxygen = gasData[0]; + gas1.helium = gasData[1]; + gas1.type = gasData[2]; + } + + m_deviceDetails->setGas1(gas1); + m_deviceDetails->setGas2(gas2); + m_deviceDetails->setGas3(gas3); + m_deviceDetails->setGas4(gas4); + m_deviceDetails->setGas5(gas5); + //Read general settings unsigned char uData[1] = {0}; //DiveMode From 4f37602836ef1f6778fbf76cd20f0d017d5fe305 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 20 Jun 2014 07:57:20 +0300 Subject: [PATCH 19/33] Move non gui code from qt-ui Moves non gui classes (configuredivecomputer, configuredivecomputerthreads and devicedetails) from qt-ui to the top level folder. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- ...guredivecomputer.cpp => configuredivecomputer.cpp | 0 ...onfiguredivecomputer.h => configuredivecomputer.h | 0 ...erthreads.cpp => configuredivecomputerthreads.cpp | 0 ...mputerthreads.h => configuredivecomputerthreads.h | 0 qt-ui/devicedetails.cpp => devicedetails.cpp | 0 qt-ui/devicedetails.h => devicedetails.h | 0 subsurface.pro | 12 ++++++------ 7 files changed, 6 insertions(+), 6 deletions(-) rename qt-ui/configuredivecomputer.cpp => configuredivecomputer.cpp (100%) rename qt-ui/configuredivecomputer.h => configuredivecomputer.h (100%) rename qt-ui/configuredivecomputerthreads.cpp => configuredivecomputerthreads.cpp (100%) rename qt-ui/configuredivecomputerthreads.h => configuredivecomputerthreads.h (100%) rename qt-ui/devicedetails.cpp => devicedetails.cpp (100%) rename qt-ui/devicedetails.h => devicedetails.h (100%) diff --git a/qt-ui/configuredivecomputer.cpp b/configuredivecomputer.cpp similarity index 100% rename from qt-ui/configuredivecomputer.cpp rename to configuredivecomputer.cpp diff --git a/qt-ui/configuredivecomputer.h b/configuredivecomputer.h similarity index 100% rename from qt-ui/configuredivecomputer.h rename to configuredivecomputer.h diff --git a/qt-ui/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp similarity index 100% rename from qt-ui/configuredivecomputerthreads.cpp rename to configuredivecomputerthreads.cpp diff --git a/qt-ui/configuredivecomputerthreads.h b/configuredivecomputerthreads.h similarity index 100% rename from qt-ui/configuredivecomputerthreads.h rename to configuredivecomputerthreads.h diff --git a/qt-ui/devicedetails.cpp b/devicedetails.cpp similarity index 100% rename from qt-ui/devicedetails.cpp rename to devicedetails.cpp diff --git a/qt-ui/devicedetails.h b/devicedetails.h similarity index 100% rename from qt-ui/devicedetails.h rename to devicedetails.h diff --git a/subsurface.pro b/subsurface.pro index 8711ab505..723513d0e 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -88,9 +88,9 @@ HEADERS = \ qt-ui/usersurvey.h \ subsurfacesysinfo.h \ qt-ui/configuredivecomputerdialog.h \ - qt-ui/configuredivecomputer.h \ - qt-ui/configuredivecomputerthreads.h \ - qt-ui/devicedetails.h + configuredivecomputer.h \ + configuredivecomputerthreads.h \ + devicedetails.h android: HEADERS -= \ qt-ui/usermanual.h \ @@ -171,9 +171,9 @@ SOURCES = \ qt-ui/usersurvey.cpp \ subsurfacesysinfo.cpp \ qt-ui/configuredivecomputerdialog.cpp \ - qt-ui/configuredivecomputer.cpp \ - qt-ui/configuredivecomputerthreads.cpp \ - qt-ui/devicedetails.cpp + configuredivecomputer.cpp \ + configuredivecomputerthreads.cpp \ + devicedetails.cpp android: SOURCES += android.cpp else: linux*: SOURCES += linux.c From 8b39d2fc172b72ade19a754f33575f663573f147 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 08:46:57 +0300 Subject: [PATCH 20/33] Read OSTC3 GasSetting Values Implements the reading of OSTC3 Gas Settings. These are settings 0x10 to 0x14 Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 42 +++++++++++++++++++++++++-- qt-ui/configuredivecomputerdialog.cpp | 24 +++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 3afb11bc5..7ee015f3e 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -2,6 +2,7 @@ #include "libdivecomputer/hw.h" #include #include +#include ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) @@ -43,13 +44,48 @@ void ReadSettingsThread::run() unsigned char gasData[4] = {0,0,0,0}; rc = hw_ostc3_device_config_read(m_data->device, 0x10, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { - //Gas 1 read successful - gas gas1; + //Gas data read successful gas1.depth = gasData[3]; gas1.oxygen = gasData[0]; gas1.helium = gasData[1]; gas1.type = gasData[2]; } + //Gas 2 + rc = hw_ostc3_device_config_read(m_data->device, 0x11, gasData, sizeof(gasData)); + if (rc == DC_STATUS_SUCCESS) { + //Gas data read successful + gas2.depth = gasData[3]; + gas2.oxygen = gasData[0]; + gas2.helium = gasData[1]; + gas2.type = gasData[2]; + } + //Gas 3 + rc = hw_ostc3_device_config_read(m_data->device, 0x12, gasData, sizeof(gasData)); + if (rc == DC_STATUS_SUCCESS) { + //Gas data read successful + gas3.depth = gasData[3]; + gas3.oxygen = gasData[0]; + gas3.helium = gasData[1]; + gas3.type = gasData[2]; + } + //Gas 4 + rc = hw_ostc3_device_config_read(m_data->device, 0x13, gasData, sizeof(gasData)); + if (rc == DC_STATUS_SUCCESS) { + //Gas data read successful + gas4.depth = gasData[3]; + gas4.oxygen = gasData[0]; + gas4.helium = gasData[1]; + gas4.type = gasData[2]; + } + //Gas 5 + rc = hw_ostc3_device_config_read(m_data->device, 0x14, gasData, sizeof(gasData)); + if (rc == DC_STATUS_SUCCESS) { + //Gas data read successful + gas5.depth = gasData[3]; + gas5.oxygen = gasData[0]; + gas5.helium = gasData[1]; + gas5.type = gasData[2]; + } m_deviceDetails->setGas1(gas1); m_deviceDetails->setGas2(gas2); @@ -57,7 +93,7 @@ void ReadSettingsThread::run() m_deviceDetails->setGas4(gas4); m_deviceDetails->setGas5(gas5); - //Read general settings + //Read other settings unsigned char uData[1] = {0}; //DiveMode rc = hw_ostc3_device_config_read(m_data->device, 0x20, uData, sizeof(uData)); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index ece02a3d0..27c377a4e 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -208,6 +208,30 @@ void ConfigureDiveComputerDialog::reloadValues() ui->ostc3GasTable->setItem(0,2, new QTableWidgetItem(QString::number(deviceDetails->gas1().helium))); ui->ostc3GasTable->setItem(0,3, new QTableWidgetItem(QString::number(deviceDetails->gas1().type))); ui->ostc3GasTable->setItem(0,4, new QTableWidgetItem(QString::number(deviceDetails->gas1().depth))); + + //load gas 2 values + ui->ostc3GasTable->setItem(1,1, new QTableWidgetItem(QString::number(deviceDetails->gas2().oxygen))); + ui->ostc3GasTable->setItem(1,2, new QTableWidgetItem(QString::number(deviceDetails->gas2().helium))); + ui->ostc3GasTable->setItem(1,3, new QTableWidgetItem(QString::number(deviceDetails->gas2().type))); + ui->ostc3GasTable->setItem(1,4, new QTableWidgetItem(QString::number(deviceDetails->gas2().depth))); + + //load gas 3 values + ui->ostc3GasTable->setItem(2,1, new QTableWidgetItem(QString::number(deviceDetails->gas3().oxygen))); + ui->ostc3GasTable->setItem(2,2, new QTableWidgetItem(QString::number(deviceDetails->gas3().helium))); + ui->ostc3GasTable->setItem(2,3, new QTableWidgetItem(QString::number(deviceDetails->gas3().type))); + ui->ostc3GasTable->setItem(2,4, new QTableWidgetItem(QString::number(deviceDetails->gas3().depth))); + + //load gas 4 values + ui->ostc3GasTable->setItem(3,1, new QTableWidgetItem(QString::number(deviceDetails->gas4().oxygen))); + ui->ostc3GasTable->setItem(3,2, new QTableWidgetItem(QString::number(deviceDetails->gas4().helium))); + ui->ostc3GasTable->setItem(3,3, new QTableWidgetItem(QString::number(deviceDetails->gas4().type))); + ui->ostc3GasTable->setItem(3,4, new QTableWidgetItem(QString::number(deviceDetails->gas4().depth))); + + //load gas 5 values + ui->ostc3GasTable->setItem(4,1, new QTableWidgetItem(QString::number(deviceDetails->gas5().oxygen))); + 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))); } From a52beebbe9ba8d335d6d867a868166996dc6711e Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 09:14:55 +0300 Subject: [PATCH 21/33] Implement saving of OSTC3 Gas Settings Implements writing OSTC3 gas settings to the device. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 38 ++++++++++++++++++++++++++- qt-ui/configuredivecomputerdialog.cpp | 38 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 7ee015f3e..ae57893dc 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -185,8 +185,44 @@ void WriteSettingsThread::run() switch (dc_device_get_type(m_data->device)) { case DC_FAMILY_HW_OSTC3: supported = true; - //write general settings + //write gas values + unsigned char gas1Data[4] = {m_deviceDetails->gas1().oxygen, + m_deviceDetails->gas1().helium, + m_deviceDetails->gas1().type, + m_deviceDetails->gas1().depth}; + unsigned char gas2Data[4] = {m_deviceDetails->gas2().oxygen, + m_deviceDetails->gas2().helium, + m_deviceDetails->gas2().type, + m_deviceDetails->gas2().depth}; + + unsigned char gas3Data[4] = {m_deviceDetails->gas3().oxygen, + m_deviceDetails->gas3().helium, + m_deviceDetails->gas3().type, + m_deviceDetails->gas3().depth}; + + unsigned char gas4Data[4] = {m_deviceDetails->gas4().oxygen, + m_deviceDetails->gas4().helium, + m_deviceDetails->gas4().type, + m_deviceDetails->gas4().depth}; + + unsigned char gas5Data[4] = {m_deviceDetails->gas5().oxygen, + m_deviceDetails->gas5().helium, + m_deviceDetails->gas5().type, + m_deviceDetails->gas5().depth}; + //gas 1 + hw_ostc3_device_config_write(m_data->device, 0x10, gas1Data, sizeof(gas1Data)); + //gas 2 + hw_ostc3_device_config_write(m_data->device, 0x11, gas2Data, sizeof(gas2Data)); + //gas 3 + hw_ostc3_device_config_write(m_data->device, 0x12, gas3Data, sizeof(gas3Data)); + //gas 4 + hw_ostc3_device_config_write(m_data->device, 0x13, gas4Data, sizeof(gas4Data)); + //gas 5 + hw_ostc3_device_config_write(m_data->device, 0x14, gas5Data, sizeof(gas5Data)); + + + //write general settings //custom text hw_ostc3_device_customtext(m_data->device, m_deviceDetails->customText().toUtf8().data()); unsigned char data[1] = {0}; diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 27c377a4e..a6dd95208 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -129,6 +129,44 @@ void ConfigureDiveComputerDialog::populateDeviceDetails() deviceDetails->setDateFormat(ui->dateFormatComboBox->currentIndex()); deviceDetails->setCompassGain(ui->compassGainComboBox->currentIndex()); deviceDetails->setSyncTime(ui->dateTimeSyncCheckBox->isChecked()); + + //set gas values + gas gas1; + gas gas2; + gas gas3; + gas gas4; + gas gas5; + + gas1.oxygen = ui->ostc3GasTable->item(0, 1)->text().toInt(); + gas1.helium = ui->ostc3GasTable->item(0, 2)->text().toInt(); + gas1.type = ui->ostc3GasTable->item(0, 3)->text().toInt(); + gas1.depth = ui->ostc3GasTable->item(0, 4)->text().toInt(); + + gas2.oxygen = ui->ostc3GasTable->item(1, 1)->text().toInt(); + gas2.helium = ui->ostc3GasTable->item(1, 2)->text().toInt(); + gas2.type = ui->ostc3GasTable->item(1, 3)->text().toInt(); + gas2.depth = ui->ostc3GasTable->item(1, 4)->text().toInt(); + + gas3.oxygen = ui->ostc3GasTable->item(2, 1)->text().toInt(); + gas3.helium = ui->ostc3GasTable->item(2, 2)->text().toInt(); + gas3.type = ui->ostc3GasTable->item(2, 3)->text().toInt(); + gas3.depth = ui->ostc3GasTable->item(2, 4)->text().toInt(); + + gas4.oxygen = ui->ostc3GasTable->item(3, 1)->text().toInt(); + gas4.helium = ui->ostc3GasTable->item(3, 2)->text().toInt(); + gas4.type = ui->ostc3GasTable->item(3, 3)->text().toInt(); + gas4.depth = ui->ostc3GasTable->item(3, 4)->text().toInt(); + + gas5.oxygen = ui->ostc3GasTable->item(4, 1)->text().toInt(); + gas5.helium = ui->ostc3GasTable->item(4, 2)->text().toInt(); + gas5.type = ui->ostc3GasTable->item(4, 3)->text().toInt(); + gas5.depth = ui->ostc3GasTable->item(4, 4)->text().toInt(); + + deviceDetails->setGas1(gas1); + deviceDetails->setGas2(gas2); + deviceDetails->setGas3(gas3); + deviceDetails->setGas4(gas4); + deviceDetails->setGas5(gas5); } void ConfigureDiveComputerDialog::readSettings() From 65b0b8a64b5477cd7121699eea4c951a873c7a9f Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 09:31:19 +0300 Subject: [PATCH 22/33] Backup/Restore of OSTC3 Gas Settings Implements backup and restore for OSTC3 Gas Settings. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 87 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 01df1c744..0459640ad 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -61,6 +61,43 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai xml += "\n"; xml += "\n"; xml += addSettingToXML("CustomText", details->customText()); + //Add gasses + QString gas1 = QString("%1,%2,%3,%4") + .arg(QString::number(details->gas1().oxygen), + QString::number(details->gas1().helium), + QString::number(details->gas1().type), + QString::number(details->gas1().depth) + ); + QString gas2 = QString("%1,%2,%3,%4") + .arg(QString::number(details->gas2().oxygen), + QString::number(details->gas2().helium), + QString::number(details->gas2().type), + QString::number(details->gas2().depth) + ); + QString gas3 = QString("%1,%2,%3,%4") + .arg(QString::number(details->gas3().oxygen), + QString::number(details->gas3().helium), + QString::number(details->gas3().type), + QString::number(details->gas3().depth) + ); + QString gas4 = QString("%1,%2,%3,%4") + .arg(QString::number(details->gas4().oxygen), + QString::number(details->gas4().helium), + QString::number(details->gas4().type), + QString::number(details->gas4().depth) + ); + QString gas5 = QString("%1,%2,%3,%4") + .arg(QString::number(details->gas5().oxygen), + QString::number(details->gas5().helium), + QString::number(details->gas5().type), + QString::number(details->gas5().depth) + ); + xml += addSettingToXML("Gas1", gas1); + xml += addSettingToXML("Gas2", gas2); + xml += addSettingToXML("Gas3", gas3); + xml += addSettingToXML("Gas4", gas4); + xml += addSettingToXML("Gas5", gas5); + // xml += addSettingToXML("DiveMode", details->diveMode()); xml += addSettingToXML("Saturation", details->saturation()); xml += addSettingToXML("Desaturation", details->desaturation()); @@ -129,6 +166,56 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de if (settingName == "CustomText") details->setCustomText(keyString); + if (settingName == "Gas1") { + QStringList gasData = keyString.split(","); + gas gas1; + gas1.oxygen = gasData.at(0).toInt(); + gas1.helium = gasData.at(1).toInt(); + gas1.type = gasData.at(2).toInt(); + gas1.depth = gasData.at(3).toInt(); + details->setGas1(gas1); + } + + if (settingName == "Gas2") { + QStringList gasData = keyString.split(","); + gas gas2; + gas2.oxygen = gasData.at(0).toInt(); + gas2.helium = gasData.at(1).toInt(); + gas2.type = gasData.at(2).toInt(); + gas2.depth = gasData.at(3).toInt(); + details->setGas1(gas2); + } + + if (settingName == "Gas3") { + QStringList gasData = keyString.split(","); + gas gas3; + gas3.oxygen = gasData.at(0).toInt(); + gas3.helium = gasData.at(1).toInt(); + gas3.type = gasData.at(2).toInt(); + gas3.depth = gasData.at(3).toInt(); + details->setGas3(gas3); + } + + if (settingName == "Gas4") { + QStringList gasData = keyString.split(","); + gas gas4; + gas4.oxygen = gasData.at(0).toInt(); + gas4.helium = gasData.at(1).toInt(); + gas4.type = gasData.at(2).toInt(); + gas4.depth = gasData.at(3).toInt(); + details->setGas4(gas4); + } + + if (settingName == "Gas5") { + QStringList gasData = keyString.split(","); + gas gas5; + gas5.oxygen = gasData.at(0).toInt(); + gas5.helium = gasData.at(1).toInt(); + gas5.type = gasData.at(2).toInt(); + gas5.depth = gasData.at(3).toInt(); + details->setGas5(gas5); + } + if (settingName == "Saturation") details->setSaturation(keyString.toInt()); From 9c032f20c02fbb7c1e3906dbc8392539e0125327 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 09:53:05 +0300 Subject: [PATCH 23/33] 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 Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 87 ++++++++++++++++++++++++ configuredivecomputerthreads.cpp | 95 +++++++++++++++++++++++++++ qt-ui/configuredivecomputerdialog.cpp | 68 +++++++++++++++++++ qt-ui/configuredivecomputerdialog.ui | 28 ++++---- 4 files changed, 264 insertions(+), 14 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 0459640ad..7b86d5bb0 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -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()); diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index ae57893dc..c20d58a0b 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -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 diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index a6dd95208..f878ec11a 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -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))); } diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 6099535e8..0f99e597a 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 701 - 620 + 699 + 618 @@ -475,12 +475,7 @@ - Gas No. - - - - - %He + @@ -488,6 +483,11 @@ %O2 + + + %He + + Type @@ -554,7 +554,7 @@ - Gas No. + @@ -579,27 +579,27 @@ - Gas 1 + Dil 1 - Gas 2 + Dil 2 - Gas 3 + Dil 3 - Gas 4 + Dil 4 - Gas 5 + Dil 5 From 8aa7fddb22cd6ab4d533082598be04649bb1ff21 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 10:22:47 +0300 Subject: [PATCH 24/33] 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 From cc6c385f3309417727f61b55550d6d47bef004dd Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Mon, 23 Jun 2014 18:16:27 +0300 Subject: [PATCH 25/33] Start Work on Firmware Update This patch implements the first step towards OSTC 3 firmware update. Its not much, just file selection, but I will build up on it from there. Implements a thread to initiate firmware updates. Currently, this is for the OSTC 3. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 15 ++++++++----- configuredivecomputer.h | 1 + configuredivecomputerthreads.cpp | 32 +++++++++++++++++++++++++++ configuredivecomputerthreads.h | 22 ++++++++++++++++-- qt-ui/configuredivecomputerdialog.cpp | 25 ++++++++++++++++----- qt-ui/configuredivecomputerdialog.h | 2 ++ qt-ui/configuredivecomputerdialog.ui | 11 +++++++-- 7 files changed, 94 insertions(+), 14 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 657f6fd10..c7b0ccbe9 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -24,10 +24,10 @@ void ConfigureDiveComputer::readSettings(device_data_t *data) readThread->deleteLater(); readThread = new ReadSettingsThread(this, data); - connect (readThread, SIGNAL(finished()), + connect(readThread, SIGNAL(finished()), this, SLOT(readThreadFinished()), Qt::QueuedConnection); - connect (readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); - connect (readThread, SIGNAL(devicedetails(DeviceDetails*)), this, + connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + connect(readThread, SIGNAL(devicedetails(DeviceDetails*)), this, SIGNAL(deviceDetailsChanged(DeviceDetails*))); readThread->start(); @@ -41,9 +41,9 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat writeThread->deleteLater(); writeThread = new WriteSettingsThread(this, data); - connect (writeThread, SIGNAL(finished()), + connect(writeThread, SIGNAL(finished()), this, SLOT(writeThreadFinished()), Qt::QueuedConnection); - connect (writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); + connect(writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); writeThread->setDeviceDetails(details); writeThread->start(); @@ -417,6 +417,11 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de return true; } +void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText) +{ + +} + void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) { currentState = newState; diff --git a/configuredivecomputer.h b/configuredivecomputer.h index 31c0cb756..f64c9c95d 100644 --- a/configuredivecomputer.h +++ b/configuredivecomputer.h @@ -34,6 +34,7 @@ public: void fetchDeviceDetails(); bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText); bool restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText); + void startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText); signals: void message(QString msg); void error(QString err); diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 66506affd..52f946179 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -467,3 +467,35 @@ void WriteSettingsThread::run() emit error(lastError); } } + + +FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName) +: QThread(parent), m_data(data), m_fileName(fileName) +{ + +} + +void FirmwareUpdateThread::run() +{ + bool supported = false; + dc_status_t rc; + rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); + if (rc == DC_STATUS_SUCCESS) { + switch (dc_device_get_type(m_data->device)) { + case DC_FAMILY_HW_OSTC3: + supported = true; + //hw_ostc3_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); + break; + } + dc_device_close(m_data->device); + + if (!supported) { + lastError = tr("This feature is not yet available for the selected dive computer."); + emit error(lastError); + } + } + else { + lastError = tr("Could not a establish connection to the dive computer."); + emit error(lastError); + } +} diff --git a/configuredivecomputerthreads.h b/configuredivecomputerthreads.h index db54db460..66df7a93b 100644 --- a/configuredivecomputerthreads.h +++ b/configuredivecomputerthreads.h @@ -8,7 +8,8 @@ #include #include "devicedetails.h" -class ReadSettingsThread : public QThread { +class ReadSettingsThread : public QThread +{ Q_OBJECT public: ReadSettingsThread(QObject *parent, device_data_t *data); @@ -22,7 +23,8 @@ private: device_data_t *m_data; }; -class WriteSettingsThread : public QThread { +class WriteSettingsThread : public QThread +{ Q_OBJECT public: WriteSettingsThread(QObject *parent, device_data_t *data); @@ -37,4 +39,20 @@ private: DeviceDetails *m_deviceDetails; }; +class FirmwareUpdateThread : public QThread +{ + Q_OBJECT +public: + FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName); + virtual void run(); + QString lastError; +signals: + void progress(int percent); + void message(QString msg); + void error(QString err); +private: + device_data_t *m_data; + QString m_fileName; +}; + #endif // CONFIGUREDIVECOMPUTERTHREADS_H diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 81d8f0326..733d64a4f 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -38,12 +38,12 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : deviceDetails = new DeviceDetails(this); config = new ConfigureDiveComputer(this); - connect (config, SIGNAL(error(QString)), this, SLOT(configError(QString))); - connect (config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); - connect (config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); - connect (config, SIGNAL(deviceDetailsChanged(DeviceDetails*)), + connect(config, SIGNAL(error(QString)), this, SLOT(configError(QString))); + connect(config, SIGNAL(message(QString)), this, SLOT(configMessage(QString))); + connect(config, SIGNAL(readFinished()), this, SLOT(deviceReadFinished())); + connect(config, SIGNAL(deviceDetailsChanged(DeviceDetails*)), this, SLOT(deviceDetailsReceived(DeviceDetails*))); - connect (ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); + connect(ui->retrieveDetails, SIGNAL(clicked()), this, SLOT(readSettings())); memset(&device_data, 0, sizeof(device_data)); fill_computer_list(); @@ -451,3 +451,18 @@ void ConfigureDiveComputerDialog::on_tabWidget_currentChanged(int index) dcType = DC_TYPE_UEMIS; fill_device_list(dcType); } + +void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() +{ + QString filename = existing_filename ?: prefs.default_filename; + QFileInfo fi(filename); + filename = fi.absolutePath(); + QString firmwarePath = QFileDialog::getOpenFileName(this, tr("Select firmware file"), + filename, tr("All files (*.*)") + ); + if (!firmwarePath.isEmpty()) { + getDeviceData(); + QString errText; + config->startFirmwareUpdate(firmwarePath, &device_data, errText); + } +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index de068c609..71266c471 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -33,6 +33,8 @@ private slots: void on_tabWidget_currentChanged(int index); + void on_updateFirmwareButton_clicked(); + private: Ui::ConfigureDiveComputerDialog *ui; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index 4274a3abe..d0dd91155 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 787 - 672 + 785 + 670 @@ -89,6 +89,13 @@ + + + + Update Firmware + + + From 8e8d226f57eda006ee35eac128afcf882634ff01 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 3 Jul 2014 09:57:55 +0300 Subject: [PATCH 26/33] Use macros for OSTC 3 setting codes Changes the classes in configuredivecomputerthreads.cpp to use macros to hold the setting hex codes. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 142 ++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 52f946179..7bd921e6d 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -4,6 +4,46 @@ #include #include +#define OSTC3_GAS1 0x10 +#define OSTC3_GAS2 0x11 +#define OSTC3_GAS3 0x12 +#define OSTC3_GAS4 0x13 +#define OSTC3_GAS5 0x14 +#define OSTC3_DIL1 0x15 +#define OSTC3_DIL2 0x16 +#define OSTC3_DIL3 0x17 +#define OSTC3_DIL4 0x18 +#define OSTC3_DIL5 0x19 +#define OSTC3_SP1 0x1A +#define OSTC3_SP2 0x1B +#define OSTC3_SP3 0x1C +#define OSTC3_SP4 0x1D +#define OSTC3_SP5 0x1E +#define OSTC3_CCR_MODE 0x1F +#define OSTC3_DIVE_MODE 0x20 +#define OSTC3_DECO_TYPE 0x21 +#define OSTC3_PP02_MAX 0x22 +#define OSTC3_PP02_MIN 0x23 +#define OSTC3_FUTURE_TTS 0x24 +#define OSTC3_GF_LOW 0x25 +#define OSTC3_GF_HIGH 0x26 +#define OSTC3_AGF_LOW 0x27 +#define OSTC3_AGF_HIGH 0x28 +#define OSTC3_AGF_SELECTABLE 0x29 +#define OSTC3_SATURATION 0x2A +#define OSTC3_DESATURATION 0x2B +#define OSTC3_LAST_DECO 0x2C +#define OSTC3_BRIGHTNESS 0x2D +#define OSTC3_UNITS 0x2E +#define OSTC3_SAMPLING_RATE 0x2F +#define OSTC3_SALINITY 0x30 +#define OSTC3_DIVEMODE_COLOR 0x31 +#define OSTC3_LANGUAGE 0x32 +#define OSTC3_DATE_FORMAT 0x33 +#define OSTC3_COMPASS_GAIN 0x34 +#define OSTC3_PRESSURE_SENSOR_OFFSET 0x35 +#define OSTC3_SAFETY_STOP 0x36 + ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data) { @@ -42,7 +82,7 @@ void ReadSettingsThread::run() gas gas5; //Gas 1 unsigned char gasData[4] = {0,0,0,0}; - rc = hw_ostc3_device_config_read(m_data->device, 0x10, gasData, sizeof(gasData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS1, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful gas1.depth = gasData[3]; @@ -51,7 +91,7 @@ void ReadSettingsThread::run() gas1.type = gasData[2]; } //Gas 2 - rc = hw_ostc3_device_config_read(m_data->device, 0x11, gasData, sizeof(gasData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS2, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful gas2.depth = gasData[3]; @@ -60,7 +100,7 @@ void ReadSettingsThread::run() gas2.type = gasData[2]; } //Gas 3 - rc = hw_ostc3_device_config_read(m_data->device, 0x12, gasData, sizeof(gasData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS3, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful gas3.depth = gasData[3]; @@ -69,7 +109,7 @@ void ReadSettingsThread::run() gas3.type = gasData[2]; } //Gas 4 - rc = hw_ostc3_device_config_read(m_data->device, 0x13, gasData, sizeof(gasData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS4, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful gas4.depth = gasData[3]; @@ -78,7 +118,7 @@ void ReadSettingsThread::run() gas4.type = gasData[2]; } //Gas 5 - rc = hw_ostc3_device_config_read(m_data->device, 0x14, gasData, sizeof(gasData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_GAS5, gasData, sizeof(gasData)); if (rc == DC_STATUS_SUCCESS) { //Gas data read successful gas5.depth = gasData[3]; @@ -101,7 +141,7 @@ void ReadSettingsThread::run() 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)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL1, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful dil1.depth = dilData[3]; @@ -110,7 +150,7 @@ void ReadSettingsThread::run() dil1.type = dilData[2]; } //Dil 2 - rc = hw_ostc3_device_config_read(m_data->device, 0x16, dilData, sizeof(dilData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL2, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful dil2.depth = dilData[3]; @@ -119,7 +159,7 @@ void ReadSettingsThread::run() dil2.type = dilData[2]; } //Dil 3 - rc = hw_ostc3_device_config_read(m_data->device, 0x17, dilData, sizeof(dilData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL3, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful dil3.depth = dilData[3]; @@ -128,7 +168,7 @@ void ReadSettingsThread::run() dil3.type = dilData[2]; } //Dil 4 - rc = hw_ostc3_device_config_read(m_data->device, 0x18, dilData, sizeof(dilData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL4, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful dil4.depth = dilData[3]; @@ -137,7 +177,7 @@ void ReadSettingsThread::run() dil4.type = dilData[2]; } //Dil 5 - rc = hw_ostc3_device_config_read(m_data->device, 0x19, dilData, sizeof(dilData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIL5, dilData, sizeof(dilData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful dil5.depth = dilData[3]; @@ -162,35 +202,35 @@ void ReadSettingsThread::run() unsigned char spData[2] = {0,0}; //Sp 1 - rc = hw_ostc3_device_config_read(m_data->device, 0x1A, spData, sizeof(spData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP1, 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)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP2, 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)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP3, 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)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP4, 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)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SP5, spData, sizeof(spData)); if (rc == DC_STATUS_SUCCESS) { //Data read successful sp5.sp = dilData[0]; @@ -201,43 +241,43 @@ void ReadSettingsThread::run() //Read other settings unsigned char uData[1] = {0}; //DiveMode - rc = hw_ostc3_device_config_read(m_data->device, 0x20, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIVE_MODE, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setDiveMode(uData[0]); //Saturation - rc = hw_ostc3_device_config_read(m_data->device, 0x2A, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SATURATION, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setSaturation(uData[0]); //LastDeco - rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_LAST_DECO, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setLastDeco(uData[0]); //Brightness - rc = hw_ostc3_device_config_read(m_data->device, 0x2D, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_BRIGHTNESS, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setBrightness(uData[0]); //Units - rc = hw_ostc3_device_config_read(m_data->device, 0x2E, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_UNITS, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setUnits(uData[0]); //Sampling Rate - rc = hw_ostc3_device_config_read(m_data->device, 0x2F, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SAMPLING_RATE, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setSamplingRate(uData[0]); //Salinity - rc = hw_ostc3_device_config_read(m_data->device, 0x30, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_SALINITY, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setSalinity(uData[0]); //Dive mode colour - rc = hw_ostc3_device_config_read(m_data->device, 0x31, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DIVEMODE_COLOR, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setDiveModeColor(uData[0]); //Language - rc = hw_ostc3_device_config_read(m_data->device, 0x32, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_LANGUAGE, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setLanguage(uData[0]); //Date Format - rc = hw_ostc3_device_config_read(m_data->device, 0x33, uData, sizeof(uData)); + rc = hw_ostc3_device_config_read(m_data->device, OSTC3_DATE_FORMAT, uData, sizeof(uData)); if (rc == DC_STATUS_SUCCESS) m_deviceDetails->setDateFormat(uData[0]); @@ -316,15 +356,15 @@ void WriteSettingsThread::run() m_deviceDetails->gas5().type, m_deviceDetails->gas5().depth}; //gas 1 - hw_ostc3_device_config_write(m_data->device, 0x10, gas1Data, sizeof(gas1Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_GAS1, gas1Data, sizeof(gas1Data)); //gas 2 - hw_ostc3_device_config_write(m_data->device, 0x11, gas2Data, sizeof(gas2Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_GAS2, gas2Data, sizeof(gas2Data)); //gas 3 - hw_ostc3_device_config_write(m_data->device, 0x12, gas3Data, sizeof(gas3Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_GAS3, gas3Data, sizeof(gas3Data)); //gas 4 - hw_ostc3_device_config_write(m_data->device, 0x13, gas4Data, sizeof(gas4Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_GAS4, gas4Data, sizeof(gas4Data)); //gas 5 - hw_ostc3_device_config_write(m_data->device, 0x14, gas5Data, sizeof(gas5Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_GAS5, gas5Data, sizeof(gas5Data)); //write set point values unsigned char sp1Data[2] = {m_deviceDetails->sp1().sp, @@ -343,15 +383,15 @@ void WriteSettingsThread::run() m_deviceDetails->sp5().depth}; //sp 1 - hw_ostc3_device_config_write(m_data->device, 0x1A, sp1Data, sizeof(sp1Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SP1, sp1Data, sizeof(sp1Data)); //sp 2 - hw_ostc3_device_config_write(m_data->device, 0x1B, sp2Data, sizeof(sp2Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SP2, sp2Data, sizeof(sp2Data)); //sp 3 - hw_ostc3_device_config_write(m_data->device, 0x1C, sp3Data, sizeof(sp3Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SP3, sp3Data, sizeof(sp3Data)); //sp 4 - hw_ostc3_device_config_write(m_data->device, 0x1D, sp4Data, sizeof(sp4Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SP4, sp4Data, sizeof(sp4Data)); //sp 5 - hw_ostc3_device_config_write(m_data->device, 0x1E, sp5Data, sizeof(sp5Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SP5, sp5Data, sizeof(sp5Data)); //write dil values unsigned char dil1Data[4] = {m_deviceDetails->dil1().oxygen, @@ -379,15 +419,15 @@ void WriteSettingsThread::run() m_deviceDetails->dil5().type, m_deviceDetails->dil5().depth}; //dil 1 - hw_ostc3_device_config_write(m_data->device, 0x15, dil1Data, sizeof(gas1Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIL1, dil1Data, sizeof(gas1Data)); //dil 2 - hw_ostc3_device_config_write(m_data->device, 0x16, dil2Data, sizeof(dil2Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIL2, dil2Data, sizeof(dil2Data)); //dil 3 - hw_ostc3_device_config_write(m_data->device, 0x17, dil3Data, sizeof(dil3Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIL3, dil3Data, sizeof(dil3Data)); //dil 4 - hw_ostc3_device_config_write(m_data->device, 0x18, dil4Data, sizeof(dil4Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIL4, dil4Data, sizeof(dil4Data)); //dil 5 - hw_ostc3_device_config_write(m_data->device, 0x19, dil5Data, sizeof(dil5Data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIL5, dil5Data, sizeof(dil5Data)); //write general settings @@ -397,47 +437,47 @@ void WriteSettingsThread::run() //dive mode data[0] = m_deviceDetails->diveMode(); - hw_ostc3_device_config_write(m_data->device, 0x20, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIVE_MODE, data, sizeof(data)); //saturation data[0] = m_deviceDetails->saturation(); - hw_ostc3_device_config_write(m_data->device, 0x2A, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SATURATION, data, sizeof(data)); //last deco data[0] = m_deviceDetails->lastDeco(); - hw_ostc3_device_config_write(m_data->device, 0x2C, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_LAST_DECO, data, sizeof(data)); //brightness data[0] = m_deviceDetails->brightness(); - hw_ostc3_device_config_write(m_data->device, 0x2D, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_BRIGHTNESS, data, sizeof(data)); //units data[0] = m_deviceDetails->units(); - hw_ostc3_device_config_write(m_data->device, 0x2E, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_UNITS, data, sizeof(data)); //sampling rate data[0] = m_deviceDetails->samplingRate(); - hw_ostc3_device_config_write(m_data->device, 0x2F, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SAMPLING_RATE, data, sizeof(data)); //salinity data[0] = m_deviceDetails->salinity(); - hw_ostc3_device_config_write(m_data->device, 0x30, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_SALINITY, data, sizeof(data)); //dive mode colour data[0] = m_deviceDetails->diveModeColor(); - hw_ostc3_device_config_write(m_data->device, 0x31, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DIVEMODE_COLOR, data, sizeof(data)); //language data[0] = m_deviceDetails->language(); - hw_ostc3_device_config_write(m_data->device, 0x32, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_LANGUAGE, data, sizeof(data)); //date format data[0] = m_deviceDetails->dateFormat(); - hw_ostc3_device_config_write(m_data->device, 0x33, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_DATE_FORMAT, data, sizeof(data)); //compass gain data[0] = m_deviceDetails->compassGain(); - hw_ostc3_device_config_write(m_data->device, 0x34, data, sizeof(data)); + hw_ostc3_device_config_write(m_data->device, OSTC3_COMPASS_GAIN, data, sizeof(data)); //sync date and time if (m_deviceDetails->syncTime()) { From 91ccd890482c411c91c65a999573ba85fb28aa07 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sun, 6 Jul 2014 06:53:42 +0300 Subject: [PATCH 27/33] Use QXmlStreamReader for dive computer settings backup This patch changes the code in the ConfigureDiveComputer class to use QXmlStreamWriter instead of an hardcoded xml structure. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 86 ++++++++++++++++++++------------------- configuredivecomputer.h | 1 - 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index c7b0ccbe9..4a251e051 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) : QObject(parent), @@ -54,13 +55,17 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai QString xml = ""; QString vendor = data->vendor; QString product = data->product; - xml += ""; - xml += "\n"; - xml += addSettingToXML("Vendor", vendor); - xml += addSettingToXML("Product", product); - xml += "\n"; - xml += "\n"; - xml += addSettingToXML("CustomText", details->customText()); + QXmlStreamWriter writer(&xml); + writer.setAutoFormatting(true); + + writer.writeStartDocument(); + writer.writeStartElement("DiveComputerSettingsBackup"); + writer.writeStartElement("DiveComputer"); + writer.writeTextElement("Vendor", vendor); + writer.writeTextElement("Product", product); + writer.writeEndElement(); + writer.writeStartElement("Settings"); + writer.writeTextElement("CustomText", details->customText()); //Add gasses QString gas1 = QString("%1,%2,%3,%4") .arg(QString::number(details->gas1().oxygen), @@ -92,11 +97,11 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai QString::number(details->gas5().type), QString::number(details->gas5().depth) ); - xml += addSettingToXML("Gas1", gas1); - xml += addSettingToXML("Gas2", gas2); - xml += addSettingToXML("Gas3", gas3); - xml += addSettingToXML("Gas4", gas4); - xml += addSettingToXML("Gas5", gas5); + writer.writeTextElement("Gas1", gas1); + writer.writeTextElement("Gas2", gas2); + writer.writeTextElement("Gas3", gas3); + writer.writeTextElement("Gas4", gas4); + writer.writeTextElement("Gas5", gas5); // //Add dil values QString dil1 = QString("%1,%2,%3,%4") @@ -129,11 +134,11 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai 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); + writer.writeTextElement("Dil1", dil1); + writer.writeTextElement("Dil2", dil2); + writer.writeTextElement("Dil3", dil3); + writer.writeTextElement("Dil4", dil4); + writer.writeTextElement("Dil5", dil5); // //Add set point values QString sp1 = QString("%1,%2") @@ -156,27 +161,30 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai .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); + writer.writeTextElement("SetPoint1", sp1); + writer.writeTextElement("SetPoint2", sp2); + writer.writeTextElement("SetPoint3", sp3); + writer.writeTextElement("SetPoint4", sp4); + writer.writeTextElement("SetPoint5", sp5); //Other Settings - xml += addSettingToXML("DiveMode", details->diveMode()); - xml += addSettingToXML("Saturation", details->saturation()); - xml += addSettingToXML("Desaturation", details->desaturation()); - xml += addSettingToXML("LastDeco", details->lastDeco()); - xml += addSettingToXML("Brightness", details->brightness()); - xml += addSettingToXML("Units", details->units()); - xml += addSettingToXML("SamplingRate", details->samplingRate()); - xml += addSettingToXML("Salinity", details->salinity()); - xml += addSettingToXML("DiveModeColor", details->diveModeColor()); - xml += addSettingToXML("Language", details->language()); - xml += addSettingToXML("DateFormat", details->dateFormat()); - xml += addSettingToXML("CompassGain", details->compassGain()); - xml += "\n"; - xml += "\n"; + writer.writeTextElement("DiveMode", QString::number(details->diveMode())); + writer.writeTextElement("Saturation", QString::number(details->saturation())); + writer.writeTextElement("Desaturation", QString::number(details->desaturation())); + writer.writeTextElement("LastDeco", QString::number(details->lastDeco())); + writer.writeTextElement("Brightness", QString::number(details->brightness())); + writer.writeTextElement("Units", QString::number(details->units())); + writer.writeTextElement("SamplingRate", QString::number(details->samplingRate())); + writer.writeTextElement("Salinity", QString::number(details->salinity())); + writer.writeTextElement("DiveModeColor", QString::number(details->diveModeColor())); + writer.writeTextElement("Language", QString::number(details->language())); + writer.writeTextElement("DateFormat", QString::number(details->dateFormat())); + writer.writeTextElement("CompassGain", QString::number(details->compassGain())); + + writer.writeEndElement(); + writer.writeEndElement(); + + writer.writeEndDocument(); QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { errorText = tr("Could not save the backup file %1. Error Message: %2") @@ -428,12 +436,6 @@ void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState) emit stateChanged(currentState); } - -QString ConfigureDiveComputer::addSettingToXML(QString settingName, QVariant value) -{ - return "\n<" + settingName + ">" + value.toString() + ""; -} - void ConfigureDiveComputer::setError(QString err) { lastError = err; diff --git a/configuredivecomputer.h b/configuredivecomputer.h index f64c9c95d..0cd16d311 100644 --- a/configuredivecomputer.h +++ b/configuredivecomputer.h @@ -47,7 +47,6 @@ private: ReadSettingsThread *readThread; WriteSettingsThread *writeThread; void setState(states newState); - QString addSettingToXML(QString settingName, QVariant value); private slots: void readThreadFinished(); void writeThreadFinished(); From a9b55d7f0d00d68523058c5714fa4b199cbf2211 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 16 Jul 2014 12:04:54 +0300 Subject: [PATCH 28/33] Change Dive Computer Configuration dialog Changes the layout of the ConfigureDiveComputer dialog to use a list of supported computers on the left, with a stacked widget showing the configurable details. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- icons/ostc3.png | Bin 0 -> 28943 bytes qt-ui/configuredivecomputerdialog.cpp | 37 +- qt-ui/configuredivecomputerdialog.h | 3 +- qt-ui/configuredivecomputerdialog.ui | 1425 +++++++++++++------------ subsurface.qrc | 3 +- 5 files changed, 749 insertions(+), 719 deletions(-) create mode 100644 icons/ostc3.png diff --git a/icons/ostc3.png b/icons/ostc3.png new file mode 100644 index 0000000000000000000000000000000000000000..5c49a76b35a4e0e294d9cf48774dbababb06866c GIT binary patch literal 28943 zcmV+VKn1^vP)004Lh1^@s6b)xxi00009a7bBm000XU z000XU0RWnu7ytkOAY({UO#lFGm;eBCjsO7Oe*gf2lK=pFw*Ua%`~UzlkpKW4Fmz_f zK>z@7l}SWFRCwC#op+R6#kKW+RrlVG)03k{qnr>y1R-+H$$-HIV-uWn&KW11pW}ND z*f@f*v9Yni4;xHQA`1kHBWa>0&vfpas=hz!cFzdo?C(A7N3AsrAp~^yJ$>q&efHi* zXsvnvJb(VTj(Gkf_}@KUot^8JEL?ba;QMx|T=s=!Ckv(G=+2!xf3CI8|2w~Tt@ZN( z_`h`yJYdZwM;vk3>lbu&ADWOca=9$UQVBoMR4Nrl#zu?xKm6dk26qpC^Z5XL{`^yp z<2d#EtX}=n!`7{P^?v*8b%0x`uya>GGr2rr5SSldp_L|+PE!gz9^drT4VyP@dbQSi z{P_TU{`_4h9*-|L>A2(GbJSsny{;~mwu*%UyZZYn6-xwRKp2L#A75#LFvRyf6q>Zzwr1!kTPz~|2%XYu02C!cuCF&|j5eEHGoWLk_24>3AAitD=gK|m1wC>0Wh z0fFxm1U?lnpj`2B-6-oRg|s9=7-9*DEghs3Se8XyLx$<>%oCe7Z#qS5J@R}2K7UdR z7cMyKh{F$m$ASCqx6VN@G&IEI3FE0jxRDxQxYgeK!z7D|AS z0wDy1fUmF}2O$K)kuC${gt`y9XDK6{^Wz`pywc-4yK z?XK&x>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{R#Y8c; zdtzq#KPDz7zQF&X^KVfDKI7CMy#IkWE$;3EFi%*LshJrzKDCKN zB0(aVBqk+ZrL3G}(#s^1vA&%M$qFq6)7k9E@aX8LbA`fJ`9FHJ*8ljbuIJ)WVc7rB6OX?p0Hl`G zr|Vg`U?KIH49$&=)HgMebt~V0a_g4%p^5P?FJ8Kw=B5@@sB1nq&jgICRuyx}0YVw7 z6qXT_2UXXBIbd=aDpN8S_vrSh+bcMpG6g<%Dc7td$iL1&xhUru>kyAPG?8QC-+{u{DXn-;YOpuYRxBwX+T0f zYq0BB7KwPwfXFzyJKF`hN%q{AXnE z;oT!|(n?oWE?oFd5rz?&T|{?ZO@0&^8xt(^|hzd>6KE-WxnTnmb5HC u47Ylox8wN``X>b7zcZ}z{CV!5|2F{7T83~qTG*`s0000device->setEditText(default_dive_computer_device); - on_tabWidget_currentChanged(0); + ui->DiveComputerList->setCurrentRow(0); + on_DiveComputerList_currentRowChanged(0); } ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog() @@ -435,23 +436,6 @@ void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked() } } -void ConfigureDiveComputerDialog::on_tabWidget_currentChanged(int index) -{ - switch (index) { - case 0: - selected_vendor = "Heinrichs Weikamp"; - selected_product = "OSTC 3"; - break; - } - - int dcType = DC_TYPE_SERIAL; - - - if (selected_vendor == QString("Uemis")) - dcType = DC_TYPE_UEMIS; - fill_device_list(dcType); -} - void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() { QString filename = existing_filename ?: prefs.default_filename; @@ -466,3 +450,20 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() config->startFirmwareUpdate(firmwarePath, &device_data, errText); } } + +void ConfigureDiveComputerDialog::on_DiveComputerList_currentRowChanged(int currentRow) +{ + switch (currentRow) { + case 0: + selected_vendor = "Heinrichs Weikamp"; + selected_product = "OSTC 3"; + break; + } + + int dcType = DC_TYPE_SERIAL; + + + if (selected_vendor == QString("Uemis")) + dcType = DC_TYPE_UEMIS; + fill_device_list(dcType); +} diff --git a/qt-ui/configuredivecomputerdialog.h b/qt-ui/configuredivecomputerdialog.h index 71266c471..66871efa3 100644 --- a/qt-ui/configuredivecomputerdialog.h +++ b/qt-ui/configuredivecomputerdialog.h @@ -31,10 +31,11 @@ private slots: void on_restoreBackupButton_clicked(); - void on_tabWidget_currentChanged(int index); void on_updateFirmwareButton_clicked(); + void on_DiveComputerList_currentRowChanged(int currentRow); + private: Ui::ConfigureDiveComputerDialog *ui; diff --git a/qt-ui/configuredivecomputerdialog.ui b/qt-ui/configuredivecomputerdialog.ui index d0dd91155..41745a652 100644 --- a/qt-ui/configuredivecomputerdialog.ui +++ b/qt-ui/configuredivecomputerdialog.ui @@ -6,8 +6,8 @@ 0 0 - 785 - 670 + 844 + 616 @@ -98,682 +98,6 @@ - - - - 0 - - - - HW OSTC 3 - - - - - - - m/°C - - - - - ft/°F - - - - - - - - Salinity (0-5%): - - - salinitySpinBox - - - - - - - Custom Text: - - - customTextLlineEdit - - - - - - - % - - - - - - - % - - - - - - - % - - - 5 - - - - - - - m - - - - - - - Last Deco: - - - lastDecoSpinBox - - - - - - - - Eco - - - - - Medium - - - - - High - - - - - - - - true - - - - - - - - English - - - - - German - - - - - French - - - - - Italian - - - - - - - - Language: - - - languageComboBox - - - - - - - - 1 - 0 - - - - - - - - - 1 - 0 - - - - - 230LSB/Gauss - - - - - 330LSB/Gauss - - - - - 390LSB/Gauss - - - - - 440LSB/Gauss - - - - - 660LSB/Gauss - - - - - 820LSB/Gauss - - - - - 1090LSB/Gauss - - - - - 1370LSB/Gauss - - - - - - - - Compass Gain: - - - compassGainComboBox - - - - - - - Dive Mode: - - - diveModeComboBox - - - - - - - - 0 - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %He - - - - - %O2 - - - - - Type - - - - - Change Depth - - - - - Dil 1 - - - - - Dil 2 - - - - - Dil 3 - - - - - Dil 4 - - - - - Dil 5 - - - - - - - - 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 - - - - - - - - 2s - - - - - 10s - - - - - - - - Dive Mode Colour: - - - diveModeColour - - - - - - - - 0 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set Point [cbar] - - - - - Change Depth [m] - - - - - SP 1 - - - - - SP 2 - - - - - SP 3 - - - - - SP 4 - - - - - SP 5 - - - - - - - - - - - - color: rgb(242, 19, 25); - - - - - - - - - - - - - @@ -798,6 +122,709 @@ + + + + Qt::Horizontal + + + + + 200 + 16777215 + + + + + 12 + + + + + 64 + 64 + + + + + OSTC 3 + + + + :/icons/ostc3.png:/icons/ostc3.png + + + + + + + + + + Serial No. + + + serialNoLineEdit + + + + + + + true + + + + + + + Firmware Version: + + + firmwareVersionLineEdit + + + + + + + true + + + + + + + Custom Text: + + + customTextLlineEdit + + + + + + + + 1 + 0 + + + + + + + + Language: + + + languageComboBox + + + + + + + + English + + + + + German + + + + + French + + + + + Italian + + + + + + + + Dive Mode: + + + diveModeComboBox + + + + + + + + OC + + + + + CC + + + + + Gauge + + + + + Apnea + + + + + + + + Date Format: + + + dateFormatComboBox + + + + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + + + + + + + Saturation: + + + saturationSpinBox + + + + + + + % + + + + + + + Desaturation: + + + desaturationSpinBox + + + + + + + % + + + + + + + Last Deco: + + + lastDecoSpinBox + + + + + + + m + + + + + + + Brightness: + + + brightnessComboBox + + + + + + + + Eco + + + + + Medium + + + + + High + + + + + + + + Sampling Rate: + + + samplingRateComboBox + + + + + + + + 2s + + + + + 10s + + + + + + + + Units: + + + unitsComboBox + + + + + + + + m/°C + + + + + ft/°F + + + + + + + + Dive Mode Colour: + + + diveModeColour + + + + + + + + Standard + + + + + Red + + + + + Green + + + + + Blue + + + + + + + + Salinity (0-5%): + + + salinitySpinBox + + + + + + + % + + + 5 + + + + + + + Sync dive computer time with PC + + + + + + + Compass Gain: + + + compassGainComboBox + + + + + + + + 1 + 0 + + + + + 230LSB/Gauss + + + + + 330LSB/Gauss + + + + + 390LSB/Gauss + + + + + 440LSB/Gauss + + + + + 660LSB/Gauss + + + + + 820LSB/Gauss + + + + + 1090LSB/Gauss + + + + + 1370LSB/Gauss + + + + + + + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %O2 + + + + + %He + + + + + Type + + + + + Change Depth + + + + + Gas 1 + + + + + Gas 2 + + + + + Gas 3 + + + + + Gas 4 + + + + + Gas 5 + + + + + + + + + 0 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %He + + + + + %O2 + + + + + Type + + + + + Change Depth + + + + + Dil 1 + + + + + Dil 2 + + + + + Dil 3 + + + + + Dil 4 + + + + + Dil 5 + + + + + + + + + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Set Point [cbar] + + + + + Change Depth [m] + + + + + SP 1 + + + + + SP 2 + + + + + SP 3 + + + + + SP 4 + + + + + SP 5 + + + + + + + + + + + + + color: rgb(242, 19, 25); + + + + + + + + + + + + + @@ -807,27 +834,27 @@ saveSettingsPushButton backupButton restoreBackupButton - tabWidget - serialNoLineEdit - firmwareVersionLineEdit - customTextLlineEdit - languageComboBox - diveModeComboBox - dateFormatComboBox - saturationSpinBox - desaturationSpinBox - lastDecoSpinBox - brightnessComboBox - samplingRateComboBox - unitsComboBox - diveModeColour - salinitySpinBox - dateTimeSyncCheckBox - compassGainComboBox - ostc3GasTable - ostc3DilTable cancel - - + + + + + + DiveComputerList + currentRowChanged(int) + dcStackedWidget + setCurrentIndex(int) + + + 258 + 130 + + + 292 + 118 + + + + diff --git a/subsurface.qrc b/subsurface.qrc index dfeea6819..1951bb424 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -59,10 +59,11 @@ icons/ead.png icons/icon-HR.png icons/calendarbg.png - icons/pictures.png + icons/pictures.png icons/subsurface/index.theme icons/subsurface/32x32/actions/go-down.png icons/subsurface/32x32/actions/go-up.png icons/subsurface/32x32/actions/window-close.png + icons/ostc3.png From 4cc60ea940621ff21d082dad76bd9f2a710296f7 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 22 Jul 2014 19:38:30 +0300 Subject: [PATCH 29/33] Use QXmlStreamReader for xml restore This patch changes reading of OSTC 3 settings backup xml from libxml to QXmlStreamReader to match the use of QXmlStreamWriter in the xml saving. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 404 ++++++++++++++++++-------------------- 1 file changed, 190 insertions(+), 214 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index 4a251e051..fac603f84 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -26,10 +26,10 @@ void ConfigureDiveComputer::readSettings(device_data_t *data) readThread = new ReadSettingsThread(this, data); connect(readThread, SIGNAL(finished()), - this, SLOT(readThreadFinished()), Qt::QueuedConnection); + this, SLOT(readThreadFinished()), Qt::QueuedConnection); connect(readThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); connect(readThread, SIGNAL(devicedetails(DeviceDetails*)), this, - SIGNAL(deviceDetailsChanged(DeviceDetails*))); + SIGNAL(deviceDetailsChanged(DeviceDetails*))); readThread->start(); } @@ -43,7 +43,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat writeThread = new WriteSettingsThread(this, data); connect(writeThread, SIGNAL(finished()), - this, SLOT(writeThreadFinished()), Qt::QueuedConnection); + this, SLOT(writeThreadFinished()), Qt::QueuedConnection); connect(writeThread, SIGNAL(error(QString)), this, SLOT(setError(QString))); writeThread->setDeviceDetails(details); @@ -201,225 +201,201 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText) { - xmlDocPtr doc; - xmlNodePtr node; - xmlChar *key; - - doc = xmlParseFile(fileName.toUtf8().data()); - - if (doc == NULL) { - errorText = tr("Could not read the backup file."); + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) { + errorText = tr("Could not open backup file: %1").arg(file.errorString()); return false; } - node = xmlDocGetRootElement(doc); - if (node == NULL) { - errorText = tr("The specified file is invalid."); - xmlFreeDoc(doc); - return false; - } + QString xml = file.readAll(); - if (xmlStrcmp(node->name, (const xmlChar *) "DiveComputerSettingsBackup")) { - errorText = tr("The specified file does not contain a valid backup."); - xmlFreeDoc(doc); - return false; - } + QXmlStreamReader reader(xml); + while (!reader.atEnd()) { + if (reader.isStartElement()) { + QString settingName = reader.name().toString(); + reader.readNext(); + QString keyString = reader.text().toString(); - xmlNodePtr child = node->children; + if (settingName == "CustomText") + details->setCustomText(keyString); - while (child != NULL) { - QString nodeName = (char *)child->name; - if (nodeName == "Settings") { - xmlNodePtr settingNode = child->children; - while (settingNode != NULL) { - QString settingName = (char *)settingNode->name; - key = xmlNodeListGetString(doc, settingNode->xmlChildrenNode, 1); - QString keyString = (char *)key; - if (settingName != "text") { - if (settingName == "CustomText") - details->setCustomText(keyString); - - if (settingName == "Gas1") { - QStringList gasData = keyString.split(","); - gas gas1; - gas1.oxygen = gasData.at(0).toInt(); - gas1.helium = gasData.at(1).toInt(); - gas1.type = gasData.at(2).toInt(); - gas1.depth = gasData.at(3).toInt(); - details->setGas1(gas1); - } - - if (settingName == "Gas2") { - QStringList gasData = keyString.split(","); - gas gas2; - gas2.oxygen = gasData.at(0).toInt(); - gas2.helium = gasData.at(1).toInt(); - gas2.type = gasData.at(2).toInt(); - gas2.depth = gasData.at(3).toInt(); - details->setGas1(gas2); - } - - if (settingName == "Gas3") { - QStringList gasData = keyString.split(","); - gas gas3; - gas3.oxygen = gasData.at(0).toInt(); - gas3.helium = gasData.at(1).toInt(); - gas3.type = gasData.at(2).toInt(); - gas3.depth = gasData.at(3).toInt(); - details->setGas3(gas3); - } - - if (settingName == "Gas4") { - QStringList gasData = keyString.split(","); - gas gas4; - gas4.oxygen = gasData.at(0).toInt(); - gas4.helium = gasData.at(1).toInt(); - gas4.type = gasData.at(2).toInt(); - gas4.depth = gasData.at(3).toInt(); - details->setGas4(gas4); - } - - if (settingName == "Gas5") { - QStringList gasData = keyString.split(","); - gas gas5; - gas5.oxygen = gasData.at(0).toInt(); - gas5.helium = gasData.at(1).toInt(); - gas5.type = gasData.at(2).toInt(); - gas5.depth = gasData.at(3).toInt(); - 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 == "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()); - - if (settingName == "Desaturation") - details->setDesaturation(keyString.toInt()); - - if (settingName == "DiveMode") - details->setDiveMode(keyString.toInt()); - - if (settingName == "LastDeco") - details->setLastDeco(keyString.toInt()); - - if (settingName == "Brightness") - details->setBrightness(keyString.toInt()); - - if (settingName == "Units") - details->setUnits(keyString.toInt()); - - if (settingName == "SamplingRate") - details->setSamplingRate(keyString.toInt()); - - if (settingName == "Salinity") - details->setSalinity(keyString.toInt()); - - if (settingName == "DiveModeColour") - details->setDiveModeColor(keyString.toInt()); - - if (settingName == "Language") - details->setLanguage(keyString.toInt()); - - if (settingName == "DateFormat") - details->setDateFormat(keyString.toInt()); - - if (settingName == "CompassGain") - details->setCompassGain(keyString.toInt()); - } - - settingNode = settingNode->next; + if (settingName == "Gas1") { + QStringList gasData = keyString.split(","); + gas gas1; + gas1.oxygen = gasData.at(0).toInt(); + gas1.helium = gasData.at(1).toInt(); + gas1.type = gasData.at(2).toInt(); + gas1.depth = gasData.at(3).toInt(); + details->setGas1(gas1); } + + if (settingName == "Gas2") { + QStringList gasData = keyString.split(","); + gas gas2; + gas2.oxygen = gasData.at(0).toInt(); + gas2.helium = gasData.at(1).toInt(); + gas2.type = gasData.at(2).toInt(); + gas2.depth = gasData.at(3).toInt(); + details->setGas1(gas2); + } + + if (settingName == "Gas3") { + QStringList gasData = keyString.split(","); + gas gas3; + gas3.oxygen = gasData.at(0).toInt(); + gas3.helium = gasData.at(1).toInt(); + gas3.type = gasData.at(2).toInt(); + gas3.depth = gasData.at(3).toInt(); + details->setGas3(gas3); + } + + if (settingName == "Gas4") { + QStringList gasData = keyString.split(","); + gas gas4; + gas4.oxygen = gasData.at(0).toInt(); + gas4.helium = gasData.at(1).toInt(); + gas4.type = gasData.at(2).toInt(); + gas4.depth = gasData.at(3).toInt(); + details->setGas4(gas4); + } + + if (settingName == "Gas5") { + QStringList gasData = keyString.split(","); + gas gas5; + gas5.oxygen = gasData.at(0).toInt(); + gas5.helium = gasData.at(1).toInt(); + gas5.type = gasData.at(2).toInt(); + gas5.depth = gasData.at(3).toInt(); + 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 == "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()); + + if (settingName == "Desaturation") + details->setDesaturation(keyString.toInt()); + + if (settingName == "DiveMode") + details->setDiveMode(keyString.toInt()); + + if (settingName == "LastDeco") + details->setLastDeco(keyString.toInt()); + + if (settingName == "Brightness") + details->setBrightness(keyString.toInt()); + + if (settingName == "Units") + details->setUnits(keyString.toInt()); + + if (settingName == "SamplingRate") + details->setSamplingRate(keyString.toInt()); + + if (settingName == "Salinity") + details->setSalinity(keyString.toInt()); + + if (settingName == "DiveModeColour") + details->setDiveModeColor(keyString.toInt()); + + if (settingName == "Language") + details->setLanguage(keyString.toInt()); + + if (settingName == "DateFormat") + details->setDateFormat(keyString.toInt()); + + if (settingName == "CompassGain") + details->setCompassGain(keyString.toInt()); } - child = child->next; + reader.readNext(); } return true; From 24cb0b0496e8f593f22f3e1cd25b286ad8c7031f Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 31 Jul 2014 18:43:52 +0300 Subject: [PATCH 30/33] Hide status message when an error message is present To avoid confusion, this code update makes the status text empty whenever there is an error message. This makes the error message more prominent. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- qt-ui/configuredivecomputerdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index c9e8da751..293dd244b 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -246,6 +246,7 @@ void ConfigureDiveComputerDialog::configMessage(QString msg) void ConfigureDiveComputerDialog::configError(QString err) { + ui->statusLabel->setText(""); ui->errorLabel->setText(err); } From 4e99382c96c71e5427a7f1ef011b04f0e560a1f6 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 31 Jul 2014 18:51:38 +0300 Subject: [PATCH 31/33] Improve on error reporting in the ConfigureDiveComputer class This patch improves on the error reporting for the dive computer configuration dialog to use config->lastError. The previous code was using a different argument in each function, which lacked uniformity. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputer.cpp | 10 +++++----- configuredivecomputer.h | 6 +++--- qt-ui/configuredivecomputerdialog.cpp | 13 +++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp index fac603f84..5fe5a4a91 100644 --- a/configuredivecomputer.cpp +++ b/configuredivecomputer.cpp @@ -50,7 +50,7 @@ void ConfigureDiveComputer::saveDeviceDetails(DeviceDetails *details, device_dat writeThread->start(); } -bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText) +bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data) { QString xml = ""; QString vendor = data->vendor; @@ -187,7 +187,7 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai writer.writeEndDocument(); QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { - errorText = tr("Could not save the backup file %1. Error Message: %2") + lastError = tr("Could not save the backup file %1. Error Message: %2") .arg(fileName, file.errorString()); return false; } @@ -199,11 +199,11 @@ bool ConfigureDiveComputer::saveXMLBackup(QString fileName, DeviceDetails *detai return true; } -bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText) +bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *details) { QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - errorText = tr("Could not open backup file: %1").arg(file.errorString()); + lastError = tr("Could not open backup file: %1").arg(file.errorString()); return false; } @@ -401,7 +401,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString fileName, DeviceDetails *de return true; } -void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText) +void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t *data) { } diff --git a/configuredivecomputer.h b/configuredivecomputer.h index 0cd16d311..4522e9fbe 100644 --- a/configuredivecomputer.h +++ b/configuredivecomputer.h @@ -32,9 +32,9 @@ public: device_data_t *m_data; void saveDeviceDetails(DeviceDetails *details, device_data_t *data); void fetchDeviceDetails(); - bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data, QString errorText); - bool restoreXMLBackup(QString fileName, DeviceDetails *details, QString errorText); - void startFirmwareUpdate(QString fileName, device_data_t *data, QString errorText); + bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data); + bool restoreXMLBackup(QString fileName, DeviceDetails *details); + void startFirmwareUpdate(QString fileName, device_data_t *data); signals: void message(QString msg); void error(QString err); diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 293dd244b..e40522529 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -396,11 +396,10 @@ void ConfigureDiveComputerDialog::on_backupButton_clicked() if (!backupPath.isEmpty()) { populateDeviceDetails(); getDeviceData(); - QString errorText = ""; - if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data, errorText)) { + if (!config->saveXMLBackup(backupPath, deviceDetails, &device_data)) { QMessageBox::critical(this, tr("XML Backup Error"), tr("An error occurred while saving the backup file.\n%1") - .arg(errorText) + .arg(config->lastError) ); } else { QMessageBox::information(this, tr("Backup succeeded"), @@ -420,11 +419,10 @@ void ConfigureDiveComputerDialog::on_restoreBackupButton_clicked() filename, tr("Backup files (*.xml)") ); if (!restorePath.isEmpty()) { - QString errorText = ""; - if (!config->restoreXMLBackup(restorePath, deviceDetails, errorText)) { + if (!config->restoreXMLBackup(restorePath, deviceDetails)) { QMessageBox::critical(this, tr("XML Restore Error"), tr("An error occurred while restoring the backup file.\n%1") - .arg(errorText) + .arg(config->lastError) ); } else { reloadValues(); @@ -447,8 +445,7 @@ void ConfigureDiveComputerDialog::on_updateFirmwareButton_clicked() ); if (!firmwarePath.isEmpty()) { getDeviceData(); - QString errText; - config->startFirmwareUpdate(firmwarePath, &device_data, errText); + config->startFirmwareUpdate(firmwarePath, &device_data); } } From 1b866e67f3f03347d187d941d51cd35d4c2217ff Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 17 Aug 2014 10:06:06 -0700 Subject: [PATCH 32/33] Ensure Subsurface still compiles with libdivecomputer 0.4.x The OSTC3 functions we need were introduced in 0.5.0 (more specifically, in commit 56e2dec7266e71e725604a4a8bff5e61f3d62259). Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 7bd921e6d..093499ad1 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -58,6 +58,7 @@ void ReadSettingsThread::run() if (rc == DC_STATUS_SUCCESS) { DeviceDetails *m_deviceDetails = new DeviceDetails(0); switch (dc_device_get_type(m_data->device)) { +#if DC_VERSION_CHECK(0, 5, 0) case DC_FAMILY_HW_OSTC3: supported = true; m_deviceDetails->setBrightness(0); @@ -296,7 +297,7 @@ void ReadSettingsThread::run() emit devicedetails(m_deviceDetails); break; - +#endif // divecomputer 0.5.0 } dc_device_close(m_data->device); @@ -328,6 +329,7 @@ void WriteSettingsThread::run() rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); if (rc == DC_STATUS_SUCCESS) { switch (dc_device_get_type(m_data->device)) { +#if DC_VERSION_CHECK(0,5,0) case DC_FAMILY_HW_OSTC3: supported = true; //write gas values @@ -493,7 +495,7 @@ void WriteSettingsThread::run() } break; - +#endif // divecomputer 0.5.0 } dc_device_close(m_data->device); @@ -522,10 +524,12 @@ void FirmwareUpdateThread::run() rc = rc = dc_device_open(&m_data->device, m_data->context, m_data->descriptor, m_data->devname); if (rc == DC_STATUS_SUCCESS) { switch (dc_device_get_type(m_data->device)) { +#if DC_VERSION_CHECK(0, 5, 0) case DC_FAMILY_HW_OSTC3: supported = true; //hw_ostc3_device_fwupdate(m_data->device, m_fileName.toUtf8().data()); break; +#endif // divecomputer 0.5.0 } dc_device_close(m_data->device); From 7264ec2fa877eeffa99745ac4d7af91b93217aa5 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Mon, 18 Aug 2014 01:57:29 +0300 Subject: [PATCH 33/33] Change presentation of OSTC 3 firmware version This change changes the way we present the OSTC 3 firmware version to a correct value, showing the major and minor version number. Signed-off-by: Joseph W. Joshua Signed-off-by: Thiago Macieira --- configuredivecomputerthreads.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp index 093499ad1..0e32f5475 100644 --- a/configuredivecomputerthreads.cpp +++ b/configuredivecomputerthreads.cpp @@ -289,8 +289,7 @@ void ReadSettingsThread::run() if (rc == DC_STATUS_SUCCESS) { int serial = fData[0] + (fData[1] << 8); m_deviceDetails->setSerialNo(QString::number(serial)); - int fw = (fData[2] << 8) + fData[3]; - m_deviceDetails->setFirmwareVersion(QString::number(fw)); + m_deviceDetails->setFirmwareVersion(QString::number(fData[2]) + "." + QString::number(fData[3])); QByteArray ar((char *)fData + 4, 60); m_deviceDetails->setCustomText(ar.trimmed()); }