#pragma once #include "CCOS.Dev.FPD.iRayDM.h" #include "include/IRayFpdSys_MAM.h" const int SCAN_EVENT_NUM = 5; namespace CCOS::Dev::Detail::Detector { namespace nsDPC = CCOS::Dev::Detail::Detector; class IRayCtrl { string g_strAppPath; int m_nPanelCount; int m_nCurrentPanelID; void* m_pCurrentDPC; map* m_pDPC2PanelID; map* m_pPanelID2DPC; DeviceIndexStruct m_stDeviceIndex[3]; //配置的探测器列表 ResDataObject m_ObjFPDsInfo[3]; //存储探测器数量和类型 //int m_nActiveFPDAppMode[2]; WORD* m_pImgBuffer; WORD* m_pwRawImageData; //原始图像内存 WORD* m_pwPreviewImg; //preview内存 int m_nCmdConnectResult; ENUM_PANEL_STATUS m_ePanelStatus; //探测器的状态 PARPARE READY WINDOWON OFF //DeviceErrorInfor m_WarnRes; //warn配置文件列表 //DeviceErrorInfor m_ErrRes; //error配置文件列表 //DeviceErrorList m_ErrList; //当前错误列表 //DeviceErrorList m_ErrListTemp; //初始化时未发送到UI的ERROR //DeviceErrorList m_WarnList; //当前错误列表 //int m_nExpTag; //Siemens未用,曝光帧数 //CFPDMSMProxy m_fpdMSM; //状态机实例 //CStringArray m_strErrorCodes;//要恢复的错误号列表,目前只用来存储单个错误号 //int m_nErrorIndex; //UINT_PTR m_ntimer_GetHardware; // 查询WIFI电量的定时器 //UINT_PTR m_ntimer_CheckCalibration; // 查询WIFI电量的定时器 //UINT_PTR m_ntimer_TemperCheck; //UINT_PTR m_ntimer_ResetSNList; //UINT_PTR m_ntimer_ReconnectFPD; bool m_bOpened; //初始化开始与否;初始化未开始,屏蔽DLL反馈的各种状态信息; bool m_bInitialing; //bool m_bBatteryCharging; //电池充电与否的状态 //bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程 //bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用 //bool m_bSNListExisted; //bool m_bSetCorrectFile; //bool m_bSendRecoverMessage; //bool m_bHasGrid; // XCU通知有栅/无栅的状态 //bool m_bContinueCalibration; //校正报错后是否继续校正 //bool m_bHasSNList; //bool m_bTestSensitivity; //bool m_bPingStatus; //bool m_bDefectAccept; //bool m_bDoorOpen; //bool m_bForceGridSuppress; bool m_bInCalibrating; bool m_bInExposure; bool m_bWindowOn; //曝光窗口是否打开了 bool m_bPMSLoginStatus; bool m_bShowAttachInfo; bool m_bModuleConnecting; bool m_bModulePresent; volatile bool m_bScanResult; string m_strSourceID; //非SIEMENS用,FPDAPP用 FPDAPP的BUS SOURCE wstring m_wcsRecoverInfo; //恢复图像的结果,包含序列号和成功/失败的一个JSON结构体 string m_strCalibTime; string m_strWorkdir_Template; //int m_nReconnectTimes; int m_nDoseParam;// 校正用的曝光计量,发送到UI 且本地记录 int m_nRequireTimer; //查询WIFI电量的周期,Patient界面 10分钟检查一次 int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次 //int m_nComPort ; //红外适配器用的串口号 //int m_nConnectTimeout; int m_nCalibDueSetting; // 校正文件的保质期天数 int m_nFixedFDPlace;//固定板在哪个工作位 int m_nOffsetTime; long m_nGrayHist[256]; // 统计defect文件,每个坏点分类的个数 int m_nOldDay; //校正日期定期检查的上次时间(某一天) //int m_nTemperCheckTimes;//温度已经查询的时间 //int m_nTemperCheckTimeConf;//温度检查查询多久,配置项 /*int m_nCalibStatus; int m_nTemperCheckResult; int m_nSID; int m_nXCUStatus; int m_nMaxShockNumber; int m_nBatteryCapacity; int m_nBatteryCharges; int m_nGridLicense; float m_fCalibTemperature1; float m_fCalibTemperature2; float m_fCalibTemperature; float m_fBatteryTemperature; float m_fTemperatureMin; float m_fTemperatureMax; float m_fGradientMean; float m_fGradientStdDev; bool m_bDueDateWarnSend; bool m_bWallDueDateWarnSend;*/ //校正相关变量 /*list m_listCalibItem; list::iterator m_iterCalibDose;*/ //int m_nCalibrationMode; //校正模式,ZSKK or Factory //int m_nDefectExpTimes; //int m_nDefectTotalTimes; //int m_nGainExpTimes; //int m_nGainTotalFrames; //int m_nDefectTotalFrames; //int m_nPingSuccessTime; //ping成功次数,iRay探测器ping成功不代表能连接上探测器,需要等待一段时间,目前等待一分钟 //int m_nActiveState; //int m_nLastExpFDIndex; //bool m_bImageRecoverBeCanceled; //string m_strLastError; //DLL反馈的错误内容 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 SetPrepCapMode(int nDetectorID, int nPrepCapMode); //bool SetSelfCapEnable(int nDetectorID, int nSelfCapEnable); //bool SetSelfClearEnable(int nDetectorID, int nSelfClearEnable); //bool SetDynaOffsetGapTime(int nDetectorID, int nDynaOffsetGapTime); //bool SetInnerSubFlowAttr(int nDetectorID, int nInnerSubFlow); //bool SetXWindowDelay(int nDetectorID, int nXWidnowTime); //bool GetExpWindowTime(int nDetectorID, int& nExpWindowTime); //bool SetExpWindowTime(int nDetectorID, int nExpWindow); //bool GetDetectorStatus(int nDetectorID, int& state); //bool ReadBatteryStatus(int nPanelIndex); //bool CheckBattery(int nPanelIndex, bool bLog = true); //bool GetBatterySN(int nDetectorID, char* inoutSN); //bool GetBatteryExist(int nDetectorID, int& nExist); //bool GetBatteryRemaining(int nDetectorID, int& nRemaining); //bool GetBatteryChargingStatus(int nDetectorID, int& nStatus); //bool GetFPDTempT1(int nDetectorID, float& fTempT1); //bool GetHallSensor(int nDetectorID, int& nPosition); //bool GetLifeTime(int nDetectorID, int& nLifeTime); //bool GetPowerOnCount(int nDetectorID, int& nPowerOnCount); //bool GetCorrectionOption(int nDetectorID, int& nOption); //bool GetFWUpdateProgress(int nDetectorID, int& nOption); //bool ReadWifiStatus(int nPanelIndex); //bool CheckWiFi(int nPanelIndex, bool bLog = true); //bool CheckTemperature(int nPanelIndex); //bool ReadTempStatus(int nPanelIndex); //bool ReadLivingTime(int nDetectorID); //bool CheckLivingTime(int nDetectorID); //bool GetProductNo(int nDetectorID, int&); //bool GetSrcIP(int nDetectorID, char* pszUROM_SrcIP); //bool GetSerialNo(int nDetectorID, char* pszUROM_SerialNo); //bool GetMainVersion(int nDetectorID, char* pszMainVersion); //bool GetReadVersion(int nDetectorID, char* pszReadVersion); //bool GetMcuVersion(int nDetectorID, char* pszMcuVersion); //bool GetArmVersion(int nDetectorID, char* pszArmVersion); //bool GetKernelVersion(int nDetectorID, char* pszKernelVersion); //bool GetDelayTime(int nDetectorID, int& nDelayTime); //bool SetDelayTime(int nDetectorID, int nDelayTime); //bool SetAppMode(int nDetectorID); //bool UploadCalibrationFileToFDindex10(); //bool SetCorrectFile(); //bool GetCorrectFileIndex(int& nGainMapIndex, int& nDefectMapIndex); //bool GetSetDelayTime(int nDetectorID, int& nSetDelayTime); //bool GetWifiLinkQuality(int nDetectorID, int& nQuality); //string ProductNo2Type(int nProductNo); //bool GetROMInfo(int nPanelIndex, bool bFDAttach); //bool GetXWindowDelay(int nDetectorID, int& nXWidnowTime); //bool GetPrepCapMode(int nDetectorID, int& nPrepCapMode); //bool GetConnState(int nDetectorID, int& nConnState); //bool GetSelfCapEnable(int nDetectorID, int& nSelfCapEnable); //bool GetSelfClearEnable(int nDetectorID, int& nSelfClearEnable); //bool GetDynaOffsetGapTime(int nDetectorID, int& nDynOffsetGapTime); //bool GetInnerSubFlow(int nDetectorID, int& nInnerSubFlow); //bool WriteRom(int nDetectorID); //int SetInnerSubFlow(int nDetectorID, int nInnerSubFlow); //int SetCapModeFunc(int nDetectorID, int nSetCapMode); //int SetFPDCalParam(int nDetectorID, int nSetSelfCapEnable, int nSetSelfClearEnable); //bool GetActivePanelNum(int& nFindActiveFD); //bool StartOffsetThread(); //static DWORD OffsetThread(LPVOID pParam); //void DisconnectFD(int nDetectorID); //bool IsFWNeedUpdate(int nDetectorID); //bool UpdateFirmware(int nPanelIndex, bool bUpdate); //bool UploadCalibFileFromFD(int nDetectorID, int nIndex, string strFileName, bool bGain); //bool DownloadCalibrationFileToFD(bool bGainFile, bool bExpMode); //bool DownloadUserDefectFileToFD(bool bLTE); //bool ReadCumstomFile(int nDetectorID); //bool DownloadfromDetector(int nDetectorID); //bool BackupCalibFiles(int nDetectorID, bool bDownload, bool bExpMode); //bool DeleteOneFolder(string strSourceFolder); //bool CleanCalibFiles(int nDetectorID, bool bExpMode); //bool CleanCalibReport(int nDetectorID, bool bExpMode); //bool BackupCalibReport(int nDetectorID, bool bExpMode); //bool RestoreSensitivity(int nDetectorID); //bool RestoreCalibReport(int nDetectorID, bool bExpMode); //bool CheckLastImageStatus(int nDetectorID); //bool RecoverImage(); //bool GetCalibrationTime(int nDetectorID, bool bExpMode); //void GetFwName(string strFirmPath, string& strFirmwareName); ////bool LoadSensitivity(int nDetectorID); //bool SyncTimePC2FD(int nDetectorID); //void OnProcessAttach(); //void StartModuleThread(); //static DWORD _stdcall onModuleThread(void* pParam); // 红外配对的线程 //bool OnModuleConnect(); //bool OnDetectorShareStatus(DETECTOR_SHARE_STATUS eStatus, int nDetectorID = 0); //bool IsConnected(string strIP); //bool CheckSNInList(string strSN, bool bGetIP, string& strIP); //bool InDetectorShare(); //bool GetCurrentFDInfo(); //bool GetConnectConf(int nDetectorID); //bool UpdatePanelSerialFile(string strPanelType, string strSN, string strSetIP, string strDate, bool bActive); ////bool GetPanelSNList(string strPanelSerial, PanelSerialList& stpanelInfo); //bool SetConnectConf(bool bConnect, int nDetectorID); //void SetAttachFPDInfo(string strFPDType, int nDetectorID); //bool ModifyConfigIni(string strIniPath, string strSN, string strIP); //bool CheckPanelSize(string strPanelType); //HANDLE m_pHardwareStatusThread; //HANDLE m_hEndHWStatusThreadEvent; //HANDLE m_hHWStatusThreadEndEvent; //bool StartHardwareStatusThread(); //static DWORD HardwareStatusThread(LPVOID pParam); //bool GetHardwareStatus(); //bool GetConnectionStatus(int nDetectorID); //bool AnalysisCalibrationData(bool bExpMode); //bool CreatCalibrationReport(bool bModifyItem, bool bExpMode); //int ParseDefectFile(int nPanelIndex, bool bExpMode, bool bManual = false); //bool OpenDefectTemplateFile(const char* pszFilePath, void** ppHandler, unsigned short* pWidth, unsigned short* pHeight, char** ppPoints, char** ppRows, char** ppCols, char** ppDualReadCols2); //bool CloseDefectTemplateFile(void* pHandler); //bool TestDefectFile(); //bool SetLEDStatus(int nPanelIndex, bool bGreen); //HMODULE m_hFpdAttachModule; //FnGetAttachmentSDKVersion m_fpGetAttachmentSDKVersion; //FnRegisterDeviceStateNotify m_fpRegisterDeviceStateNotify; //FnInitLibrary m_fpInitLibrary; //FnUnInitLibrary m_fpUnInitLibrary; //FnGetFDInfo m_fpGetFDInfo; //FnSetFDIpWifiInfo m_fpSetFDIpWifiInfo; //FnSetFDIpInfo m_fpSetFDIpInfo; //FnSetFDWifiInfo m_fpSetFDWifiInfo; //int m_nRecoverImageTimes; // 自动恢复图像失败的次数,2次后终止,由用户操作 HANDLE m_hArrayEvent[SCAN_EVENT_NUM]; HANDLE m_hExitEvent; HANDLE m_hRecoverImage; HANDLE m_hCofirmCalib; HANDLE m_hEndCalibEvent; HANDLE m_hOffsetEvent; HANDLE m_hIRayScanEnd; HANDLE m_hSharedEvent; HANDLE m_hWindowOffEvent; HANDLE m_pOffsetThread; HANDLE m_pXWindowoffThread; HANDLE m_hScanEventThread; HANDLE m_hInitThread; public: IRayCtrl(); ~IRayCtrl(); bool Init(string strAppPath); bool AddDPCs(nsDPC::FPDDeviceIRay* pDrvDPC, ResDataObject& Configuration, DeviceIndexStruct& DeviceStruct); bool DelDPCs(nsDPC::FPDDeviceIRay* pDrvDPC); bool Connect(string strAppPath, nsDPC::FPDDeviceIRay* pDrvDPC); bool DisConnect(nsDPC::FPDDeviceIRay* pDrvDPC); void ProcessEvent(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, int nParam2, int nPtrParamLen, void* pParam); void OnProcessTaskResult(int nDetectorID, int nParam1, int nParam2, bool bResult); bool ScanResult(DetectorProfile* pDetectorProfile); bool EnterExam(APP_STATUS eStatus); bool ActivePanel(nsDPC::FPDDeviceIRay* pDrvDPC, bool bActive); //bool SwithPanel(int nPanelId); //bool ResetFPD(nsDPC::FPDDeviceIRay* pDrvDPC); bool SelectExamMode(int nLogicMode, nsDPC::FPDDeviceIRay* pDrvDPC); bool SetSyncMode(int nPanelIndex, int nSetSyncMode); RET_STATUS PrepareAcquisition(nsDPC::FPDDeviceIRay* pDrvDPC); RET_STATUS StartAcquisition(nsDPC::FPDDeviceIRay* pDrvDPC); RET_STATUS StopAcquisition(nsDPC::FPDDeviceIRay* pDrvDPC); bool ActiveConfigurationMode(int nDetectorID, int nConfigurationID); bool SelectMode(int nAppMode, int nExpMode, int nFilterMode); //bool InitCalibration(); //bool GetiRayPanelCalibItem(); //RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE Type, nsDPC::FPDDeviceIRay* pDrvDPC); //RET_STATUS PrepareCalibration(nsDPC::FPDDeviceIRay* pDrvDPC); //RET_STATUS StartCalibration(nsDPC::FPDDeviceIRay* pDrvDPC); //RET_STATUS CompleteCalibration(nsDPC::FPDDeviceIRay* pDrvDPC); //RET_STATUS AbortCalibration(nsDPC::FPDDeviceIRay* pDrvDPC); //RET_STATUS OnUpdateFirmware(nsDPC::FPDDeviceIRay* pDrvDPC); //bool ConfirmCalibration(); //bool AcceptCalibration(); //bool RejectCalibration(); //bool CreateCalibrationFile(); //void OnEndCalibraion(); //bool UploadCalibrationFiles(nsDPC::FPDDeviceIRay* pDrvDPC, string strFileName); //bool SetLTEMode(bool bEnable); //bool RecoverLastImage(); //bool RecoverLastImageAuto(); //void PMSStatus(bool bEnable); //bool SaveFailedCalibFiles(int nDetectorID, bool bExpMode); //bool CopyFile2Folder(string strSrcPath, string strDstPath); //bool WriteCumstomFile(int nDetectorID); //bool CancelImageRecover(); ////WORD *m_pImageBuffer; //SDK所需的一个大的图像buffer //ResDataObject m_PanelConfigPath; //加载PanelConfigPath,通过探测器类型获取配置文件名称 ////ResDataObject m_ObjFPDInfo; //存储配置文件中探测器数量和类型信息 //bool m_bCalibResultFailed; private: bool ExitDetectorScanThread(); void DeleteHandle(); bool LoadIRayDLL(string strWorkPath); bool FreeIRayDLL(); FPDRESULT IrayFnInvoke(int nDetectorID, int nCommandID, IRayCmdParam pars[], int nParCount); bool TestError(int nDetectorID, int nErrorStatus); void StartInitFPDThread(); static DWORD __stdcall onInitPanel(void* pParam); //初始化线程 void Action_Init(); bool DetectorInitProcess(int nDetectorID); bool RetryConnect(int nPanelIndex); bool OnInitStatus(int nPanelIndex, ENUM_PANEL_EVENT_STATE ePanelState); void CheckSDKiniFile(int nDetectorID); void iRayScanEventThread(); //辅助线程 static DWORD __stdcall onScanEvent(void* pParam); bool WaitRespond(int nTimeOut); void SendNotify(); void ResetLock(); void Pausetime(DWORD dwSpan); bool WaitReady(int nPanelIndex, int nMs); bool GetAttr(int nDetectorID, int nAttrID, int& nValue); bool GetAttr(int nDetectorID, int nAttrID, float& fValue); bool GetAttr(int nDetectorID, int nAttrID, char* pszAttr); bool SetAttr(int nDetectorID, int nAttrID, int nValue); bool GetSyncMode(int nDetectorID, int& nTriggerMode); string TriggerModeName(int nTriggerMode); //void OnProcessPreImg(); void OnProcessImg(); bool GetEffectiveImage(WORD* pOutImg, WORD* pInImg, int nInWidth); bool GetMammoAppMode(int nDetectorID); bool SetMammoAppMode(int nDetectorID, int nAppMode, int nExpMode, int nFilterMode); bool StartXWindowOffThread(); static DWORD XWindowOffThread(LPVOID pParam); bool ClearCorrectionOption(int nDetectorID); bool SetCorrectionOption(int nDetectorID, int nExpMode); bool GetCorrectionOption(int nDetectorID, int& nOption); bool PerformOffset(int nDetectorID, int nOffsetType); bool FlipX(WORD* pData, int nWidth, int nHeight); bool FlipXRotate90(WORD* pData, int nWidth, int nHeight); private: HMODULE m_hIRayModule; FnGetSDKVersion m_fpGetSDKVersion; FnSetUserCode m_fpSetUserCode; FnNotifyScanResult m_fpNotifyScanResult; FnRegisterScanNotify m_fpRegisterScanNotify; FnScanOnce m_fpScanOnce; FnCallback m_fpCallback; FnCreate m_fpCreate; FnDestroy m_fpDestroy; FnGetAttr m_fpGetAttr; FnSetAttr m_fpSetAttr; FnInvoke m_fpInvoke; FnAbort m_fpAbort; FnOpenDefectTemplateFile m_fpOpenDefectTemplateFile; FnSaveDefectTemplateFile m_fpSaveDefectTemplateFile; FnCloseDefectTemplateFile m_fpCloseDefectTemplateFile; ResDataObject m_ModeConfig; //string m_strPanelType; //探测器类型 string m_strWorkPath; //工作路径 //string m_strPanelIP; //配置文件中的IP地址 ////bool m_bOpened; //true: SDK Open成功,避免重复执行 //bool m_bConnected; //true: SDK Connect成功,避免重复执行 //bool m_bLoaded; //true: 已经加载过SDK APP_STATUS m_eAppStatus; //记录当前软件的工作状态(界面) int m_nCurrentMode; //记录探测器当前逻辑模式 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; int m_nTriggerMode; int m_nAppMode; int m_nExpMode; int m_nFilterMode; int m_nTotalFrameNum; int m_nCurrentFrame; int m_nClinicalApplicationMode; //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: 接受当前增益校正曝光结果 int m_nSaveRaw; //0:不存; 1:预览图; 2:raw图; 4:实际尺寸图像; //bool m_bPreviewImg; //true: 当前获取的是预览图 ////int m_nGainNodeCount; //校正曝光的总节点个数 ////int m_nGainNodeIndex; //校正曝光的节点Index ////int m_nGainExpCount; //校正曝光节点需要曝光的次数 ////int m_nGainExpIndex; //校正曝光节点已曝光的次数 ////bool m_bAttaching; //true: 探测器正在attach过程中 ////bool m_bModuleConnecting; //true: 探测器正在连接过程中。固件升级、attach时使用 ////bool m_bModulePresent; //记录红外探头是否和探测器接触 //string m_strModuleType; //红外获取的探测器类型; //string m_strModuleIP;//红外获取的探测器IP; //string m_strModuleSN; //红外获取的探测器SN //string m_strModuleSSID; //红外获取的SSID ////string m_strModuleSetIP; //attach时设置给探测器的IP //bool m_bModuleEnable; //true: 使用红外扫描功能 //bool m_bUpdateFirmwareDirect; //true: 直接升级固件 ////bool m_bNeedUpdateFW; //true: 需要升级固件 需要通过配置获知是否需要升级 ////SYNC_MODE m_eSyncMode; //同步模式 ////bool m_bTransImageSuccess; //true:图像传输成功 ////int m_nTotalShockNumber; //string m_strAttachFPD; //记录要attach的探测器类型 //int m_nAttachFPDID; //记录要attach的探测器ID //int m_nUpdateFPDID; //记录要固件升级的探测器ID //bool m_bIsImageRecovering; //是否处于图像恢复流程 //PanelSerialXMLControl m_objSNlist; }; }