CCOS.Dev.IODevice.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. cout << "IODevice::CompleteInit() IN" << endl;
  72. //这里为IODevice创建一个单独的mqttConnection
  73. }
  74. void SYSTEM_CALL IODevice::CompleteUnInit()
  75. {
  76. }
  77. bool IODevice::GetDeviceType(GUID& DevType)
  78. {
  79. return true;
  80. }
  81. RET_STATUS IODevice::CmdToLogicDev(ResDataObject PARAM_IN* pCmd)
  82. {
  83. return RET_SUCCEED;
  84. }
  85. RET_STATUS IODevice::Request(ResDataObject PARAM_IN* pRequest, ResDataObject PARAM_OUT* pResponse)
  86. {
  87. return RET_SUCCEED;
  88. }
  89. //-----------------------------------------------------------------------------
  90. // IODriver
  91. //-----------------------------------------------------------------------------
  92. IODriver::IODriver ()
  93. {
  94. EventCenter.reset (new IOEventCenter);
  95. }
  96. IODriver::~IODriver ()
  97. {
  98. }
  99. void IODriver::Prepare ()
  100. {
  101. }
  102. /*
  103. unsigned long IODriver::GetVersion ()
  104. {
  105. return 0;
  106. }
  107. std::string IODriver::GetVersionString ()
  108. {
  109. return std::string {};
  110. }
  111. */
  112. /*
  113. void IODriver::IOCtrl ()
  114. {
  115. }
  116. */
  117. bool IODriver::DriverEntry (std::string CfgFileName)
  118. {
  119. m_ConfigFileName = CfgFileName;
  120. return true;
  121. }
  122. bool IODriver::Connect ()
  123. {
  124. return false;
  125. }
  126. void IODriver::Disconnect ()
  127. {
  128. }
  129. bool IODriver::isConnected () const
  130. {
  131. return false;
  132. }
  133. bool IODriver::OnHeartBeat ()
  134. {
  135. return true;
  136. }
  137. bool IODriver::GetDeviceConfig(std::string& Cfg)
  138. {
  139. return false;
  140. }
  141. bool IODriver::SetDeviceConfig(std::string Cfg)
  142. {
  143. return false;
  144. }