#pragma once #include //转存文件内容使用 #include #include "ResDataObject.h" #include "DetectorDefinition.h" #include "CCOS.Dev.FPD.Sensview.h" //SDK头文件 #include "SDK/Include/nvDentalDet.h" //链接库 #ifdef WIN64 #pragma comment(lib, "SDK\\Lib\\win64\\nvDentalDet.lib") #else #pragma comment(lib, "SDK\\Lib\\win32\\nvDentalDet.lib") #endif #define SENSVIEW_SCAN_NUM 5 namespace nsDPC = CCOS::Dev::Detail::Detector; namespace CCOS::Dev::Detail::Detector { class SensviewCtrl { public: SensviewCtrl(); ~SensviewCtrl(); static void ProcessEventCallback(void* lpCallbackData, NV_EVENTTYPE eventID, void* lpEventData); bool Init(string strAppPath); bool AddDPCs(nsDPC::FPDDeviceSensview* pDrvDPC, ResDataObject& Configuration, DeviceIndexStruct& DeviceStruct ); bool DelDPCs(nsDPC::FPDDeviceSensview* pDrvDPC); bool ActivePanel(nsDPC::FPDDeviceSensview* pDrvDPC, bool bActive); bool SwithPanel(int nPanelId); bool EnterExam(APP_STATUS eStatus); bool Connect(string strAppPath, nsDPC::FPDDeviceSensview* pDrvDPC); bool DisConnect(nsDPC::FPDDeviceSensview* pDrvDPC); bool ResetFPD(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode); bool SetAcqMode(nsDPC::FPDDeviceSensview* pDrvDPC, int nLogicMode, DetModeInfo& AcqModeInfo); RET_STATUS PrepareAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS StartAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS StopAcquisition(nsDPC::FPDDeviceSensview* pDrvDPC); bool InitCalibration(); RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE Type, nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS PrepareCalibration(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS StartCalibration(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS CompleteCalibration(nsDPC::FPDDeviceSensview* pDrvDPC); RET_STATUS AbortCalibration(nsDPC::FPDDeviceSensview* pDrvDPC); bool ConfirmCalibration(); bool AcceptCalibration(); bool RejectCalibration(); void OnEndCalibraion(); bool RecoverLastImage(); bool RecoverLastImageAuto(); bool SaveFailedCalibFiles(int nDetectorID, bool bExpMode); bool CopyFile2Folder(string strSrcPath, string strDstPath); bool CancelImageRecover(); bool SetFluPPS(float fFluPPS); bool GetFluPPS(float& fFluPPS); bool StartOffset(bool isAll); bool AbortOffset(); public: bool m_bCalibResultFailed; string m_strWorkPath; //工作路径 APP_STATUS m_eAppStatus; //记录当前软件的工作状态(界面) int m_nCurrentMode; //记录探测器当前application mode string m_strCurrentExamType; int m_nImageWidth; int m_nImageHeight; int m_nHeightOffset; int m_nBottomOffset; int m_nWidthOffset; int m_nRightOffset; int m_nRawImgWidth; //图像原始宽 int m_nRawImgHeight; //图像原始高 int m_nImgBits; int m_nPixelPitch; bool m_bPreviewEnable; float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数 int m_nPreviewWidth; int m_nPreviewHeight; CCOS_CALIBRATION_TYPE m_eCaliType; // 记录当前校正模式 float m_fCurrentDose; // 记录当前的Dose要求 int m_nCaliFailedCount; //记录增益校正失败次数,超过一定次数自动停止校正 bool m_bGainPreparing; //true: 正在进入增益校正状态 bool m_bGainProcess; //true: 处于增益曝光的一次小循环当中(WindowOn ~ SDK返回当前曝光结果) bool m_bConfirmCaliRst; //true: 接受当前增益校正曝光结果 bool m_bSaveRaw; //false:不存; true:存原图; bool m_bPreviewImg; //false:不要预览图; true:要预览图 //int m_nGainNodeCount; //校正曝光的总节点个数 //int m_nGainNodeIndex; //校正曝光的节点Index //int m_nGainExpCount; //校正曝光节点需要曝光的次数 //int m_nGainExpIndex; //校正曝光节点已曝光的次数 bool m_bIsImageRecovering; //是否处于图像恢复流程 bool m_bGrabStatus; //采集状态 int m_nFrameID; //动态图一次采集的ID int m_nExiThreshold; //EXI检测阈值 private: bool LoadSDKDLL(string strWorkPath); void FreeSDKDLL(); void StartInitFPDThread(); static DWORD _stdcall onInitPanel(void* pParam); //初始化线程 void Action_Init(); bool DetectorInitProcess(int nPanelIndex, bool bFetchCalibration = false); bool RetryConnect(int nPanelIndex); bool OnInitStatus(int nPanelIndex, ENUM_PANEL_EVENT_STATE ePanelState); void ScanAddHandle(); void ScanEventThread(); //监控线程 static DWORD __stdcall onScanEvent(void* pParam); //初始化线程 void ConfFeedback(int nEventID, int nDetectorID = -1, const char* pszMsg = "", int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL); void InfoFeedback(int nEventID, int nDetectorID = -1, int nParam1 = 0, float fParam2 = 0, const char* pszMsg = "", int nPtrParamLen = 0, void* pParam = NULL); void StatusFeedback(int nEventID, int nParam1 = 0, const char* pszMsg = "", int nDetectorID = -1, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL); void DataFeedback(int nEventID, void* pParam = NULL, int nParam1 = 0, float fParam2 = 0, const char* pszMsg = "", int nPtrParamLen = 0, int nDetectorID = -1); void WarnFeedback(int nEventID, const char* pszMsg = "", int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL, int nDetectorID = -1); void ErrorFeedback(int nEventID, const char* pszMsg = "", int nDetectorID = -1, int nParam1 = 0, float fParam2 = 0, int nPtrParamLen = 0, void* pParam = NULL); bool TestError(int nDetectorID, int nErrorStatus); bool ReadBatteryStatus(int nPanelIndex); bool CheckBattery(int nPanelIndex); bool ReadWifiStatus(int nPanelIndex); bool CheckWiFi(int nPanelIndex); bool CheckTemperature(int nPanelIndex); bool ReadTempStatus(int nPanelIndex); bool SetAppMode(int nDetectorID, int nMode); bool SetDetectorFluSync(int nDetectorID, int nFluSync); bool SetDetectorBinningMode(int nDetectorID, int nBinningMode); bool SetDetectorGainMode(int nDetectorID, int nGainValue); bool SetDetectorCorrection(int nDetectorID, int nCorrectionType); bool ClearCorrection(int nPanelIndex); bool OffsetCalibration(); bool OffsetProcess(int nDetectorID, int nMode); bool WaitRespond(int nTimeOut); void SendNotify(); void ResetLock(); void Pausetime(DWORD dwSpan); bool StartXWindowOffThread(); static DWORD XWindowOffThread(LPVOID pParam); void DisconnectFD(int nDetectorID); bool DownloadfromDetector(int nDetectorID); bool DeleteOneFolder(string strSourceFolder); bool CleanCalibFiles(int nDetectorID, bool bExpMode); bool RecoverImage(); bool OnEXIT(); void DeleteHandle(); bool GetCalibrationTime(int nDetectorID, bool bExpMode); bool FlipX(WORD* pData, int nWidth, int nHeight); bool FlipXRotate90(WORD* pData, int nWidth, int nHeight); bool IsConnected(string strIP); void OnProcessPreImg(); void OnProcessImg(); HANDLE m_pHardwareStatusThread; HANDLE m_hEndHWStatusThreadEvent; HANDLE m_hHWStatusThreadEndEvent; bool StartHardwareStatusThread(); static DWORD HardwareStatusThread(LPVOID pParam); bool GetHardwareStatus(); bool GetConnectionStatus(int nDetectorID); bool SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight); bool CheckImageEXI(WORD* pImage, int nWidth, int nHeight, int nImageBit, int nThreshold, float fArea); bool SetOffsetModeScope(); bool ListDetectorTriggerMode(int nDetectorID); bool ListDetectorBinningMode(int nDetectorID); bool ListDetectorGainMode(int nDetectorID); bool ListDetectorInfo(int nDetectorID); private: //句柄 HMODULE m_hSDKModule; //线程 HANDLE m_hInitThread; HANDLE m_hScanEventThread; //辅助线程句柄 HANDLE m_hArrayEvent[SENSVIEW_SCAN_NUM]; HANDLE m_hExitEvent; HANDLE m_hRecoverImage; HANDLE m_hCofirmCalib; HANDLE m_hEndCalibEvent; HANDLE m_hOffsetEvent; HANDLE m_hScanEnd; //结束辅助线程句柄 HANDLE m_hSharedEvent; //等待SDK回调句柄 HANDLE m_hWindowOffEvent; HANDLE m_pXWindowoffThread; string g_strAppPath; int m_nPanelCount; int m_nDetectorID; //SDK探测器ID(1,2,3) int m_nDetectorIndex; //当前激活探测器的index(0,1,2) FPDDeviceSensview* m_pCurrentDPC; map* m_pDPC2PanelID; map* m_pPanelID2DPC; DeviceIndexStruct m_stDeviceIndex[3]; //配置的探测器列表//不超过三块板 ResDataObject m_ObjFPDsInfo[3]; //存储探测器数量和类型 ResDataObject m_ModeConfig; WORD* m_pwRawImageData; //原始图像内存 WORD* m_pwPreviewImg; //preview内存 map m_mapLogicModeOperationMode; // DeviceErrorInfor m_WarnRes; //warn配置文件列表 DeviceErrorInfor m_ErrRes; //error配置文件列表 DeviceErrorList m_ErrList; //当前错误列表 DeviceErrorList m_ErrListTemp; //初始化时未发送到UI的ERROR DeviceErrorList m_WarnList; //当前错误列表 bool m_bInitialing; //是否在初始化过程中 bool m_bBatteryCharging; //电池充电与否的状态 bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程 bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用 bool m_bSetCorrectFile; bool m_bForceGridSuppress; bool m_bInCalibrating; bool m_bInExposure; int m_nDoseParam;// 校正用的曝光计量,发送到UI 且本地记录 int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次 int m_nCalibDueSetting; // 校正文件的保质期天数 int m_nOldDay; //校正日期定期检查的上次时间(某一天) int m_nSID; //SID值 int m_nGridLicense; float m_fCalibTemperature; //校正相关变量 int m_nCalibrationMode; //校正模式,ZSKK or Factory int m_nCorrectionType; //其他 bool m_bOffsetAll; float m_fFrameRate; }; }