DIOS.Dev.SyncBoxe.2000ST.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #pragma once
  2. #include "CommonFun.h"
  3. #include "IODeviceWithSCF.tlh"
  4. #include "IODeviceWithSCF.tli"
  5. #include "DIOS.Dev.SYNBOX.Mould.hpp"
  6. #include "2000TBoxDevice.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(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF, string configfile);
  21. ~SyncBoxDevice();
  22. virtual std::string GetGUID() const override;
  23. protected:
  24. void Register();
  25. void OnCallBack();
  26. public:
  27. std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit;
  28. std::unique_ptr<DynBoxDevice> m_DynBoxDevice;
  29. std::unique_ptr<CollimatorDevice> m_CollimatorDevice;
  30. string m_strConfigPath;
  31. ResDataObject m_Config;
  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_bDemoConnected; // 在 DEMO 模式下, 调用过 Connect 吗?
  63. SyncBoxDevice* m_p2000tDevice{ nullptr };
  64. //std::unique_ptr <DynBoxDevice> pSDCDevice;
  65. ResDataObject m_DeviceConfig;
  66. string g_strAppPath;
  67. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  68. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  69. std::unique_ptr <ResDataObject> m_pAttribute;
  70. std::unique_ptr <ResDataObject> m_pDescription;
  71. bool SaveConfigFile(bool bSendNotify);
  72. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  73. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  74. //
  75. void ReadVersion();
  76. };
  77. }