CCOS.Dev.IODevice.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. #include "CCOS.Dev.IODevice.hpp"
  3. #include "CCOS.Dev.IODevice.Detail.hpp"
  4. using namespace CCOS::Dev;
  5. //-----------------------------------------------------------------------------
  6. // IODevice
  7. // The root / base class for any IODevice
  8. //-----------------------------------------------------------------------------
  9. // 最终的子类务必在继承函数中,创建 m_Detail !
  10. IODevice::IODevice (Detail::IODeviceDetail * detail)
  11. {
  12. assert (detail);
  13. m_Detail.reset (detail);
  14. this->EventCenter = m_Detail->EventCenter;
  15. }
  16. IODevice::~IODevice ()
  17. {
  18. }
  19. std::string IODevice::GetGUID () const
  20. {
  21. assert (m_Detail);
  22. return m_Detail->GetGUID ();
  23. }
  24. std::string IODevice::GetResource () const
  25. {
  26. assert (m_Detail);
  27. return m_Detail->GetResource ();
  28. }
  29. bool IODevice::Prepare()
  30. {
  31. assert(m_Detail);
  32. return m_Detail->Prepare();
  33. }
  34. RET_STATUS IODevice::Add (const std::string funcName, JSONString In, JSONString & Out)
  35. {
  36. assert (m_Detail);
  37. return m_Detail->Add (funcName, In, Out);
  38. }
  39. RET_STATUS IODevice::Delete (const std::string funcName, JSONString In, JSONString & Out)
  40. {
  41. assert (m_Detail);
  42. return m_Detail->Delete (funcName, In, Out);
  43. }
  44. RET_STATUS IODevice::Get (const std::string funcName, JSONString& Out)
  45. {
  46. assert (m_Detail);
  47. return m_Detail->Get (funcName, Out);
  48. }
  49. RET_STATUS IODevice::Set (const std::string funcName, JSONString In)
  50. {
  51. assert (m_Detail);
  52. return m_Detail->Set (funcName, In);
  53. }
  54. RET_STATUS IODevice::Update (const std::string funcName, JSONString In, JSONString & Out)
  55. {
  56. assert (m_Detail);
  57. return m_Detail->Update (funcName, In, Out);
  58. }
  59. RET_STATUS IODevice::Action (const std::string funcName, JSONString In, JSONString & Out)
  60. {
  61. assert (m_Detail);
  62. return m_Detail->Action (funcName, In, Out);
  63. }
  64. void IODevice::SubscribeSelf()
  65. {
  66. assert(m_Detail);
  67. return m_Detail->SubscribeSelf(m_pMqttConntion);
  68. }
  69. void SYSTEM_CALL IODevice::CompleteInit()
  70. {
  71. //这里为IODevice创建一个单独的mqttConnection
  72. }
  73. void SYSTEM_CALL IODevice::CompleteUnInit()
  74. {
  75. }
  76. bool IODevice::GetDeviceType(GUID& DevType)
  77. {
  78. return true;
  79. }
  80. RET_STATUS IODevice::CmdToLogicDev(ResDataObject PARAM_IN* pCmd)
  81. {
  82. return RET_SUCCEED;
  83. }
  84. RET_STATUS IODevice::Request(ResDataObject PARAM_IN* pRequest, ResDataObject PARAM_OUT* pResponse)
  85. {
  86. return RET_SUCCEED;
  87. }
  88. //-----------------------------------------------------------------------------
  89. // IODriver
  90. //-----------------------------------------------------------------------------
  91. IODriver::IODriver ()
  92. {
  93. EventCenter.reset (new IOEventCenter);
  94. }
  95. IODriver::~IODriver ()
  96. {
  97. }
  98. void IODriver::Prepare ()
  99. {
  100. }
  101. /*
  102. unsigned long IODriver::GetVersion ()
  103. {
  104. return 0;
  105. }
  106. std::string IODriver::GetVersionString ()
  107. {
  108. return std::string {};
  109. }
  110. */
  111. /*
  112. void IODriver::IOCtrl ()
  113. {
  114. }
  115. */
  116. bool IODriver::DriverEntry (std::string CfgFileName)
  117. {
  118. m_ConfigFileName = CfgFileName;
  119. return true;
  120. }
  121. bool IODriver::Connect ()
  122. {
  123. return false;
  124. }
  125. void IODriver::Disconnect ()
  126. {
  127. }
  128. bool IODriver::isConnected () const
  129. {
  130. return false;
  131. }
  132. bool IODriver::OnHeartBeat ()
  133. {
  134. return true;
  135. }
  136. bool IODriver::GetDeviceConfig(std::string& Cfg)
  137. {
  138. return false;
  139. }
  140. bool IODriver::SetDeviceConfig(std::string Cfg)
  141. {
  142. return false;
  143. }