#pragma once #include "CCOS.Dev.FPDDeviceMould.hpp" #include "OemAcq.h" #include "OemSync.h" #include "OemCtrl.h" #include "OemCalib.h" #include "DetectorConfiguration.h" #include "FPDErrorWarningProcess.h" #pragma warning(disable:26812) //枚举类型“ENUM_PANEL_EVENT_STATE”未设定范围。相比于 "enum",首选 "enum class" (Enum.3) #pragma warning(disable:26451) //算术溢出 : 使用 4 字节值上的运算符 * ,然后将结果转换到 8 字节值。在调用运算符 * 之前将值强制转换为宽类型可避免溢出(io.2)。 #ifdef CCOSDEVFPDTRIXELLDR_EXPORTS #define CCOSDEVFPDTRIXELLDR_API __declspec(dllexport) #else #define CCOSDEVFPDTRIXELLDR_API __declspec(dllimport) #endif class TrixellCtrl; namespace CCOS::Dev::Detail::Detector { class CCOSDEVFPDTRIXELLDR_API TrixellDriver : public FPDDriverMould { FPDDeviceTrixell* pObjDev; bool m_bConnect; //driver是否连接的标记位 ResDataObject m_DeviceConfig; ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件 ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容 std::unique_ptr m_pAttribute; std::unique_ptr m_pDescription; public: TrixellDriver(); virtual ~TrixellDriver(); virtual void Prepare() override; virtual bool Connect() override; virtual void Disconnect() override; virtual bool isConnected() const override; virtual auto CreateDevice(int index)->std::unique_ptr override; virtual std::string DriverProbe() override; virtual std::string GetResource() override; virtual std::string DeviceProbe() override; virtual bool GetDeviceConfig(std::string& Cfg) override; virtual bool SetDeviceConfig(std::string Cfg) override; bool SaveConfigFile(bool bSendNotify); bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue); bool SetDeviceConfigValue(ResDataObject & config, const char* pInnerKey, int nPathID, const char* szValue); }; namespace nsDetail = CCOS::Dev::Detail; class CCOSDEVFPDTRIXELLDR_API FPDDeviceTrixell : public FPDDeviceMould { using super = IODeviceDetail; //IODeviceDetail类的别名声明 ResDataObject* m_pPreviewImageHead; ResDataObject* m_pFullImageHead; std::unique_ptr m_DetectorCtrlUnit; std::unique_ptr m_AcqUnit; std::unique_ptr m_SyncUnit; std::unique_ptr m_CalibUnit; std::unique_ptr m_Temperature; std::unique_ptr m_Battery; std::unique_ptr m_Wifi; std::unique_ptr m_DetectorConfiguration; std::unique_ptr m_WarnAndError; //std::unique_ptr m_CalibProcess; int m_nDeviceIndex; //当前探测器的ID std::string m_strWorkPath; bool m_bExited; TrixellCtrl* m_pDetectors; APP_STATUS m_eAppStatus; WORD* m_pwFullImageData; //裁剪后的有效图像内存 WORD* m_pwRawImageData; //原始图像内存 WORD* m_pwPreviewImg; //preview内存 SYSTEMTIME m_stImgCreateTime; bool m_bForceGridSuppress; string m_strLastError; //DLL反馈的错误内容 bool m_bAttached; //bool m_bOpened; //初始化开始与否;初始化未开始,屏蔽DLL反馈的各种状态信息; bool m_bBatteryCharging; //电池充电与否的状态 //bool m_bRecoveringImage;//是否在恢复图像的流程中;若是,屏蔽其他错误,以防止干扰恢复图像的界面流程 //bool m_bAbortRecover; //放弃恢复图像(状态),恢复图像过程中中止,恢复图像失败的提示不再往上发送;目前不起作用 //int m_nRecoverImageTimes; // 恢复图像失败的次数,每2次提示用户一次 bool m_bImagePendingOrNot; //是否有未获取成功的图像 bool m_bResetDetector; //是否reset探测器,暂时不用 bool m_bNotifyCalWarn; //是否通知校正警告 int m_nBatteryCapacity; int m_nBatteryCharges; int m_nShockCounts; float m_fDoseParam;// 校正用的曝光计量,发送到UI 且本地记录 ////int m_nImageHeight; ////int m_nImageWidth; ////int m_nImgBits; ////int m_nPixelSpacing; ////int m_nSensitivity; ////float m_fDose; ////bool m_bConnect; int m_nFullImgWidth; //有效图像的宽 int m_nFullImgHeight; //有效图像的高 int m_nTopOffset; //图像上边裁剪像素值 int m_nLeftOffset; //图像左侧裁剪像素值 int m_nImageBits; //图像位数 float m_fFactorEXI2UGY; //探测器EXI -> UGY 转换系数 bool m_bPreviewEnable; //是否显示preview image int m_nXrayCalibNum; HANDLE m_PauseCalibrationEvt; HANDLE m_ExitEvt; HANDLE m_ConnectEvt; HANDLE m_hNotifyThread; DWORD m_NotifyThreadID; HANDLE m_WaitCalibDoseEvt; static DWORD WINAPI OnNotify(LPVOID pParam); HANDLE m_UploadCalibMapOver; ResDataObject m_CalibDoseList; //加载平板自己的校正剂量配置 int m_nCalibTotalExposureNum; //校正曝光总次数 int m_nCalibCurrentCalibrationRound; //校正曝光第几轮 int m_nCalibCurrentExposureIndex; //校正曝光第几次 int m_nCalibCurrentExposureNum; //已校正曝光总次数 public: DeviceIndexStruct m_stDeviceConfig; public: FPDDeviceTrixell(std::shared_ptr center, std::string strConfigPath); ~FPDDeviceTrixell(); virtual std::string GetGUID() const override; virtual bool Prepare() override; bool CreateDevice(); void Register(); RET_STATUS Connect(); RET_STATUS GetDeviceDictionary(std::string& out); RET_STATUS ActiveDetector(bool bActive); RET_STATUS WakeupDetector(); RET_STATUS EnterExam(int nExamMode); RET_STATUS ResetConnect(); RET_STATUS SetAcqMode(string strAcqMode); RET_STATUS SetAcqMode(int nMode); //RET_STATUS SetSyncMode(SYNC_MODE eSyncMode, HARDWARE_TRIGGER_MODE eTriggerMode); //RET_STATUS SetXwindow(float fXwindowSize); RET_STATUS PrepareAcquisition(); RET_STATUS StartAcquisition(string in = ""); RET_STATUS StopAcquisition(); RET_STATUS ActiveCalibration(CCOS_CALIBRATION_TYPE eType); RET_STATUS PrepareCalibration(); RET_STATUS GetRequestedDose(std::string& strDose); RET_STATUS SetRequestedDose(std::string strDose); RET_STATUS StartCalibration(); RET_STATUS StopCalibration(); RET_STATUS GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo); RET_STATUS AcceptCalibration(); RET_STATUS RejectCalibration(); RET_STATUS SaveCalibrationFile(bool bSaveFlag); RET_STATUS DisConnectFPD(); RET_STATUS DisConnectFPDForce(); RET_STATUS SetSaveRawDataMode(int nSaveRawDataMode); RET_STATUS OfflineFPD(int nOfflineFPDMode); RET_STATUS OnlineFPD(int nOnlineFPDMode); RET_STATUS GetAutonumousImageList(int nDetectorID, vector& AutonumousList); RET_STATUS RemoveAutonumousImageList(string strMeta); RET_STATUS RemoveAutonumousAll(); RET_STATUS GetImageMetaData(string strMetaData); RET_STATUS ExportAutonumousAll(); RET_STATUS GetDetectorInfo(string& strFDI); RET_STATUS ActiveSyncMode(int nSyncMode); void OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); bool GetLogicMode(string& strAcqMode, int& nLogicMode); private: bool LoadConfig(); bool OnInitResult(bool bSuccess); string GetFileVersion(string strFilePathName); void SendTemperatureValue(); void SendWifiValue(); void SendBatteryValue(); void OnProcessTemperature(int nID, float fTemperature); void Action_ExpReady(); RET_STATUS XWindowOnNotify(); RET_STATUS XWindowOffNotify(); bool OnProcessImage(WORD* pImage, int nWidth, int nHeight, float fImageReferUGY = 2.5); bool OnProcessPreviewImage(WORD* pRawImage, int nWidth, int nHeight); bool GetEffectiveImage(WORD* pwInImgData, int nRawImageWidth); void PrevImageDateArrived(WORD* pImg); void FullImageDateArrived(WORD* pImg); RET_STATUS AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize); string MakeImageHead(IMAGE_VIEW_TYPE Type); RET_STATUS PauseCalibration(); bool CompleteCalibration(); void AbortCalibration(); void CheckCalibrationDue(); void OnError(int nIndex, string strErrCode, string strErr = ""); void ClearError(int nDetectorID, std::string strErrorCode, std::string strErr = ""); void OnWarn(int nIndex, string strWarnCode, string strWarn = ""); void ClearWarn(int nDetectorID, std::string strWarnCode, std::string strWarn = ""); void SendAllError(); RET_STATUS ResetError(); void OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); void OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); void OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); void OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); void OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); void OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam); protected: void RegisterCtrl(nsDetail::Dispatch* Dispatch); void RegisterAcq(nsDetail::Dispatch* Dispatch); void RegisterSync(nsDetail::Dispatch* Dispatch); void RegisterCalib(nsDetail::Dispatch* Dispatch); void RegisterOthers(nsDetail::Dispatch* Dispatch); void RegisterAutonumous(nsDetail::Dispatch* Dispatch); }; } //end namespace CCOS::Dev::Detail::Detector