SensviewCtrl.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. #pragma once
  2. #include <map>
  3. //转存文件内容使用
  4. #include <shellapi.h>
  5. #include "ResDataObject.h"
  6. #include "DetectorDefinition.h"
  7. #include "CCOS.Dev.FPD.Sensview.h"
  8. //SDK头文件
  9. #include "SDK/Include/nvDentalDet.h"
  10. //链接库
  11. #ifdef WIN64
  12. #pragma comment(lib, "SDK\\Lib\\win64\\nvDentalDet.lib")
  13. #else
  14. #pragma comment(lib, "SDK\\Lib\\win32\\nvDentalDet.lib")
  15. #endif
  16. #define SENSVIEW_SCAN_NUM 5
  17. namespace nsDPC = CCOS::Dev::Detail::Detector;
  18. namespace CCOS::Dev::Detail::Detector
  19. {
  20. class SensviewCtrl
  21. {
  22. public:
  23. SensviewCtrl();
  24. ~SensviewCtrl();
  25. static void ProcessEventCallback(void* lpCallbackData, NV_EVENTTYPE eventID, void* lpEventData);
  26. bool Init(string strAppPath);
  27. bool AddDPCs(nsDPC::FPDDeviceSensview* pDrvDPC, ResDataObject& Configuration, DeviceIndexStruct& DeviceStruct );
  28. bool DelDPCs(nsDPC::FPDDeviceSensview* pDrvDPC);
  29. bool ActivePanel(nsDPC::FPDDeviceSensview* pDrvDPC, bool bActive);
  30. bool SwithPanel(int nPanelId);
  31. bool EnterExam(APP_STATUS eStatus);
  32. bool Connect(string strAppPath, nsDPC::FPDDeviceSensview* pDrvDPC);
  33. bool DisConnect(nsDPC::FPDDeviceSensview* pDrvDPC);
  34. bool ResetFPD(nsDPC::FPDDeviceSensview* pDrvDPC);
  35. RET_STATUS SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode);
  36. bool SetAcqMode(nsDPC::FPDDeviceSensview* pDrvDPC, int nLogicMode, DetModeInfo& AcqModeInfo);
  37. RET_STATUS PrepareAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC);
  38. RET_STATUS StartAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC);
  39. RET_STATUS StopAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC);
  40. bool InitCalibration();
  41. RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE Type, nsDPC::FPDDeviceSensview* pDrvDPC);
  42. RET_STATUS PrepareCalibration(nsDPC::FPDDeviceSensview* pDrvDPC);
  43. RET_STATUS StartCalibration(nsDPC::FPDDeviceSensview* pDrvDPC);
  44. RET_STATUS CompleteCalibration(nsDPC::FPDDeviceSensview* pDrvDPC);
  45. RET_STATUS AbortCalibration(nsDPC::FPDDeviceSensview* pDrvDPC);
  46. bool ConfirmCalibration();
  47. bool AcceptCalibration();
  48. bool RejectCalibration();
  49. void OnEndCalibraion();
  50. bool RecoverLastImage();
  51. bool RecoverLastImageAuto();
  52. bool SaveFailedCalibFiles(int nDetectorID, bool bExpMode);
  53. bool CopyFile2Folder(string strSrcPath, string strDstPath);
  54. bool CancelImageRecover();
  55. bool SetFluPPS(float fFluPPS);
  56. bool GetFluPPS(float& fFluPPS);
  57. bool StartOffset(bool isAll);
  58. bool AbortOffset();
  59. public:
  60. bool m_bCalibResultFailed;
  61. string m_strWorkPath; //工作路径
  62. APP_STATUS m_eAppStatus; //记录当前软件的工作状态(界面)
  63. int m_nCurrentMode; //记录探测器当前application mode
  64. string m_strCurrentExamType;
  65. int m_nImageWidth;
  66. int m_nImageHeight;
  67. int m_nHeightOffset;
  68. int m_nBottomOffset;
  69. int m_nWidthOffset;
  70. int m_nRightOffset;
  71. int m_nRawImgWidth; //图像原始宽
  72. int m_nRawImgHeight; //图像原始高
  73. int m_nImgBits;
  74. int m_nPixelPitch;
  75. bool m_bPreviewEnable;
  76. float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数
  77. int m_nPreviewWidth;
  78. int m_nPreviewHeight;
  79. CCOS_CALIBRATION_TYPE m_eCaliType; // 记录当前校正模式
  80. float m_fCurrentDose; // 记录当前的Dose要求
  81. int m_nCaliFailedCount; //记录增益校正失败次数,超过一定次数自动停止校正
  82. bool m_bGainPreparing; //true: 正在进入增益校正状态
  83. bool m_bGainProcess; //true: 处于增益曝光的一次小循环当中(WindowOn ~ SDK返回当前曝光结果)
  84. bool m_bConfirmCaliRst; //true: 接受当前增益校正曝光结果
  85. bool m_bSaveRaw; //false:不存; true:存原图;
  86. bool m_bPreviewImg; //false:不要预览图; true:要预览图
  87. //int m_nGainNodeCount; //校正曝光的总节点个数
  88. //int m_nGainNodeIndex; //校正曝光的节点Index
  89. //int m_nGainExpCount; //校正曝光节点需要曝光的次数
  90. //int m_nGainExpIndex; //校正曝光节点已曝光的次数
  91. bool m_bIsImageRecovering; //是否处于图像恢复流程
  92. bool m_bGrabStatus; //采集状态
  93. int m_nFrameID; //动态图一次采集的ID
  94. int m_nExiThreshold; //EXI检测阈值
  95. private:
  96. bool LoadSDKDLL(string strWorkPath);
  97. void FreeSDKDLL();
  98. void StartInitFPDThread();
  99. static DWORD _stdcall onInitPanel(void* pParam); //初始化线程
  100. void Action_Init();
  101. bool DetectorInitProcess(int nPanelIndex, bool bFetchCalibration = false);
  102. bool RetryConnect(int nPanelIndex);
  103. bool OnInitStatus(int nPanelIndex, ENUM_PANEL_EVENT_STATE ePanelState);
  104. void ScanAddHandle();
  105. void ScanEventThread(); //监控线程
  106. static DWORD __stdcall onScanEvent(void* pParam); //初始化线程
  107. void ConfFeedback(int nEventID, int nDetectorID = -1, const char* pszMsg = "", int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL);
  108. void InfoFeedback(int nEventID, int nDetectorID = -1, int nParam1 = 0, float fParam2 = 0, const char* pszMsg = "", int nPtrParamLen = 0, void* pParam = NULL);
  109. void StatusFeedback(int nEventID, int nParam1 = 0, const char* pszMsg = "", int nDetectorID = -1, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL);
  110. void DataFeedback(int nEventID, void* pParam = NULL, int nParam1 = 0, float fParam2 = 0, const char* pszMsg = "", int nPtrParamLen = 0, int nDetectorID = -1);
  111. void WarnFeedback(int nEventID, const char* pszMsg = "", int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL, int nDetectorID = -1);
  112. void ErrorFeedback(int nEventID, const char* pszMsg = "", int nDetectorID = -1, int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL);
  113. bool TestError(int nDetectorID, int nErrorStatus);
  114. bool ReadBatteryStatus(int nPanelIndex);
  115. bool CheckBattery(int nPanelIndex);
  116. bool ReadWifiStatus(int nPanelIndex);
  117. bool CheckWiFi(int nPanelIndex);
  118. bool CheckTemperature(int nPanelIndex);
  119. bool ReadTempStatus(int nPanelIndex);
  120. bool SetAppMode(int nDetectorID, int nMode);
  121. bool SetDetectorFluSync(int nDetectorID, int nFluSync);
  122. bool SetDetectorBinningMode(int nDetectorID, int nBinningMode);
  123. bool SetDetectorGainMode(int nDetectorID, int nGainValue);
  124. bool SetDetectorCorrection(int nDetectorID, int nCorrectionType);
  125. bool ClearCorrection(int nPanelIndex);
  126. bool OffsetCalibration();
  127. bool OffsetProcess(int nDetectorID, int nMode);
  128. bool WaitRespond(int nTimeOut);
  129. void SendNotify();
  130. void ResetLock();
  131. void Pausetime(DWORD dwSpan);
  132. bool StartXWindowOffThread();
  133. static DWORD XWindowOffThread(LPVOID pParam);
  134. void DisconnectFD(int nDetectorID);
  135. bool DownloadfromDetector(int nDetectorID);
  136. bool DeleteOneFolder(string strSourceFolder);
  137. bool CleanCalibFiles(int nDetectorID, bool bExpMode);
  138. bool RecoverImage();
  139. bool OnEXIT();
  140. void DeleteHandle();
  141. bool GetCalibrationTime(int nDetectorID, bool bExpMode);
  142. bool FlipX(WORD* pData, int nWidth, int nHeight);
  143. bool FlipXRotate90(WORD* pData, int nWidth, int nHeight);
  144. bool IsConnected(string strIP);
  145. void OnProcessPreImg();
  146. void OnProcessImg();
  147. HANDLE m_pHardwareStatusThread;
  148. HANDLE m_hEndHWStatusThreadEvent;
  149. HANDLE m_hHWStatusThreadEndEvent;
  150. bool StartHardwareStatusThread();
  151. static DWORD HardwareStatusThread(LPVOID pParam);
  152. bool GetHardwareStatus();
  153. bool GetConnectionStatus(int nDetectorID);
  154. bool SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight);
  155. bool CheckImageEXI(WORD* pImage, int nWidth, int nHeight, int nImageBit, int nThreshold, float fArea);
  156. bool SetOffsetModeScope();
  157. bool ListDetectorTriggerMode(int nDetectorID);
  158. bool ListDetectorBinningMode(int nDetectorID);
  159. bool ListDetectorGainMode(int nDetectorID);
  160. bool ListDetectorInfo(int nDetectorID);
  161. private:
  162. //句柄
  163. HMODULE m_hSDKModule;
  164. //线程
  165. HANDLE m_hInitThread;
  166. HANDLE m_hScanEventThread;
  167. //辅助线程句柄
  168. HANDLE m_hArrayEvent[SENSVIEW_SCAN_NUM];
  169. HANDLE m_hExitEvent;
  170. HANDLE m_hRecoverImage;
  171. HANDLE m_hCofirmCalib;
  172. HANDLE m_hEndCalibEvent;
  173. HANDLE m_hOffsetEvent;
  174. HANDLE m_hScanEnd; //结束辅助线程句柄
  175. HANDLE m_hSharedEvent; //等待SDK回调句柄
  176. HANDLE m_hWindowOffEvent;
  177. HANDLE m_pXWindowoffThread;
  178. string g_strAppPath;
  179. int m_nPanelCount;
  180. int m_nDetectorID; //SDK探测器ID(1,2,3)
  181. int m_nDetectorIndex; //当前激活探测器的index(0,1,2)
  182. FPDDeviceSensview* m_pCurrentDPC;
  183. map<FPDDeviceSensview*, int>* m_pDPC2PanelID;
  184. map<int, FPDDeviceSensview*>* m_pPanelID2DPC;
  185. DeviceIndexStruct m_stDeviceIndex[3]; //配置的探测器列表//不超过三块板
  186. ResDataObject m_ObjFPDsInfo[3]; //存储探测器数量和类型
  187. ResDataObject m_ModeConfig;
  188. WORD* m_pwRawImageData; //原始图像内存
  189. WORD* m_pwPreviewImg; //preview内存
  190. map<int, int> m_mapLogicModeOperationMode; //<nLogicMode, nOperationMode>
  191. DeviceErrorInfor m_WarnRes; //warn配置文件列表
  192. DeviceErrorInfor m_ErrRes; //error配置文件列表
  193. DeviceErrorList m_ErrList; //当前错误列表
  194. DeviceErrorList m_ErrListTemp; //初始化时未发送到UI的ERROR
  195. DeviceErrorList m_WarnList; //当前错误列表
  196. bool m_bInitialing; //是否在初始化过程中
  197. bool m_bBatteryCharging; //电池充电与否的状态
  198. bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程
  199. bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用
  200. bool m_bSetCorrectFile;
  201. bool m_bForceGridSuppress;
  202. bool m_bInCalibrating;
  203. bool m_bInExposure;
  204. int m_nDoseParam;// 校正用的曝光计量,发送到UI 且本地记录
  205. int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次
  206. int m_nCalibDueSetting; // 校正文件的保质期天数
  207. int m_nOldDay; //校正日期定期检查的上次时间(某一天)
  208. int m_nSID; //SID值
  209. int m_nGridLicense;
  210. float m_fCalibTemperature;
  211. //校正相关变量
  212. int m_nCalibrationMode; //校正模式,ZSKK or Factory
  213. int m_nCorrectionType;
  214. //其他
  215. bool m_bOffsetAll;
  216. float m_fFrameRate;
  217. };
  218. }