// #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; }