DIOS.Dev.SyncBoxe.DYN.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #pragma once
  2. #include "CommonFun.h"
  3. #include "IODeviceWithSCF.tlh"
  4. #include "IODeviceWithSCF.tli"
  5. #include "DIOS.Dev.SYNBOX.Mould.hpp"
  6. #include "DynBoxDevice.hpp"
  7. #include "CollimatorDevice.h"
  8. #ifdef DIOSDEVSYNDYN_EXPORTS
  9. #define _DIOSDEVDYNBOX_API __declspec(dllexport)
  10. #else
  11. #define _DIOSDEVDYNBOX_API __declspec(dllimport)
  12. #endif
  13. namespace DIOS::Dev::Detail::SYNBOX
  14. {
  15. class _DIOSDEVDYNBOX_API SyncBoxDevice :public IODeviceWithSCF <IODeviceDetail>
  16. {
  17. using super = IODeviceWithSCF <IODeviceDetail>;
  18. public:
  19. SyncBoxDevice(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF);
  20. ~SyncBoxDevice();
  21. virtual std::string GetGUID() const override;
  22. //V3新方法
  23. virtual void SubscribeSelf(dios_mqtt_connection* conn) override;
  24. //void SubscribeSelf() override;
  25. protected:
  26. void Register();
  27. void OnCallBack();
  28. public:
  29. std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit;
  30. std::unique_ptr<DynBoxDevice> m_DynBoxDevice;
  31. std::unique_ptr<CollimatorDevice> m_CollimatorDevice;
  32. };
  33. }
  34. //-----------------------------------------------------------------------------
  35. // DynBoxDriver
  36. //-----------------------------------------------------------------------------
  37. namespace DIOS::Dev::Detail::SYNBOX
  38. {
  39. class _DIOSDEVDYNBOX_API DynBoxDriver : public IODriverWithSCF <DriverMould>
  40. {
  41. using super = IODriverWithSCF <DriverMould>;
  42. public:
  43. DynBoxDriver ();
  44. virtual ~DynBoxDriver ();
  45. public:
  46. virtual void Prepare () override;
  47. virtual bool Connect () override;
  48. virtual void Disconnect() override;
  49. virtual bool isConnected() const override;
  50. virtual void Dequeue (const char * Packet, DWORD Length) override;
  51. virtual void FireNotify (int code, std::string key, std::string content) override;
  52. virtual auto CreateDevice (int index)->std::unique_ptr <IODevice> override;
  53. virtual bool GetDeviceConfig(std::string& Cfg) override;
  54. virtual bool SetDeviceConfig(std::string Cfg) override;
  55. virtual std::string DriverProbe () override;
  56. virtual std::string GetResource () override;
  57. virtual std::string DeviceProbe () override;
  58. private:
  59. static PACKET_RET callbackPackageProcess (const char* RecData, DWORD nLength, DWORD& PacketLength);
  60. void CanShakeHand();
  61. void SetCANState(bool state);
  62. bool m_bDemoMode;
  63. bool m_bDemoConnected; // 在 DEMO 模式下, 调用过 Connect 吗?
  64. SyncBoxDevice* pSDCDevice{ nullptr };
  65. //std::unique_ptr <DynBoxDevice> pSDCDevice;
  66. ResDataObject m_DeviceConfig;
  67. string g_strAppPath;
  68. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  69. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  70. std::unique_ptr <ResDataObject> m_pAttribute;
  71. std::unique_ptr <ResDataObject> m_pDescription;
  72. bool SaveConfigFile(bool bSendNotify);
  73. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  74. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  75. };
  76. }