2021-10-13 17:38:31 +08:00
|
|
|
//
|
|
|
|
|
// 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
|
2021-10-13 17:38:31 +08:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static DeviceManager* Default(){
|
|
|
|
|
static DeviceManager manager;
|
|
|
|
|
return &manager;
|
|
|
|
|
}
|
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.
|
|
|
|
|
*/
|
2021-10-13 17:38:31 +08:00
|
|
|
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);
|
2021-10-13 17:38:31 +08:00
|
|
|
|
|
|
|
|
protected:
|
2022-01-11 16:58:03 +08:00
|
|
|
void timerEvent(QTimerEvent* event) override;
|
2021-10-13 17:38:31 +08:00
|
|
|
|
|
|
|
|
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-01-11 16:58:03 +08:00
|
|
|
int timerID = -1;
|
|
|
|
|
int deviceInfTimerID = -1;
|
|
|
|
|
int lastStatus = -1;
|
|
|
|
|
bool previewing = false;
|
2022-01-14 14:19:56 +08:00
|
|
|
volatile bool endLoop = false;
|
2022-01-11 16:58:03 +08:00
|
|
|
bool errorOccurred = false;
|
|
|
|
|
QThread* previewDataCaller;
|
2021-10-13 17:38:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif //GUI_DEVICEMANAGER_H
|