DIOS.Dev.FPD.Yuying.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 "DetectorDefinition.h"
  15. #ifdef CCOSDEVFPDYUYING_EXPORTS
  16. #define __CCOSDEVFPDYUYING_EXPORTS__ __declspec(dllexport)
  17. #else
  18. #define __CCOSDEVFPDYUYING_EXPORTS__ __declspec(dllimport)
  19. #endif
  20. namespace CCOS::Dev::Detail::Detector
  21. {
  22. //-----------------------------------------------------------------------------
  23. // YuyingDriver
  24. //-----------------------------------------------------------------------------
  25. class __CCOSDEVFPDYUYING_EXPORTS__ YuyingDriver : public FPDDriverMould
  26. {
  27. using super = FPDDriverMould;
  28. FPDDeviceYuying* 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. YuyingDriver();
  37. virtual ~YuyingDriver();
  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. // FPDDeviceYuying
  54. //-----------------------------------------------------------------------------
  55. class YuyingCtrl;
  56. class __CCOSDEVFPDYUYING_EXPORTS__ FPDDeviceYuying : public FPDDeviceMould
  57. {
  58. using super = IODeviceDetail;
  59. ResDataObject* m_pPreviewImageHead;
  60. ResDataObject* m_pFullImageHead;
  61. private:
  62. std::unique_ptr <AcqUnit> m_AcqUnit;
  63. std::unique_ptr <SyncUnit> m_SyncUnit;
  64. std::unique_ptr <CalibUnit> m_CalibUnit;
  65. std::unique_ptr <DetectorCtrlUnit> m_DetectorCtrlUnit;
  66. std::unique_ptr <DeviceTemperatureMould> m_Temperature;
  67. std::unique_ptr <DeviceBatteryMould> m_Battery;
  68. std::unique_ptr <DeviceWifiMould> m_Wifi;
  69. std::unique_ptr <DetectorConfiguration> m_DetectorConfiguration;
  70. std::unique_ptr <FPDErrorWarning> m_WarnAndError;
  71. std::unique_ptr <CalibrationProcess> m_CalibProcess;
  72. int m_nDeviceIndex; //当前探测器的ID
  73. DeviceIndexStruct m_stDeviceConfig;
  74. APP_STATUS m_eAppStatus; //DROC的当前状态,检查/校正/ATTACH界面
  75. WORD* m_pwFullImageData; //裁剪后的有效图像内存
  76. WORD* m_pwRawImageData; //原始图像内存
  77. WORD* m_pwPreviewImg; //preview内存
  78. SYSTEMTIME m_stImgCreateTime;
  79. unsigned int m_nWorkStation;
  80. int m_nGridLicense;
  81. string m_strModuleIP;
  82. string m_strModuleSN; //从红外获取的探测器SN号
  83. string m_strShockSensor;
  84. string m_strBatterySN;
  85. string m_strMotionStatus;// 探测器方位信息
  86. string m_strSelfTest;// 探测器自检信息
  87. string m_strLastError; //DLL反馈的错误内容
  88. string m_strCalibTime;
  89. string m_strWorkPath;
  90. bool m_bDisConnected;
  91. bool m_bAttached;
  92. bool m_bOpened; //初始化开始与否
  93. bool m_bBatteryCharging; //电池充电与否的状态
  94. bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程
  95. bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用
  96. int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次
  97. bool m_bSendRecoverMessage;
  98. bool m_bUIConfirmRecover;
  99. bool m_bRecoverImageStatusInit;
  100. ResDataObject m_RecoverImageStatus;
  101. bool m_bUIReady;
  102. bool m_bImagePendingOrNot; //是否有未获取成功的图像
  103. bool m_bResetDetector; //是否reset探测器,暂时不用
  104. bool m_bOnlyHaveFpd;//当前系统是否只配置了一个真实的探测器并且处于AED同步模式,其他设备没有或者是demo的 1-是 0-否 默认否
  105. int m_nBatteryCapacity;
  106. int m_nBatteryCharges;
  107. float m_fBatteryTemperature;
  108. int m_nShockCounts;
  109. int m_nCalibTotalExposureNum; //校正曝光总次数
  110. CCOS_CALIBRATION_TYPE m_nCalibrationType;
  111. int m_fDoseParam;// 校正用的曝光计量,发送到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. HANDLE m_ExitEvt;
  126. int m_nXrayCalibNum;
  127. HANDLE m_OffsetCalibrationEvt;
  128. HANDLE m_PauseCalibrationEvt;
  129. HANDLE m_CompleteCalibrationEvt;
  130. HANDLE m_CrateCalibReportEvt;
  131. HANDLE m_WaitCalibDoseEvt;
  132. HANDLE m_WriteCumstomFileEvt;
  133. HANDLE m_hNotifyThread;
  134. DWORD m_NotifyThreadID;
  135. static DWORD WINAPI OnNotify(LPVOID pParam);
  136. HANDLE m_UploadCalibMapOver;
  137. HANDLE m_CalibGapEvt;
  138. int m_nGenWaitGap;
  139. int m_nConfXrayOnGap;
  140. float m_CalTemperlowWarn;
  141. float m_CalTemperupWarn;
  142. bool m_CalTemperWarnInitialed;
  143. ResDataObject m_CalibDoseList;
  144. bool LoadConfig();
  145. void SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight);
  146. void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  147. void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  148. void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  149. void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  150. void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  151. bool OnInitResult(bool bSuccess);
  152. bool LoadSensitivity();
  153. bool CallSiemensRecoverAction(bool bErrorResult);
  154. bool OnProcessImage(WORD* pImage, int nWidth, int nHeight, float fImageReferUGY = 2.5);
  155. bool OnProcessPreviewImage(WORD* pRawImage, int nWidth, int nHeight);
  156. bool GetEffectiveImage(WORD* pwInImgData, int nRawImageWidth);
  157. void OnProcessTemperature(int nID, float fTemperature);
  158. void Action_ExpReady();
  159. bool CompleteCalibration();
  160. bool SaveConfigFile(bool bSendNotify);
  161. string GetFileVersion(string strFilePathName);
  162. void SendTemperatureValue(float fTemp);
  163. void SendWifiValue(int nWifi);
  164. void SendBatteryValue(int nBattery);
  165. void PrevImageDateArrived(WORD* pImg);
  166. void FullImageDateArrived(WORD* pImg);
  167. RET_STATUS PauseCalibration();
  168. bool CheckCalibartionDue();
  169. void AbortCalibration();
  170. void StopCalibrationInside();
  171. //向HW(转到发生器模块)发送当前探测器的状态
  172. void OnError(string strErrCode, string strErr = "");
  173. void OnErrorX(string strErrCode);
  174. //响应警告事件 nIndex:探测器ID strWarnCode:警告事件ID,strWarn:警告内容
  175. void OnWarn(int nIndex, string strWarnCode, string strWarn = "");
  176. void OnWarnX(string strWarnCode);
  177. void SendAllError();
  178. void ProcessTempreatureOnLostCommunicate();
  179. void ResetAllError();
  180. RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize);
  181. string MakeImageHead(IMAGE_VIEW_TYPE Type);
  182. public:
  183. FPDDeviceYuying(std::shared_ptr <IOEventCenter> center, string ConfigPath);
  184. ~FPDDeviceYuying();
  185. bool m_bOffsetCalibRunning;
  186. public:
  187. void Register();
  188. virtual std::string GetGUID() const override;
  189. virtual bool Prepare() override;
  190. protected:
  191. void RegisterCtrl(CCOS::Dev::Detail::Dispatch* Dispatch);
  192. void RegisterAcq(CCOS::Dev::Detail::Dispatch* Dispatch);
  193. void RegisterSync(CCOS::Dev::Detail::Dispatch* Dispatch);
  194. void RegisterCalib(CCOS::Dev::Detail::Dispatch* Dispatch);
  195. void RegisterOthers(CCOS::Dev::Detail::Dispatch* Dispatch);
  196. public:
  197. bool CreateDevice();
  198. RET_STATUS Connect();
  199. RET_STATUS ActiveDetector(bool bActive);
  200. RET_STATUS SetAcqMode(string 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 ActiveCalibration(CCOS_CALIBRATION_TYPE in);
  209. RET_STATUS PrepareCalibration();
  210. RET_STATUS GetRequestedDose(string& strDose);
  211. RET_STATUS StartCalibration();
  212. RET_STATUS StopCalibration();
  213. RET_STATUS SetCorrectionType(CCOS_CORRECTION_TYPE in);
  214. RET_STATUS EnterExam(int nExamStatus);
  215. RET_STATUS ResetConnect();
  216. RET_STATUS DisConnectFPD();
  217. RET_STATUS AttachConnect();
  218. RET_STATUS CancelAttach();
  219. RET_STATUS SetAttachStatus(int nStatus);
  220. RET_STATUS SaveSensitivity();
  221. RET_STATUS RecoverImage(bool bRecoverIt);
  222. RET_STATUS GetRecoverImageState(string& strREI);
  223. RET_STATUS ResetError();
  224. void SyncErrorList();
  225. void ClearAllError();
  226. void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  227. };
  228. }