Skip to content

节点通信 Node Communication

说明 / Overview

仿真节点间消息路由与通信的接口(C++ 专属)。
Interfaces for message routing and communication between simulation nodes (C++ only).


SendRouteMessage

bool SendRouteMessage(int length, void *pBuffer, int msgId, int toNodeId, ESimOne_Client_Type toNodeType)

节点通信数据发送API
Node communication data sending API.

该函数用于向指定节点发送数据
This function is used to send data to a specified node. This function is used to send data to a specified node.

Parameters:

名称 类型 描述 默认
length int 发送数据的长度
The length of the data to send.
—
pBuffer void * 发送数据的缓冲区指针
Pointer to the data buffer to be sent.
—
msgId int 发送的消息ID
The ID of the message being sent.
—
toNodeId int 消息接收节点的ID
ID of the node to which the message is sent.
—
toNodeType ESimOne_Client_Type 消息接收节点的类型
Type of the node to which the message is sent.
—

Returns:

类型 描述
bool 成功返回true,失败返回false
Returns true if successful, false otherwise.

ReceiveRouteMessageCB

bool ReceiveRouteMessageCB(void(*cb)(int fromId, ESimOne_Client_Type fromType, int length, const void *pBuffer, int commandId))

节点通信数据接收API
Node communication data receiving API.

该函数用于注册回调,以从其他节点接收数据
This function is used to register a callback to receive data from other nodes. This function is used to register a callback to receive data from other nodes.

Parameters:

名称 类型 描述 默认
cb void(*)(int fromId, ESimOne_Client_Type fromType, int length, const void *pBuffer, int commandId) 回调函数,用于处理接收到的数据
Callback function for handling received data.
—

Returns:

类型 描述
bool 成功返回true,失败返回false
Returns true if successful, false otherwise.

SetLogOut

bool SetLogOut(ESimOne_LogLevel_Type level, const char *format,...)

日志设置接口
Logging configuration interface.

用于配置日志级别和输出格式
Used to configure the log level and output format. Used to configure the log level and output format.

Parameters:

名称 类型 描述 默认
level ESimOne_LogLevel_Type 日志级别(警告、错误、信息)
Log level (warning, error, info).
—
format const char * 日志输出格式
The output format for the log.
—
— ... — —

Returns:

类型 描述
bool 成功设置返回true,否则返回false
Returns true if the configuration is successful, false otherwise.

LogUserData2SimOne

bool LogUserData2SimOne(int commandId, char *userData, int userDataLength)

向SimOne内部写入数据,记录到回放文件里
Log user defined data to SimOne.

此函数用于向SimOne内部写入数据,记录到回放文件里

Parameters:

名称 类型 描述 默认
commandId int 自定义数据的ID,用于标识数据类型
ID for the custom data.
—
userData char * 用户数据指针
User data pointer.
—
userDataLength int 用户数据长度
User data length.
—

Returns:

类型 描述
bool 成功获取返回true,否则返回false
Returns true if the information is successfully retrieved, false otherwise.