123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- //
- #include "CCOS.Dev.IODevice.hpp"
- #include "CCOS.Dev.IODevice.Detail.hpp"
- using namespace CCOS::Dev;
- //-----------------------------------------------------------------------------
- // IODevice
- // The root / base class for any IODevice
- //-----------------------------------------------------------------------------
- // 最终的子类务必在继承函数中,创建 m_Detail !
- IODevice::IODevice (Detail::IODeviceDetail * detail)
- {
- assert (detail);
- m_Detail.reset (detail);
- this->EventCenter = m_Detail->EventCenter;
- }
- IODevice::~IODevice ()
- {
- }
- std::string IODevice::GetGUID () const
- {
- assert (m_Detail);
- return m_Detail->GetGUID ();
- }
- std::string IODevice::GetResource () const
- {
- assert (m_Detail);
- return m_Detail->GetResource ();
- }
- bool IODevice::Prepare()
- {
- assert(m_Detail);
- return m_Detail->Prepare();
- }
- RET_STATUS IODevice::Add (const std::string funcName, JSONString In, JSONString & Out)
- {
- assert (m_Detail);
- return m_Detail->Add (funcName, In, Out);
- }
- RET_STATUS IODevice::Delete (const std::string funcName, JSONString In, JSONString & Out)
- {
- assert (m_Detail);
- return m_Detail->Delete (funcName, In, Out);
- }
- RET_STATUS IODevice::Get (const std::string funcName, JSONString& Out)
- {
- assert (m_Detail);
- return m_Detail->Get (funcName, Out);
- }
- RET_STATUS IODevice::Set (const std::string funcName, JSONString In)
- {
- assert (m_Detail);
- return m_Detail->Set (funcName, In);
- }
- RET_STATUS IODevice::Update (const std::string funcName, JSONString In, JSONString & Out)
- {
- assert (m_Detail);
- return m_Detail->Update (funcName, In, Out);
- }
- RET_STATUS IODevice::Action (const std::string funcName, JSONString In, JSONString & Out)
- {
- assert (m_Detail);
- return m_Detail->Action (funcName, In, Out);
- }
- void IODevice::SubscribeSelf()
- {
- assert(m_Detail);
- return m_Detail->SubscribeSelf(m_pMqttConntion);
- }
- void SYSTEM_CALL IODevice::CompleteInit()
- {
- //这里为IODevice创建一个单独的mqttConnection
- }
- void SYSTEM_CALL IODevice::CompleteUnInit()
- {
- }
- bool IODevice::GetDeviceType(GUID& DevType)
- {
- return true;
- }
- RET_STATUS IODevice::CmdToLogicDev(ResDataObject PARAM_IN* pCmd)
- {
- return RET_SUCCEED;
- }
- RET_STATUS IODevice::Request(ResDataObject PARAM_IN* pRequest, ResDataObject PARAM_OUT* pResponse)
- {
- return RET_SUCCEED;
- }
- //-----------------------------------------------------------------------------
- // IODriver
- //-----------------------------------------------------------------------------
- IODriver::IODriver ()
- {
- EventCenter.reset (new IOEventCenter);
- }
- IODriver::~IODriver ()
- {
- }
- void IODriver::Prepare ()
- {
- }
- /*
- unsigned long IODriver::GetVersion ()
- {
- return 0;
- }
- std::string IODriver::GetVersionString ()
- {
- return std::string {};
- }
- */
- /*
- void IODriver::IOCtrl ()
- {
- }
- */
- bool IODriver::DriverEntry (std::string CfgFileName)
- {
- m_ConfigFileName = CfgFileName;
- return true;
- }
- bool IODriver::Connect ()
- {
- return false;
- }
- void IODriver::Disconnect ()
- {
- }
- bool IODriver::isConnected () const
- {
- return false;
- }
- bool IODriver::OnHeartBeat ()
- {
- return true;
- }
- bool IODriver::GetDeviceConfig(std::string& Cfg)
- {
- return false;
- }
- bool IODriver::SetDeviceConfig(std::string Cfg)
- {
- return false;
- }
|