Files
GUI/src/device/DeviceManager.h

208 lines
6.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>
2023-08-21 14:22:41 +08:00
#include "DeviceDefs.h"
2022-06-13 11:21:44 +08:00
2023-08-21 14:22:41 +08:00
class DmsSyncAction;
class DmsAsyncAction;
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
2023-08-21 14:22:41 +08:00
~DeviceManager() override
{
// mCmdSendThread->quit();
// mCmdSendThread->wait();
// mCmdSendThread->deleteLater();
mDmsInfoReceiveThread->quit();
mDmsInfoReceiveThread->wait();
mDmsInfoReceiveThread->deleteLater();
}
2022-06-13 11:21:44 +08:00
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
*/
2023-08-21 14:22:41 +08:00
QString getSoftwareVersion();
2022-05-17 16:15:20 +08:00
2023-08-21 14:22:41 +08:00
// void setErrorOccurred(bool v) {
// mErrorOccurred = v;
// }
2022-05-17 16:15:20 +08:00
2023-08-21 14:22:41 +08:00
// bool getErrorOccurred() {
// return mErrorOccurred;
// }
2022-06-13 11:21:44 +08:00
void emitErrorCallback(const char *msg);
2023-08-21 14:22:41 +08:00
void emitInfoCallback(const QString& aMessage,const unsigned int aInfoType);
bool hasValidEmptyScan();
bool updateTransferProgress();
2023-08-22 17:51:08 +08:00
int getTransferProgress();
public slots:
void updateReconState();
2022-06-13 11:21:44 +08:00
signals:
2022-01-12 15:55:10 +08:00
void raiseGlobalError(QString msg);
void raiseGlobalInfo(const QPair<QString,unsigned int>& aInfoData);
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
*/
2023-08-21 14:22:41 +08:00
void startScan(const QString& json, bool empty = false);
2022-06-13 11:21:44 +08:00
void startPreview();
2023-08-21 14:22:41 +08:00
void shutdown();
//-----------------new
DeviceStatus getDeviceStatus();
bool startFullScan(const QString& aPatientInfo);
void stopFullScan();
void stopPreviewScan();
void getDeviceTemperature();
void getScanProcess();
2023-08-31 14:26:54 +08:00
bool getCEStatus();
bool startCEScan();
2023-08-21 14:22:41 +08:00
void startTransfer();
void initEmptyScanMeasurementID();
2023-08-31 15:44:11 +08:00
void controlDrainage(const QString& aCode);
2023-08-21 14:22:41 +08:00
2023-08-31 14:26:54 +08:00
void processScanProgress(const QString& aProgress);
void processInitializeProgress(const QString& aProgress);
2023-08-21 14:22:41 +08:00
void prepareFinishScan(bool isNormalFinish, const QString& aReason = "");
2023-08-31 14:26:54 +08:00
void prepareFinishInitialize();
2023-08-21 14:22:41 +08:00
void processAlarm(const QString& aAlarm);
void processPreviewData(const QString& aPreviewData);
void processGetSoftwareVersion(const QString& aSoftwareVersion);
void processDeviceTemperature(const QString& aResponseTemperature);
void processTransferProgress(const QString& aProgress);
void insertEmptyScanRecord();
void insertScanRecord();
private slots:
//DMS
void processReceiveDMSInfoResult(int aServerID, int aActionID, const QString& aContents);
2023-08-31 14:26:54 +08:00
2023-08-21 14:22:41 +08:00
//Recon
void processReconCreateEmptyScan(bool aResult, const QString& aScanID, const QString& aMessage);
void processReconCreateScan(bool aResult, const QString& aScanID, const QString& aMessage);
void processReconQueryScanState(bool aResult, const QVariant& aState);
void startCreateReconRecord();
void updateReconConnectionState(bool aIsConnected);
2023-08-21 14:22:41 +08:00
//GUI
void scanTimeout();
signals:
//DMS
void responseGetDeviceStatus(const QString& aDeviceStatus);
void responseGetDeviceTemperature(const QString& aDeviceTemperature);
void responseFullScan(const QString& aResponse);
2023-08-31 14:26:54 +08:00
void responseCEScan(const QString& aResponse);
2023-08-21 14:22:41 +08:00
void responseGetScanProgress(const QString& aProgrese);
void responseStopScan(const QString& aResponse);
void responsePreviewScan(const QString& aResponse);
void responseGetSoftwareVersion(const QString& aSoftwareVersion);
void responseTransfer(const QString& aResponse);
2023-08-22 17:51:08 +08:00
void responseGetTransferProgress(const QString& aProgress);
2023-08-31 14:26:54 +08:00
void responseGetCEStatus(const QString& aProgress);
2023-09-06 10:23:25 +08:00
void responsePumpControl(const QString& aResponse);
void responseSetSimulatorMode(const QString& aResponse);
void responseSetHeartBeat(const QString& aResponese);
2023-08-21 14:22:41 +08:00
//Recon
void createEmptyScanToRecon(const QString& aScanID, const QString& aPath);
void createScanToRecon(const QString& aScanID, const QString& aPatientID, const QString& aReferenceID, const QString& aPath);
void queryScanStatusToRecon(const QStringList& aScanIDs);
2023-08-22 17:51:08 +08:00
void updateReconStateFinished();
//GUI
void initializeFinished();
2023-08-31 14:26:54 +08:00
void initializeProgress(const QString& aProgress);
void transferStatusUpdated();
void startPreviewScanResult(bool aIsSucessful);
void startPumpControlResult(bool aIsSucessful);
2022-06-13 11:21:44 +08:00
2023-08-21 14:22:41 +08:00
private:
int mTemperatureTimer = -1;
int mScanProgressTimer = -1;
2023-08-22 17:51:08 +08:00
int mTransferProgress = 0;
2023-08-21 14:22:41 +08:00
bool mIsEmptyScan = false;
bool mIsTransferEmptyScan = false;
bool mIsScanning = false;
bool mIsTransfering = false;
bool mIsPreviewing = false;
2023-08-31 14:26:54 +08:00
bool mIsInitializing = false;
2023-08-21 14:22:41 +08:00
QString mCurrentScanMeasurementID = "";
QString mCurrentEmptyMeasurementID = "";
QString mCurrentPatientName = "";
QString mCurrentPatientID = "";
QString mCurrentAccessionNumber = "";
2023-08-21 14:22:41 +08:00
QString mCurrentLaterality = "";
QString mCurrentOperatorName = "";
QString mCurrentTransferMeasurementID = "";
QString mCurrentTransferPatientID = "";
QString mSoftwareVersion = "";
QThread* mDmsInfoReceiveThread = nullptr;
QThread* mReconHttpThread = nullptr;
DmsSyncAction* mGetDeviceStatusAction = nullptr;
DmsSyncAction* mFullScanAction = nullptr;
DmsSyncAction* mPreviewScanAction = nullptr;
DmsSyncAction* mCEScanAction = nullptr;
DmsSyncAction* mStopScanAction = nullptr;
DmsSyncAction* mTransferAction = nullptr;
2023-08-22 17:51:08 +08:00
DmsSyncAction* mGetTransferProgressAction = nullptr;
2023-08-31 14:26:54 +08:00
DmsSyncAction* mGetCEStatusAction = nullptr;
DmsSyncAction* mPumpControlAction = nullptr;
2023-09-06 10:23:25 +08:00
DmsSyncAction* mSetSimulatorModeAction = nullptr;
DmsSyncAction* mSetHeartBeatAction = nullptr;
2023-08-21 14:22:41 +08:00
DmsAsyncAction* mGetDeviceTemperatureAction = nullptr;
DmsAsyncAction* mGetScanProgressAction = nullptr;
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
2022-06-13 11:21:44 +08:00
};
#endif //GUI_DEVICEMANAGER_H