#ifndef __UT_ROBOT_SDK_CHANNEL_LABOR_HPP__ #define __UT_ROBOT_SDK_CHANNEL_LABOR_HPP__ #include #include #include namespace unitree { namespace robot { /* * @brief * @class: ChannelLabor */ template class ChannelLabor { public: ChannelLabor() {} virtual ~ChannelLabor() {} void InitChannel(const std::string& name, const std::function& recvMesageCallback, int32_t queuelen = 0) { std::string sendChannelName = mNamerPtr->GetSendChannelName(name); std::string recvChannelName = mNamerPtr->GetRecvChannelName(name); mSendChannlPtr = ChannelFactory::Instance()->CreateSendChannel(sendChannelName); mRecvChannlPtr = ChannelFactory::Instance()->CreateRecvChannel(recvChannelName, recvMesageCallback, queuelen); } bool Send(const SEND_MSG& msg, int64_t waitTimeout) { return mSendChannlPtr->Write(msg, waitTimeout); } int64_t GetLastDataAvailableTime() const { return mRecvChannlPtr->GetLastDataAvailableTime(); } protected: ChannelNamerPtr mNamerPtr; private: ChannelPtr mSendChannlPtr; ChannelPtr mRecvChannlPtr; }; template using ChannelLaborPtr = std::shared_ptr>; /* * @brief * @class: ClientChannelLabor */ template class ClientChannelLabor : public ChannelLabor { public: ClientChannelLabor() { ChannelLabor::mNamerPtr = ChannelNamerPtr(new ClientChannelNamer()); } ~ClientChannelLabor() {} }; template using ClientChannelLaborPtr = std::shared_ptr>; /* * @brief * @class: ServerChannelLabor */ template class ServerChannelLabor : public ChannelLabor { public: ServerChannelLabor() { ChannelLabor::mNamerPtr = ChannelNamerPtr(new ServerChannelNamer()); } ~ServerChannelLabor() {} }; template using ServerChannelLaborPtr = std::shared_ptr>; } } #endif//__UT_ROBOT_SDK_CHANNEL_LABOR_HPP__