DIOS.Dev.FPD.Yuying.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. //void* m_pDetectors;
  62. YuyingCtrl* 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. DeviceIndexStruct m_stDeviceConfig;
  78. APP_STATUS m_eAppStatus; //DROC的当前状态,检查/校正/ATTACH界面
  79. WORD* m_pwFullImageData; //裁剪后的有效图像内存
  80. WORD* m_pwRawImageData; //原始图像内存
  81. WORD* m_pwPreviewImg; //preview内存
  82. SYSTEMTIME m_stImgCreateTime;
  83. unsigned int m_nWorkStation;
  84. int m_nGridLicense;
  85. bool m_bForceGridSuppress;
  86. string m_strModuleIP;
  87. string m_strModuleSN; //从红外获取的探测器SN号
  88. string m_strShockSensor;
  89. string m_strBatterySN;
  90. string m_strMotionStatus;// 探测器方位信息
  91. string m_strSelfTest;// 探测器自检信息
  92. string m_strLastError; //DLL反馈的错误内容
  93. string m_strCalibTime;
  94. bool m_bDisConnected;
  95. bool m_bAttached;
  96. bool m_bOpened; //初始化开始与否
  97. bool m_bBatteryCharging; //电池充电与否的状态
  98. bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程
  99. bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用
  100. int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次
  101. bool m_bSendRecoverMessage;
  102. bool m_bUIConfirmRecover;
  103. bool m_bRecoverImageStatusInit;
  104. ResDataObject m_RecoverImageStatus;
  105. bool m_bUIReady;
  106. bool m_bImagePendingOrNot; //是否有未获取成功的图像
  107. bool m_bResetDetector; //是否reset探测器,暂时不用
  108. int m_nBatteryCapacity;
  109. int m_nBatteryCharges;
  110. float m_fBatteryTemperature;
  111. int m_nShockCounts;
  112. CCOS_CALIBRATION_TYPE m_nCalibrationType;
  113. int m_fDoseParam;// 校正用的曝光计量,发送到UI 且本地记录
  114. int m_nRawImgWidth; //原始图像宽
  115. int m_nRawImgHeight; //原始图像高
  116. int m_nFullImgWidth; //有效图像的宽
  117. int m_nFullImgHeight; //有效图像的高
  118. int m_nTopOffset; //图像上边裁剪像素值
  119. int m_nBottomOffset; //图像下边裁剪像素值
  120. int m_nLeftOffset; //图像左侧裁剪像素值
  121. int m_nRightOffset; //图像右侧裁剪像素值
  122. int m_nImageBits; //图像位数
  123. float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数
  124. bool m_bPreviewEnable; //是否显示preview image
  125. bool m_bTestSensitivity;
  126. bool m_bSaveRaw;
  127. HANDLE m_ExitEvt;
  128. int m_nXrayCalibNum;
  129. HANDLE m_OffsetCalibrationEvt;
  130. HANDLE m_PauseCalibrationEvt;
  131. HANDLE m_CompleteCalibrationEvt;
  132. HANDLE m_CrateCalibReportEvt;
  133. HANDLE m_WaitCalibDoseEvt;
  134. HANDLE m_WriteCumstomFileEvt;
  135. HANDLE m_hNotifyThread;
  136. DWORD m_NotifyThreadID;
  137. static DWORD WINAPI OnNotify(LPVOID pParam);
  138. HANDLE m_UploadCalibMapOver;
  139. HANDLE m_CalibGapEvt;
  140. int m_nGenWaitGap;
  141. int m_nConfXrayOnGap;
  142. float m_CalTemperlowWarn;
  143. float m_CalTemperupWarn;
  144. bool m_CalTemperWarnInitialed;
  145. ResDataObject m_CalibDoseList;
  146. bool LoadConfig();
  147. void SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight);
  148. void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  149. void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  150. void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  151. void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  152. void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  153. void OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  154. bool OnInitResult(bool bSuccess);
  155. bool LoadSensitivity();
  156. bool CallSiemensRecoverAction(bool bErrorResult);
  157. bool OnProcessImage(WORD* pImage, int nWidth, int nHeight, float fImageReferUGY = 2.5);
  158. bool OnProcessPreviewImage(WORD* pRawImage, int nWidth, int nHeight);
  159. void OnProcessTemperature(int nID, float fTemperature);
  160. void InitializeTemperatureConfigs();
  161. void Action_ExpReady();
  162. bool CompleteCalibration();
  163. bool SaveConfigFile(bool bSendNotify);
  164. string GetFileVersion(string strFilePathName);
  165. void SendTemperatureValue(float fTemp);
  166. void SendWifiValue(int nWifi);
  167. void SendBatteryValue(int nBattery);
  168. RET_STATUS XWindowOnNotify();
  169. RET_STATUS XWindowOffNotify();
  170. void PrevImageDateArrived(WORD* pImg);
  171. void FullImageDateArrived(WORD* pImg);
  172. RET_STATUS PauseCalibration();
  173. bool CheckCalibartionDue();
  174. void AbortCalibration();
  175. void StopCalibrationInside();
  176. //向HW(转到发生器模块)发送当前探测器的状态
  177. void OnError(string strErrCode, string strErr = "");
  178. void OnErrorX(string strErrCode);
  179. //响应警告事件 nIndex:探测器ID strWarnCode:警告事件ID,strWarn:警告内容
  180. void OnWarn(int nIndex, string strWarnCode, string strWarn = "");
  181. void OnWarnX(string strWarnCode);
  182. void SendAllError();
  183. void ProcessTempreatureOnLostCommunicate();
  184. void ResetAllError();
  185. RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize);
  186. string MakeImageHead(IMAGE_VIEW_TYPE Type);
  187. public:
  188. FPDDeviceYuying(std::shared_ptr <IOEventCenter> center, string ConfigPath);
  189. ~FPDDeviceYuying();
  190. bool m_bOffsetCalibRunning;
  191. public:
  192. void Register();
  193. virtual std::string GetGUID() const override;
  194. virtual bool Prepare() override;
  195. protected:
  196. void RegisterCtrl(CCOS::Dev::Detail::Dispatch* Dispatch);
  197. void RegisterAcq(CCOS::Dev::Detail::Dispatch* Dispatch);
  198. void RegisterSync(CCOS::Dev::Detail::Dispatch* Dispatch);
  199. void RegisterCalib(CCOS::Dev::Detail::Dispatch* Dispatch);
  200. void RegisterOthers(CCOS::Dev::Detail::Dispatch* Dispatch);
  201. public:
  202. bool CreateDevice();
  203. RET_STATUS Connect();
  204. RET_STATUS ActiveDetector(bool bActive);
  205. RET_STATUS SetAcqMode(int mode);
  206. RET_STATUS SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode);
  207. RET_STATUS SetXwindow(float XwindowSize);
  208. RET_STATUS PrepareAcquisition();
  209. RET_STATUS StartAcquisition(string in = "");
  210. RET_STATUS StopAcquisition();
  211. RET_STATUS ActiveSyncMode(int nSyncMode);
  212. RET_STATUS SetSID(int nSID);
  213. RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE in);
  214. RET_STATUS PrepareCalibration();
  215. RET_STATUS GetRequestedDose(string& strDose);
  216. RET_STATUS StartCalibration();
  217. RET_STATUS StopCalibration();
  218. RET_STATUS SetCorrectionType(CCOS_CORRECTION_TYPE in);
  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. void SyncErrorList();
  233. void ClearAllError();
  234. void UnactiveBySDK(void* pActviedDPC);
  235. void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  236. void SaveFailedCalibFile();
  237. bool GetCalibrationTime(bool ExpMode);
  238. };
  239. }