ARCS SDK API  0.25.0
载入中...
搜索中...
未找到
trace.h
浏览该文件的文档.
1/** @file trace.h
2 * @brief 向控制器日志系统注入日志方面的接口
3 */
4#ifndef AUBO_SDK_TRACE_INTERFACE_H
5#define AUBO_SDK_TRACE_INTERFACE_H
6
7#include <string>
8#include <vector>
9#include <memory>
10#include <sstream>
11
12#include <aubo/global_config.h>
13#include <aubo/type_def.h>
14
15namespace arcs {
16namespace common_interface {
17
18/**
19 * 提供给控制器扩展程序的日志记录系统
20 */
21class ARCS_ABI_EXPORT Trace
22{
23public:
25 virtual ~Trace();
26
27 /**
28 * 向 aubo_control 日志注入告警信息
29 *
30 * TraceLevel: \n
31 * 0 - FATAL \n
32 * 1 - ERROR \n
33 * 2 - WARNING \n
34 * 3 - INFO \n
35 * 4 - DEBUG \n
36 *
37 * code定义参考 error_stack
38 *
39 * @param level
40 * @param code
41 * @param args
42 * @return
43 *
44 * @par Python函数原型
45 * alarm(self: pyaubo_sdk.Trace, arg0: arcs::common_interface::TraceLevel,
46 * arg1: int, arg2: List[str]) -> int
47 *
48 * @par Lua函数原型
49 * alarm(level: number, code: number, args: table) -> nil
50 *
51 * @par JSON-RPC请求示例
52 * {"jsonrpc":"2.0","method":"rob1.Trace.alarm","params":["",1,["Error","Trajectory
53 * planning failed!","1"]],"id":1}
54 *
55 * @par JSON-RPC响应示例
56 * {"id":1,"jsonrpc":"2.0","result":0}
57 *
58 */
59 int alarm(TraceLevel level, int code,
60 const std::vector<std::string> &args = {});
61
62 /**
63 * 打印文本信息到日志中
64 *
65 * @param msg 文本信息
66 * @return
67 *
68 * @par Python函数原型
69 * textmsg(self: pyaubo_sdk.Trace, arg0: str) -> int
70 *
71 * @par Lua函数原型
72 * textmsg(msg: string) -> nil
73 *
74 * @par JSON-RPC请求示例
75 * {"jsonrpc":"2.0","method":"rob1.Trace.textmsg","params":["test"],"id":1}
76 *
77 * @par JSON-RPC响应示例
78 * {"id":1,"jsonrpc":"2.0","result":0}
79 *
80 */
81 int textmsg(const std::string &msg);
82
83 /**
84 * 通知上位机
85 *
86 * @param msg
87 * @return
88 */
89 int notify(const std::string &msg);
90
91 /**
92 * 向连接的 RTDE 客户端发送弹窗请求
93 *
94 * @param level
95 * @param title
96 * @param msg
97 * @param mode 模式 \n
98 * 0: 普通模式 \n
99 * 1: 阻塞模式 \n
100 * 2: 输入模式 bool \n
101 * 3: 输入模式 int \n
102 * 4: 输入模式 double \n
103 * 5: 输入模式 string \n
104 * @return
105 *
106 * @par Python函数原型
107 * popup(self: pyaubo_sdk.Trace, arg0: arcs::common_interface::TraceLevel,
108 * arg1: str, arg2: str, arg3: int) -> int
109 *
110 * @par Lua函数原型
111 * popup(level: number, title: string, msg: string, mode: number) -> nil
112 *
113 * @par JSON-RPC请求示例
114 * {"jsonrpc":"2.0","method":"rob1.Trace.popup","params":["","Error","Trajectory
115 * planning failed!",1],"id":1}
116 *
117 * @par JSON-RPC响应示例
118 * {"id":1,"jsonrpc":"2.0","result":0}
119 *
120 */
121 int popup(TraceLevel level, const std::string &title,
122 const std::string &msg, int mode);
123
124 /**
125 * peek最新的 AlarmInfo(上次一获取之后)
126 *
127 * last_time设置为0时,可以获取到所有的AlarmInfo
128 *
129 * @param num
130 * @param last_time
131 * @return
132 *
133 * @par Python函数原型
134 * peek(self: pyaubo_sdk.Trace, arg0: int, arg1: int) ->
135 * List[arcs::common_interface::RobotMsg]
136 *
137 * @par Lua函数原型
138 * peek(num: number, last_time: number) -> table
139 *
140 * @par JSON-RPC请求示例
141 * {"jsonrpc":"2.0","method":"rob1.Trace.peek","params":[1,0],"id":1}
142 *
143 * @par JSON-RPC响应示例
144 * {{"id":1,"jsonrpc":"2.0","result":[{"args":["RobotModeType.Running"],
145 * "code":30045,"level":"INFO","source":"rob1","timestamp":5102883064300}]}
146 *
147 */
148 RobotMsgVector peek(size_t num, uint64_t last_time = 0);
149
150protected:
151 void *d_;
152};
153
154using TracePtr = std::shared_ptr<Trace>;
155
156// clang-format off
157#define Trace_DECLARES \
158 _INST(Trace, 3, alarm, level, code, args) \
159 _INST(Trace, 4, popup, level, title, msg, mode) \
160 _INST(Trace, 1, textmsg, msg) \
161 _INST(Trace, 1, notify, msg) \
162 _FUNC(Trace, 2, peek, num, last_time)
163// clang-format on
164} // namespace common_interface
165} // namespace arcs
166#endif
提供给控制器扩展程序的日志记录系统
Definition trace.h:22
int popup(TraceLevel level, const std::string &title, const std::string &msg, int mode)
向连接的 RTDE 客户端发送弹窗请求
int alarm(TraceLevel level, int code, const std::vector< std::string > &args={})
向 aubo_control 日志注入告警信息
RobotMsgVector peek(size_t num, uint64_t last_time=0)
peek最新的 AlarmInfo(上次一获取之后)
int textmsg(const std::string &msg)
打印文本信息到日志中
int notify(const std::string &msg)
通知上位机
std::shared_ptr< Trace > TracePtr
Definition trace.h:154
std::vector< RobotMsg > RobotMsgVector
Definition type_def.h:712
数据类型的定义