223 lines
7.1 KiB
C++
223 lines
7.1 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 char *msg);
|
|
void emitInfoCallback(const QString& aMessage,const unsigned int aInfoType);
|
|
bool hasValidEmptyScan();
|
|
bool updateTransferProgress();
|
|
int getTransferProgress();
|
|
|
|
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();
|
|
bool startFullScan(const QString& aPatientInfo);
|
|
void stopFullScan();
|
|
void stopPreviewScan();
|
|
void getDeviceTemperature();
|
|
void getScanProcess();
|
|
bool getCEStatus();
|
|
bool startCEScan();
|
|
void startTransfer();
|
|
void initEmptyScanMeasurementID();
|
|
void controlDrainage(const QString& aCode);
|
|
void checkInitStatus();
|
|
void initGUI(bool aIsInitSucceed);
|
|
|
|
void processScanProgress(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 processGetSoftwareVersion(const QString& aSoftwareVersion);
|
|
void processDeviceTemperature(const QString& aResponseTemperature);
|
|
void processTransferProgress(const QString& aProgress);
|
|
void processShutDownDms(const QString& aResponse);
|
|
void processPumpResult(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);
|
|
void processReconCreateScan(bool aResult, const QString& aScanID, const QString& aMessage);
|
|
void processReconQueryScanState(bool aResult, const QVariant& aState);
|
|
void startCreateReconRecord();
|
|
void updateReconConnectionState(bool aIsConnected);
|
|
//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 responseTransfer(const QString& aResponse);
|
|
void responseGetTransferProgress(const QString& aProgress);
|
|
void responseGetCEStatus(const QString& aProgress);
|
|
void responsePumpControl(const QString& aResponse);
|
|
void responseSetSimulatorMode(const QString& aResponse);
|
|
void responseSetHeartBeat(const QString& aResponese);
|
|
void responseStopTransfer(const QString& aResponse);
|
|
void responseShutDown(const QString& aResponse);
|
|
void responseCheckInitStatus(const QString& aResponse);
|
|
//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);
|
|
void updateReconStateFinished();
|
|
//GUI
|
|
void initializeFinished();
|
|
void initializeProgress(const QString& aProgress);
|
|
void transferStatusUpdated();
|
|
void startPreviewScanResult(bool aIsSucessful);
|
|
void startPumpControlResult(bool aIsSucessful);
|
|
void shutdownDmsSended();
|
|
void shutdownDmsFailed();
|
|
|
|
|
|
private:
|
|
int mTemperatureTimer = -1;
|
|
int mScanProgressTimer = -1;
|
|
int mCheckInitStatusTimer = -1;
|
|
int mTransferProgress = 0;
|
|
bool mIsEmptyScan = false;
|
|
bool mIsTransferEmptyScan = false;
|
|
bool mIsScanning = false;
|
|
bool mIsTransfering = false;
|
|
bool mIsPreviewing = false;
|
|
bool mIsInitializing = false;
|
|
|
|
QString mCurrentScanMeasurementID = "";
|
|
QString mCurrentEmptyMeasurementID = "";
|
|
QString mCurrentPatientName = "";
|
|
QString mCurrentPatientID = "";
|
|
QString mCurrentAccessionNumber = "";
|
|
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;
|
|
DmsSyncAction* mGetTransferProgressAction = nullptr;
|
|
DmsSyncAction* mGetCEStatusAction = nullptr;
|
|
DmsSyncAction* mSetSimulatorModeAction = nullptr;
|
|
DmsSyncAction* mSetHeartBeatAction = nullptr;
|
|
DmsSyncAction* mCheckInitStatusAction = nullptr;
|
|
|
|
DmsAsyncAction* mGetDeviceTemperatureAction = nullptr;
|
|
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
|
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
|
DmsAsyncAction* mStopTransferAction = nullptr;
|
|
DmsAsyncAction* mShutDownAction = nullptr;
|
|
DmsAsyncAction* mPumpControlAction = nullptr;
|
|
|
|
InfoReceiveWorker* mInfoReceiveWorker = nullptr;
|
|
|
|
friend class InfoReceiveWorker;
|
|
};
|
|
|
|
|
|
#endif //GUI_DEVICEMANAGER_H
|