DIOS.Dev.FPD.iRay.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. 
  2. #pragma once
  3. #include "CCOS.Dev.FPDDeviceMould.hpp"
  4. #include "TemperatureMould.hpp"
  5. #include "BatteryMould.hpp"
  6. #include "WifiMould.hpp"
  7. #include "OEM.Acq.h"
  8. #include "OEM.Sync.h"
  9. #include "OEM.Calib.h"
  10. #include "OEM.DetectorCtrl.h"
  11. #include "DetectorConfiguration.h"
  12. #include "FPDErrorWarningProcess.h"
  13. #include "CalibrationProcess.h"
  14. #include "IRayDefinition.h"
  15. #ifdef CCOSDEVFPDIRAY_EXPORTS
  16. #define CCOSDEVFPDIRAY_API __declspec(dllexport)
  17. #else
  18. #define CCOSDEVFPDIRAY_API __declspec(dllimport)
  19. #endif
  20. namespace CCOS::Dev::Detail::Detector
  21. {
  22. //-----------------------------------------------------------------------------
  23. // IRayDriver
  24. //-----------------------------------------------------------------------------
  25. class CCOSDEVFPDIRAY_API IRayDriver : public FPDDriverMould
  26. {
  27. using super = FPDDriverMould;
  28. FPDDeviceIRay* dev;
  29. bool m_bConnect;
  30. ResDataObject m_ConfigAll;
  31. ResDataObject m_Configurations;
  32. ResDataObject m_DeviceConfig;
  33. std::unique_ptr <ResDataObject> m_pAttribute;
  34. std::unique_ptr <ResDataObject> m_pDescription;
  35. public:
  36. IRayDriver();
  37. virtual ~IRayDriver();
  38. virtual void Prepare() override;
  39. virtual bool Connect() override;
  40. virtual void Disconnect() override;
  41. virtual bool isConnected() const override;
  42. virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
  43. virtual std::string DriverProbe() override;
  44. virtual std::string GetResource() override;
  45. virtual std::string DeviceProbe() override;
  46. virtual bool GetDeviceConfig(std::string& Cfg) override;
  47. virtual bool SetDeviceConfig(std::string Cfg) override;
  48. bool SaveConfigFile(bool bSendNotify);
  49. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  50. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  51. };
  52. //-----------------------------------------------------------------------------
  53. // FPDDeviceIRay
  54. //-----------------------------------------------------------------------------
  55. class IRayCtrl;
  56. class CCOSDEVFPDIRAY_API FPDDeviceIRay : public FPDDeviceMould
  57. {
  58. using super = IODeviceDetail;
  59. ResDataObject* m_pPreviewImageHead;
  60. ResDataObject* m_pFullImageHead;
  61. //void* m_pDetectors;
  62. IRayCtrl* m_pDetectors;
  63. private:
  64. std::unique_ptr <AcqUnit> m_AcqUnit;
  65. std::unique_ptr <SyncUnit> m_SyncUnit;
  66. std::unique_ptr <CalibUnit> m_CalibUnit;
  67. std::unique_ptr <DetectorCtrlUnit> m_DetectorCtrlUnit;
  68. std::unique_ptr <DeviceTemperatureMould> m_Temperature;
  69. std::unique_ptr <DeviceBatteryMould> m_Battery;
  70. std::unique_ptr <DeviceWifiMould> m_Wifi;
  71. std::unique_ptr <DetectorConfiguration> m_DetectorConfiguration;
  72. std::unique_ptr <FPDErrorWarning> m_WarnAndError;
  73. std::unique_ptr <CalibrationProcess> m_CalibProcess;
  74. int m_nDeviceIndex; //当前探测器的ID
  75. std::string g_strAppPath;
  76. std::string m_strSDKPath;
  77. APP_STATUS m_eAppStatus; //DROC的当前状态,检查/校正/ATTACH界面
  78. WORD* m_pwFullImageData; //裁剪后的有效图像内存
  79. WORD* m_pwRawImageData; //原始图像内存
  80. WORD* m_pwPreviewImg; //preview内存
  81. SYSTEMTIME m_stImgCreateTime;
  82. unsigned int m_nWorkStation;
  83. int m_nGridLicense;
  84. bool m_bForceGridSuppress;
  85. string m_strModuleIP;
  86. string m_strModuleSN; //从红外获取的探测器SN号
  87. string m_strShockSensor;
  88. string m_strBatterySN;
  89. string m_strMotionStatus;// 探测器方位信息
  90. string m_strSelfTest;// 探测器自检信息
  91. string m_strLastError; //DLL反馈的错误内容
  92. string m_strCalibTime;
  93. bool m_bDisConnected;
  94. bool m_bAttached;
  95. bool m_bOpened; //初始化开始与否
  96. bool m_bBatteryCharging; //电池充电与否的状态
  97. bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程
  98. bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用
  99. int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次
  100. bool m_bSendRecoverMessage;
  101. bool m_bUIConfirmRecover;
  102. bool m_bRecoverImageStatusInit;
  103. ResDataObject m_RecoverImageStatus;
  104. bool m_bImagePendingOrNot; //是否有未获取成功的图像
  105. bool m_bResetDetector; //是否reset探测器,暂时不用
  106. int m_nBatteryCapacity;
  107. int m_nBatteryCharges;
  108. float m_fBatteryTemperature;
  109. int m_nShockCounts;
  110. CCOS_CALIBRATION_TYPE m_nCalibrationType;
  111. int m_nDoseParam;// 校正用的曝光计量,发送到UI 且本地记录
  112. int m_nRawImgWidth; //原始图像宽
  113. int m_nRawImgHeight; //原始图像高
  114. int m_nFullImgWidth; //有效图像的宽
  115. int m_nFullImgHeight; //有效图像的高
  116. int m_nTopOffset; //图像上边裁剪像素值
  117. int m_nBottomOffset; //图像下边裁剪像素值
  118. int m_nLeftOffset; //图像左侧裁剪像素值
  119. int m_nRightOffset; //图像右侧裁剪像素值
  120. int m_nImageBits; //图像位数
  121. float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数
  122. bool m_bPreviewEnable; //是否显示preview image
  123. bool m_bTestSensitivity;
  124. bool m_bSaveRaw;
  125. bool m_bNotifyCalWarn; //是否通知校正警告
  126. HANDLE m_ExitEvt;
  127. int m_nXrayCalibNum;
  128. HANDLE m_OffsetCalibrationEvt;
  129. HANDLE m_PauseCalibrationEvt;
  130. HANDLE m_CompleteCalibrationEvt;
  131. HANDLE m_CrateCalibReportEvt;
  132. HANDLE m_WaitCalibDoseEvt;
  133. HANDLE m_WriteCumstomFileEvt;
  134. HANDLE m_hNotifyThread;
  135. DWORD m_NotifyThreadID;
  136. static DWORD WINAPI OnNotify(LPVOID pParam);
  137. HANDLE m_UploadCalibMapOver;
  138. HANDLE m_CalibGapEvt;
  139. float m_CalTemperlowWarn;
  140. float m_CalTemperupWarn;
  141. bool m_CalTemperWarnInitialed;
  142. ResDataObject m_CalibDoseList; //加载平板自己的校正剂量配置
  143. int m_nCalibTotalExposureNum; //校正曝光总次数
  144. int m_nCalibCurrentCalibrationRound; //校正曝光第几轮
  145. int m_nCalibCurrentExposureIndex; //校正曝光第几次
  146. int m_nCalibCurrentExposureNum; //已校正曝光总次数
  147. bool LoadConfig();
  148. void SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight);
  149. void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  150. void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  151. void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  152. void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  153. void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  154. void OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  155. bool OnInitResult(bool bSuccess);
  156. bool LoadSensitivity();
  157. bool CallSiemensRecoverAction(bool bErrorResult);
  158. bool OnProcessImage(WORD* pImage, int nWidth, int nHeight, float fImageReferUGY = 2.5);
  159. bool OnProcessPreviewImage(WORD* pRawImage, int nWidth, int nHeight);
  160. int NewGridSuppressed(int nHeight, int nWidth, int nImageBits, unsigned short* puImageData);
  161. void OnProcessTemperature(int nID, float fTemperature);
  162. void InitializeTemperatureConfigs();
  163. void Action_ExpReady();
  164. bool CompleteCalibration();
  165. bool SaveConfigFile(bool bSendNotify);
  166. string GetFileVersion(string strFilePathName);
  167. void SendTemperatureValue(float fTemp);
  168. void SendWifiValue(int nWifi);
  169. void SendBatteryValue(int nBattery);
  170. RET_STATUS XWindowOnNotify();
  171. RET_STATUS XWindowOffNotify();
  172. void PrevImageDateArrived(WORD* pImg);
  173. void FullImageDateArrived(WORD* pImg);
  174. RET_STATUS PauseCalibration();
  175. bool CheckCalibartionDue();
  176. void AbortCalibration();
  177. void StopCalibrationInside();
  178. //向HW(转到发生器模块)发送当前探测器的状态
  179. void OnError(string strErrCode, string strErr = "");
  180. void OnErrorX(string strErrCode);
  181. //响应警告事件 nIndex:探测器ID strWarnCode:警告事件ID,strWarn:警告内容
  182. void OnWarn(int nIndex, string strWarnCode, string strWarn = "");
  183. void OnWarnX(string strWarnCode);
  184. void SendAllError();
  185. void ProcessTempreatureOnLostCommunicate();
  186. void ResetAllError();
  187. RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize);
  188. string MakeImageHead(IMAGE_VIEW_TYPE Type);
  189. public:
  190. DeviceIndexStruct m_stDeviceConfig;
  191. public:
  192. FPDDeviceIRay(std::shared_ptr <IOEventCenter> center, string ConfigPath);
  193. ~FPDDeviceIRay();
  194. void Register();
  195. virtual std::string GetGUID() const override;
  196. virtual bool Prepare() override;
  197. bool CreateDevice();
  198. RET_STATUS Connect();
  199. RET_STATUS ActiveDetector(bool bActive);
  200. RET_STATUS SetAcqMode(int mode);
  201. RET_STATUS SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode);
  202. RET_STATUS SetXwindow(float XwindowSize);
  203. RET_STATUS PrepareAcquisition();
  204. RET_STATUS StartAcquisition(string in = "");
  205. RET_STATUS StopAcquisition();
  206. RET_STATUS ActiveSyncMode(int nSyncMode);
  207. RET_STATUS SetSID(int nSID);
  208. RET_STATUS SetCorrectionType(CCOS_CORRECTION_TYPE in);
  209. RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE in);
  210. RET_STATUS PrepareCalibration();
  211. RET_STATUS GetRequestedDose(string& strDose);
  212. RET_STATUS SetRequestedDose(std::string strDose);
  213. RET_STATUS StartCalibration();
  214. RET_STATUS StopCalibration();
  215. RET_STATUS GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo);
  216. RET_STATUS AcceptCalibration();
  217. RET_STATUS RejectCalibration();
  218. RET_STATUS SaveCalibrationFile(bool bSaveFlag);
  219. RET_STATUS EnterExam(int nExamStatus);
  220. RET_STATUS ResetConnect();
  221. RET_STATUS DisConnectFPD();
  222. RET_STATUS UpdateFirmware();
  223. RET_STATUS AttachConnect();
  224. RET_STATUS CancelAttach();
  225. RET_STATUS SetAttachStatus(int nStatus);
  226. RET_STATUS SaveSensitivity();
  227. RET_STATUS RecoverImage(bool bRecoverIt);
  228. RET_STATUS GetRecoverImageState(string& strREI);
  229. RET_STATUS GetDetectorInfo(string& strFDI);
  230. RET_STATUS UploadCalibrationFiles(string strFileName);
  231. RET_STATUS ResetError();
  232. RET_STATUS UpdateNotifyStatusTimePeriod(int nTime);
  233. void SyncErrorList();
  234. void ClearAllError();
  235. void UnactiveBySDK(void* pActviedDPC);
  236. void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  237. void SaveFailedCalibFile();
  238. bool GetCalibrationTime(bool ExpMode);
  239. protected:
  240. void RegisterCtrl(CCOS::Dev::Detail::Dispatch* Dispatch);
  241. void RegisterAcq(CCOS::Dev::Detail::Dispatch* Dispatch);
  242. void RegisterSync(CCOS::Dev::Detail::Dispatch* Dispatch);
  243. void RegisterCalib(CCOS::Dev::Detail::Dispatch* Dispatch);
  244. void RegisterOthers(CCOS::Dev::Detail::Dispatch* Dispatch);
  245. };
  246. }