2025-03-12 10:03:16 +08:00
|
|
|
|
/*
|
|
|
|
|
|
@file TimetableMsgBusMng.h
|
|
|
|
|
|
@brief 消息管理类
|
|
|
|
|
|
@author 曹顶法
|
|
|
|
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#include "pub_sysinfo_api/SysInfoApi.h"
|
|
|
|
|
|
#include "net_msg_bus_api/CMbCommunicator.h"
|
|
|
|
|
|
#include "rdb_api/CRdbAccessEx.h"
|
|
|
|
|
|
#include "TimetableRtdbTableOperate.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace kbd_app
|
|
|
|
|
|
{
|
|
|
|
|
|
class CTimetableMsgBusMng
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
2025-03-12 14:17:53 +08:00
|
|
|
|
CTimetableMsgBusMng(const iot_public::SRunAppInfo &stRunAppInfo,
|
|
|
|
|
|
const iot_public::CSysInfoInterfacePtr &ptrSysInfo);
|
2025-03-12 10:03:16 +08:00
|
|
|
|
virtual ~CTimetableMsgBusMng();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 初始化
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int initialize();
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 订阅消息通道
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int subscribeMessage();
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 取消消息订阅
|
|
|
|
|
|
@return 成功返回kbdSuccess,失败返回错误码
|
|
|
|
|
|
*/
|
|
|
|
|
|
int unsubscribeMessage();
|
|
|
|
|
|
/*
|
|
|
|
|
|
@brief 接收消息
|
2025-03-12 14:17:53 +08:00
|
|
|
|
@param iot_net::CMbMessage & objMsg 返回的消息
|
2025-03-12 10:03:16 +08:00
|
|
|
|
@param int nTimeoutMsec 超时时间
|
|
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
2025-03-12 14:17:53 +08:00
|
|
|
|
bool recvMsg(iot_net::CMbMessage &objMsg, int nTimeoutMsec = 0);
|
2025-03-12 10:03:16 +08:00
|
|
|
|
/*
|
|
|
|
|
|
@brief 发送消息
|
|
|
|
|
|
@param const std::string & strMsg 消息内容
|
|
|
|
|
|
@param const int nChannel 通道
|
|
|
|
|
|
@param const int nMsgType 消息类型
|
|
|
|
|
|
@param const int nDstDomain 目的域,strNodeName非空时使用sendtohost
|
|
|
|
|
|
@param const std::string & strNodeName 目标节点,非空时使用sendtohost,否在使用sendtodomain
|
|
|
|
|
|
@return 成功返回true,失败返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool sendMsgToMsgBus(const std::string &strMsg,
|
|
|
|
|
|
const int nChannel,
|
|
|
|
|
|
const int nMsgType,
|
|
|
|
|
|
const int nDstDomain,
|
|
|
|
|
|
const std::string &strNodeName);
|
|
|
|
|
|
/* @brief 获取通信器名称 */
|
|
|
|
|
|
std::string getCommunicatorName();
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2025-03-12 14:17:53 +08:00
|
|
|
|
iot_net::CMbCommunicator m_objCommunicator; //< 消息总线通信器
|
|
|
|
|
|
iot_public::SRunAppInfo m_stRunAppInfo; //< 本应用相关运行参数
|
|
|
|
|
|
iot_public::CSysInfoInterfacePtr m_ptrSysInfo; //< 系统信息访问库智能指针
|
2025-03-12 10:03:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef boost::shared_ptr<CTimetableMsgBusMng> CTimetableMsgBusMngPtr;
|
|
|
|
|
|
}
|