DIOS.Dev.Collimator.Demo.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #pragma once
  2. #include "DIOS.Dev.Collimator.Mould.hpp"
  3. #include "IODeviceWithSCF.tlh"
  4. #include "IODeviceWithSCF.tli"
  5. #include "DIOS.Dev.MSGMould.hpp"
  6. #ifndef DIOSCOLLIAMTORDEMO_EXPORTS
  7. #ifdef _WIN64
  8. #ifdef _DEBUG
  9. #pragma comment(lib, "DIOS.Dev.Collimator.Demo64D.lib")
  10. #else
  11. #pragma comment(lib, "DIOS.Dev.Collimator.Demo64.lib")
  12. #endif
  13. #else
  14. #ifdef _DEBUG
  15. #pragma comment(lib, "DIOS.Dev.Collimator.DemoD.lib")
  16. #else
  17. #pragma comment(lib, "DIOS.Dev.Collimator.Demo.lib")
  18. #endif
  19. #endif
  20. #endif
  21. #ifdef DIOSCOLLIAMTORDEMO_EXPORTS
  22. #define _DIOSCOLLIAMTORDEMO_API __declspec(dllexport)
  23. #else
  24. #define _DIOSCOLLIAMTORDEMO_API __declspec(dllimport)
  25. #endif
  26. namespace DIOS::Dev::Detail::Collimator
  27. {
  28. typedef struct tagDemoCommand
  29. {
  30. UINT8 nFrameHeader1;
  31. UINT8 nFrameHeader2;
  32. UINT8 nCommand;
  33. UINT8 nData;
  34. UINT8 nCheckSum;
  35. UINT8 nEndFlag;
  36. }DemoCOMMAND;
  37. //-----------------------------------------------------------------------------
  38. // CollimatorDevice
  39. //-----------------------------------------------------------------------------
  40. namespace nDev = DIOS::Dev;
  41. class _DIOSCOLLIAMTORDEMO_API DemoDevice : public IODeviceDetail,public ColliamtorMould
  42. {
  43. using super = IODeviceDetail;
  44. using superColl = ColliamtorMould;
  45. public:
  46. DemoDevice (std::shared_ptr <IOEventCenter> center, std::string configfile);
  47. ~DemoDevice ();
  48. virtual std::string GetGUID() const override;
  49. virtual RET_STATUS SetCollimatorSize(unsigned short xsize, unsigned short ysize) override;
  50. virtual RET_STATUS SetCollimatorSID(unsigned short sid) override;
  51. virtual RET_STATUS SetCollimatorFilter(unsigned short pParams) override;
  52. virtual RET_STATUS SetCollimatorAngle(float pParams) override;
  53. virtual RET_STATUS SetCollimatorMode(unsigned short pParams) override;
  54. virtual int GetCollimatorLight();
  55. virtual RET_STATUS SetCollimatorLight(unsigned short pParams) override;
  56. void OnCallBack(const char* strPackage, DWORD Length);
  57. private:
  58. void Register();
  59. void FireNotify (std::string key, std::string context);
  60. };
  61. }
  62. //-----------------------------------------------------------------------------
  63. // CollimatorDriver
  64. //-----------------------------------------------------------------------------
  65. namespace DIOS::Dev::Detail::Collimator
  66. {
  67. class _DIOSCOLLIAMTORDEMO_API DemoDriver : public IODriverWithSCF <DriverMould>
  68. {
  69. using super = IODriverWithSCF <DriverMould>;
  70. public:
  71. DemoDriver ();
  72. virtual ~DemoDriver ();
  73. public:
  74. virtual void Prepare () override;
  75. virtual bool DATA_ACTION Connect () override;
  76. virtual void Disconnect() override;
  77. virtual bool isConnected() const override;
  78. virtual void Dequeue (const char * Packet, DWORD Length) override;
  79. virtual void FireNotify (int code, std::string key, std::string content) override;
  80. virtual auto CreateDevice (int index)->std::unique_ptr <IODevice> override;
  81. virtual std::string DriverProbe () override;
  82. virtual std::string GetResource () override;
  83. virtual std::string DeviceProbe () override;
  84. private:
  85. bool SaveConfigFile(bool bSendNotify);
  86. virtual bool GetDeviceConfig(std::string& Cfg) override;
  87. virtual bool SetDeviceConfig(std::string Cfg) override;
  88. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  89. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  90. static PACKET_RET callbackPackageProcess (const char* RecData, DWORD nLength, DWORD& PacketLength);
  91. bool m_bDemoMode; // DEMO 模式
  92. bool m_bDemoConnected; // 在 DEMO 模式下, 是否调用过 Connect
  93. //webconfig使用
  94. ResDataObject m_DeviceConfig;
  95. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  96. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  97. ResDataObject m_DeviceConfigSend;
  98. std::unique_ptr <ResDataObject> m_pAttribute;
  99. std::unique_ptr <ResDataObject> m_pDescription;
  100. DemoDevice* m_pDevice {nullptr};
  101. };
  102. }