259 lines
8.9 KiB
C++
259 lines
8.9 KiB
C++
#ifndef GUI_DEVICEMANAGER_H
|
|
#define GUI_DEVICEMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QThread>
|
|
#include "DeviceDefs.h"
|
|
#include "InfoReceiveWorker.h"
|
|
|
|
class DmsSyncAction;
|
|
class DmsAsyncAction;
|
|
|
|
class DeviceManager : public QObject
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
static DeviceManager *Default() {
|
|
static DeviceManager manager;
|
|
return &manager;
|
|
}
|
|
|
|
DeviceManager() = default;
|
|
|
|
~DeviceManager() override
|
|
{
|
|
mInfoReceiveWorker->exit();
|
|
mDmsInfoReceiveThread->quit();
|
|
mDmsInfoReceiveThread->wait();
|
|
mDmsInfoReceiveThread->deleteLater();
|
|
|
|
mReconHttpThread->quit();
|
|
mReconHttpThread->wait();
|
|
mReconHttpThread->deleteLater();
|
|
}
|
|
|
|
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();
|
|
|
|
// void setErrorOccurred(bool v) {
|
|
// mErrorOccurred = v;
|
|
// }
|
|
|
|
// bool getErrorOccurred() {
|
|
// return mErrorOccurred;
|
|
// }
|
|
|
|
void emitErrorCallback(const QString& msg);
|
|
void emitInfoCallback(const QString& aMessage,const unsigned int aInfoType);
|
|
bool hasValidEmptyScan();
|
|
void prepareEmergencyReset();
|
|
|
|
public slots:
|
|
void updateReconState();
|
|
|
|
signals:
|
|
|
|
void raiseGlobalError(QString msg);
|
|
void raiseGlobalInfo(const QPair<QString,unsigned int>& aInfoData);
|
|
|
|
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 QString& json, bool empty = false);
|
|
void startPreview();
|
|
void shutdownDms();
|
|
void shutdownOperationSystem();
|
|
|
|
//-----------------new
|
|
DeviceStatus getDeviceStatus();
|
|
void startScanProcess();
|
|
void stopScanProcess();
|
|
bool startFullScan(const QString& aPatientInfo);
|
|
void stopFullScan();
|
|
void stopPreviewScan();
|
|
void getDeviceTemperature();
|
|
void getScanProcess();
|
|
void getAutoLocatePosition();
|
|
bool getCEStatus();
|
|
bool startCEScan();
|
|
void initEmptyScanMeasurementID();
|
|
void startDrainage();
|
|
void startAutoDrainage();
|
|
void startWaterflood();
|
|
void startWaterClean();
|
|
void exitWaterProcess();
|
|
void checkInitStatus();
|
|
bool startAutoLocate();
|
|
void stopAutoLocate();
|
|
void initGUI(bool aIsInitSucceed, const QString& aInfo = "");
|
|
void checkDataQuality();
|
|
|
|
void processScanProgress(const QString& aProgress);
|
|
void processAutoLocatePosition(const QString& aProgress);
|
|
void processInitializeProgress(const QString& aProgress);
|
|
void prepareFinishScan(bool isNormalFinish, const QString& aReason = "");
|
|
void prepareFinishInitialize();
|
|
void processAlarm(const QString& aAlarm);
|
|
void processPreviewData(const QString& aPreviewData);
|
|
void processDeviceTemperature(const QString& aResponseTemperature);
|
|
void processShutDownDms(const QString& aResponse);
|
|
void processDrainageResult(const QString& aResponse);
|
|
void processWaterfloodResult(const QString& aResponse);
|
|
void processWaterCleanResult(const QString& aResponse);
|
|
void processWaterProcessExitResult(const QString& aResponse);
|
|
void processWaterProcessFinishedResult(const QString& aResponse);
|
|
void processGetSoftwareVersion(const QString& aResponse);
|
|
void processEmergencyButtonReset(const QString& aResponse);
|
|
|
|
void insertEmptyScanRecord();
|
|
void insertScanRecord();
|
|
|
|
private slots:
|
|
//DMS
|
|
void processReceiveDMSInfoResult(int aServerID, int aActionID, const QString& aContents);
|
|
|
|
//Recon
|
|
void processReconCreateEmptyScan(bool aResult, const QString& aScanID, const QString& aMessage, bool aIsConnectSucceed);
|
|
void processReconCreateScan(bool aResult, const QString& aScanID, const QString& aMessage, bool aIsConnectSucceed);
|
|
void processReconQueryScanState(bool aResult, const QVariant& aState);
|
|
void startCreateReconRecord();
|
|
void updateReconConnectionState(bool aIsConnected);
|
|
void prepareCheckReconConnection();
|
|
void processReconMessage(const QString& aMessage);
|
|
|
|
//GUI
|
|
void scanTimeout();
|
|
|
|
signals:
|
|
//DMS
|
|
void responseGetDeviceStatus(const QString& aDeviceStatus);
|
|
void responseGetDeviceTemperature(const QString& aDeviceTemperature);
|
|
void responseFullScan(const QString& aResponse);
|
|
void responseCEScan(const QString& aResponse);
|
|
void responseGetScanProgress(const QString& aProgrese);
|
|
void responseStopScan(const QString& aResponse);
|
|
void responsePreviewScan(const QString& aResponse);
|
|
void responseGetSoftwareVersion(const QString& aSoftwareVersion);
|
|
void responseGetCEStatus(const QString& aProgress);
|
|
void responseDrainageControl(const QString& aResponse);
|
|
void responseWaterflood(const QString& aResponse);
|
|
void responseWaterclean(const QString& aResponse);
|
|
void responseWaterProcessExit(const QString& aResponse);
|
|
void responseSetSimulatorMode(const QString& aResponse);
|
|
void responseSetHeartBeat(const QString& aResponese);
|
|
void responseShutDown(const QString& aResponse);
|
|
void responseCheckInitStatus(const QString& aResponse);
|
|
void responseStartAutoLocate(const QString& aResponse);
|
|
void responseStopAutoLocate(const QString& aResponse);
|
|
void responseGetAutoLocatePosition(const QString& aResponse);
|
|
void responseCheckDataQuality(const QString& aResponse);
|
|
void responseEmergencyButtonReset(const QString& aResponse);
|
|
//Recon
|
|
void createEmptyScanToRecon(const QString& aScanID, const QString& aPath);
|
|
void createScanToRecon(const QString& aScanID,const QString& aMPPSUID, const QString& aReferenceID, const QString& aPath);
|
|
void queryScanStatusToRecon(const QStringList& aScanIDs);
|
|
void updateReconStateFinished();
|
|
void checkReconConnection();
|
|
//GUI
|
|
void initializeFinished();
|
|
void initializeProgress(const QString& aProgress);
|
|
void startPreviewScanResult(bool aIsSucessful);
|
|
void startDrainageControlResult(bool aIsSucessful);
|
|
void startWaterfloodResult(bool aIsSucessful);
|
|
void startWaterCleanResult(bool aIsSucessful);
|
|
void exitWaterProcessResult(bool aIsSucessful);
|
|
void waterProcessFinishedResult(bool aIsSucessful, const QString& aInfoCode);
|
|
void startAutoLocateResult(bool aIsSucessful);
|
|
void updateAutoLocatePosition(int aX, int aY, int aZ);
|
|
void autolocatePositionEffective();
|
|
void shutdownDmsSended();
|
|
void shutdownDmsFailed();
|
|
void getDmsVersionResponsed(const QString& aDmsVersion);
|
|
void emergencyButtonPushed(bool aIsLeft, bool aIsReset);
|
|
|
|
|
|
private:
|
|
int mTemperatureTimer = -1;
|
|
int mScanProgressTimer = -1;
|
|
int mCheckInitStatusTimer = -1;
|
|
int mGetAutoLocatePositionTimer = -1;
|
|
int mEffectivePositionCount = 0;
|
|
bool mIsEmptyScan = false;
|
|
bool mIsScanning = false;
|
|
bool mIsPreviewing = false;
|
|
bool mIsInitializing = false;
|
|
bool mIsAutoLocating = false;
|
|
bool mIsFirstInTransferPorgress = false;
|
|
bool mIsAutoDrainage = false;
|
|
|
|
QString mCurrentScanMeasurementID = "";
|
|
QString mCurrentEmptyMeasurementID = "";
|
|
QString mCurrentPatientName = "";
|
|
QString mCurrentPatientID = "";
|
|
QString mCurrentAccessionNumber = "";
|
|
QString mCurrentLaterality = "";
|
|
QString mCurrentOperatorName = "";
|
|
QString mSoftwareVersion = "";
|
|
QString mReconTransferPath = "";
|
|
|
|
QThread* mDmsInfoReceiveThread = nullptr;
|
|
QThread* mReconHttpThread = nullptr;
|
|
DmsSyncAction* mGetDeviceStatusAction = nullptr;
|
|
DmsSyncAction* mFullScanAction = nullptr;
|
|
DmsSyncAction* mPreviewScanAction = nullptr;
|
|
DmsSyncAction* mCEScanAction = nullptr;
|
|
DmsSyncAction* mStopScanAction = nullptr;
|
|
DmsSyncAction* mGetCEStatusAction = nullptr;
|
|
DmsSyncAction* mSetSimulatorModeAction = nullptr;
|
|
DmsSyncAction* mSetHeartBeatAction = nullptr;
|
|
DmsSyncAction* mCheckInitStatusAction = nullptr;
|
|
DmsSyncAction* mStartAutoLocateAction = nullptr;
|
|
DmsSyncAction* mStopAutoLocateAction = nullptr;
|
|
DmsSyncAction* mCheckDataQualityAction = nullptr;
|
|
|
|
DmsAsyncAction* mGetDeviceTemperatureAction = nullptr;
|
|
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
|
DmsAsyncAction* mShutDownAction = nullptr;
|
|
DmsAsyncAction* mDrainageControlAction = nullptr;
|
|
DmsAsyncAction* mWaterfloodAction = nullptr;
|
|
DmsAsyncAction* mWaterCleanAction = nullptr;
|
|
DmsAsyncAction* mWaterProcessExitAction = nullptr;
|
|
DmsAsyncAction* mGetAutoLocatePositionAction = nullptr;
|
|
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
|
DmsAsyncAction* mEmergencyResetAction = nullptr;
|
|
|
|
InfoReceiveWorker* mInfoReceiveWorker = nullptr;
|
|
|
|
friend class InfoReceiveWorker;
|
|
};
|
|
|
|
|
|
#endif //GUI_DEVICEMANAGER_H
|