PDF
AUBO SDK  0.26.0
trace.h
浏览该文件的文档.
1/** @file trace.h
2 * \~chinese @brief 向控制器日志系统注入日志方面的接口 \~english @brief Interface for injecting logs into the controller's logging system
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 * \chinese
20 * @defgroup Trace Trace (日志与弹窗)
21 * 提供给控制器扩展程序的日志记录系统
22 * \endchinese
23 *
24 * \english
25 * @defgroup Trace Log and Pop-up
26 * Log recording system for controller extension programs
27 * \endenglish
28 */
29class ARCS_ABI_EXPORT Trace
30{
31public:
33 virtual ~Trace();
34
35 /**
36 * @ingroup Trace
37 * \~chinese 向 aubo_control 日志注入告警信息 \~english Injects alarm information into the aubo_control log
38 *
39 * TraceLevel: \n
40 * 0 - FATAL \n
41 * 1 - ERROR \n
42 * 2 - WARNING \n
43 * 3 - INFO \n
44 * 4 - DEBUG \n
45 *
46 * \~chinese code定义参考 error_stack \~english Code definitions refer to error_stack
47 *
48 * @param level
49 * @param code
50 * @param args
51 * @return
52 *
53 * \~chinese @par Python函数原型 \~english @par Python function prototype
54 * alarm(self: pyaubo_sdk.Trace, arg0: arcs::common_interface::TraceLevel,
55 * arg1: int, arg2: List[str]) -> int
56 *
57 * \~chinese @par Lua函数原型 \~english @par Lua function prototype
58 * alarm(level: number, code: number, args: table) -> nil
59 *
60 * \~chinese @par JSON-RPC请求示例 \~english @par JSON-RPC request example
61 * {"jsonrpc":"2.0","method":"rob1.Trace.alarm","params":["",1,["Error","Trajectory
62 * planning failed!","1"]],"id":1}
63 *
64 * \~chinese @par JSON-RPC响应示例 \~engish @par JSON-RPC response example
65 * {"id":1,"jsonrpc":"2.0","result":0}
66 *
67 */
68 int alarm(TraceLevel level, int code,
69 const std::vector<std::string> &args = {});
70
71 /**
72 * @ingroup Trace
73 * \chinese
74 * 打印文本信息到日志中
75 *
76 * @param msg 文本信息
77 * @return
78 *
79 * @par Python函数原型
80 * textmsg(self: pyaubo_sdk.Trace, arg0: str) -> int
81 *
82 * @par Lua函数原型
83 * textmsg(msg: string) -> nil
84 *
85 * @par JSON-RPC请求示例
86 * {"jsonrpc":"2.0","method":"rob1.Trace.textmsg","params":["test"],"id":1}
87 *
88 * @par JSON-RPC响应示例
89 * {"id":1,"jsonrpc":"2.0","result":0}
90 * \endchinese
91 * \english
92 * print message into log
93 *
94 * @param msg message information
95 * @return
96 *
97 * @par Python function prototype
98 * textmsg(self: pyaubo_sdk.Trace, arg0: str) -> int
99 *
100 * @par Lua function prototype
101 * textmsg(msg: string) -> nil
102 *
103 * @par JSON-RPC request example
104 * {"jsonrpc":"2.0","method":"rob1.Trace.textmsg","params":["test"],"id":1}
105 *
106 * @par JSON-RPC responose example
107 * {"id":1,"jsonrpc":"2.0","result":0}
108 * \endenglish
109 */
110 int textmsg(const std::string &msg);
111
112 /**
113 * \~chinese 通知上位机 \~english Notify the system
114 *
115 * @param msg
116 * @return
117 */
118 int notify(const std::string &msg);
119
120 /**
121 * @ingroup Trace
122 * \chinese
123 * 向连接的 RTDE 客户端发送弹窗请求
124 *
125 * @param level
126 * @param title
127 * @param msg
128 * @param mode 模式 \n
129 * 0: 普通模式 \n
130 * 1: 阻塞模式 \n
131 * 2: 输入模式 bool \n
132 * 3: 输入模式 int \n
133 * 4: 输入模式 double \n
134 * 5: 输入模式 string \n
135 * @return
136 *
137 * @par Python函数原型
138 * popup(self: pyaubo_sdk.Trace, arg0: arcs::common_interface::TraceLevel,
139 * arg1: str, arg2: str, arg3: int) -> int
140 *
141 * @par Lua函数原型
142 * popup(level: number, title: string, msg: string, mode: number) -> nil
143 *
144 * @par JSON-RPC请求示例
145 * {"jsonrpc":"2.0","method":"rob1.Trace.popup","params":["","Error","Trajectory
146 * planning failed!",1],"id":1}
147 *
148 * @par JSON-RPC响应示例
149 * {"id":1,"jsonrpc":"2.0","result":0}
150 * \endchinese
151 * \english
152 * Send a popup request to the connected RTDE client
153 *
154 * @param level
155 * @param title
156 * @param msg
157 * @param mode mode \n
158 * 0: normal mode \n
159 * 1: blocking mode \n
160 * 2: input mode bool \n
161 * 3: input mode int \n
162 * 4: input mode double \n
163 * 5: input mode string \n
164 * @return
165 *
166 * @par Python function prototype
167 * popup(self: pyaubo_sdk.Trace, arg0: arcs::common_interface::TraceLevel,
168 * arg1: str, arg2: str, arg3: int) -> int
169 *
170 * @par Lua function prototype
171 * popup(level: number, title: string, msg: string, mode: number) -> nil
172 *
173 * @par JSON-RPC request example
174 * {"jsonrpc":"2.0","method":"rob1.Trace.popup","params":["","Error","Trajectory
175 * planning failed!",1],"id":1}
176 *
177 * @par JSON-RPC response example
178 * {"id":1,"jsonrpc":"2.0","result":0}
179 * \endenglish
180 */
181 int popup(TraceLevel level, const std::string &title,
182 const std::string &msg, int mode);
183
184 /**
185 * @ingroup Trace
186 * \chinese
187 * peek最新的 AlarmInfo(上次一获取之后)
188 *
189 * last_time设置为0时,可以获取到所有的AlarmInfo
190 *
191 * @param num
192 * @param last_time
193 * @return
194 *
195 * @par Python函数原型
196 * peek(self: pyaubo_sdk.Trace, arg0: int, arg1: int) ->
197 * List[arcs::common_interface::RobotMsg]
198 *
199 * @par Lua函数原型
200 * peek(num: number, last_time: number) -> table
201 *
202 * @par JSON-RPC请求示例
203 * {"jsonrpc":"2.0","method":"rob1.Trace.peek","params":[1,0],"id":1}
204 *
205 * @par JSON-RPC响应示例
206 * {{"id":1,"jsonrpc":"2.0","result":[{"args":["RobotModeType.Running"],
207 * "code":30045,"level":"INFO","source":"rob1","timestamp":5102883064300}]}
208 * \endchinese
209 * \english
210 * peek the latest AlarmInfo (after the last retrieval)
211 *
212 * When last_time is set as 0, retrieve all AlarmInfo
213 *
214 * @param num
215 * @param last_time
216 * @return
217 *
218 * @par Python function prototype
219 * peek(self: pyaubo_sdk.Trace, arg0: int, arg1: int) ->
220 * List[arcs::common_interface::RobotMsg]
221 *
222 * @par Lua function prototype
223 * peek(num: number, last_time: number) -> table
224 *
225 * @par JSON-RPC request example
226 * {"jsonrpc":"2.0","method":"rob1.Trace.peek","params":[1,0],"id":1}
227 *
228 * @par JSON-RPC response example
229 * {{"id":1,"jsonrpc":"2.0","result":[{"args":["RobotModeType.Running"],
230 * "code":30045,"level":"INFO","source":"rob1","timestamp":5102883064300}]}
231 * \endenglish
232 */
233 RobotMsgVector peek(size_t num, uint64_t last_time = 0);
234
235protected:
236 void *d_;
237};
238
239using TracePtr = std::shared_ptr<Trace>;
240
241} // namespace common_interface
242} // namespace arcs
243#endif
int notify(const std::string &msg)
通知上位机
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 日志注入告警信息 code定义参考 error_stack
RobotMsgVector peek(size_t num, uint64_t last_time=0)
peek最新的 AlarmInfo(上次一获取之后)
int textmsg(const std::string &msg)
打印文本信息到日志中
std::shared_ptr< Trace > TracePtr
std::vector< RobotMsg > RobotMsgVector
数据类型的定义