#pragma once #include "DIOS.Dev.Collimator.Mould.hpp" #include "IODeviceWithSCF.tlh" #include "IODeviceWithSCF.tli" #include "DIOS.Dev.MSGMould.hpp" #ifndef DIOSCOLLIAMTORDEMO_EXPORTS #ifdef _WIN64 #ifdef _DEBUG #pragma comment(lib, "DIOS.Dev.Collimator.Demo64D.lib") #else #pragma comment(lib, "DIOS.Dev.Collimator.Demo64.lib") #endif #else #ifdef _DEBUG #pragma comment(lib, "DIOS.Dev.Collimator.DemoD.lib") #else #pragma comment(lib, "DIOS.Dev.Collimator.Demo.lib") #endif #endif #endif #ifdef DIOSCOLLIAMTORDEMO_EXPORTS #define _DIOSCOLLIAMTORDEMO_API __declspec(dllexport) #else #define _DIOSCOLLIAMTORDEMO_API __declspec(dllimport) #endif namespace DIOS::Dev::Detail::Collimator { typedef struct tagDemoCommand { UINT8 nFrameHeader1; UINT8 nFrameHeader2; UINT8 nCommand; UINT8 nData; UINT8 nCheckSum; UINT8 nEndFlag; }DemoCOMMAND; //----------------------------------------------------------------------------- // CollimatorDevice //----------------------------------------------------------------------------- namespace nDev = DIOS::Dev; class _DIOSCOLLIAMTORDEMO_API DemoDevice : public IODeviceDetail,public ColliamtorMould { using super = IODeviceDetail; using superColl = ColliamtorMould; public: DemoDevice (std::shared_ptr center, std::string configfile); ~DemoDevice (); virtual std::string GetGUID() const override; virtual RET_STATUS SetCollimatorSize(unsigned short xsize, unsigned short ysize) override; virtual RET_STATUS SetCollimatorSID(unsigned short sid) override; virtual RET_STATUS SetCollimatorFilter(unsigned short pParams) override; virtual RET_STATUS SetCollimatorAngle(float pParams) override; virtual RET_STATUS SetCollimatorMode(unsigned short pParams) override; virtual int GetCollimatorLight(); virtual RET_STATUS SetCollimatorLight(unsigned short pParams) override; void OnCallBack(const char* strPackage, DWORD Length); private: void Register(); void FireNotify (std::string key, std::string context); }; } //----------------------------------------------------------------------------- // CollimatorDriver //----------------------------------------------------------------------------- namespace DIOS::Dev::Detail::Collimator { class _DIOSCOLLIAMTORDEMO_API DemoDriver : public IODriverWithSCF { using super = IODriverWithSCF ; public: DemoDriver (); virtual ~DemoDriver (); public: virtual void Prepare () override; virtual bool DATA_ACTION Connect () override; virtual void Disconnect() override; virtual bool isConnected() const override; virtual void Dequeue (const char * Packet, DWORD Length) override; virtual void FireNotify (int code, std::string key, std::string content) 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; private: bool SaveConfigFile(bool bSendNotify); virtual bool GetDeviceConfig(std::string& Cfg) override; virtual bool SetDeviceConfig(std::string Cfg) override; bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue); bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue); static PACKET_RET callbackPackageProcess (const char* RecData, DWORD nLength, DWORD& PacketLength); bool m_bDemoMode; // DEMO 模式 bool m_bDemoConnected; // 在 DEMO 模式下, 是否调用过 Connect //webconfig使用 ResDataObject m_DeviceConfig; ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件 ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容 ResDataObject m_DeviceConfigSend; std::unique_ptr m_pAttribute; std::unique_ptr m_pDescription; DemoDevice* m_pDevice {nullptr}; }; }