DIOS.Dev.FPD.iRay.h 10 KB

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