DIOS.Dev.FPD.XiuYuan.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. 
  2. #pragma once
  3. #include "CCOS.Dev.FPDDeviceMould.hpp"
  4. #include "OEM.Acq.h"
  5. #include "OEM.Sync.h"
  6. #include "OEM.Calib.h"
  7. #include "OEM.DetectorCtrl.h"
  8. #include "DetectorConfiguration.h"
  9. #include "FPDErrorWarningProcess.h"
  10. #include "DetectorDefinition.h"
  11. #ifdef CCOSDEVFPDXIUYUAN_EXPORTS
  12. #define __CCOSDEVFPDXIUYUAN_EXPORTS__ __declspec(dllexport)
  13. #else
  14. #define __CCOSDEVFPDXIUYUAN_EXPORTS__ __declspec(dllimport)
  15. #endif
  16. namespace CCOS::Dev::Detail::Detector
  17. {
  18. //-----------------------------------------------------------------------------
  19. // XiuYuanDriver
  20. //-----------------------------------------------------------------------------
  21. class __CCOSDEVFPDXIUYUAN_EXPORTS__ XiuYuanDriver : public FPDDriverMould
  22. {
  23. using super = FPDDriverMould;
  24. FPDDeviceXiuYuan* dev;
  25. bool m_bConnect;
  26. ResDataObject m_ConfigAll;
  27. ResDataObject m_Configurations;
  28. ResDataObject m_DeviceConfig;
  29. std::unique_ptr <ResDataObject> m_pAttribute;
  30. std::unique_ptr <ResDataObject> m_pDescription;
  31. public:
  32. XiuYuanDriver();
  33. virtual ~XiuYuanDriver();
  34. virtual void Prepare() override;
  35. virtual bool Connect() override;
  36. virtual void Disconnect() override;
  37. virtual bool isConnected() const override;
  38. virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
  39. virtual std::string DriverProbe() override;
  40. virtual std::string GetResource() override;
  41. virtual std::string DeviceProbe() override;
  42. virtual bool GetDeviceConfig(std::string& Cfg) override;
  43. virtual bool SetDeviceConfig(std::string Cfg) override;
  44. bool SaveConfigFile(bool bSendNotify);
  45. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  46. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  47. };
  48. //-----------------------------------------------------------------------------
  49. // FPDDeviceXiuYuan
  50. //-----------------------------------------------------------------------------
  51. class XiuYuanCtrl;
  52. class __CCOSDEVFPDXIUYUAN_EXPORTS__ FPDDeviceXiuYuan : public FPDDeviceMould
  53. {
  54. using super = IODeviceDetail;
  55. private:
  56. std::unique_ptr <AcqUnit> m_AcqUnit;
  57. std::unique_ptr <SyncUnit> m_SyncUnit;
  58. std::unique_ptr <CalibUnit> m_CalibUnit;
  59. std::unique_ptr <DetectorCtrlUnit> m_DetectorCtrlUnit;
  60. std::unique_ptr <DeviceTemperatureMould> m_Temperature;
  61. std::unique_ptr <DeviceBatteryMould> m_Battery;
  62. std::unique_ptr <DeviceWifiMould> m_Wifi;
  63. std::unique_ptr <DetectorConfiguration> m_DetectorConfiguration;
  64. std::unique_ptr <FPDErrorWarning> m_WarnAndError;
  65. SYNC_MODE m_eSyncMode;
  66. APP_STATUS m_eAppStatus; //DROC的当前状态
  67. SYSTEMTIME m_stImgCreateTime;
  68. ResDataObject m_CalibDoseList; //ZSKK校正时加载校正剂量配置
  69. DeviceIndexStruct m_stDeviceConfig;
  70. CCOS_CALIBRATION_TYPE m_CalibType;
  71. WORD* m_pFullImgBuffer; //裁剪后的有效图像内存
  72. WORD* m_pPreviewImgBuffer;
  73. std::string m_strWorkPath;
  74. int m_nCalibTotalExposureNum; //校正曝光总次数
  75. int m_nFullImgWidth; //有效图像的宽
  76. int m_nFullImgHeight; //有效图像的高
  77. int m_nAngle;
  78. int m_nPixelSpacing;
  79. int m_nSensitivity;
  80. int m_nImageBits; //图像位数
  81. int m_nPreviewEnable;
  82. int m_nPreviewImageWidth;
  83. int m_nPreviewImageHeight;
  84. int m_nCalibCurrentCalibrationRound;
  85. int m_nCalibCurrentExposureIndex;
  86. int m_nCalibCurrentExposureNum;
  87. float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数
  88. bool m_bSaveRaw;
  89. bool m_bConnectStatus;
  90. bool LoadConfig();
  91. void SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight);
  92. void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  93. void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  94. void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  95. void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  96. void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  97. void OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  98. bool GetEffectiveImage(WORD* pwInImgData, int nRawImageWidth);
  99. bool CompleteCalibration();
  100. bool SaveConfigFile(bool bSendNotify);
  101. string GetFileVersion(string strFilePathName);
  102. void SendTemperatureValue(float fTemp);
  103. void SendWifiValue(int nWifi);
  104. void SendBatteryValue(int nBattery);
  105. void AbortCalibration();
  106. bool Support_DarkCalib();
  107. bool Support_XrayCalib();
  108. RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize);
  109. string MakeImageHead(IMAGE_VIEW_TYPE Type);
  110. public:
  111. FPDDeviceXiuYuan(std::shared_ptr <IOEventCenter> center, string ConfigPath);
  112. ~FPDDeviceXiuYuan();
  113. bool m_bOffsetCalibRunning;
  114. public:
  115. void Register();
  116. virtual std::string GetGUID() const override;
  117. virtual bool Prepare() override;
  118. protected:
  119. void RegisterCtrl(CCOS::Dev::Detail::Dispatch* Dispatch);
  120. void RegisterAcq(CCOS::Dev::Detail::Dispatch* Dispatch);
  121. void RegisterSync(CCOS::Dev::Detail::Dispatch* Dispatch);
  122. void RegisterCalib(CCOS::Dev::Detail::Dispatch* Dispatch);
  123. void RegisterOthers(CCOS::Dev::Detail::Dispatch* Dispatch);
  124. public:
  125. bool CreateDevice();
  126. RET_STATUS Connect();
  127. RET_STATUS ActiveDetector(bool bActive);
  128. RET_STATUS SetAcqMode(string strAcqMode);
  129. RET_STATUS GetSyncMode(SYNC_MODE& eSyncMode);
  130. RET_STATUS PrepareAcquisition();
  131. RET_STATUS StartAcquisition(string in = "");
  132. RET_STATUS StopAcquisition();
  133. RET_STATUS ActiveSyncMode(int nSyncMode);
  134. RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE in);
  135. RET_STATUS PrepareCalibration();
  136. RET_STATUS GetRequestedDose(string& strDose);
  137. RET_STATUS SetRequestedDose(std::string strDose);
  138. RET_STATUS GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo);
  139. RET_STATUS StartCalibration();
  140. RET_STATUS StopCalibration();
  141. RET_STATUS AcceptCalibration();
  142. RET_STATUS RejectCalibration();
  143. RET_STATUS SaveCalibrationFile(bool bSaveFlag);
  144. RET_STATUS UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode);
  145. RET_STATUS UpdateNotifyStatusTimePeriod(int nTime);
  146. RET_STATUS UpdateReconnectTimePeriod(int nTime);
  147. RET_STATUS EnterExam(int nExamStatus);
  148. void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  149. };
  150. }