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-05-30 06:56:27 +00:00
|
|
|
class ConfigureDiveComputer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ConfigureDiveComputer(QObject *parent = 0);
|
2014-06-10 15:25:25 +00:00
|
|
|
void readSettings(device_data_t *data);
|
2014-05-30 06:56:27 +00:00
|
|
|
|
|
|
|
enum states {
|
|
|
|
INITIAL,
|
|
|
|
READING,
|
|
|
|
WRITING,
|
2014-10-17 22:33:47 +00:00
|
|
|
RESETTING,
|
2014-10-20 20:58:21 +00:00
|
|
|
FWUPDATE,
|
2014-05-30 06:56:27 +00:00
|
|
|
CANCELLING,
|
|
|
|
CANCELLED,
|
|
|
|
ERROR,
|
|
|
|
DONE,
|
|
|
|
};
|
|
|
|
|
|
|
|
QString lastError;
|
|
|
|
states currentState;
|
2014-06-10 12:03:26 +00:00
|
|
|
device_data_t *m_data;
|
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);
|
2014-05-30 06:56:27 +00:00
|
|
|
signals:
|
|
|
|
void message(QString msg);
|
|
|
|
void error(QString err);
|
|
|
|
void readFinished();
|
|
|
|
void writeFinished();
|
|
|
|
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;
|
2014-05-30 06:56:27 +00:00
|
|
|
void setState(states newState);
|
|
|
|
private slots:
|
|
|
|
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
|