2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-06-10 12:03:26 +00:00
|
|
|
#include "configuredivecomputerthreads.h"
|
2017-04-13 21:55:33 +00:00
|
|
|
#include "libdivecomputer/hw_ostc.h"
|
|
|
|
#include "libdivecomputer/hw_ostc3.h"
|
2015-05-27 19:19:12 +00:00
|
|
|
#include "libdivecomputer.h"
|
2019-08-05 17:41:15 +00:00
|
|
|
#include "units.h"
|
|
|
|
#include "errorhelper.h"
|
2014-06-10 12:03:26 +00:00
|
|
|
|
2014-07-03 06:57:55 +00:00
|
|
|
#define OSTC3_GAS1 0x10
|
|
|
|
#define OSTC3_GAS2 0x11
|
|
|
|
#define OSTC3_GAS3 0x12
|
|
|
|
#define OSTC3_GAS4 0x13
|
|
|
|
#define OSTC3_GAS5 0x14
|
|
|
|
#define OSTC3_DIL1 0x15
|
|
|
|
#define OSTC3_DIL2 0x16
|
|
|
|
#define OSTC3_DIL3 0x17
|
|
|
|
#define OSTC3_DIL4 0x18
|
|
|
|
#define OSTC3_DIL5 0x19
|
|
|
|
#define OSTC3_SP1 0x1A
|
|
|
|
#define OSTC3_SP2 0x1B
|
|
|
|
#define OSTC3_SP3 0x1C
|
|
|
|
#define OSTC3_SP4 0x1D
|
|
|
|
#define OSTC3_SP5 0x1E
|
|
|
|
#define OSTC3_CCR_MODE 0x1F
|
|
|
|
#define OSTC3_DIVE_MODE 0x20
|
|
|
|
#define OSTC3_DECO_TYPE 0x21
|
2014-10-17 22:33:36 +00:00
|
|
|
#define OSTC3_PPO2_MAX 0x22
|
|
|
|
#define OSTC3_PPO2_MIN 0x23
|
2014-07-03 06:57:55 +00:00
|
|
|
#define OSTC3_FUTURE_TTS 0x24
|
|
|
|
#define OSTC3_GF_LOW 0x25
|
|
|
|
#define OSTC3_GF_HIGH 0x26
|
|
|
|
#define OSTC3_AGF_LOW 0x27
|
|
|
|
#define OSTC3_AGF_HIGH 0x28
|
|
|
|
#define OSTC3_AGF_SELECTABLE 0x29
|
2017-04-27 19:25:04 +00:00
|
|
|
#define OSTC4_VPM_CONSERVATISM 0x29
|
2014-07-03 06:57:55 +00:00
|
|
|
#define OSTC3_SATURATION 0x2A
|
|
|
|
#define OSTC3_DESATURATION 0x2B
|
|
|
|
#define OSTC3_LAST_DECO 0x2C
|
|
|
|
#define OSTC3_BRIGHTNESS 0x2D
|
|
|
|
#define OSTC3_UNITS 0x2E
|
|
|
|
#define OSTC3_SAMPLING_RATE 0x2F
|
|
|
|
#define OSTC3_SALINITY 0x30
|
|
|
|
#define OSTC3_DIVEMODE_COLOR 0x31
|
|
|
|
#define OSTC3_LANGUAGE 0x32
|
|
|
|
#define OSTC3_DATE_FORMAT 0x33
|
|
|
|
#define OSTC3_COMPASS_GAIN 0x34
|
|
|
|
#define OSTC3_PRESSURE_SENSOR_OFFSET 0x35
|
|
|
|
#define OSTC3_SAFETY_STOP 0x36
|
2014-10-17 22:33:42 +00:00
|
|
|
#define OSTC3_CALIBRATION_GAS_O2 0x37
|
|
|
|
#define OSTC3_SETPOINT_FALLBACK 0x38
|
|
|
|
#define OSTC3_FLIP_SCREEN 0x39
|
2015-09-02 22:00:00 +00:00
|
|
|
#define OSTC3_LEFT_BUTTON_SENSIVITY 0x3A
|
2017-08-04 13:25:54 +00:00
|
|
|
#define OSTC3_RIGHT_BUTTON_SENSIVITY 0x3B
|
2017-04-27 19:25:04 +00:00
|
|
|
#define OSTC4_BUTTON_SENSIVITY 0x3A
|
2015-09-02 22:00:00 +00:00
|
|
|
#define OSTC3_BOTTOM_GAS_CONSUMPTION 0x3C
|
|
|
|
#define OSTC3_DECO_GAS_CONSUMPTION 0x3D
|
|
|
|
#define OSTC3_MOD_WARNING 0x3E
|
2017-04-27 19:25:04 +00:00
|
|
|
#define OSTC4_TRAVEL_GAS_CONSUMPTION 0x3E
|
2015-09-02 22:00:00 +00:00
|
|
|
#define OSTC3_DYNAMIC_ASCEND_RATE 0x3F
|
|
|
|
#define OSTC3_GRAPHICAL_SPEED_INDICATOR 0x40
|
|
|
|
#define OSTC3_ALWAYS_SHOW_PPO2 0x41
|
2016-01-22 13:17:49 +00:00
|
|
|
#define OSTC3_TEMP_SENSOR_OFFSET 0x42
|
2016-01-22 13:17:50 +00:00
|
|
|
#define OSTC3_SAFETY_STOP_LENGTH 0x43
|
|
|
|
#define OSTC3_SAFETY_STOP_START_DEPTH 0x44
|
|
|
|
#define OSTC3_SAFETY_STOP_END_DEPTH 0x45
|
|
|
|
#define OSTC3_SAFETY_STOP_RESET_DEPTH 0x46
|
2014-07-03 06:57:55 +00:00
|
|
|
|
2014-10-12 14:51:28 +00:00
|
|
|
#define SUUNTO_VYPER_MAXDEPTH 0x1e
|
|
|
|
#define SUUNTO_VYPER_TOTAL_TIME 0x20
|
|
|
|
#define SUUNTO_VYPER_NUMBEROFDIVES 0x22
|
|
|
|
#define SUUNTO_VYPER_COMPUTER_TYPE 0x24
|
|
|
|
#define SUUNTO_VYPER_FIRMWARE 0x25
|
|
|
|
#define SUUNTO_VYPER_SERIALNUMBER 0x26
|
|
|
|
#define SUUNTO_VYPER_CUSTOM_TEXT 0x2c
|
|
|
|
#define SUUNTO_VYPER_SAMPLING_RATE 0x53
|
|
|
|
#define SUUNTO_VYPER_ALTITUDE_SAFETY 0x54
|
|
|
|
#define SUUNTO_VYPER_TIMEFORMAT 0x60
|
|
|
|
#define SUUNTO_VYPER_UNITS 0x62
|
|
|
|
#define SUUNTO_VYPER_MODEL 0x63
|
|
|
|
#define SUUNTO_VYPER_LIGHT 0x64
|
|
|
|
#define SUUNTO_VYPER_ALARM_DEPTH_TIME 0x65
|
|
|
|
#define SUUNTO_VYPER_ALARM_TIME 0x66
|
|
|
|
#define SUUNTO_VYPER_ALARM_DEPTH 0x68
|
2017-11-16 21:00:26 +00:00
|
|
|
#define SUUNTO_VYPER_CUSTOM_TEXT_LENGTH 30
|
2014-10-12 14:51:28 +00:00
|
|
|
|
2014-10-27 20:55:00 +00:00
|
|
|
#ifdef DEBUG_OSTC
|
|
|
|
// Fake io to ostc memory banks
|
|
|
|
#define hw_ostc_device_eeprom_read local_hw_ostc_device_eeprom_read
|
|
|
|
#define hw_ostc_device_eeprom_write local_hw_ostc_device_eeprom_write
|
|
|
|
#define OSTC_FILE "../OSTC-data-dump.bin"
|
|
|
|
|
2014-12-30 15:13:42 +00:00
|
|
|
// Fake the open function.
|
|
|
|
static dc_status_t local_dc_device_open(dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *name)
|
|
|
|
{
|
|
|
|
if (strcmp(dc_descriptor_get_vendor(descriptor), "Heinrichs Weikamp") == 0 &&strcmp(dc_descriptor_get_product(descriptor), "OSTC 2N") == 0)
|
|
|
|
return DC_STATUS_SUCCESS;
|
|
|
|
else
|
|
|
|
return dc_device_open(out, context, descriptor, name);
|
|
|
|
}
|
|
|
|
#define dc_device_open local_dc_device_open
|
|
|
|
|
2014-10-27 20:55:00 +00:00
|
|
|
static dc_status_t local_hw_ostc_device_eeprom_read(void *ignored, unsigned char bank, unsigned char data[], unsigned int data_size)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
if ((f = fopen(OSTC_FILE, "r")) == NULL)
|
|
|
|
return DC_STATUS_NODEVICE;
|
|
|
|
fseek(f, bank * 256, SEEK_SET);
|
|
|
|
if (fread(data, sizeof(unsigned char), data_size, f) != data_size) {
|
|
|
|
fclose(f);
|
|
|
|
return DC_STATUS_IO;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return DC_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static dc_status_t local_hw_ostc_device_eeprom_write(void *ignored, unsigned char bank, unsigned char data[], unsigned int data_size)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
if ((f = fopen(OSTC_FILE, "r+")) == NULL)
|
|
|
|
f = fopen(OSTC_FILE, "w");
|
|
|
|
fseek(f, bank * 256, SEEK_SET);
|
|
|
|
fwrite(data, sizeof(unsigned char), data_size, f);
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return DC_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2014-10-12 14:51:28 +00:00
|
|
|
|
2014-12-29 04:56:58 +00:00
|
|
|
static int read_ostc_cf(unsigned char data[], unsigned char cf)
|
|
|
|
{
|
2014-10-27 20:55:02 +00:00
|
|
|
return data[128 + (cf % 32) * 4 + 3] << 8 ^ data[128 + (cf % 32) * 4 + 2];
|
|
|
|
}
|
|
|
|
|
2014-12-29 04:56:58 +00:00
|
|
|
static void write_ostc_cf(unsigned char data[], unsigned char cf, unsigned char max_CF, unsigned int value)
|
|
|
|
{
|
2014-10-27 20:55:02 +00:00
|
|
|
// Only write settings supported by this firmware.
|
|
|
|
if (cf > max_CF)
|
|
|
|
return;
|
|
|
|
|
|
|
|
data[128 + (cf % 32) * 4 + 3] = (value & 0xff00) >> 8;
|
|
|
|
data[128 + (cf % 32) * 4 + 2] = (value & 0x00ff);
|
|
|
|
}
|
|
|
|
|
2015-01-20 21:40:54 +00:00
|
|
|
#define EMIT_PROGRESS() do { \
|
|
|
|
progress.current++; \
|
|
|
|
progress_cb(device, DC_EVENT_PROGRESS, &progress, userdata); \
|
|
|
|
} while (0)
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t read_suunto_vyper_settings(dc_device_t *device, DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:07 +00:00
|
|
|
{
|
2017-11-16 21:00:26 +00:00
|
|
|
unsigned char data[SUUNTO_VYPER_CUSTOM_TEXT_LENGTH + 1];
|
2014-12-29 07:52:07 +00:00
|
|
|
dc_status_t rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
|
|
|
progress.maximum = 16;
|
|
|
|
|
2014-12-29 07:52:07 +00:00
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_COMPUTER_TYPE, data, 1);
|
|
|
|
if (rc == DC_STATUS_SUCCESS) {
|
2016-12-28 19:55:54 +00:00
|
|
|
dc_descriptor_t *desc = get_descriptor(DC_FAMILY_SUUNTO_VYPER, data[0]);
|
|
|
|
|
|
|
|
if (desc) {
|
|
|
|
// We found a supported device
|
|
|
|
// we can safely proceed with reading/writing to this device.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.model = dc_descriptor_get_product(desc);
|
2016-12-28 19:55:54 +00:00
|
|
|
dc_descriptor_free(desc);
|
|
|
|
} else {
|
2014-12-29 07:52:07 +00:00
|
|
|
return DC_STATUS_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
}
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2014-12-29 07:52:07 +00:00
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_MAXDEPTH, data, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
// in ft * 128.0
|
|
|
|
int depth = feet_to_mm(data[0] << 8 ^ data[1]) / 128;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.maxDepth = depth;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_TOTAL_TIME, data, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int total_time = data[0] << 8 ^ data[1];
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.totalTime = total_time;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_NUMBEROFDIVES, data, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int number_of_dives = data[0] << 8 ^ data[1];
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.numberOfDives = number_of_dives;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_FIRMWARE, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.firmwareVersion = QString::number(data[0]) + ".0.0";
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_SERIALNUMBER, data, 4);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int serial_number = data[0] * 1000000 + data[1] * 10000 + data[2] * 100 + data[3];
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.serialNo = QString::number(serial_number);
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
2017-11-16 21:00:26 +00:00
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_CUSTOM_TEXT, data, SUUNTO_VYPER_CUSTOM_TEXT_LENGTH);
|
2014-12-29 07:52:07 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2017-11-16 21:00:26 +00:00
|
|
|
data[SUUNTO_VYPER_CUSTOM_TEXT_LENGTH] = 0;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.customText = (const char *)data;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_SAMPLING_RATE, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.samplingRate = (int)data[0];
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_ALTITUDE_SAFETY, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.altitude = data[0] & 0x03;
|
|
|
|
deviceDetails.personalSafety = data[0] >> 2 & 0x03;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_TIMEFORMAT, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.timeFormat = data[0] & 0x01;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_UNITS, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.units = data[0] & 0x01;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_MODEL, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.diveMode = data[0] & 0x03;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_LIGHT, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.lightEnabled = data[0] >> 7;
|
|
|
|
deviceDetails.light = data[0] & 0x7F;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_ALARM_DEPTH_TIME, data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.alarmTimeEnabled = data[0] & 0x01;
|
|
|
|
deviceDetails.alarmDepthEnabled = data[0] >> 1 & 0x01;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_ALARM_TIME, data, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int time = data[0] << 8 ^ data[1];
|
|
|
|
// The stinger stores alarm time in seconds instead of minutes.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.model == "Stinger")
|
2014-12-29 07:52:07 +00:00
|
|
|
time /= 60;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.alarmTime = time;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
rc = dc_device_read(device, SUUNTO_VYPER_ALARM_DEPTH, data, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
depth = feet_to_mm(data[0] << 8 ^ data[1]) / 128;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.alarmDepth = depth;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:07 +00:00
|
|
|
|
|
|
|
return DC_STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t write_suunto_vyper_settings(dc_device_t *device, DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:08 +00:00
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
|
|
|
progress.maximum = 10;
|
2014-12-29 07:52:08 +00:00
|
|
|
unsigned char data;
|
|
|
|
unsigned char data2[2];
|
|
|
|
int time;
|
2015-01-20 21:40:54 +00:00
|
|
|
|
2014-12-29 07:52:08 +00:00
|
|
|
// Maybee we should read the model from the device to sanity check it here too..
|
|
|
|
// For now we just check that we actually read a device before writing to one.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.model == "")
|
2014-12-29 07:52:08 +00:00
|
|
|
return DC_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_CUSTOM_TEXT,
|
2014-12-29 08:16:47 +00:00
|
|
|
// Convert the customText to a 30 char wide padded with " "
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
(const unsigned char *)qPrintable(QString("%1").arg(deviceDetails.customText, -30, QChar(' '))),
|
2017-11-16 21:00:26 +00:00
|
|
|
SUUNTO_VYPER_CUSTOM_TEXT_LENGTH);
|
2014-12-29 07:52:08 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.samplingRate;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_SAMPLING_RATE, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.personalSafety << 2 ^ deviceDetails.altitude;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_ALTITUDE_SAFETY, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.timeFormat;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_TIMEFORMAT, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.units;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_UNITS, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.diveMode;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_MODEL, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.lightEnabled << 7 ^ (deviceDetails.light & 0x7F);
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_LIGHT, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data = deviceDetails.alarmDepthEnabled << 1 ^ deviceDetails.alarmTimeEnabled;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_ALARM_DEPTH_TIME, &data, 1);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
|
|
|
// The stinger stores alarm time in seconds instead of minutes.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
time = deviceDetails.alarmTime;
|
|
|
|
if (deviceDetails.model == "Stinger")
|
2014-12-29 07:52:08 +00:00
|
|
|
time *= 60;
|
|
|
|
data2[0] = time >> 8;
|
|
|
|
data2[1] = time & 0xFF;
|
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_ALARM_TIME, data2, 2);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data2[0] = (int)(mm_to_feet(deviceDetails.alarmDepth) * 128) >> 8;
|
|
|
|
data2[1] = (int)(mm_to_feet(deviceDetails.alarmDepth) * 128) & 0x0FF;
|
2014-12-29 07:52:08 +00:00
|
|
|
rc = dc_device_write(device, SUUNTO_VYPER_ALARM_DEPTH, data2, 2);
|
2015-01-20 21:40:54 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:08 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t read_ostc4_settings(dc_device_t *device, DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2017-04-26 18:49:12 +00:00
|
|
|
{
|
2017-04-27 18:35:02 +00:00
|
|
|
// This code is really similar to the OSTC3 code, but there are minor
|
|
|
|
// differences in what the data means, and how to communicate with the
|
|
|
|
// device. If anyone can find a good way to harmonize the two, be my guest.
|
2017-04-26 18:49:12 +00:00
|
|
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
2023-02-24 01:26:09 +00:00
|
|
|
progress.maximum = 47;
|
2017-04-26 18:49:12 +00:00
|
|
|
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2017-04-27 18:35:02 +00:00
|
|
|
//Read gas mixes
|
|
|
|
gas gas1;
|
|
|
|
gas gas2;
|
|
|
|
gas gas3;
|
|
|
|
gas gas4;
|
|
|
|
gas gas5;
|
|
|
|
unsigned char gasData[4] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS1, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas1.oxygen = gasData[0];
|
|
|
|
gas1.helium = gasData[1];
|
|
|
|
gas1.type = gasData[2];
|
|
|
|
gas1.depth = gasData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS2, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas2.oxygen = gasData[0];
|
|
|
|
gas2.helium = gasData[1];
|
|
|
|
gas2.type = gasData[2];
|
|
|
|
gas2.depth = gasData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS3, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas3.oxygen = gasData[0];
|
|
|
|
gas3.helium = gasData[1];
|
|
|
|
gas3.type = gasData[2];
|
|
|
|
gas3.depth = gasData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS4, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas4.oxygen = gasData[0];
|
|
|
|
gas4.helium = gasData[1];
|
|
|
|
gas4.type = gasData[2];
|
|
|
|
gas4.depth = gasData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS5, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas5.oxygen = gasData[0];
|
|
|
|
gas5.helium = gasData[1];
|
|
|
|
gas5.type = gasData[2];
|
|
|
|
gas5.depth = gasData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas1 = gas1;
|
|
|
|
deviceDetails.gas2 = gas2;
|
|
|
|
deviceDetails.gas3 = gas3;
|
|
|
|
deviceDetails.gas4 = gas4;
|
|
|
|
deviceDetails.gas5 = gas5;
|
2017-04-27 18:35:02 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
//Read Dil Values
|
|
|
|
gas dil1;
|
|
|
|
gas dil2;
|
|
|
|
gas dil3;
|
|
|
|
gas dil4;
|
|
|
|
gas dil5;
|
|
|
|
unsigned char dilData[4] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL1, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil1.oxygen = dilData[0];
|
|
|
|
dil1.helium = dilData[1];
|
|
|
|
dil1.type = dilData[2];
|
|
|
|
dil1.depth = dilData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL2, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil2.oxygen = dilData[0];
|
|
|
|
dil2.helium = dilData[1];
|
|
|
|
dil2.type = dilData[2];
|
|
|
|
dil2.depth = dilData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL3, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil3.oxygen = dilData[0];
|
|
|
|
dil3.helium = dilData[1];
|
|
|
|
dil3.type = dilData[2];
|
|
|
|
dil3.depth = dilData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL4, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil4.oxygen = dilData[0];
|
|
|
|
dil4.helium = dilData[1];
|
|
|
|
dil4.type = dilData[2];
|
|
|
|
dil4.depth = dilData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL5, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil5.oxygen = dilData[0];
|
|
|
|
dil5.helium = dilData[1];
|
|
|
|
dil5.type = dilData[2];
|
|
|
|
dil5.depth = dilData[3];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil1 = dil1;
|
|
|
|
deviceDetails.dil2 = dil2;
|
|
|
|
deviceDetails.dil3 = dil3;
|
|
|
|
deviceDetails.dil4 = dil4;
|
|
|
|
deviceDetails.dil5 = dil5;
|
2017-04-27 18:35:02 +00:00
|
|
|
|
|
|
|
//Read setpoint Values
|
|
|
|
setpoint sp1;
|
|
|
|
setpoint sp2;
|
|
|
|
setpoint sp3;
|
|
|
|
setpoint sp4;
|
|
|
|
setpoint sp5;
|
|
|
|
unsigned char spData[4] = { 0, 0, 0, 0};
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP1, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp1.sp = spData[0];
|
|
|
|
sp1.depth = spData[1];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP2, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp2.sp = spData[0];
|
|
|
|
sp2.depth = spData[1];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP3, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp3.sp = spData[0];
|
|
|
|
sp3.depth = spData[1];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP4, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp4.sp = spData[0];
|
|
|
|
sp4.depth = spData[1];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP5, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp5.sp = spData[0];
|
|
|
|
sp5.depth = spData[1];
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp1 = sp1;
|
|
|
|
deviceDetails.sp2 = sp2;
|
|
|
|
deviceDetails.sp3 = sp3;
|
|
|
|
deviceDetails.sp4 = sp4;
|
|
|
|
deviceDetails.sp5 = sp5;
|
2017-04-27 18:35:02 +00:00
|
|
|
|
|
|
|
//Read other settings
|
|
|
|
unsigned char uData[4] = { 0 };
|
|
|
|
|
|
|
|
#define READ_SETTING(_OSTC4_SETTING, _DEVICE_DETAIL) \
|
|
|
|
do { \
|
|
|
|
rc = hw_ostc3_device_config_read(device, _OSTC4_SETTING, uData, sizeof(uData)); \
|
|
|
|
if (rc != DC_STATUS_SUCCESS) \
|
|
|
|
return rc; \
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails._DEVICE_DETAIL = uData[0]; \
|
2017-04-27 18:35:02 +00:00
|
|
|
EMIT_PROGRESS(); \
|
|
|
|
} while (0)
|
|
|
|
|
2017-04-27 19:21:00 +00:00
|
|
|
READ_SETTING(OSTC3_DIVE_MODE, diveMode);
|
|
|
|
READ_SETTING(OSTC3_LAST_DECO, lastDeco);
|
|
|
|
READ_SETTING(OSTC3_BRIGHTNESS, brightness);
|
|
|
|
READ_SETTING(OSTC3_UNITS, units);
|
|
|
|
READ_SETTING(OSTC3_SALINITY, salinity);
|
|
|
|
READ_SETTING(OSTC3_DIVEMODE_COLOR, diveModeColor);
|
|
|
|
READ_SETTING(OSTC3_LANGUAGE, language);
|
|
|
|
READ_SETTING(OSTC3_DATE_FORMAT, dateFormat);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP, safetyStop);
|
|
|
|
READ_SETTING(OSTC3_GF_HIGH, gfHigh);
|
|
|
|
READ_SETTING(OSTC3_GF_LOW, gfLow);
|
|
|
|
READ_SETTING(OSTC3_PPO2_MIN, ppO2Min);
|
|
|
|
READ_SETTING(OSTC3_PPO2_MAX, ppO2Max);
|
|
|
|
READ_SETTING(OSTC3_FUTURE_TTS, futureTTS);
|
|
|
|
READ_SETTING(OSTC3_CCR_MODE, ccrMode);
|
|
|
|
READ_SETTING(OSTC3_DECO_TYPE, decoType);
|
|
|
|
READ_SETTING(OSTC3_AGF_HIGH, aGFHigh);
|
|
|
|
READ_SETTING(OSTC3_AGF_LOW, aGFLow);
|
2017-04-27 19:25:04 +00:00
|
|
|
READ_SETTING(OSTC4_VPM_CONSERVATISM, vpmConservatism);
|
2017-04-27 19:21:00 +00:00
|
|
|
READ_SETTING(OSTC3_SETPOINT_FALLBACK, setPointFallback);
|
2017-04-27 19:25:04 +00:00
|
|
|
READ_SETTING(OSTC4_BUTTON_SENSIVITY, buttonSensitivity);
|
2017-04-27 19:21:00 +00:00
|
|
|
READ_SETTING(OSTC3_BOTTOM_GAS_CONSUMPTION, bottomGasConsumption);
|
|
|
|
READ_SETTING(OSTC3_DECO_GAS_CONSUMPTION, decoGasConsumption);
|
2017-04-27 19:25:04 +00:00
|
|
|
READ_SETTING(OSTC4_TRAVEL_GAS_CONSUMPTION, travelGasConsumption);
|
2017-04-27 19:21:00 +00:00
|
|
|
READ_SETTING(OSTC3_ALWAYS_SHOW_PPO2, alwaysShowppO2);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_LENGTH, safetyStopLength);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_START_DEPTH, safetyStopStartDepth);
|
2017-04-27 19:25:04 +00:00
|
|
|
/*
|
|
|
|
* Settings not yet implemented
|
|
|
|
*
|
|
|
|
* logbook offset 0x47 0..9000 low byte 0..9000 high byte
|
|
|
|
* Extra display 0x71 0=0ff, 1=BigFont
|
|
|
|
* Custom View Center 0x72 0..8 (..9 Bonex Version)
|
|
|
|
* CV Center Fallback 0x73 0..20 sec
|
|
|
|
* Custom View Corner 0x74 1..7
|
|
|
|
* CV Corner Fallback 0x75 0..20 sec
|
|
|
|
*/
|
2017-04-27 19:21:00 +00:00
|
|
|
|
2017-04-27 18:35:02 +00:00
|
|
|
#undef READ_SETTING
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_PRESSURE_SENSOR_OFFSET, uData, sizeof(uData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
// OSTC3 stores the pressureSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.pressureSensorOffset = (signed char)uData[0];
|
2017-04-27 18:35:02 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_TEMP_SENSOR_OFFSET, uData, sizeof(uData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
// OSTC3 stores the tempSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.tempSensorOffset = (signed char)uData[0];
|
2017-04-27 18:35:02 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
//read firmware settings
|
|
|
|
unsigned char fData[64] = { 0 };
|
|
|
|
rc = hw_ostc3_device_version(device, fData, sizeof(fData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int serial = fData[0] + (fData[1] << 8);
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.serialNo = QString::number(serial);
|
2017-04-27 18:35:02 +00:00
|
|
|
unsigned char X, Y, Z, beta;
|
|
|
|
unsigned int firmwareOnDevice = (fData[3] << 8) + fData[2];
|
|
|
|
X = (firmwareOnDevice & 0xF800) >> 11;
|
|
|
|
Y = (firmwareOnDevice & 0x07C0) >> 6;
|
|
|
|
Z = (firmwareOnDevice & 0x003E) >> 1;
|
|
|
|
beta = firmwareOnDevice & 0x0001;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.firmwareVersion = QString("%1.%2.%3%4").arg(X).arg(Y).arg(Z).arg(beta?" beta":"");
|
2017-04-27 18:35:02 +00:00
|
|
|
QByteArray ar((char *)fData + 4, 60);
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.customText = ar.trimmed();
|
2017-04-27 18:35:02 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2017-04-26 18:49:12 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t write_ostc4_settings(dc_device_t *device, const DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2017-04-26 18:49:12 +00:00
|
|
|
{
|
2017-04-27 18:35:02 +00:00
|
|
|
// This code is really similar to the OSTC3 code, but there are minor
|
|
|
|
// differences in what the data means, and how to communicate with the
|
|
|
|
// device. If anyone can find a good way to harmonize the two, be my guest.
|
2017-04-26 18:49:12 +00:00
|
|
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
2017-04-27 19:25:04 +00:00
|
|
|
progress.maximum = 21;
|
2017-04-27 18:35:02 +00:00
|
|
|
|
|
|
|
//write gas values
|
|
|
|
unsigned char gas1Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas1.oxygen,
|
|
|
|
deviceDetails.gas1.helium,
|
|
|
|
deviceDetails.gas1.type,
|
|
|
|
deviceDetails.gas1.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas2Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas2.oxygen,
|
|
|
|
deviceDetails.gas2.helium,
|
|
|
|
deviceDetails.gas2.type,
|
|
|
|
deviceDetails.gas2.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas3Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas3.oxygen,
|
|
|
|
deviceDetails.gas3.helium,
|
|
|
|
deviceDetails.gas3.type,
|
|
|
|
deviceDetails.gas3.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas4Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas4.oxygen,
|
|
|
|
deviceDetails.gas4.helium,
|
|
|
|
deviceDetails.gas4.type,
|
|
|
|
deviceDetails.gas4.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas5Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas5.oxygen,
|
|
|
|
deviceDetails.gas5.helium,
|
|
|
|
deviceDetails.gas5.type,
|
|
|
|
deviceDetails.gas5.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
//gas 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS1, gas1Data, sizeof(gas1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//gas 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS2, gas2Data, sizeof(gas2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//gas 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS3, gas3Data, sizeof(gas3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//gas 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS4, gas4Data, sizeof(gas4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//gas 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS5, gas5Data, sizeof(gas5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
//write setpoint values
|
|
|
|
unsigned char sp1Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp1.sp,
|
|
|
|
deviceDetails.sp1.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp2Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp2.sp,
|
|
|
|
deviceDetails.sp2.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp3Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp3.sp,
|
|
|
|
deviceDetails.sp3.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp4Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp4.sp,
|
|
|
|
deviceDetails.sp4.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp5Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp5.sp,
|
|
|
|
deviceDetails.sp5.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//sp 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP1, sp1Data, sizeof(sp1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//sp 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP2, sp2Data, sizeof(sp2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//sp 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP3, sp3Data, sizeof(sp3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//sp 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP4, sp4Data, sizeof(sp4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//sp 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP5, sp5Data, sizeof(sp5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
//write dil values
|
|
|
|
unsigned char dil1Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil1.oxygen,
|
|
|
|
deviceDetails.dil1.helium,
|
|
|
|
deviceDetails.dil1.type,
|
|
|
|
deviceDetails.dil1.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil2Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil2.oxygen,
|
|
|
|
deviceDetails.dil2.helium,
|
|
|
|
deviceDetails.dil2.type,
|
|
|
|
deviceDetails.dil2.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil3Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil3.oxygen,
|
|
|
|
deviceDetails.dil3.helium,
|
|
|
|
deviceDetails.dil3.type,
|
|
|
|
deviceDetails.dil3.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil4Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil4.oxygen,
|
|
|
|
deviceDetails.dil4.helium,
|
|
|
|
deviceDetails.dil4.type,
|
|
|
|
deviceDetails.dil4.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil5Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil5.oxygen,
|
|
|
|
deviceDetails.dil5.helium,
|
|
|
|
deviceDetails.dil5.type,
|
|
|
|
deviceDetails.dil5.depth
|
2017-04-27 18:35:02 +00:00
|
|
|
};
|
|
|
|
//dil 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL1, dil1Data, sizeof(gas1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//dil 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL2, dil2Data, sizeof(dil2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//dil 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL3, dil3Data, sizeof(dil3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//dil 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL4, dil4Data, sizeof(dil4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
//dil 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL5, dil5Data, sizeof(dil5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
//write general settings
|
|
|
|
//custom text
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
rc = hw_ostc3_device_customtext(device, qPrintable(deviceDetails.customText));
|
2017-04-27 18:35:02 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
unsigned char data[4] = { 0 };
|
|
|
|
#define WRITE_SETTING(_OSTC4_SETTING, _DEVICE_DETAIL) \
|
|
|
|
do { \
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = deviceDetails._DEVICE_DETAIL; \
|
2017-04-27 18:35:02 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, _OSTC4_SETTING, data, sizeof(data)); \
|
|
|
|
if (rc != DC_STATUS_SUCCESS) \
|
|
|
|
return rc; \
|
|
|
|
EMIT_PROGRESS(); \
|
|
|
|
} while (0)
|
|
|
|
|
2017-04-27 19:21:00 +00:00
|
|
|
WRITE_SETTING(OSTC3_DIVE_MODE, diveMode);
|
|
|
|
WRITE_SETTING(OSTC3_LAST_DECO, lastDeco);
|
|
|
|
WRITE_SETTING(OSTC3_BRIGHTNESS, brightness);
|
|
|
|
WRITE_SETTING(OSTC3_UNITS, units);
|
|
|
|
WRITE_SETTING(OSTC3_SALINITY, salinity);
|
|
|
|
WRITE_SETTING(OSTC3_DIVEMODE_COLOR, diveModeColor);
|
|
|
|
WRITE_SETTING(OSTC3_LANGUAGE, language);
|
|
|
|
WRITE_SETTING(OSTC3_DATE_FORMAT, dateFormat);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP, safetyStop);
|
|
|
|
WRITE_SETTING(OSTC3_GF_HIGH, gfHigh);
|
|
|
|
WRITE_SETTING(OSTC3_GF_LOW, gfLow);
|
|
|
|
WRITE_SETTING(OSTC3_PPO2_MIN, ppO2Min);
|
|
|
|
WRITE_SETTING(OSTC3_PPO2_MAX, ppO2Max);
|
|
|
|
WRITE_SETTING(OSTC3_FUTURE_TTS, futureTTS);
|
|
|
|
WRITE_SETTING(OSTC3_CCR_MODE, ccrMode);
|
|
|
|
WRITE_SETTING(OSTC3_DECO_TYPE, decoType);
|
|
|
|
WRITE_SETTING(OSTC3_AGF_HIGH, aGFHigh);
|
|
|
|
WRITE_SETTING(OSTC3_AGF_LOW, aGFLow);
|
2017-04-27 19:25:04 +00:00
|
|
|
WRITE_SETTING(OSTC4_VPM_CONSERVATISM, vpmConservatism);
|
2017-04-27 19:21:00 +00:00
|
|
|
WRITE_SETTING(OSTC3_SETPOINT_FALLBACK, setPointFallback);
|
2017-04-27 19:25:04 +00:00
|
|
|
WRITE_SETTING(OSTC4_BUTTON_SENSIVITY, buttonSensitivity);
|
2017-04-27 19:21:00 +00:00
|
|
|
WRITE_SETTING(OSTC3_BOTTOM_GAS_CONSUMPTION, bottomGasConsumption);
|
|
|
|
WRITE_SETTING(OSTC3_DECO_GAS_CONSUMPTION, decoGasConsumption);
|
2017-04-27 19:25:04 +00:00
|
|
|
WRITE_SETTING(OSTC4_TRAVEL_GAS_CONSUMPTION, travelGasConsumption);
|
2017-04-27 19:21:00 +00:00
|
|
|
WRITE_SETTING(OSTC3_ALWAYS_SHOW_PPO2, alwaysShowppO2);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_LENGTH, safetyStopLength);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_START_DEPTH, safetyStopStartDepth);
|
2017-04-27 19:25:04 +00:00
|
|
|
/*
|
|
|
|
* Settings not yet implemented
|
|
|
|
*
|
|
|
|
* logbook offset 0x47 0..9000 low byte 0..9000 high byte
|
|
|
|
* Extra display 0x71 0=0ff, 1=BigFont
|
|
|
|
* Custom View Center 0x72 0..8 (..9 Bonex Version)
|
|
|
|
* CV Center Fallback 0x73 0..20 sec
|
|
|
|
* Custom View Corner 0x74 1..7
|
|
|
|
* CV Corner Fallback 0x75 0..20 sec
|
|
|
|
*/
|
2017-04-27 19:21:00 +00:00
|
|
|
|
2017-04-27 18:35:02 +00:00
|
|
|
#undef WRITE_SETTING
|
|
|
|
|
|
|
|
// OSTC3 stores the pressureSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = (unsigned char)deviceDetails.pressureSensorOffset;
|
2017-04-27 18:35:02 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_PRESSURE_SENSOR_OFFSET, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
// OSTC3 stores the tempSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = (unsigned char)deviceDetails.tempSensorOffset;
|
2017-04-27 18:35:02 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_TEMP_SENSOR_OFFSET, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
|
|
|
|
//sync date and time
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.syncTime) {
|
2017-04-27 18:35:02 +00:00
|
|
|
dc_datetime_t now;
|
|
|
|
dc_datetime_localtime(&now, dc_datetime_now());
|
|
|
|
|
2017-08-21 03:39:52 +00:00
|
|
|
rc = dc_device_timesync(device, &now);
|
2017-04-27 18:35:02 +00:00
|
|
|
}
|
2017-04-26 18:49:12 +00:00
|
|
|
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t read_ostc3_settings(dc_device_t *device, DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:09 +00:00
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
2018-04-25 17:46:43 +00:00
|
|
|
progress.maximum = 56;
|
2015-09-24 22:59:03 +00:00
|
|
|
unsigned char hardware[1];
|
|
|
|
|
|
|
|
//Read hardware type
|
|
|
|
rc = hw_ostc3_device_hardware (device, hardware, sizeof (hardware));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
2016-12-28 19:55:54 +00:00
|
|
|
dc_descriptor_t *desc = get_descriptor(DC_FAMILY_HW_OSTC3, hardware[0]);
|
|
|
|
if (desc) {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.model = dc_descriptor_get_product(desc);
|
2016-12-28 19:55:54 +00:00
|
|
|
dc_descriptor_free(desc);
|
|
|
|
} else {
|
|
|
|
return DC_STATUS_UNSUPPORTED;
|
2015-09-24 22:59:03 +00:00
|
|
|
}
|
2015-09-02 22:00:02 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.model == "OSTC 4")
|
|
|
|
return read_ostc4_settings(device, deviceDetails, progress_cb, userdata);
|
2017-04-26 18:49:12 +00:00
|
|
|
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2014-12-29 07:52:09 +00:00
|
|
|
//Read gas mixes
|
|
|
|
gas gas1;
|
|
|
|
gas gas2;
|
|
|
|
gas gas3;
|
|
|
|
gas gas4;
|
|
|
|
gas gas5;
|
|
|
|
unsigned char gasData[4] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS1, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas1.oxygen = gasData[0];
|
|
|
|
gas1.helium = gasData[1];
|
|
|
|
gas1.type = gasData[2];
|
|
|
|
gas1.depth = gasData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS2, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas2.oxygen = gasData[0];
|
|
|
|
gas2.helium = gasData[1];
|
|
|
|
gas2.type = gasData[2];
|
|
|
|
gas2.depth = gasData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS3, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas3.oxygen = gasData[0];
|
|
|
|
gas3.helium = gasData[1];
|
|
|
|
gas3.type = gasData[2];
|
|
|
|
gas3.depth = gasData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS4, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas4.oxygen = gasData[0];
|
|
|
|
gas4.helium = gasData[1];
|
|
|
|
gas4.type = gasData[2];
|
|
|
|
gas4.depth = gasData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_GAS5, gasData, sizeof(gasData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
gas5.oxygen = gasData[0];
|
|
|
|
gas5.helium = gasData[1];
|
|
|
|
gas5.type = gasData[2];
|
|
|
|
gas5.depth = gasData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas1 = gas1;
|
|
|
|
deviceDetails.gas2 = gas2;
|
|
|
|
deviceDetails.gas3 = gas3;
|
|
|
|
deviceDetails.gas4 = gas4;
|
|
|
|
deviceDetails.gas5 = gas5;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
//Read Dil Values
|
|
|
|
gas dil1;
|
|
|
|
gas dil2;
|
|
|
|
gas dil3;
|
|
|
|
gas dil4;
|
|
|
|
gas dil5;
|
|
|
|
unsigned char dilData[4] = { 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL1, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil1.oxygen = dilData[0];
|
|
|
|
dil1.helium = dilData[1];
|
|
|
|
dil1.type = dilData[2];
|
|
|
|
dil1.depth = dilData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL2, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil2.oxygen = dilData[0];
|
|
|
|
dil2.helium = dilData[1];
|
|
|
|
dil2.type = dilData[2];
|
|
|
|
dil2.depth = dilData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL3, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil3.oxygen = dilData[0];
|
|
|
|
dil3.helium = dilData[1];
|
|
|
|
dil3.type = dilData[2];
|
|
|
|
dil3.depth = dilData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL4, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil4.oxygen = dilData[0];
|
|
|
|
dil4.helium = dilData[1];
|
|
|
|
dil4.type = dilData[2];
|
|
|
|
dil4.depth = dilData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_DIL5, dilData, sizeof(dilData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
dil5.oxygen = dilData[0];
|
|
|
|
dil5.helium = dilData[1];
|
|
|
|
dil5.type = dilData[2];
|
|
|
|
dil5.depth = dilData[3];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil1 = dil1;
|
|
|
|
deviceDetails.dil2 = dil2;
|
|
|
|
deviceDetails.dil3 = dil3;
|
|
|
|
deviceDetails.dil4 = dil4;
|
|
|
|
deviceDetails.dil5 = dil5;
|
2014-12-29 07:52:09 +00:00
|
|
|
|
2017-03-06 12:36:42 +00:00
|
|
|
//Read setpoint Values
|
2014-12-29 07:52:09 +00:00
|
|
|
setpoint sp1;
|
|
|
|
setpoint sp2;
|
|
|
|
setpoint sp3;
|
|
|
|
setpoint sp4;
|
|
|
|
setpoint sp5;
|
|
|
|
unsigned char spData[2] = { 0, 0 };
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP1, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp1.sp = spData[0];
|
|
|
|
sp1.depth = spData[1];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP2, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp2.sp = spData[0];
|
|
|
|
sp2.depth = spData[1];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP3, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp3.sp = spData[0];
|
|
|
|
sp3.depth = spData[1];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP4, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp4.sp = spData[0];
|
|
|
|
sp4.depth = spData[1];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_SP5, spData, sizeof(spData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
sp5.sp = spData[0];
|
|
|
|
sp5.depth = spData[1];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp1 = sp1;
|
|
|
|
deviceDetails.sp2 = sp2;
|
|
|
|
deviceDetails.sp3 = sp3;
|
|
|
|
deviceDetails.sp4 = sp4;
|
|
|
|
deviceDetails.sp5 = sp5;
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
//Read other settings
|
|
|
|
unsigned char uData[1] = { 0 };
|
|
|
|
|
2014-12-29 08:16:47 +00:00
|
|
|
#define READ_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \
|
|
|
|
do { \
|
2014-12-29 07:52:09 +00:00
|
|
|
rc = hw_ostc3_device_config_read(device, _OSTC3_SETTING, uData, sizeof(uData)); \
|
2014-12-29 08:16:47 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS) \
|
|
|
|
return rc; \
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails._DEVICE_DETAIL = uData[0]; \
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS(); \
|
2014-12-29 07:52:09 +00:00
|
|
|
} while (0)
|
|
|
|
|
2015-09-02 21:59:59 +00:00
|
|
|
READ_SETTING(OSTC3_DIVE_MODE, diveMode);
|
|
|
|
READ_SETTING(OSTC3_SATURATION, saturation);
|
|
|
|
READ_SETTING(OSTC3_DESATURATION, desaturation);
|
|
|
|
READ_SETTING(OSTC3_LAST_DECO, lastDeco);
|
|
|
|
READ_SETTING(OSTC3_BRIGHTNESS, brightness);
|
|
|
|
READ_SETTING(OSTC3_UNITS, units);
|
|
|
|
READ_SETTING(OSTC3_SAMPLING_RATE, samplingRate);
|
|
|
|
READ_SETTING(OSTC3_SALINITY, salinity);
|
|
|
|
READ_SETTING(OSTC3_DIVEMODE_COLOR, diveModeColor);
|
|
|
|
READ_SETTING(OSTC3_LANGUAGE, language);
|
|
|
|
READ_SETTING(OSTC3_DATE_FORMAT, dateFormat);
|
|
|
|
READ_SETTING(OSTC3_COMPASS_GAIN, compassGain);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP, safetyStop);
|
|
|
|
READ_SETTING(OSTC3_GF_HIGH, gfHigh);
|
|
|
|
READ_SETTING(OSTC3_GF_LOW, gfLow);
|
|
|
|
READ_SETTING(OSTC3_PPO2_MIN, ppO2Min);
|
|
|
|
READ_SETTING(OSTC3_PPO2_MAX, ppO2Max);
|
|
|
|
READ_SETTING(OSTC3_FUTURE_TTS, futureTTS);
|
|
|
|
READ_SETTING(OSTC3_CCR_MODE, ccrMode);
|
|
|
|
READ_SETTING(OSTC3_DECO_TYPE, decoType);
|
|
|
|
READ_SETTING(OSTC3_AGF_SELECTABLE, aGFSelectable);
|
|
|
|
READ_SETTING(OSTC3_AGF_HIGH, aGFHigh);
|
|
|
|
READ_SETTING(OSTC3_AGF_LOW, aGFLow);
|
|
|
|
READ_SETTING(OSTC3_CALIBRATION_GAS_O2, calibrationGas);
|
|
|
|
READ_SETTING(OSTC3_FLIP_SCREEN, flipScreen);
|
2015-09-02 22:00:00 +00:00
|
|
|
READ_SETTING(OSTC3_LEFT_BUTTON_SENSIVITY, leftButtonSensitivity);
|
|
|
|
READ_SETTING(OSTC3_RIGHT_BUTTON_SENSIVITY, rightButtonSensitivity);
|
|
|
|
READ_SETTING(OSTC3_BOTTOM_GAS_CONSUMPTION, bottomGasConsumption);
|
|
|
|
READ_SETTING(OSTC3_DECO_GAS_CONSUMPTION, decoGasConsumption);
|
|
|
|
READ_SETTING(OSTC3_MOD_WARNING, modWarning);
|
2016-01-22 13:17:46 +00:00
|
|
|
READ_SETTING(OSTC3_DYNAMIC_ASCEND_RATE, dynamicAscendRate);
|
|
|
|
READ_SETTING(OSTC3_GRAPHICAL_SPEED_INDICATOR, graphicalSpeedIndicator);
|
|
|
|
READ_SETTING(OSTC3_ALWAYS_SHOW_PPO2, alwaysShowppO2);
|
2016-01-22 13:17:50 +00:00
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_LENGTH, safetyStopLength);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_START_DEPTH, safetyStopStartDepth);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_END_DEPTH, safetyStopEndDepth);
|
|
|
|
READ_SETTING(OSTC3_SAFETY_STOP_RESET_DEPTH, safetyStopResetDepth);
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
#undef READ_SETTING
|
|
|
|
|
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_PRESSURE_SENSOR_OFFSET, uData, sizeof(uData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
// OSTC3 stores the pressureSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.pressureSensorOffset = (signed char)uData[0];
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
2016-01-22 13:17:49 +00:00
|
|
|
rc = hw_ostc3_device_config_read(device, OSTC3_TEMP_SENSOR_OFFSET, uData, sizeof(uData));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
// OSTC3 stores the tempSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.tempSensorOffset = (signed char)uData[0];
|
2016-01-22 13:17:49 +00:00
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2014-12-29 07:52:09 +00:00
|
|
|
//read firmware settings
|
|
|
|
unsigned char fData[64] = { 0 };
|
2014-12-29 08:16:47 +00:00
|
|
|
rc = hw_ostc3_device_version(device, fData, sizeof(fData));
|
2014-12-29 07:52:09 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
int serial = fData[0] + (fData[1] << 8);
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.serialNo = QString::number(serial);
|
|
|
|
deviceDetails.firmwareVersion = QString::number(fData[2]) + "." + QString::number(fData[3]);
|
2014-12-29 07:52:09 +00:00
|
|
|
QByteArray ar((char *)fData + 4, 60);
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.customText = ar.trimmed();
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:09 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t write_ostc3_settings(dc_device_t *device, const DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:11 +00:00
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
2018-04-25 17:46:43 +00:00
|
|
|
progress.maximum = 55;
|
2015-09-02 22:00:02 +00:00
|
|
|
|
2014-12-29 07:52:11 +00:00
|
|
|
//write gas values
|
|
|
|
unsigned char gas1Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas1.oxygen,
|
|
|
|
deviceDetails.gas1.helium,
|
|
|
|
deviceDetails.gas1.type,
|
|
|
|
deviceDetails.gas1.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas2Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas2.oxygen,
|
|
|
|
deviceDetails.gas2.helium,
|
|
|
|
deviceDetails.gas2.type,
|
|
|
|
deviceDetails.gas2.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas3Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas3.oxygen,
|
|
|
|
deviceDetails.gas3.helium,
|
|
|
|
deviceDetails.gas3.type,
|
|
|
|
deviceDetails.gas3.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas4Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas4.oxygen,
|
|
|
|
deviceDetails.gas4.helium,
|
|
|
|
deviceDetails.gas4.type,
|
|
|
|
deviceDetails.gas4.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char gas5Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas5.oxygen,
|
|
|
|
deviceDetails.gas5.helium,
|
|
|
|
deviceDetails.gas5.type,
|
|
|
|
deviceDetails.gas5.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
//gas 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS1, gas1Data, sizeof(gas1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//gas 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS2, gas2Data, sizeof(gas2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//gas 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS3, gas3Data, sizeof(gas3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//gas 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS4, gas4Data, sizeof(gas4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//gas 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_GAS5, gas5Data, sizeof(gas5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
|
2017-03-06 12:36:42 +00:00
|
|
|
//write setpoint values
|
2014-12-29 07:52:11 +00:00
|
|
|
unsigned char sp1Data[2] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp1.sp,
|
|
|
|
deviceDetails.sp1.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp2Data[2] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp2.sp,
|
|
|
|
deviceDetails.sp2.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp3Data[2] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp3.sp,
|
|
|
|
deviceDetails.sp3.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp4Data[2] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp4.sp,
|
|
|
|
deviceDetails.sp4.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char sp5Data[2] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp5.sp,
|
|
|
|
deviceDetails.sp5.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//sp 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP1, sp1Data, sizeof(sp1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//sp 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP2, sp2Data, sizeof(sp2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//sp 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP3, sp3Data, sizeof(sp3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//sp 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP4, sp4Data, sizeof(sp4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//sp 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_SP5, sp5Data, sizeof(sp5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
|
|
|
|
//write dil values
|
|
|
|
unsigned char dil1Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil1.oxygen,
|
|
|
|
deviceDetails.dil1.helium,
|
|
|
|
deviceDetails.dil1.type,
|
|
|
|
deviceDetails.dil1.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil2Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil2.oxygen,
|
|
|
|
deviceDetails.dil2.helium,
|
|
|
|
deviceDetails.dil2.type,
|
|
|
|
deviceDetails.dil2.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil3Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil3.oxygen,
|
|
|
|
deviceDetails.dil3.helium,
|
|
|
|
deviceDetails.dil3.type,
|
|
|
|
deviceDetails.dil3.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil4Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil4.oxygen,
|
|
|
|
deviceDetails.dil4.helium,
|
|
|
|
deviceDetails.dil4.type,
|
|
|
|
deviceDetails.dil4.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned char dil5Data[4] = {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil5.oxygen,
|
|
|
|
deviceDetails.dil5.helium,
|
|
|
|
deviceDetails.dil5.type,
|
|
|
|
deviceDetails.dil5.depth
|
2014-12-29 07:52:11 +00:00
|
|
|
};
|
|
|
|
//dil 1
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL1, dil1Data, sizeof(gas1Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//dil 2
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL2, dil2Data, sizeof(dil2Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//dil 3
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL3, dil3Data, sizeof(dil3Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//dil 4
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL4, dil4Data, sizeof(dil4Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
//dil 5
|
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_DIL5, dil5Data, sizeof(dil5Data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
|
|
|
|
//write general settings
|
|
|
|
//custom text
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
rc = hw_ostc3_device_customtext(device, qPrintable(deviceDetails.customText));
|
2014-12-29 07:52:11 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
2014-12-29 08:16:47 +00:00
|
|
|
unsigned char data[1] = { 0 };
|
|
|
|
#define WRITE_SETTING(_OSTC3_SETTING, _DEVICE_DETAIL) \
|
|
|
|
do { \
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = deviceDetails._DEVICE_DETAIL; \
|
2014-12-29 07:52:11 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, _OSTC3_SETTING, data, sizeof(data)); \
|
2014-12-29 08:16:47 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS) \
|
|
|
|
return rc; \
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS(); \
|
2014-12-29 07:52:11 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
WRITE_SETTING(OSTC3_DIVE_MODE, diveMode);
|
|
|
|
WRITE_SETTING(OSTC3_SATURATION, saturation);
|
|
|
|
WRITE_SETTING(OSTC3_DESATURATION, desaturation);
|
|
|
|
WRITE_SETTING(OSTC3_LAST_DECO, lastDeco);
|
|
|
|
WRITE_SETTING(OSTC3_BRIGHTNESS, brightness);
|
|
|
|
WRITE_SETTING(OSTC3_UNITS, units);
|
|
|
|
WRITE_SETTING(OSTC3_SAMPLING_RATE, samplingRate);
|
|
|
|
WRITE_SETTING(OSTC3_SALINITY, salinity);
|
|
|
|
WRITE_SETTING(OSTC3_DIVEMODE_COLOR, diveModeColor);
|
|
|
|
WRITE_SETTING(OSTC3_LANGUAGE, language);
|
|
|
|
WRITE_SETTING(OSTC3_DATE_FORMAT, dateFormat);
|
|
|
|
WRITE_SETTING(OSTC3_COMPASS_GAIN, compassGain);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP, safetyStop);
|
|
|
|
WRITE_SETTING(OSTC3_GF_HIGH, gfHigh);
|
|
|
|
WRITE_SETTING(OSTC3_GF_LOW, gfLow);
|
|
|
|
WRITE_SETTING(OSTC3_PPO2_MIN, ppO2Min);
|
|
|
|
WRITE_SETTING(OSTC3_PPO2_MAX, ppO2Max);
|
|
|
|
WRITE_SETTING(OSTC3_FUTURE_TTS, futureTTS);
|
|
|
|
WRITE_SETTING(OSTC3_CCR_MODE, ccrMode);
|
|
|
|
WRITE_SETTING(OSTC3_DECO_TYPE, decoType);
|
|
|
|
WRITE_SETTING(OSTC3_AGF_SELECTABLE, aGFSelectable);
|
|
|
|
WRITE_SETTING(OSTC3_AGF_HIGH, aGFHigh);
|
|
|
|
WRITE_SETTING(OSTC3_AGF_LOW, aGFLow);
|
|
|
|
WRITE_SETTING(OSTC3_CALIBRATION_GAS_O2, calibrationGas);
|
|
|
|
WRITE_SETTING(OSTC3_FLIP_SCREEN, flipScreen);
|
2015-09-02 22:00:00 +00:00
|
|
|
WRITE_SETTING(OSTC3_LEFT_BUTTON_SENSIVITY, leftButtonSensitivity);
|
|
|
|
WRITE_SETTING(OSTC3_RIGHT_BUTTON_SENSIVITY, rightButtonSensitivity);
|
|
|
|
WRITE_SETTING(OSTC3_BOTTOM_GAS_CONSUMPTION, bottomGasConsumption);
|
|
|
|
WRITE_SETTING(OSTC3_DECO_GAS_CONSUMPTION, decoGasConsumption);
|
|
|
|
WRITE_SETTING(OSTC3_MOD_WARNING, modWarning);
|
2016-01-22 13:17:46 +00:00
|
|
|
WRITE_SETTING(OSTC3_DYNAMIC_ASCEND_RATE, dynamicAscendRate);
|
|
|
|
WRITE_SETTING(OSTC3_GRAPHICAL_SPEED_INDICATOR, graphicalSpeedIndicator);
|
|
|
|
WRITE_SETTING(OSTC3_ALWAYS_SHOW_PPO2, alwaysShowppO2);
|
2016-01-22 13:17:50 +00:00
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_LENGTH, safetyStopLength);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_START_DEPTH, safetyStopStartDepth);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_END_DEPTH, safetyStopEndDepth);
|
|
|
|
WRITE_SETTING(OSTC3_SAFETY_STOP_RESET_DEPTH, safetyStopResetDepth);
|
2014-12-29 07:52:11 +00:00
|
|
|
|
|
|
|
#undef WRITE_SETTING
|
|
|
|
|
|
|
|
// OSTC3 stores the pressureSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = (unsigned char)deviceDetails.pressureSensorOffset;
|
2014-12-29 07:52:11 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_PRESSURE_SENSOR_OFFSET, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
|
2016-01-22 13:17:49 +00:00
|
|
|
// OSTC3 stores the tempSensorOffset in two-complement
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[0] = (unsigned char)deviceDetails.tempSensorOffset;
|
2016-01-22 13:17:49 +00:00
|
|
|
rc = hw_ostc3_device_config_write(device, OSTC3_TEMP_SENSOR_OFFSET, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
EMIT_PROGRESS();
|
|
|
|
|
2014-12-29 07:52:11 +00:00
|
|
|
//sync date and time
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.syncTime) {
|
2016-01-22 13:17:48 +00:00
|
|
|
dc_datetime_t now;
|
|
|
|
dc_datetime_localtime(&now, dc_datetime_now());
|
|
|
|
|
2017-08-21 03:39:52 +00:00
|
|
|
rc = dc_device_timesync(device, &now);
|
2014-12-29 07:52:11 +00:00
|
|
|
}
|
2015-09-02 22:00:02 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:11 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t read_ostc_settings(dc_device_t *device, DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:10 +00:00
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
|
|
|
progress.maximum = 3;
|
|
|
|
|
2014-12-29 07:52:10 +00:00
|
|
|
unsigned char data[256] = {};
|
|
|
|
#ifdef DEBUG_OSTC_CF
|
2019-03-19 15:22:51 +00:00
|
|
|
// open question: how should we report settings not supported back?
|
2014-12-29 07:52:10 +00:00
|
|
|
unsigned char max_CF = 0;
|
|
|
|
#endif
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 0, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.serialNo = QString::number(data[1] << 8 ^ data[0]);
|
|
|
|
deviceDetails.numberOfDives = data[3] << 8 ^ data[2];
|
2014-12-29 07:52:10 +00:00
|
|
|
//Byte5-6:
|
|
|
|
//Gas 1 default (%O2=21, %He=0)
|
|
|
|
gas gas1;
|
|
|
|
gas1.oxygen = data[6];
|
|
|
|
gas1.helium = data[7];
|
|
|
|
//Byte9-10:
|
|
|
|
//Gas 2 default (%O2=21, %He=0)
|
|
|
|
gas gas2;
|
|
|
|
gas2.oxygen = data[10];
|
|
|
|
gas2.helium = data[11];
|
|
|
|
//Byte13-14:
|
|
|
|
//Gas 3 default (%O2=21, %He=0)
|
|
|
|
gas gas3;
|
|
|
|
gas3.oxygen = data[14];
|
|
|
|
gas3.helium = data[15];
|
|
|
|
//Byte17-18:
|
|
|
|
//Gas 4 default (%O2=21, %He=0)
|
|
|
|
gas gas4;
|
|
|
|
gas4.oxygen = data[18];
|
|
|
|
gas4.helium = data[19];
|
|
|
|
//Byte21-22:
|
|
|
|
//Gas 5 default (%O2=21, %He=0)
|
|
|
|
gas gas5;
|
|
|
|
gas5.oxygen = data[22];
|
|
|
|
gas5.helium = data[23];
|
|
|
|
//Byte25-26:
|
|
|
|
//Gas 6 current (%O2, %He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.salinity = data[26];
|
2014-12-29 07:52:10 +00:00
|
|
|
// Active Gas Flag Register
|
|
|
|
gas1.type = data[27] & 0x01;
|
|
|
|
gas2.type = (data[27] & 0x02) >> 1;
|
|
|
|
gas3.type = (data[27] & 0x04) >> 2;
|
|
|
|
gas4.type = (data[27] & 0x08) >> 3;
|
|
|
|
gas5.type = (data[27] & 0x10) >> 4;
|
|
|
|
|
|
|
|
// Gas switch depths
|
|
|
|
gas1.depth = data[28];
|
|
|
|
gas2.depth = data[29];
|
|
|
|
gas3.depth = data[30];
|
|
|
|
gas4.depth = data[31];
|
|
|
|
gas5.depth = data[32];
|
|
|
|
// 33 which gas is Fist gas
|
2014-12-29 08:16:47 +00:00
|
|
|
switch (data[33]) {
|
2014-12-29 07:52:10 +00:00
|
|
|
case 1:
|
|
|
|
gas1.type = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gas2.type = 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
gas3.type = 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
gas4.type = 2;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
gas5.type = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//Error?
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Data filled up, set the gases.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gas1 = gas1;
|
|
|
|
deviceDetails.gas2 = gas2;
|
|
|
|
deviceDetails.gas3 = gas3;
|
|
|
|
deviceDetails.gas4 = gas4;
|
|
|
|
deviceDetails.gas5 = gas5;
|
|
|
|
deviceDetails.decoType = data[34];
|
2014-12-29 07:52:10 +00:00
|
|
|
//Byte36:
|
|
|
|
//Use O2 Sensor Module in CC Modes (0= OFF, 1= ON) (Only available in old OSTC1 - unused for OSTC Mk.2/2N)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
//deviceDetails.ccrMode = data[35];
|
2014-12-29 07:52:10 +00:00
|
|
|
setpoint sp1;
|
|
|
|
sp1.sp = data[36];
|
|
|
|
sp1.depth = 0;
|
|
|
|
setpoint sp2;
|
|
|
|
sp2.sp = data[37];
|
|
|
|
sp2.depth = 0;
|
|
|
|
setpoint sp3;
|
|
|
|
sp3.sp = data[38];
|
|
|
|
sp3.depth = 0;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.sp1 = sp1;
|
|
|
|
deviceDetails.sp2 = sp2;
|
|
|
|
deviceDetails.sp3 = sp3;
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte41-42:
|
|
|
|
// Lowest Battery voltage seen (in mV)
|
|
|
|
// Byte43:
|
|
|
|
// Lowest Battery voltage seen at (Month)
|
|
|
|
// Byte44:
|
|
|
|
// Lowest Battery voltage seen at (Day)
|
|
|
|
// Byte45:
|
|
|
|
// Lowest Battery voltage seen at (Year)
|
|
|
|
// Byte46-47:
|
|
|
|
// Lowest Battery voltage seen at (Temperature in 0.1 °C)
|
|
|
|
// Byte48:
|
|
|
|
// Last complete charge at (Month)
|
|
|
|
// Byte49:
|
|
|
|
// Last complete charge at (Day)
|
|
|
|
// Byte50:
|
|
|
|
// Last complete charge at (Year)
|
|
|
|
// Byte51-52:
|
|
|
|
// Total charge cycles
|
|
|
|
// Byte53-54:
|
|
|
|
// Total complete charge cycles
|
|
|
|
// Byte55-56:
|
|
|
|
// Temperature Extrema minimum (Temperature in 0.1 °C)
|
|
|
|
// Byte57:
|
|
|
|
// Temperature Extrema minimum at (Month)
|
|
|
|
// Byte58:
|
|
|
|
// Temperature Extrema minimum at (Day)
|
|
|
|
// Byte59:
|
|
|
|
// Temperature Extrema minimum at (Year)
|
|
|
|
// Byte60-61:
|
|
|
|
// Temperature Extrema maximum (Temperature in 0.1 °C)
|
|
|
|
// Byte62:
|
|
|
|
// Temperature Extrema maximum at (Month)
|
|
|
|
// Byte63:
|
|
|
|
// Temperature Extrema maximum at (Day)
|
|
|
|
// Byte64:
|
|
|
|
// Temperature Extrema maximum at (Year)
|
|
|
|
// Byte65:
|
|
|
|
// Custom Text active (=1), Custom Text Disabled (<>1)
|
|
|
|
// Byte66-90:
|
|
|
|
// TO FIX EDITOR SYNTAX/INDENT {
|
|
|
|
// (25Bytes): Custom Text for Surfacemode (Real text must end with "}")
|
|
|
|
// Example: OSTC Dive Computer} (19 Characters incl. "}") Bytes 85-90 will be ignored.
|
|
|
|
if (data[64] == 1) {
|
|
|
|
// Make shure the data is null-terminated
|
|
|
|
data[89] = 0;
|
|
|
|
// Find the internal termination and replace it with 0
|
|
|
|
char *term = strchr((char *)data + 65, (int)'}');
|
|
|
|
if (term)
|
|
|
|
*term = 0;
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.customText = (const char *)data + 65;
|
2014-12-29 07:52:10 +00:00
|
|
|
}
|
|
|
|
// Byte91:
|
|
|
|
// Dim OLED in Divemode (>0), Normal mode (=0)
|
|
|
|
// Byte92:
|
|
|
|
// Date format for all outputs:
|
|
|
|
// =0: MM/DD/YY
|
|
|
|
// =1: DD/MM/YY
|
|
|
|
// =2: YY/MM/DD
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dateFormat = data[91];
|
2014-12-29 08:16:47 +00:00
|
|
|
// Byte93:
|
|
|
|
// Total number of CF used in installed firmware
|
2014-12-29 07:52:10 +00:00
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
max_CF = data[92];
|
|
|
|
#endif
|
|
|
|
// Byte94:
|
|
|
|
// Last selected view for customview area in surface mode
|
|
|
|
// Byte95:
|
|
|
|
// Last selected view for customview area in dive mode
|
|
|
|
// Byte96-97:
|
|
|
|
// Diluent 1 Default (%O2,%He)
|
|
|
|
// Byte98-99:
|
|
|
|
// Diluent 1 Current (%O2,%He)
|
2016-03-06 22:40:57 +00:00
|
|
|
gas dil1(data[97], data[98]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte100-101:
|
|
|
|
// Gasuent 2 Default (%O2,%He)
|
|
|
|
// Byte102-103:
|
|
|
|
// Gasuent 2 Current (%O2,%He)
|
2016-03-06 22:40:57 +00:00
|
|
|
gas dil2(data[101], data[102]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte104-105:
|
|
|
|
// Gasuent 3 Default (%O2,%He)
|
|
|
|
// Byte106-107:
|
|
|
|
// Gasuent 3 Current (%O2,%He)
|
2016-03-06 22:40:57 +00:00
|
|
|
gas dil3(data[105], data[106]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte108-109:
|
|
|
|
// Gasuent 4 Default (%O2,%He)
|
|
|
|
// Byte110-111:
|
|
|
|
// Gasuent 4 Current (%O2,%He)
|
2016-03-06 22:40:57 +00:00
|
|
|
gas dil4(data[109], data[110]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte112-113:
|
|
|
|
// Gasuent 5 Default (%O2,%He)
|
|
|
|
// Byte114-115:
|
|
|
|
// Gasuent 5 Current (%O2,%He)
|
2016-03-06 22:40:57 +00:00
|
|
|
gas dil5(data[113], data[114]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte116:
|
|
|
|
// First Diluent (1-5)
|
2014-12-29 08:16:47 +00:00
|
|
|
switch (data[115]) {
|
2014-12-29 07:52:10 +00:00
|
|
|
case 1:
|
|
|
|
dil1.type = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dil2.type = 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
dil3.type = 2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
dil4.type = 2;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
dil5.type = 2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//Error?
|
|
|
|
break;
|
|
|
|
}
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.dil1 = dil1;
|
|
|
|
deviceDetails.dil2 = dil2;
|
|
|
|
deviceDetails.dil3 = dil3;
|
|
|
|
deviceDetails.dil4 = dil4;
|
|
|
|
deviceDetails.dil5 = dil5;
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte117-128:
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF0-CF31)
|
|
|
|
|
|
|
|
// Decode the relevant ones
|
|
|
|
// CF11: Factor for saturation processes
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.saturation = read_ostc_cf(data, 11);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF12: Factor for desaturation processes
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.desaturation = read_ostc_cf(data, 12);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF17: Lower threshold for ppO2 warning
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.ppO2Min = read_ostc_cf(data, 17);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF18: Upper threshold for ppO2 warning
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.ppO2Max = read_ostc_cf(data, 18);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF20: Depth sampling rate for Profile storage
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.samplingRate = read_ostc_cf(data, 20);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF29: Depth of last decompression stop
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.lastDeco = read_ostc_cf(data, 29);
|
2014-12-29 07:52:10 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 0; cf <= 31 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 1, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte1:
|
|
|
|
// Logbook version indicator (Not writable!)
|
|
|
|
// Byte2-3:
|
|
|
|
// Last Firmware installed, 1st Byte.2nd Byte (e.g. „1.90“) (Not writable!)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.firmwareVersion = QString::number(data[1]) + "." + QString::number(data[2]);
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte4:
|
|
|
|
// OLED brightness (=0: Eco, =1 High) (Not writable!)
|
|
|
|
// Byte5-11:
|
|
|
|
// Time/Date vault during firmware updates
|
|
|
|
// Byte12-128
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF 32-63)
|
|
|
|
|
|
|
|
// Decode the relevant ones
|
|
|
|
// CF32: Gradient Factor low
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gfLow = read_ostc_cf(data, 32);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF33: Gradient Factor high
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.gfHigh = read_ostc_cf(data, 33);
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF56: Bottom gas consumption
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.bottomGasConsumption = read_ostc_cf(data, 56);
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF57: Ascent gas consumption
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.decoGasConsumption = read_ostc_cf(data, 57);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF58: Future time to surface setFutureTTS
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.futureTTS = read_ostc_cf(data, 58);
|
2014-12-29 07:52:10 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 32; cf <= 63 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 2, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:10 +00:00
|
|
|
// Byte1-4:
|
|
|
|
// not used/reserved (Not writable!)
|
|
|
|
// Byte5-128:
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF 64-95)
|
|
|
|
|
|
|
|
// Decode the relevant ones
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF60: Graphic velocity
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.graphicalSpeedIndicator = read_ostc_cf(data, 60);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF65: Show safety stop
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.safetyStop = read_ostc_cf(data, 65);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF67: Alternaitve Gradient Factor low
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.aGFLow = read_ostc_cf(data, 67);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF68: Alternative Gradient Factor high
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.aGFHigh = read_ostc_cf(data, 68);
|
2014-12-29 07:52:10 +00:00
|
|
|
// CF69: Allow Gradient Factor change
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.aGFSelectable = read_ostc_cf(data, 69);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF70: Safety Stop Duration [s]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.safetyStopLength = read_ostc_cf(data, 70);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF71: Safety Stop Start Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.safetyStopStartDepth = read_ostc_cf(data, 71);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF72: Safety Stop End Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.safetyStopEndDepth = read_ostc_cf(data, 72);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF73: Safety Stop Reset Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
deviceDetails.safetyStopResetDepth = read_ostc_cf(data, 73);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF74: Battery Timeout [min]
|
|
|
|
|
2014-12-29 07:52:10 +00:00
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 64; cf <= 95 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
static dc_status_t write_ostc_settings(dc_device_t *device, const DeviceDetails &deviceDetails, dc_event_callback_t progress_cb, void *userdata)
|
2014-12-29 07:52:12 +00:00
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
dc_event_progress_t progress;
|
|
|
|
progress.current = 0;
|
|
|
|
progress.maximum = 7;
|
2014-12-29 07:52:12 +00:00
|
|
|
unsigned char data[256] = {};
|
|
|
|
unsigned char max_CF = 0;
|
|
|
|
|
|
|
|
// Because we write whole memory blocks, we read all the current
|
|
|
|
// values out and then change then ones we should change.
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 0, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
//Byte5-6:
|
|
|
|
//Gas 1 default (%O2=21, %He=0)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas gas1 = deviceDetails.gas1;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[6] = gas1.oxygen;
|
|
|
|
data[7] = gas1.helium;
|
|
|
|
//Byte9-10:
|
|
|
|
//Gas 2 default (%O2=21, %He=0)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas gas2 = deviceDetails.gas2;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[10] = gas2.oxygen;
|
|
|
|
data[11] = gas2.helium;
|
|
|
|
//Byte13-14:
|
|
|
|
//Gas 3 default (%O2=21, %He=0)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas gas3 = deviceDetails.gas3;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[14] = gas3.oxygen;
|
|
|
|
data[15] = gas3.helium;
|
|
|
|
//Byte17-18:
|
|
|
|
//Gas 4 default (%O2=21, %He=0)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas gas4 = deviceDetails.gas4;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[18] = gas4.oxygen;
|
|
|
|
data[19] = gas4.helium;
|
|
|
|
//Byte21-22:
|
|
|
|
//Gas 5 default (%O2=21, %He=0)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas gas5 = deviceDetails.gas5;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[22] = gas5.oxygen;
|
|
|
|
data[23] = gas5.helium;
|
|
|
|
//Byte25-26:
|
|
|
|
//Gas 6 current (%O2, %He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[26] = deviceDetails.salinity;
|
2014-12-29 07:52:12 +00:00
|
|
|
// Gas types, 0=Disabled, 1=Active, 2=Fist
|
|
|
|
// Active Gas Flag Register
|
|
|
|
data[27] = 0;
|
|
|
|
if (gas1.type)
|
|
|
|
data[27] ^= 0x01;
|
|
|
|
if (gas2.type)
|
|
|
|
data[27] ^= 0x02;
|
|
|
|
if (gas3.type)
|
|
|
|
data[27] ^= 0x04;
|
|
|
|
if (gas4.type)
|
|
|
|
data[27] ^= 0x08;
|
|
|
|
if (gas5.type)
|
|
|
|
data[27] ^= 0x10;
|
|
|
|
|
|
|
|
// Gas switch depths
|
|
|
|
data[28] = gas1.depth;
|
|
|
|
data[29] = gas2.depth;
|
|
|
|
data[30] = gas3.depth;
|
|
|
|
data[31] = gas4.depth;
|
|
|
|
data[32] = gas5.depth;
|
|
|
|
// 33 which gas is Fist gas
|
|
|
|
if (gas1.type == 2)
|
|
|
|
data[33] = 1;
|
|
|
|
else if (gas2.type == 2)
|
|
|
|
data[33] = 2;
|
|
|
|
else if (gas3.type == 2)
|
|
|
|
data[33] = 3;
|
|
|
|
else if (gas4.type == 2)
|
|
|
|
data[33] = 4;
|
|
|
|
else if (gas5.type == 2)
|
|
|
|
data[33] = 5;
|
|
|
|
else
|
2019-03-19 15:22:51 +00:00
|
|
|
// odd: No gas was First?
|
2014-12-29 07:52:12 +00:00
|
|
|
// Set gas 1 to first
|
|
|
|
data[33] = 1;
|
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[34] = deviceDetails.decoType;
|
2014-12-29 07:52:12 +00:00
|
|
|
//Byte36:
|
|
|
|
//Use O2 Sensor Module in CC Modes (0= OFF, 1= ON) (Only available in old OSTC1 - unused for OSTC Mk.2/2N)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
//deviceDetails.ccrMode = data[35];
|
|
|
|
data[36] = deviceDetails.sp1.sp;
|
|
|
|
data[37] = deviceDetails.sp2.sp;
|
|
|
|
data[38] = deviceDetails.sp3.sp;
|
2014-12-29 07:52:12 +00:00
|
|
|
// Byte41-42:
|
|
|
|
// Lowest Battery voltage seen (in mV)
|
|
|
|
// Byte43:
|
|
|
|
// Lowest Battery voltage seen at (Month)
|
|
|
|
// Byte44:
|
|
|
|
// Lowest Battery voltage seen at (Day)
|
|
|
|
// Byte45:
|
|
|
|
// Lowest Battery voltage seen at (Year)
|
|
|
|
// Byte46-47:
|
|
|
|
// Lowest Battery voltage seen at (Temperature in 0.1 °C)
|
|
|
|
// Byte48:
|
|
|
|
// Last complete charge at (Month)
|
|
|
|
// Byte49:
|
|
|
|
// Last complete charge at (Day)
|
|
|
|
// Byte50:
|
|
|
|
// Last complete charge at (Year)
|
|
|
|
// Byte51-52:
|
|
|
|
// Total charge cycles
|
|
|
|
// Byte53-54:
|
|
|
|
// Total complete charge cycles
|
|
|
|
// Byte55-56:
|
|
|
|
// Temperature Extrema minimum (Temperature in 0.1 °C)
|
|
|
|
// Byte57:
|
|
|
|
// Temperature Extrema minimum at (Month)
|
|
|
|
// Byte58:
|
|
|
|
// Temperature Extrema minimum at (Day)
|
|
|
|
// Byte59:
|
|
|
|
// Temperature Extrema minimum at (Year)
|
|
|
|
// Byte60-61:
|
|
|
|
// Temperature Extrema maximum (Temperature in 0.1 °C)
|
|
|
|
// Byte62:
|
|
|
|
// Temperature Extrema maximum at (Month)
|
|
|
|
// Byte63:
|
|
|
|
// Temperature Extrema maximum at (Day)
|
|
|
|
// Byte64:
|
|
|
|
// Temperature Extrema maximum at (Year)
|
|
|
|
// Byte65:
|
|
|
|
// Custom Text active (=1), Custom Text Disabled (<>1)
|
|
|
|
// Byte66-90:
|
|
|
|
// (25Bytes): Custom Text for Surfacemode (Real text must end with "}")
|
|
|
|
// Example: "OSTC Dive Computer}" (19 Characters incl. "}") Bytes 85-90 will be ignored.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.customText == "") {
|
2014-12-29 07:52:12 +00:00
|
|
|
data[64] = 0;
|
|
|
|
} else {
|
|
|
|
data[64] = 1;
|
|
|
|
// Copy the string to the right place in the memory, padded with 0x20 (" ")
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
strncpy((char *)data + 65, qPrintable(QString("%1").arg(deviceDetails.customText, -23, QChar(' '))), 23);
|
2014-12-29 07:52:12 +00:00
|
|
|
// And terminate the string.
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.customText.length() <= 23)
|
|
|
|
data[65 + deviceDetails.customText.length()] = '}';
|
2014-12-29 07:52:12 +00:00
|
|
|
else
|
|
|
|
data[90] = '}';
|
|
|
|
}
|
|
|
|
// Byte91:
|
|
|
|
// Dim OLED in Divemode (>0), Normal mode (=0)
|
|
|
|
// Byte92:
|
|
|
|
// Date format for all outputs:
|
|
|
|
// =0: MM/DD/YY
|
|
|
|
// =1: DD/MM/YY
|
|
|
|
// =2: YY/MM/DD
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
data[91] = deviceDetails.dateFormat;
|
2014-12-29 07:52:12 +00:00
|
|
|
// Byte93:
|
|
|
|
// Total number of CF used in installed firmware
|
|
|
|
max_CF = data[92];
|
|
|
|
// Byte94:
|
|
|
|
// Last selected view for customview area in surface mode
|
|
|
|
// Byte95:
|
|
|
|
// Last selected view for customview area in dive mode
|
|
|
|
// Byte96-97:
|
|
|
|
// Diluent 1 Default (%O2,%He)
|
|
|
|
// Byte98-99:
|
|
|
|
// Diluent 1 Current (%O2,%He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas dil1 = deviceDetails.dil1;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[97] = dil1.oxygen;
|
|
|
|
data[98] = dil1.helium;
|
|
|
|
// Byte100-101:
|
|
|
|
// Gasuent 2 Default (%O2,%He)
|
|
|
|
// Byte102-103:
|
|
|
|
// Gasuent 2 Current (%O2,%He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas dil2 = deviceDetails.dil2;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[101] = dil2.oxygen;
|
|
|
|
data[102] = dil2.helium;
|
|
|
|
// Byte104-105:
|
|
|
|
// Gasuent 3 Default (%O2,%He)
|
|
|
|
// Byte106-107:
|
|
|
|
// Gasuent 3 Current (%O2,%He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas dil3 = deviceDetails.dil3;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[105] = dil3.oxygen;
|
|
|
|
data[106] = dil3.helium;
|
|
|
|
// Byte108-109:
|
|
|
|
// Gasuent 4 Default (%O2,%He)
|
|
|
|
// Byte110-111:
|
|
|
|
// Gasuent 4 Current (%O2,%He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas dil4 = deviceDetails.dil4;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[109] = dil4.oxygen;
|
|
|
|
data[110] = dil4.helium;
|
|
|
|
// Byte112-113:
|
|
|
|
// Gasuent 5 Default (%O2,%He)
|
|
|
|
// Byte114-115:
|
|
|
|
// Gasuent 5 Current (%O2,%He)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
gas dil5 = deviceDetails.dil5;
|
2014-12-29 07:52:12 +00:00
|
|
|
data[113] = dil5.oxygen;
|
|
|
|
data[114] = dil5.helium;
|
|
|
|
// Byte116:
|
|
|
|
// First Diluent (1-5)
|
|
|
|
if (dil1.type == 2)
|
|
|
|
data[115] = 1;
|
|
|
|
else if (dil2.type == 2)
|
|
|
|
data[115] = 2;
|
|
|
|
else if (dil3.type == 2)
|
|
|
|
data[115] = 3;
|
|
|
|
else if (dil4.type == 2)
|
|
|
|
data[115] = 4;
|
|
|
|
else if (dil5.type == 2)
|
|
|
|
data[115] = 5;
|
|
|
|
else
|
2019-03-19 15:22:51 +00:00
|
|
|
// odd: No first diluent?
|
2014-12-29 07:52:12 +00:00
|
|
|
// Set gas 1 to fist
|
|
|
|
data[115] = 1;
|
|
|
|
|
|
|
|
// Byte117-128:
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF0-CF31)
|
|
|
|
|
|
|
|
// Write the relevant ones
|
|
|
|
// CF11: Factor for saturation processes
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 11, max_CF, deviceDetails.saturation);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF12: Factor for desaturation processes
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 12, max_CF, deviceDetails.desaturation);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF17: Lower threshold for ppO2 warning
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 17, max_CF, deviceDetails.ppO2Min);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF18: Upper threshold for ppO2 warning
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 18, max_CF, deviceDetails.ppO2Max);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF20: Depth sampling rate for Profile storage
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 20, max_CF, deviceDetails.samplingRate);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF29: Depth of last decompression stop
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 29, max_CF, deviceDetails.lastDeco);
|
2014-12-29 07:52:12 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 0; cf <= 31 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
rc = hw_ostc_device_eeprom_write(device, 0, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 1, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
// Byte1:
|
|
|
|
// Logbook version indicator (Not writable!)
|
|
|
|
// Byte2-3:
|
|
|
|
// Last Firmware installed, 1st Byte.2nd Byte (e.g. „1.90“) (Not writable!)
|
|
|
|
// Byte4:
|
|
|
|
// OLED brightness (=0: Eco, =1 High) (Not writable!)
|
|
|
|
// Byte5-11:
|
|
|
|
// Time/Date vault during firmware updates
|
|
|
|
// Byte12-128
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF 32-63)
|
|
|
|
|
|
|
|
// Decode the relevant ones
|
|
|
|
// CF32: Gradient Factor low
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 32, max_CF, deviceDetails.gfLow);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF33: Gradient Factor high
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 33, max_CF, deviceDetails.gfHigh);
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF56: Bottom gas consumption
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 56, max_CF, deviceDetails.bottomGasConsumption);
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF57: Ascent gas consumption
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 57, max_CF, deviceDetails.decoGasConsumption);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF58: Future time to surface setFutureTTS
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 58, max_CF, deviceDetails.futureTTS);
|
2014-12-29 07:52:12 +00:00
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 32; cf <= 63 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
rc = hw_ostc_device_eeprom_write(device, 1, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
|
|
|
|
rc = hw_ostc_device_eeprom_read(device, 2, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
// Byte1-4:
|
|
|
|
// not used/reserved (Not writable!)
|
|
|
|
// Byte5-128:
|
|
|
|
// not used/reserved
|
|
|
|
// Byte129-256:
|
|
|
|
// 32 custom Functions (CF 64-95)
|
|
|
|
|
|
|
|
// Decode the relevant ones
|
2015-09-02 22:00:01 +00:00
|
|
|
// CF60: Graphic velocity
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 60, max_CF, deviceDetails.graphicalSpeedIndicator);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF65: Show safety stop
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 65, max_CF, deviceDetails.safetyStop);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF67: Alternaitve Gradient Factor low
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 67, max_CF, deviceDetails.aGFLow);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF68: Alternative Gradient Factor high
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 68, max_CF, deviceDetails.aGFHigh);
|
2014-12-29 07:52:12 +00:00
|
|
|
// CF69: Allow Gradient Factor change
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 69, max_CF, deviceDetails.aGFSelectable);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF70: Safety Stop Duration [s]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 70, max_CF, deviceDetails.safetyStopLength);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF71: Safety Stop Start Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 71, max_CF, deviceDetails.safetyStopStartDepth);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF72: Safety Stop End Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 72, max_CF, deviceDetails.safetyStopEndDepth);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF73: Safety Stop Reset Depth [m]
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
write_ostc_cf(data, 73, max_CF, deviceDetails.safetyStopResetDepth);
|
2016-01-22 13:17:50 +00:00
|
|
|
// CF74: Battery Timeout [min]
|
|
|
|
|
2014-12-29 07:52:12 +00:00
|
|
|
#ifdef DEBUG_OSTC_CF
|
|
|
|
for (int cf = 64; cf <= 95 && cf <= max_CF; cf++)
|
|
|
|
printf("CF %d: %d\n", cf, read_ostc_cf(data, cf));
|
|
|
|
#endif
|
|
|
|
rc = hw_ostc_device_eeprom_write(device, 2, data, sizeof(data));
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
return rc;
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
|
|
|
|
//sync date and time
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (deviceDetails.syncTime) {
|
2014-12-29 07:52:12 +00:00
|
|
|
QDateTime timeToSet = QDateTime::currentDateTime();
|
2017-08-21 03:39:52 +00:00
|
|
|
dc_datetime_t time = { 0 };
|
2014-12-29 07:52:12 +00:00
|
|
|
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();
|
2017-08-26 19:17:19 +00:00
|
|
|
time.timezone = DC_TIMEZONE_NONE;
|
2017-08-21 03:39:52 +00:00
|
|
|
rc = dc_device_timesync(device, &time);
|
2014-12-29 07:52:12 +00:00
|
|
|
}
|
2015-09-02 22:00:03 +00:00
|
|
|
EMIT_PROGRESS();
|
2014-12-29 07:52:12 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2015-09-02 22:00:03 +00:00
|
|
|
#undef EMIT_PROGRESS
|
|
|
|
|
2015-01-20 21:40:49 +00:00
|
|
|
DeviceThread::DeviceThread(QObject *parent, device_data_t *data) : QThread(parent), m_data(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-20 21:40:51 +00:00
|
|
|
void DeviceThread::progressCB(int percent)
|
|
|
|
{
|
|
|
|
emit progress(percent);
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:36:04 +00:00
|
|
|
void DeviceThread::event_cb(dc_device_t *, dc_event_type_t event, const void *data, void *userdata)
|
2015-01-20 21:40:51 +00:00
|
|
|
{
|
|
|
|
const dc_event_progress_t *progress = (dc_event_progress_t *) data;
|
|
|
|
DeviceThread *dt = static_cast<DeviceThread*>(userdata);
|
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case DC_EVENT_PROGRESS:
|
2017-03-23 01:13:49 +00:00
|
|
|
dt->progressCB(lrint(100.0 * (double)progress->current / (double)progress->maximum));
|
2015-01-20 21:40:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
emit dt->error("Unexpected event recived");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-20 21:40:49 +00:00
|
|
|
ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
|
2014-12-29 07:52:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-06-10 12:03:26 +00:00
|
|
|
void ReadSettingsThread::run()
|
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2014-12-30 15:13:42 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
DeviceDetails deviceDetails;
|
2015-09-12 20:37:34 +00:00
|
|
|
switch (dc_device_get_type(m_data->device)) {
|
|
|
|
case DC_FAMILY_SUUNTO_VYPER:
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
rc = read_suunto_vyper_settings(m_data->device, deviceDetails, DeviceThread::event_cb, this);
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc == DC_STATUS_SUCCESS) {
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
emit devicedetails(std::move(deviceDetails));
|
2015-09-12 20:37:34 +00:00
|
|
|
} else if (rc == DC_STATUS_UNSUPPORTED) {
|
|
|
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
|
|
|
} else {
|
2018-03-03 13:34:31 +00:00
|
|
|
emit error(tr("Failed!"));
|
2015-09-12 20:37:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DC_FAMILY_HW_OSTC3:
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
rc = read_ostc3_settings(m_data->device, deviceDetails, DeviceThread::event_cb, this);
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc == DC_STATUS_SUCCESS)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
emit devicedetails(std::move(deviceDetails));
|
2015-09-12 20:37:34 +00:00
|
|
|
else
|
2018-03-03 13:34:31 +00:00
|
|
|
emit error(tr("Failed!"));
|
2015-09-12 20:37:34 +00:00
|
|
|
break;
|
2018-10-08 19:07:57 +00:00
|
|
|
|
2014-10-27 20:55:00 +00:00
|
|
|
#ifdef DEBUG_OSTC
|
2015-09-12 20:37:34 +00:00
|
|
|
case DC_FAMILY_NULL:
|
2014-10-27 20:55:00 +00:00
|
|
|
#endif
|
2015-09-12 20:37:34 +00:00
|
|
|
case DC_FAMILY_HW_OSTC:
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
rc = read_ostc_settings(m_data->device, deviceDetails, DeviceThread::event_cb, this);
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc == DC_STATUS_SUCCESS)
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
emit devicedetails(std::move(deviceDetails));
|
2015-09-12 20:37:34 +00:00
|
|
|
else
|
2018-03-03 13:34:31 +00:00
|
|
|
emit error(tr("Failed!"));
|
2015-09-12 20:37:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
|
|
|
break;
|
2014-06-10 12:03:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 13:42:02 +00:00
|
|
|
WriteSettingsThread::WriteSettingsThread(QObject *parent, device_data_t *data) :
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
DeviceThread(parent, data)
|
2014-12-28 22:38:39 +00:00
|
|
|
{
|
2014-06-10 15:25:25 +00:00
|
|
|
}
|
2014-06-10 12:03:26 +00:00
|
|
|
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
void WriteSettingsThread::setDeviceDetails(const DeviceDetails &details)
|
2014-06-10 15:25:25 +00:00
|
|
|
{
|
|
|
|
m_deviceDetails = details;
|
2014-06-10 12:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WriteSettingsThread::run()
|
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2014-12-30 15:13:42 +00:00
|
|
|
|
2015-09-12 20:37:34 +00:00
|
|
|
switch (dc_device_get_type(m_data->device)) {
|
|
|
|
case DC_FAMILY_SUUNTO_VYPER:
|
|
|
|
rc = write_suunto_vyper_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
|
|
|
if (rc == DC_STATUS_UNSUPPORTED) {
|
|
|
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
|
|
|
} else if (rc != DC_STATUS_SUCCESS) {
|
|
|
|
emit error(tr("Failed!"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DC_FAMILY_HW_OSTC3:
|
2019-03-19 15:22:51 +00:00
|
|
|
// Is this the best way?
|
computer configuration: use value semantics for DeviceDetails
The memory managements for DeviceDetails was very sketchy.
First of all, sharing a pointer to a structure between threads
seems like a recipe for disaster. Secondly, the structure was
a QObject and when first generated included in the (silly)
Qt object tree, but when generated in the threads it was not.
Clearly, this leaks.
Instead, use value semantics and use local copies of the
structure. I didn't go full length and use std::move to
move the data, because this doesn't work through signals
(which are the wrong abstraction here, but OK) and secondly
I didn't have time to analyze whether the caller still
needs the data after passing it down to the worker thread.
To be able to pass an object through signals, the class
has to be registered in the Qt MetaType system. Super
ugly, but fine for now. Ultimately, this whole thing should
probably be replaced by futures, co-routines, or whatever.
Moreover, this removes the prefix from number of "m_*"
function parameters. By convention, "m_" marks member
variables, which function parameters are not.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
make DeviceDetails a metatype
So that we can pass it as value through the signal/slot system.
(squash with original commit)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-16 08:29:54 +00:00
|
|
|
if (m_deviceDetails.model == "OSTC 4")
|
2017-04-26 18:49:12 +00:00
|
|
|
rc = write_ostc4_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
|
|
|
else
|
|
|
|
rc = write_ostc3_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
emit error(tr("Failed!"));
|
|
|
|
break;
|
2014-10-27 20:55:04 +00:00
|
|
|
#ifdef DEBUG_OSTC
|
2015-09-12 20:37:34 +00:00
|
|
|
case DC_FAMILY_NULL:
|
2014-10-27 20:55:04 +00:00
|
|
|
#endif
|
2015-09-12 20:37:34 +00:00
|
|
|
case DC_FAMILY_HW_OSTC:
|
|
|
|
rc = write_ostc_settings(m_data->device, m_deviceDetails, DeviceThread::event_cb, this);
|
|
|
|
if (rc != DC_STATUS_SUCCESS)
|
|
|
|
emit error(tr("Failed!"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
|
|
|
break;
|
2014-06-10 15:25:25 +00:00
|
|
|
}
|
2014-06-10 12:03:26 +00:00
|
|
|
}
|
2014-06-23 15:16:27 +00:00
|
|
|
|
|
|
|
|
2023-03-02 12:01:46 +00:00
|
|
|
FirmwareUpdateThread::FirmwareUpdateThread(QObject *parent, device_data_t *data, QString fileName, bool forceUpdate) : DeviceThread(parent, data), m_fileName(fileName), m_forceUpdate(forceUpdate)
|
2014-06-23 15:16:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FirmwareUpdateThread::run()
|
|
|
|
{
|
|
|
|
dc_status_t rc;
|
2015-01-20 21:40:53 +00:00
|
|
|
|
2015-09-12 20:37:34 +00:00
|
|
|
rc = dc_device_set_events(m_data->device, DC_EVENT_PROGRESS, DeviceThread::event_cb, this);
|
2015-05-27 19:19:12 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
2015-09-12 20:37:34 +00:00
|
|
|
emit error("Error registering the event handler.");
|
2015-05-27 19:19:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-09-12 20:37:34 +00:00
|
|
|
switch (dc_device_get_type(m_data->device)) {
|
|
|
|
case DC_FAMILY_HW_OSTC3:
|
2023-03-02 12:01:46 +00:00
|
|
|
rc = hw_ostc3_device_fwupdate(m_data->device, qPrintable(m_fileName), m_forceUpdate);
|
2015-09-12 20:37:34 +00:00
|
|
|
break;
|
|
|
|
case DC_FAMILY_HW_OSTC:
|
2018-02-25 12:51:41 +00:00
|
|
|
rc = hw_ostc_device_fwupdate(m_data->device, qPrintable(m_fileName));
|
2015-09-12 20:37:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
emit error(tr("This feature is not yet available for the selected dive computer."));
|
|
|
|
return;
|
2014-06-23 15:16:27 +00:00
|
|
|
}
|
2015-05-27 19:19:12 +00:00
|
|
|
|
2015-09-12 20:37:34 +00:00
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
|
|
|
emit error(tr("Firmware update failed!"));
|
|
|
|
}
|
2014-06-23 15:16:27 +00:00
|
|
|
}
|
2014-10-17 22:33:47 +00:00
|
|
|
|
|
|
|
|
2015-01-20 21:40:49 +00:00
|
|
|
ResetSettingsThread::ResetSettingsThread(QObject *parent, device_data_t *data) : DeviceThread(parent, data)
|
2014-10-17 22:33:47 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetSettingsThread::run()
|
|
|
|
{
|
2015-10-02 00:43:30 +00:00
|
|
|
dc_status_t rc = DC_STATUS_SUCCESS;
|
2015-05-27 19:19:12 +00:00
|
|
|
|
2015-09-12 20:37:34 +00:00
|
|
|
if (dc_device_get_type(m_data->device) == DC_FAMILY_HW_OSTC3) {
|
|
|
|
rc = hw_ostc3_device_config_reset(m_data->device);
|
|
|
|
emit progress(100);
|
|
|
|
}
|
|
|
|
if (rc != DC_STATUS_SUCCESS) {
|
|
|
|
emit error(tr("Reset settings failed!"));
|
2014-10-17 22:33:47 +00:00
|
|
|
}
|
|
|
|
}
|