2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-05-30 06:56:27 +00:00
|
|
|
#ifndef CONFIGUREDIVECOMPUTER_H
|
|
|
|
#define CONFIGUREDIVECOMPUTER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QThread>
|
2014-05-30 07:49:58 +00:00
|
|
|
#include <QVariant>
|
2014-05-30 06:56:27 +00:00
|
|
|
#include "libdivecomputer.h"
|
2014-06-10 12:03:26 +00:00
|
|
|
#include "configuredivecomputerthreads.h"
|
2014-05-30 07:49:58 +00:00
|
|
|
#include <QDateTime>
|
|
|
|
|
2014-06-11 06:37:27 +00:00
|
|
|
#include "libxml/xmlreader.h"
|
|
|
|
|
2014-12-29 04:56:58 +00:00
|
|
|
class ConfigureDiveComputer : public QObject {
|
2014-05-30 06:56:27 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-12-29 04:44:31 +00:00
|
|
|
explicit ConfigureDiveComputer();
|
2014-06-10 15:25:25 +00:00
|
|
|
void readSettings(device_data_t *data);
|
2014-05-30 06:56:27 +00:00
|
|
|
|
|
|
|
enum states {
|
2015-09-12 20:37:34 +00:00
|
|
|
OPEN,
|
2014-12-29 04:56:58 +00:00
|
|
|
INITIAL,
|
|
|
|
READING,
|
|
|
|
WRITING,
|
|
|
|
RESETTING,
|
|
|
|
FWUPDATE,
|
|
|
|
CANCELLING,
|
|
|
|
CANCELLED,
|
2019-08-28 09:21:24 +00:00
|
|
|
ERRORED,
|
2014-12-29 04:56:58 +00:00
|
|
|
DONE,
|
|
|
|
};
|
2014-05-30 06:56:27 +00:00
|
|
|
|
|
|
|
QString lastError;
|
|
|
|
states currentState;
|
2014-06-10 15:25:25 +00:00
|
|
|
void saveDeviceDetails(DeviceDetails *details, device_data_t *data);
|
2014-06-10 12:03:26 +00:00
|
|
|
void fetchDeviceDetails();
|
2014-07-31 15:51:38 +00:00
|
|
|
bool saveXMLBackup(QString fileName, DeviceDetails *details, device_data_t *data);
|
|
|
|
bool restoreXMLBackup(QString fileName, DeviceDetails *details);
|
|
|
|
void startFirmwareUpdate(QString fileName, device_data_t *data);
|
2014-10-17 22:33:47 +00:00
|
|
|
void resetSettings(device_data_t *data);
|
2015-09-12 20:37:34 +00:00
|
|
|
|
|
|
|
QString dc_open(device_data_t *data);
|
|
|
|
public
|
|
|
|
slots:
|
|
|
|
void dc_close(device_data_t *data);
|
2014-05-30 06:56:27 +00:00
|
|
|
signals:
|
2015-01-20 21:40:52 +00:00
|
|
|
void progress(int percent);
|
2014-05-30 06:56:27 +00:00
|
|
|
void message(QString msg);
|
|
|
|
void error(QString err);
|
|
|
|
void stateChanged(states newState);
|
2014-06-10 15:25:25 +00:00
|
|
|
void deviceDetailsChanged(DeviceDetails *newDetails);
|
2014-06-10 12:03:26 +00:00
|
|
|
|
2014-05-30 06:56:27 +00:00
|
|
|
private:
|
|
|
|
ReadSettingsThread *readThread;
|
2014-05-30 07:49:58 +00:00
|
|
|
WriteSettingsThread *writeThread;
|
2014-10-17 22:33:47 +00:00
|
|
|
ResetSettingsThread *resetThread;
|
2014-10-20 20:58:21 +00:00
|
|
|
FirmwareUpdateThread *firmwareThread;
|
2020-10-04 19:00:21 +00:00
|
|
|
void connectThreadSignals(DeviceThread *thread);
|
2014-05-30 06:56:27 +00:00
|
|
|
void setState(states newState);
|
2014-12-29 04:56:58 +00:00
|
|
|
private
|
|
|
|
slots:
|
2015-01-20 21:40:52 +00:00
|
|
|
void progressEvent(int percent);
|
2014-05-30 06:56:27 +00:00
|
|
|
void readThreadFinished();
|
2014-05-30 07:49:58 +00:00
|
|
|
void writeThreadFinished();
|
2014-10-17 22:33:47 +00:00
|
|
|
void resetThreadFinished();
|
2014-10-20 20:58:21 +00:00
|
|
|
void firmwareThreadFinished();
|
2014-05-30 06:56:27 +00:00
|
|
|
void setError(QString err);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGUREDIVECOMPUTER_H
|