Files
GUI/src/device/DeviceManager.h

106 lines
2.2 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-01-11 16:58:03 +08:00
class DeviceManager :public QObject {
Q_OBJECT
public:
static DeviceManager* Default(){
static DeviceManager manager;
return &manager;
}
DeviceManager() = default;
~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-01-14 14:19:56 +08:00
void close();
2022-05-17 16:15:20 +08:00
/**
* Get Firm ware version
* @return Firm ware version
*/
QString getSoftwareVersion();
/**
* Get Scan data output path
* @return Scan data output path
*/
QString getScanOutputPath();
2021-10-26 13:08:11 +08:00
void setErrorOccurred(bool v){
errorOccurred = v;
}
bool getErrorOccurred(){
return errorOccurred;
}
2022-01-12 15:55:10 +08:00
void emitErrorCallback(const char * msg);
signals:
void raiseGlobalError(QString msg);
protected:
2022-01-11 16:58:03 +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
*/
void startScan(const char* json, bool empty = false);
/**
* 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
*/
void scanProcess(int progress);
2022-05-12 14:53:17 +08:00
int scanPhase = 1;
2022-06-02 16:09:42 +08:00
volatile int timerID = -1;
2022-01-11 16:58:03 +08:00
int deviceInfTimerID = -1;
int lastStatus = -1;
bool previewing = false;
2022-01-14 14:19:56 +08:00
volatile bool endLoop = false;
2022-06-02 16:09:42 +08:00
volatile bool errorOccurred = false;
QThread* previewDataCaller = nullptr;
};
#endif //GUI_DEVICEMANAGER_H