From ec02737eda780284562692168569d9dd3837a1a9 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 29 May 2014 18:54:19 +0300 Subject: 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 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 qt-ui/configuredivecomputerdialog.cpp (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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; +} -- cgit v1.2.3-70-g09d2 From 791fbee260b3b0884963b8ff0e2e2968ef130792 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 29 May 2014 19:16:34 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 -- cgit v1.2.3-70-g09d2 From a7c9b25b053ee77a816e1555f1c00c3e4b996396 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 30 May 2014 09:56:27 +0300 Subject: 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 (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 -- cgit v1.2.3-70-g09d2 From 3e127a059f598a30e9cfd71411783d71f40b315f Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 30 May 2014 10:49:58 +0300 Subject: 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 | 90 +++++++++++++++++++++++++++++++++-- qt-ui/configuredivecomputer.h | 26 ++++++++-- qt-ui/configuredivecomputerdialog.cpp | 25 ++++++++++ qt-ui/configuredivecomputerdialog.h | 4 ++ qt-ui/configuredivecomputerdialog.ui | 18 +++++++ 5 files changed, 155 insertions(+), 8 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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,27 +24,55 @@ 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::readThreadFinished() +void ConfigureDiveComputer::writeThreadFinished() { setState(DONE); - emit deviceSettings(readThread->result); + if (writeThread->lastError.isEmpty()) { + //No error + emit message(tr("Setting successfully written to device")); + } } ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *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 + + + + + -- cgit v1.2.3-70-g09d2 From 2432350064c6a9109501b3df21f56a9fe41aa686 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 7 Jun 2014 21:56:44 +0300 Subject: 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(+) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 + + + + + + + + ... + + + -- cgit v1.2.3-70-g09d2 From 4fc16b16749a73b8c06d41cb7cb22b78c77ab29e Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 15:03:26 +0300 Subject: 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 (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 -- cgit v1.2.3-70-g09d2 From 20eb62a98a70c1773ff99ece05f1c69e6ca8ce15 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 18:25:25 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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; }; -- cgit v1.2.3-70-g09d2 From 3534e29ae2165aab491c2e0cdecd667dd8cf50e8 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 18:37:37 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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; }; -- cgit v1.2.3-70-g09d2 From e54d7d9178fc159f068587a59244340bec068efb Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Tue, 10 Jun 2014 19:19:28 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 + + + -- cgit v1.2.3-70-g09d2 From aad60ef6da3308960767a47cb750c2ba9aab54bd Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 09:37:27 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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; -- cgit v1.2.3-70-g09d2 From 09ec8a44e5c48b6b6a2e4ebb1253fd3cd94154ae Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 11:09:01 +0300 Subject: 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 | 259 ++++++++++++++++++---- qt-ui/configuredivecomputerthreads.cpp | 61 ++++++ qt-ui/devicedetails.cpp | 389 +++++++++++++++++++++++++++++++++ qt-ui/devicedetails.h | 148 ++++++++++++- 6 files changed, 851 insertions(+), 44 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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,44 +270,144 @@ - + + + + true + + + + Date Format: + + + + Firmware Version: + + + + + + + + 1 + 0 + + + + + + + + Units: + + + - + - MMDDYY + 2s - DDMMYY + 10s + + + + + + Dive Mode Colour: + + + + + - YYMMDD + Standard + + + + + Red + + + + + Green + + + + + Blue - - - - true + + + + Compass Gain: - - - - Sync dive computer time with PC + + + + + 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; }; -- cgit v1.2.3-70-g09d2 From 8ccf2e8f1d05fb34854ce5f5de935d523484e163 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 11 Jun 2014 11:47:25 +0300 Subject: 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 | 612 +++++++++++++++++----------------- 3 files changed, 349 insertions(+), 390 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 - + + + 0 + + + + HW OSTC 3 + + + + + + m + + - - - ft/°F - + + + + Sync dive computer time with PC + + - - - - - - - Eco - + + + + Units: + + - - - Medium - + + + + Salinity (0-5%): + + - - - High - + + + + Language: + + - - - - - - - MMDDYY - + + + + Custom Text: + + - - - DDMMYY - + + + + + 1 + 0 + + + - - - YYMMDD - + + + + Date Format: + + - - - - - - - English - + + + + Compass Gain: + + - - - German - + + + + true + + - - - French - + + + + Last Deco: + + - - - Italian - + + + + Qt::Vertical + + + + 20 + 40 + + + - - - - - - true - - - - - - - Date Format: - - - - - - - Firmware Version: - - - - - - - - 1 - 0 - - - - - - - - Units: - - - - - - - - 2s - + + + + true + + - - - 10s - + + + + + Standard + + + + + Red + + + + + Green + + + + + Blue + + + - - - - - - Dive Mode Colour: - - - - - - - - Standard - + + + + + MMDDYY + + + + + DDMMYY + + + + + YYMMDD + + + - - - Red - + + + + + m/°C + + + + + ft/°F + + + - - - Green - + + + + + English + + + + + German + + + + + French + + + + + Italian + + + - - - Blue - + + + + Brightness: + + - - - - - - Compass Gain: - - - - - - - - 1 - 0 - - - - - 230LSB/Gauss - + + + + Serial No. + + - - - 330LSB/Gauss - + + + + Dive Mode Colour: + + - - - 390LSB/Gauss - + + + + Sampling Rate: + + - - - 440LSB/Gauss - + + + + + Eco + + + + + Medium + + + + + High + + + - - - 660LSB/Gauss - + + + + + 2s + + + + + 10s + + + - - - 820LSB/Gauss - + + + + Firmware Version: + + - - - 1090LSB/Gauss - + + + + % + + + 5 + + - - - 1370LSB/Gauss - + + + + + 1 + 0 + + + + + 230LSB/Gauss + + + + + 330LSB/Gauss + + + + + 390LSB/Gauss + + + + + 440LSB/Gauss + + + + + 660LSB/Gauss + + + + + 820LSB/Gauss + + + + + 1090LSB/Gauss + + + + + 1370LSB/Gauss + + + - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - + + + @@ -469,13 +455,13 @@ - vendor - product device search retrieveDetails + saveSettingsPushButton backupButton restoreBackupButton + tabWidget serialNoLineEdit firmwareVersionLineEdit customTextLlineEdit -- cgit v1.2.3-70-g09d2 From 5292bcbf2134901e3120fb15e2f85626b2ceb1ad Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 13 Jun 2014 17:10:10 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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)); -- cgit v1.2.3-70-g09d2 From 045a6fb6b16ae402588484fb8361f15f8978bdd3 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Fri, 20 Jun 2014 07:51:32 +0300 Subject: 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 | 474 ++++++++++++++++++++++----------- qt-ui/configuredivecomputerthreads.cpp | 25 ++ 4 files changed, 354 insertions(+), 159 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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,48 +98,48 @@ HW OSTC 3 - - - - m + + + + Serial No. - - - - Dive Mode Colour: + + + + true - - + + - Sync dive computer time with PC + Firmware Version: - - - - Units: + + + + true - - + + - Salinity (0-5%): + Custom Text: - - - - % - - - 5 + + + + + 1 + 0 + @@ -150,41 +150,86 @@ - - + + + + + English + + + + + German + + + + + French + + + + + Italian + + + + + + - Date Format: + Dive Mode: - - - - - 1 - 0 - - + + + + + OC + + + + + CC + + + + + Gauge + + + + + Apnea + + - - + + - Custom Text: + Saturation: - - + + + + % + + + + + - Compass Gain: + Desaturation: - - - - true + + + + % @@ -195,49 +240,45 @@ - - - - true + + + + m - - - - - Standard - - + + + + Brightness: + + + + + - Red + Eco - Green + Medium - Blue + High - - - - Qt::Vertical - - - - 20 - 40 - + + + + Date Format: - + @@ -258,28 +299,11 @@ - - - - - English - - - - - German - - - - - French - - - - - Italian - - + + + + Units: + @@ -296,20 +320,6 @@ - - - - Brightness: - - - - - - - Serial No. - - - @@ -317,25 +327,6 @@ - - - - - Eco - - - - - Medium - - - - - High - - - - @@ -350,44 +341,61 @@ - - + + - Firmware Version: + Salinity (0-5%): - - + + + + % + + + 5 + + + + + - Dive Mode: + Dive Mode Colour: - - + + - OC + Standard - CC + Red - Gauge + Green - Apnea + Blue + + + + Compass Gain: + + + @@ -438,33 +446,183 @@ - - - - Saturation: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + - - + + - Desaturation: + Sync dive computer time with PC - - - - % + + + + Qt::Vertical - + + + 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 -- cgit v1.2.3-70-g09d2 From 8b39d2fc172b72ade19a754f33575f663573f147 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 08:46:57 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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))); } -- cgit v1.2.3-70-g09d2 From a52beebbe9ba8d335d6d867a868166996dc6711e Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 09:14:55 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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() -- cgit v1.2.3-70-g09d2 From 9c032f20c02fbb7c1e3906dbc8392539e0125327 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 09:53:05 +0300 Subject: 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 | 22 ++++---- 4 files changed, 261 insertions(+), 11 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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,17 +475,17 @@ - Gas No. + - %He + %O2 - %O2 + %He @@ -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 -- cgit v1.2.3-70-g09d2 From 8aa7fddb22cd6ab4d533082598be04649bb1ff21 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Sat, 21 Jun 2014 10:22:47 +0300 Subject: 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 | 616 ++++++++++++++++++++-------------- 4 files changed, 553 insertions(+), 246 deletions(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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,356 +101,388 @@ HW OSTC 3 - - + + + + + m/°C + + + + + ft/°F + + + + + + - Serial No. + Salinity (0-5%): + + + salinitySpinBox - - - - true + + + + Custom Text: + + + customTextLlineEdit - - - - Firmware Version: + + + + % - - - - true + + + + % - - - - Custom Text: + + + + % + + + 5 - - - - - 1 - 0 - + + + + m - - + + - Language: + Last Deco: + + + lastDecoSpinBox - - - - - English - - + + - German + Eco - French + Medium - Italian + High - - - - Dive Mode: + + + + true - - + + - OC + English - CC + German - Gauge + French - Apnea + Italian - - - - Saturation: - - - - - - - % - - - - - + + - Desaturation: - - - - - - - % + Language: - - - - - - Last Deco: + + languageComboBox - - - - m + + + + + 1 + 0 + - - - - Brightness: + + + + + 1 + 0 + - - - - - Eco + 230LSB/Gauss - Medium + 330LSB/Gauss - High + 390LSB/Gauss - - - - - - Date Format: - - - - - - MMDDYY + 440LSB/Gauss - DDMMYY + 660LSB/Gauss - YYMMDD + 820LSB/Gauss - - - - - - Units: - - - - - - m/°C + 1090LSB/Gauss - ft/°F + 1370LSB/Gauss - - + + - Sampling Rate: + Compass Gain: + + + compassGainComboBox - - - + + + + Dive Mode: + + + diveModeComboBox + + + + + + + + 0 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %He + + + + + %O2 + + + + + Type + + + + + Change Depth + + + + + Dil 1 + + + + + Dil 2 + + + - 2s + Dil 3 - + - 10s + Dil 4 + + + + + Dil 5 - - + + - Salinity (0-5%): - - - - - - - % + Units: - - 5 + + unitsComboBox - - + + - Dive Mode Colour: + Desaturation: + + + desaturationSpinBox - - + + - Standard + OC - Red + CC - Green + Gauge - Blue + Apnea - - + + - Compass Gain: + Serial No. + + + serialNoLineEdit - - - - - 1 - 0 - + + + + Brightness: + + + brightnessComboBox + + + + + + + Saturation: + + + saturationSpinBox - - - 230LSB/Gauss - - - - - 330LSB/Gauss - - - - - 390LSB/Gauss - - - - - 440LSB/Gauss - - - - - 660LSB/Gauss - - - - - 820LSB/Gauss - - - - - 1090LSB/Gauss - - - - - 1370LSB/Gauss - - + + + 0 + 1 + + @@ -525,8 +560,125 @@ - - + + + + + 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 + + @@ -559,71 +711,41 @@ - %He - - - - - %O2 - - - - - Type + Set Point [cbar] - Change Depth + Change Depth [m] - Dil 1 + SP 1 - Dil 2 + SP 2 - Dil 3 + SP 3 - Dil 4 + SP 4 - Dil 5 + SP 5 - - - - Sync dive computer time with PC - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -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 -- cgit v1.2.3-70-g09d2 From cc6c385f3309417727f61b55550d6d47bef004dd Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Mon, 23 Jun 2014 18:16:27 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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 + + + -- cgit v1.2.3-70-g09d2 From a9b55d7f0d00d68523058c5714fa4b199cbf2211 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Wed, 16 Jul 2014 12:04:54 +0300 Subject: 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 (limited to 'qt-ui/configuredivecomputerdialog.cpp') diff --git a/icons/ostc3.png b/icons/ostc3.png new file mode 100644 index 000000000..5c49a76b3 Binary files /dev/null and b/icons/ostc3.png differ diff --git a/qt-ui/configuredivecomputerdialog.cpp b/qt-ui/configuredivecomputerdialog.cpp index 733d64a4f..c9e8da751 100644 --- a/qt-ui/configuredivecomputerdialog.cpp +++ b/qt-ui/configuredivecomputerdialog.cpp @@ -50,7 +50,8 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) : if (default_dive_computer_device) ui->device->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 -- cgit v1.2.3-70-g09d2 From 24cb0b0496e8f593f22f3e1cd25b286ad8c7031f Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 31 Jul 2014 18:43:52 +0300 Subject: 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(+) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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); } -- cgit v1.2.3-70-g09d2 From 4e99382c96c71e5427a7f1ef011b04f0e560a1f6 Mon Sep 17 00:00:00 2001 From: "Joseph W. Joshua" Date: Thu, 31 Jul 2014 18:51:38 +0300 Subject: 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(-) (limited to 'qt-ui/configuredivecomputerdialog.cpp') 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); } } -- cgit v1.2.3-70-g09d2