#pragma once #include "CommonFun.h" #include "IODeviceWithSCF.tlh" #include "IODeviceWithSCF.tli" #include "DIOS.Dev.SYNBOX.Mould.hpp" #include "DynBoxDevice.hpp" #include "CollimatorDevice.h" #ifdef DIOSDEVSYNDYN_EXPORTS #define _DIOSDEVDYNBOX_API __declspec(dllexport) #else #define _DIOSDEVDYNBOX_API __declspec(dllimport) #endif namespace DIOS::Dev::Detail::SYNBOX { class _DIOSDEVDYNBOX_API SyncBoxDevice :public IODeviceWithSCF { using super = IODeviceWithSCF ; public: SyncBoxDevice(std::shared_ptr center, nsSCF::SCF SCF); ~SyncBoxDevice(); virtual std::string GetGUID() const override; //V3新方法 virtual void SubscribeSelf(dios_mqtt_connection* conn) override; //void SubscribeSelf() override; protected: void Register(); void OnCallBack(); public: std::unique_ptr m_MSGUnit; std::unique_ptr m_DynBoxDevice; std::unique_ptr m_CollimatorDevice; }; } //----------------------------------------------------------------------------- // DynBoxDriver //----------------------------------------------------------------------------- namespace DIOS::Dev::Detail::SYNBOX { class _DIOSDEVDYNBOX_API DynBoxDriver : public IODriverWithSCF { using super = IODriverWithSCF ; public: DynBoxDriver (); virtual ~DynBoxDriver (); public: virtual void Prepare () override; virtual bool 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 bool GetDeviceConfig(std::string& Cfg) override; virtual bool SetDeviceConfig(std::string Cfg) override; virtual std::string DriverProbe () override; virtual std::string GetResource () override; virtual std::string DeviceProbe () override; private: static PACKET_RET callbackPackageProcess (const char* RecData, DWORD nLength, DWORD& PacketLength); void CanShakeHand(); void SetCANState(bool state); bool m_bDemoMode; bool m_bDemoConnected; // 在 DEMO 模式下, 调用过 Connect 吗? SyncBoxDevice* pSDCDevice{ nullptr }; //std::unique_ptr pSDCDevice; ResDataObject m_DeviceConfig; string g_strAppPath; ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件 ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容 std::unique_ptr m_pAttribute; std::unique_ptr m_pDescription; 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); }; }