DIOS.Dev.FPD.TrixellDR.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #pragma once
  2. #include "CCOS.Dev.FPDDeviceMould.hpp"
  3. #include "OemAcq.h"
  4. #include "OemSync.h"
  5. #include "OemCtrl.h"
  6. #include "OemCalib.h"
  7. #include "DetectorConfiguration.h"
  8. #include "FPDErrorWarningProcess.h"
  9. #pragma warning(disable:26812) //枚举类型“ENUM_PANEL_EVENT_STATE”未设定范围。相比于 "enum",首选 "enum class" (Enum.3)
  10. #pragma warning(disable:26451) //算术溢出 : 使用 4 字节值上的运算符 * ,然后将结果转换到 8 字节值。在调用运算符 * 之前将值强制转换为宽类型可避免溢出(io.2)。
  11. #ifdef CCOSDEVFPDTRIXELLDR_EXPORTS
  12. #define CCOSDEVFPDTRIXELLDR_API __declspec(dllexport)
  13. #else
  14. #define CCOSDEVFPDTRIXELLDR_API __declspec(dllimport)
  15. #endif
  16. class TrixellCtrl;
  17. namespace CCOS::Dev::Detail::Detector
  18. {
  19. class CCOSDEVFPDTRIXELLDR_API TrixellDriver : public FPDDriverMould
  20. {
  21. FPDDeviceTrixell* pObjDev;
  22. bool m_bConnect; //driver是否连接的标记位
  23. ResDataObject m_DeviceConfig;
  24. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  25. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  26. std::unique_ptr <ResDataObject> m_pAttribute;
  27. std::unique_ptr <ResDataObject> m_pDescription;
  28. public:
  29. TrixellDriver();
  30. virtual ~TrixellDriver();
  31. virtual void Prepare() override;
  32. virtual bool Connect() override;
  33. virtual void Disconnect() override;
  34. virtual bool isConnected() const override;
  35. virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
  36. virtual std::string DriverProbe() override;
  37. virtual std::string GetResource() override;
  38. virtual std::string DeviceProbe() override;
  39. virtual bool GetDeviceConfig(std::string& Cfg) override;
  40. virtual bool SetDeviceConfig(std::string Cfg) override;
  41. bool SaveConfigFile(bool bSendNotify);
  42. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  43. bool SetDeviceConfigValue(ResDataObject & config, const char* pInnerKey, int nPathID, const char* szValue);
  44. };
  45. namespace nsDetail = CCOS::Dev::Detail;
  46. class CCOSDEVFPDTRIXELLDR_API FPDDeviceTrixell : public FPDDeviceMould
  47. {
  48. using super = IODeviceDetail; //IODeviceDetail类的别名声明
  49. ResDataObject* m_pPreviewImageHead;
  50. ResDataObject* m_pFullImageHead;
  51. std::unique_ptr <DetectorCtrlUnit> m_DetectorCtrlUnit;
  52. std::unique_ptr <AcqUnit> m_AcqUnit;
  53. std::unique_ptr <SyncUnit> m_SyncUnit;
  54. std::unique_ptr <CalibUnit> m_CalibUnit;
  55. std::unique_ptr <DeviceTemperatureMould> m_Temperature;
  56. std::unique_ptr <DeviceBatteryMould> m_Battery;
  57. std::unique_ptr <DeviceWifiMould> m_Wifi;
  58. std::unique_ptr <DetectorConfiguration> m_DetectorConfiguration;
  59. std::unique_ptr <FPDErrorWarning> m_WarnAndError;
  60. //std::unique_ptr <CalibrationProcess> m_CalibProcess;
  61. int m_nDeviceIndex; //当前探测器的ID
  62. std::string m_strWorkPath;
  63. bool m_bExited;
  64. TrixellCtrl* m_pDetectors;
  65. APP_STATUS m_eAppStatus;
  66. WORD* m_pwFullImageData; //裁剪后的有效图像内存
  67. WORD* m_pwRawImageData; //原始图像内存
  68. WORD* m_pwPreviewImg; //preview内存
  69. SYSTEMTIME m_stImgCreateTime;
  70. bool m_bForceGridSuppress;
  71. string m_strLastError; //DLL反馈的错误内容
  72. bool m_bAttached;
  73. //bool m_bOpened; //初始化开始与否;初始化未开始,屏蔽DLL反馈的各种状态信息;
  74. bool m_bBatteryCharging; //电池充电与否的状态
  75. //bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程
  76. //bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用
  77. //int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次
  78. bool m_bImagePendingOrNot; //是否有未获取成功的图像
  79. bool m_bResetDetector; //是否reset探测器,暂时不用
  80. bool m_bNotifyCalWarn; //是否通知校正警告
  81. int m_nBatteryCapacity;
  82. int m_nBatteryCharges;
  83. int m_nShockCounts;
  84. float m_fDoseParam;// 校正用的曝光计量,发送到UI 且本地记录
  85. ////int m_nImageHeight;
  86. ////int m_nImageWidth;
  87. ////int m_nImgBits;
  88. ////int m_nPixelSpacing;
  89. ////int m_nSensitivity;
  90. ////float m_fDose;
  91. ////bool m_bConnect;
  92. int m_nFullImgWidth; //有效图像的宽
  93. int m_nFullImgHeight; //有效图像的高
  94. int m_nTopOffset; //图像上边裁剪像素值
  95. int m_nLeftOffset; //图像左侧裁剪像素值
  96. int m_nImageBits; //图像位数
  97. float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数
  98. bool m_bPreviewEnable; //是否显示preview image
  99. int m_nXrayCalibNum;
  100. HANDLE m_PauseCalibrationEvt;
  101. HANDLE m_ExitEvt;
  102. HANDLE m_ConnectEvt;
  103. HANDLE m_hNotifyThread;
  104. DWORD m_NotifyThreadID;
  105. HANDLE m_WaitCalibDoseEvt;
  106. static DWORD WINAPI OnNotify(LPVOID pParam);
  107. HANDLE m_UploadCalibMapOver;
  108. ResDataObject m_CalibDoseList; //加载平板自己的校正剂量配置
  109. int m_nCalibTotalExposureNum; //校正曝光总次数
  110. int m_nCalibCurrentCalibrationRound; //校正曝光第几轮
  111. int m_nCalibCurrentExposureIndex; //校正曝光第几次
  112. int m_nCalibCurrentExposureNum; //已校正曝光总次数
  113. public:
  114. DeviceIndexStruct m_stDeviceConfig;
  115. public:
  116. FPDDeviceTrixell(std::shared_ptr<IOEventCenter> center, std::string strConfigPath);
  117. ~FPDDeviceTrixell();
  118. virtual std::string GetGUID() const override;
  119. virtual bool Prepare() override;
  120. bool CreateDevice();
  121. void Register();
  122. RET_STATUS Connect();
  123. RET_STATUS GetDeviceDictionary(std::string& out);
  124. RET_STATUS ActiveDetector(bool bActive);
  125. RET_STATUS WakeupDetector();
  126. RET_STATUS EnterExam(int nExamMode);
  127. RET_STATUS ResetConnect();
  128. RET_STATUS SetAcqMode(string strAcqMode);
  129. RET_STATUS SetAcqMode(int nMode);
  130. //RET_STATUS SetSyncMode(SYNC_MODE eSyncMode, HARDWARE_TRIGGER_MODE eTriggerMode);
  131. //RET_STATUS SetXwindow(float fXwindowSize);
  132. RET_STATUS PrepareAcquisition();
  133. RET_STATUS StartAcquisition(string in = "");
  134. RET_STATUS StopAcquisition();
  135. RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE eType);
  136. RET_STATUS PrepareCalibration();
  137. RET_STATUS GetRequestedDose(std::string& strDose);
  138. RET_STATUS SetRequestedDose(std::string strDose);
  139. RET_STATUS StartCalibration();
  140. RET_STATUS StopCalibration();
  141. RET_STATUS GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo);
  142. RET_STATUS AcceptCalibration();
  143. RET_STATUS RejectCalibration();
  144. RET_STATUS SaveCalibrationFile(bool bSaveFlag);
  145. RET_STATUS DisConnectFPD();
  146. RET_STATUS DisConnectFPDForce();
  147. RET_STATUS SetSaveRawDataMode(int nSaveRawDataMode);
  148. RET_STATUS OfflineFPD(int nOfflineFPDMode);
  149. RET_STATUS OnlineFPD(int nOnlineFPDMode);
  150. RET_STATUS GetAutonumousImageList(int nDetectorID, vector<string>& AutonumousList);
  151. RET_STATUS RemoveAutonumousImageList(string strMeta);
  152. RET_STATUS RemoveAutonumousAll();
  153. RET_STATUS GetImageMetaData(string strMetaData);
  154. RET_STATUS ExportAutonumousAll();
  155. RET_STATUS GetDetectorInfo(string& strFDI);
  156. RET_STATUS ActiveSyncMode(int nSyncMode);
  157. void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  158. bool GetLogicMode(string& strAcqMode, int& nLogicMode);
  159. private:
  160. bool LoadConfig();
  161. bool OnInitResult(bool bSuccess);
  162. string GetFileVersion(string strFilePathName);
  163. void SendTemperatureValue();
  164. void SendWifiValue();
  165. void SendBatteryValue();
  166. void OnProcessTemperature(int nID, float fTemperature);
  167. void Action_ExpReady();
  168. RET_STATUS XWindowOnNotify();
  169. RET_STATUS XWindowOffNotify();
  170. bool OnProcessImage(WORD* pImage, int nWidth, int nHeight, float fImageReferUGY = 2.5);
  171. bool OnProcessPreviewImage(WORD* pRawImage, int nWidth, int nHeight);
  172. bool GetEffectiveImage(WORD* pwInImgData, int nRawImageWidth);
  173. void PrevImageDateArrived(WORD* pImg);
  174. void FullImageDateArrived(WORD* pImg);
  175. RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize);
  176. string MakeImageHead(IMAGE_VIEW_TYPE Type);
  177. RET_STATUS PauseCalibration();
  178. bool CompleteCalibration();
  179. void AbortCalibration();
  180. void CheckCalibrationDue();
  181. void OnError(int nIndex, string strErrCode, string strErr = "");
  182. void ClearError(int nDetectorID, std::string strErrorCode, std::string strErr = "");
  183. void OnWarn(int nIndex, string strWarnCode, string strWarn = "");
  184. void ClearWarn(int nDetectorID, std::string strWarnCode, std::string strWarn = "");
  185. void SendAllError();
  186. RET_STATUS ResetError();
  187. void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  188. void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  189. void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  190. void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  191. void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  192. void OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam);
  193. protected:
  194. void RegisterCtrl(nsDetail::Dispatch* Dispatch);
  195. void RegisterAcq(nsDetail::Dispatch* Dispatch);
  196. void RegisterSync(nsDetail::Dispatch* Dispatch);
  197. void RegisterCalib(nsDetail::Dispatch* Dispatch);
  198. void RegisterOthers(nsDetail::Dispatch* Dispatch);
  199. void RegisterAutonumous(nsDetail::Dispatch* Dispatch);
  200. };
  201. } //end namespace CCOS::Dev::Detail::Detector