124 lines
2.4 KiB
C++
124 lines
2.4 KiB
C++
//
|
|
// Created by Krad on 2021/10/12.
|
|
//
|
|
|
|
#ifndef GUI_DEVICEMANAGER_H
|
|
#define GUI_DEVICEMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QThread>
|
|
|
|
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;
|
|
|
|
/**
|
|
* init device, include Shimlib and it's error call back,
|
|
* deviceInfTimer to get temperature of water, and the
|
|
* preview data caller thread.
|
|
*/
|
|
void initDevice();
|
|
|
|
/**
|
|
* close and release the device reference resource.
|
|
*/
|
|
void close();
|
|
|
|
/**
|
|
* Get Firm ware version
|
|
* @return Firm ware version
|
|
*/
|
|
static QString getSoftwareVersion();
|
|
|
|
/**
|
|
* Get Scan data output path
|
|
* @return Scan data output path
|
|
*/
|
|
static QString getScanOutputPath();
|
|
|
|
void setErrorOccurred(bool v) {
|
|
mErrorOccurred = v;
|
|
}
|
|
|
|
bool getErrorOccurred() {
|
|
return mErrorOccurred;
|
|
}
|
|
|
|
void emitErrorCallback(const char *msg);
|
|
|
|
signals:
|
|
|
|
void raiseGlobalError(QString msg);
|
|
|
|
protected:
|
|
void timerEvent(QTimerEvent *event) override;
|
|
|
|
private:
|
|
/**
|
|
* 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
|
|
*/
|
|
void postScanCommand();
|
|
|
|
/**
|
|
* Post Continue Scan command to Shimlib
|
|
* @param useTimer start a new timer flag
|
|
*/
|
|
void postContinueCommand(bool useTimer = false);
|
|
|
|
/**
|
|
* 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 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
|