Files
GUI/src/device/DeviceManager.h

124 lines
2.4 KiB
C
Raw Normal View History

//
// Created by Krad on 2021/10/12.
//
#ifndef GUI_DEVICEMANAGER_H
#define GUI_DEVICEMANAGER_H
#include <QObject>
2021-10-22 14:48:55 +08:00
#include <QThread>
2022-06-13 11:21:44 +08:00
class DeviceManager : public QObject {
Q_OBJECT
public:
2022-06-13 11:21:44 +08:00
static DeviceManager *Default() {
static DeviceManager manager;
return &manager;
}
2022-06-13 11:21:44 +08:00
DeviceManager() = default;
2022-06-13 11:21:44 +08:00
~DeviceManager() override = default;
DeviceManager(const DeviceManager &) = delete;
DeviceManager operator=(const DeviceManager &) = delete;
2022-05-17 16:15:20 +08:00
/**
* init device, include Shimlib and it's error call back,
* deviceInfTimer to get temperature of water, and the
* preview data caller thread.
*/
void initDevice();
2022-05-17 16:15:20 +08:00
/**
* close and release the device reference resource.
*/
2022-06-13 11:21:44 +08:00
void close();
2022-05-17 16:15:20 +08:00
/**
* Get Firm ware version
* @return Firm ware version
*/
2022-06-13 11:21:44 +08:00
static QString getSoftwareVersion();
2022-05-17 16:15:20 +08:00
/**
* Get Scan data output path
* @return Scan data output path
*/
2022-06-13 11:21:44 +08:00
static QString getScanOutputPath();
2022-05-17 16:15:20 +08:00
2022-06-13 11:21:44 +08:00
void setErrorOccurred(bool v) {
mErrorOccurred = v;
2021-10-26 13:08:11 +08:00
}
2022-06-13 11:21:44 +08:00
bool getErrorOccurred() {
return mErrorOccurred;
2021-10-26 13:08:11 +08:00
}
2022-06-13 11:21:44 +08:00
void emitErrorCallback(const char *msg);
signals:
2022-01-12 15:55:10 +08:00
void raiseGlobalError(QString msg);
protected:
2022-06-13 11:21:44 +08:00
void timerEvent(QTimerEvent *event) override;
private:
2022-05-17 16:15:20 +08:00
/**
* To start a new scan operation
* @param json The patient information json string
* @param empty Empty scan flag
*/
2022-06-13 11:21:44 +08:00
void startScan(const char *json, bool empty = false);
2022-05-17 16:15:20 +08:00
2022-06-13 11:21:44 +08:00
/**
* Post Scan start command to Shimlib
*/
2022-05-12 14:53:17 +08:00
void postScanCommand();
2022-05-17 16:15:20 +08:00
/**
* Post Continue Scan command to Shimlib
* @param useTimer start a new timer flag
*/
2022-05-12 14:53:17 +08:00
void postContinueCommand(bool useTimer = false);
2022-05-17 16:15:20 +08:00
/**
* Prepare for finishing the Scan
*/
void prepareFinishScan();
/**
* exit the current Scan process timer
*/
void exitScanTimer();
/**
* Process scan progress change
* @param Scan progress
*/
2022-06-13 11:21:44 +08:00
void scanProcess(int aProgress);
void initPreviewThread();
void stopScan();
void startPreview();
int mScanPhase = 1;
volatile int mTimerID = -1;
int mDeviceInfTimerID = -1;
int mLastStatus = -1;
bool mPreviewing = false;
volatile bool mEndLoop = false;
volatile bool mErrorOccurred = false;
QThread *mPreviewDataCaller = nullptr;
};
#endif //GUI_DEVICEMANAGER_H