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