// // Created by Krad on 2021/10/12. // #ifndef GUI_DEVICEMANAGER_H #define GUI_DEVICEMANAGER_H #include #include 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 */ QString getSoftwareVersion(); /** * Get Scan data output path * @return Scan data output path */ QString getScanOutputPath(); void setErrorOccurred(bool v){ errorOccurred = v; } bool getErrorOccurred(){ return errorOccurred; } 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 progress); int scanPhase = 1; volatile int timerID = -1; int deviceInfTimerID = -1; int lastStatus = -1; bool previewing = false; volatile bool endLoop = false; volatile bool errorOccurred = false; QThread* previewDataCaller = nullptr; }; #endif //GUI_DEVICEMANAGER_H