ARCS SDK API  0.25.0
载入中...
搜索中...
未找到
register_control.h
浏览该文件的文档.
1/** @file register_control.h
2 * @brief 寄存器操作接口,用于三个模块之间的数据交换功能
3 */
4#ifndef AUBO_SDK_REGISTER_CONTROL_INTERFACE_H
5#define AUBO_SDK_REGISTER_CONTROL_INTERFACE_H
6
7#include <stdint.h>
8#include <memory>
9#include <vector>
10
11#include <aubo/type_def.h>
12#include <aubo/global_config.h>
13
15{
16 /** MODBUS unit not initiallized
17 */
19
20 /** MODBUS unit disconnected
21 */
23
24 /** The function code received in the query is not an allowable action for
25 * the server (or slave).
26 */
28
29 /** The function code received in the query is not an allowable action for
30 * the server (or slave), check that the entered signal address corresponds
31 * to the setup of the remote MODBUS server.
32 */
34
35 /** A value contained in the query data field is not an allowable value for
36 * server (or slave), check that the enterd signal value is valid for the
37 * specified address on the remote MODBUS server.
38 */
40
41 /** An unrecoverable error occurred while the server (or slave) was
42 * attempting to perform the requested action.
43 */
45
46 /** Specialized use in conjunction with programming commands sent to the
47 * remote MODBUS unit.
48 */
50
51 /** Specialized use in conjunction with programming commands sent to the
52 * remote MODBUS unit, the slave (server) is not able to respond now
53 */
55};
56
57namespace arcs {
58namespace common_interface {
59
60/**
61 * 通用寄存器
62 */
63class ARCS_ABI_EXPORT RegisterControl
64{
65public:
68
69 /**
70 * Reads the boolean from one of the input registers, which can also be
71 * accessed by a Field bus. Note, uses it’s own memory space.
72 *
73 * 从一个输入寄存器中读取布尔值,也可以通过现场总线进行访问。
74 * 注意,它使用自己的内存空间。
75 *
76 * @param address Address of the register (0:127)
77 * 寄存器的地址(0:127)
78 * @return The boolean value held by the register (true, false)
79 * 寄存器中保存的布尔值(true、false)
80 *
81 * @note The lower range of the boolean input registers [0:63] is reserved
82 * for FieldBus/PLC interface usage. The upper range [64:127] cannot be
83 * accessed by FieldBus/PLC interfaces, since it is reserved for external
84 * RTDE clients.
85 * 布尔输入寄存器的较低范围[0:63]保留供FieldBus/PLC接口使用。
86 * 较高范围[64:127]无法通过FieldBus/PLC接口访问,因为它保留供外部RTDE客户端使用。
87 *
88 * @par Python函数原型
89 * getBoolInput(self: pyaubo_sdk.RegisterControl, arg0: int) -> bool
90 *
91 * @par Lua函数原型
92 * getBoolInput(address: number) -> boolean
93 *
94 * @par JSON-RPC请求示例
95 * {"jsonrpc":"2.0","method":"RegisterControl.getBoolInput","params":[0],"id":1}
96 *
97 * @par JSON-RPC响应示例
98 * {"id":1,"jsonrpc":"2.0","result":false}
99 *
100 */
101 bool getBoolInput(uint32_t address);
102
103 /**
104 *
105 * @param address
106 * @param value
107 * @return
108 *
109 * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
110 *
111 * @par Python函数原型
112 * setBoolInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: bool) ->
113 * int
114 *
115 * @par Lua函数原型
116 * setBoolInput(address: number, value: boolean) -> nil
117 *
118 * @par JSON-RPC请求示例
119 * {"jsonrpc":"2.0","method":"RegisterControl.setBoolInput","params":[0,true],"id":1}
120 *
121 * @par JSON-RPC响应示例
122 * {"id":1,"jsonrpc":"2.0","result":0}
123 *
124 */
125 int setBoolInput(uint32_t address, bool value);
126
127 /**
128 * Reads the integer from one of the input registers, which can also be
129 * accessed by a Field bus. Note, uses it’s own memory space.
130 *
131 * 从一个输入寄存器中读取整数值,也可以通过现场总线进行访问。
132 * 注意,它使用自己的内存空间。
133 *
134 * @param address Address of the register (0:47)
135 * 寄存器的地址(0:47)
136 * @return The value held by the register [-2,147,483,648 : 2,147,483,647]
137 * 寄存器中保存的整数值[-2,147,483,648 : 2,147,483,647]
138 *
139 * @note The lower range of the integer input registers [0:23] is reserved
140 * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
141 * accessed by FieldBus/PLC interfaces, since it is reserved for external
142 * RTDE clients.
143 * 整数输入寄存器的较低范围[0:23]保留供FieldBus/PLC接口使用。
144 * 较高范围[24:47]无法通过FieldBus/PLC接口访问,因为它保留供外部RTDE客户端使用。
145 *
146 * @par Python函数原型
147 * getInt32Input(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
148 *
149 * @par Lua函数原型
150 * getInt32Input(address: number) -> number
151 *
152 * @par JSON-RPC请求示例
153 * {"jsonrpc":"2.0","method":"RegisterControl.getInt32Input","params":[0],"id":1}
154 *
155 * @par JSON-RPC响应示例
156 * {"id":1,"jsonrpc":"2.0","result":0}
157 *
158 */
159 int getInt32Input(uint32_t address);
160
161 /**
162 *
163 * @param address
164 * @param value
165 * @return
166 *
167 * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
168 *
169 * @par Python函数原型
170 * setInt32Input(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int) ->
171 * int
172 *
173 * @par Lua函数原型
174 * setInt32Input(address: number, value: number) -> nil
175 *
176 * @par JSON-RPC请求示例
177 * {"jsonrpc":"2.0","method":"RegisterControl.setInt32Input","params":[0,33],"id":1}
178 *
179 * @par JSON-RPC响应示例
180 * {"id":1,"jsonrpc":"2.0","result":0}
181 *
182 */
183 int setInt32Input(uint32_t address, int value);
184
185 /**
186 * Reads the float from one of the input registers, which can also be
187 * accessed by a Field bus. Note, uses it’s own memory space.
188 *
189 * 从一个输入寄存器中读取浮点数,也可以通过现场总线进行访问。
190 * 注意,它使用自己的内存空间。
191 *
192 * @param address Address of the register (0:47)
193 * 寄存器地址(0:47)
194 * @return The value held by the register (float)
195 * 寄存器中保存的浮点数值
196 *
197 * @note The lower range of the float input registers [0:23] is reserved
198 * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
199 * accessed by FieldBus/PLC interfaces, since it is reserved for external
200 * RTDE clients.
201 * 浮点数输入寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
202 * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
203 *
204 * @par Python函数原型
205 * getFloatInput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
206 *
207 * @par Lua函数原型
208 * getFloatInput(address: number) -> number
209 *
210 * @par JSON-RPC请求示例
211 * {"jsonrpc":"2.0","method":"RegisterControl.getFloatInput","params":[0],"id":1}
212 *
213 * @par JSON-RPC响应示例
214 * {"id":1,"jsonrpc":"2.0","result":0.0}
215 *
216 */
217 float getFloatInput(uint32_t address);
218
219 /**
220 *
221 * @param address
222 * @param value
223 * @return
224 *
225 * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
226 *
227 * @par Python函数原型
228 * setFloatInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
229 * -> int
230 *
231 * @par Lua函数原型
232 * setFloatInput(address: number, value: number) -> nil
233 *
234 * @par JSON-RPC请求示例
235 * {"jsonrpc":"2.0","method":"RegisterControl.setFloatInput","params":[0,3.3],"id":1}
236 *
237 * @par JSON-RPC响应示例
238 * {"id":1,"jsonrpc":"2.0","result":0}
239 *
240 */
241 int setFloatInput(uint32_t address, float value);
242
243 /**
244 *
245 * @param address
246 * @return
247 *
248 * @par Python函数原型
249 * getDoubleInput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
250 *
251 * @par Lua函数原型
252 * getDoubleInput(address: number) -> number
253 *
254 * @par JSON-RPC请求示例
255 * {"jsonrpc":"2.0","method":"RegisterControl.getDoubleInput","params":[0],"id":1}
256 *
257 * @par JSON-RPC响应示例
258 * {"id":1,"jsonrpc":"2.0","result":0.0}
259 *
260 */
261 double getDoubleInput(uint32_t address);
262
263 /**
264 *
265 * @param address
266 * @param value
267 * @return
268 *
269 * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
270 *
271 * @par Python函数原型
272 * setDoubleInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
273 * -> int
274 *
275 * @par Lua函数原型
276 * setDoubleInput(address: number, value: number) -> nil
277 *
278 * @par JSON-RPC请求示例
279 * {"jsonrpc":"2.0","method":"RegisterControl.setDoubleInput","params":[0,6.6],"id":1}
280 *
281 * @par JSON-RPC响应示例
282 * {"id":1,"jsonrpc":"2.0","result":0}
283 *
284 */
285 int setDoubleInput(uint32_t address, double value);
286
287 /**
288 * Reads the boolean from one of the output registers, which can also be
289 * accessed by a Field bus.
290 * Note, uses it’s own memory space.
291 *
292 * 从一个输出寄存器中读取布尔值,也可以通过现场总线进行访问。
293 * 注意,它使用自己的内存空间。
294 *
295 * @param address Address of the register (0:127)
296 * 寄存器地址(0:127)
297 * @return The boolean value held by the register (true, false)
298 * 寄存器中保存的布尔值(true, false)
299 *
300 * @note The lower range of the boolean output registers [0:63] is reserved
301 * for FieldBus/PLC interface usage. The upper range [64:127] cannot be
302 * accessed by FieldBus/PLC interfaces, since it is reserved for external
303 * RTDE clients
304 * 布尔输出寄存器的较低范围[0:63]保留供现场总线/PLC接口使用。
305 * 较高范围[64:127]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
306 *
307 * @par Python函数原型
308 * getBoolOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> bool
309 *
310 * @par Lua函数原型
311 * getBoolOutput(address: number) -> boolean
312 *
313 * @par JSON-RPC请求示例
314 * {"jsonrpc":"2.0","method":"RegisterControl.getBoolOutput","params":[0],"id":1}
315 *
316 * @par JSON-RPC响应示例
317 * {"id":1,"jsonrpc":"2.0","result":false}
318 *
319 */
320 bool getBoolOutput(uint32_t address);
321
322 /**
323 *
324 * @param address
325 * @param value
326 * @return
327 *
328 * @par Python函数原型
329 * setBoolOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: bool) ->
330 * int
331 *
332 * @par Lua函数原型
333 * setBoolOutput(address: number, value: boolean) -> nil
334 *
335 * @par JSON-RPC请求示例
336 * {"jsonrpc":"2.0","method":"RegisterControl.setBoolOutput","params":[0,false],"id":1}
337 *
338 * @par JSON-RPC响应示例
339 * {"id":1,"jsonrpc":"2.0","result":0}
340 *
341 */
342 int setBoolOutput(uint32_t address, bool value);
343
344 /**
345 * Reads the integer from one of the output registers, which can also be
346 * accessed by a Field bus. Note, uses it’s own memory space.
347 *
348 * 从一个输出寄存器中读取整数值,也可以通过现场总线进行访问。
349 * 注意,它使用自己的内存空间。
350 *
351 * @param address Address of the register (0:47)
352 * 寄存器地址(0:47)
353 * @return The int value held by the register [-2,147,483,648 :
354 * 2,147,483,647]
355 * 寄存器中保存的整数值(-2,147,483,648 : 2,147,483,647)
356 *
357 * @note The lower range of the integer output registers [0:23] is reserved
358 * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
359 * accessed by FieldBus/PLC interfaces, since it is reserved for external
360 * RTDE clients.
361 * 整数输出寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
362 * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
363 *
364 * @par Python函数原型
365 * getInt32Output(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
366 *
367 * @par Lua函数原型
368 * getInt32Output(address: number) -> number
369 *
370 * @par JSON-RPC请求示例
371 * {"jsonrpc":"2.0","method":"RegisterControl.getInt32Output","params":[0],"id":1}
372 *
373 * @par JSON-RPC响应示例
374 * {"id":1,"jsonrpc":"2.0","result":0}
375 *
376 */
377 int getInt32Output(uint32_t address);
378
379 /**
380 *
381 * @param address
382 * @param value
383 * @return
384 *
385 * @par Python函数原型
386 * setInt32Output(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int) ->
387 * int
388 *
389 * @par Lua函数原型
390 * setInt32Output(address: number, value: number) -> nil
391 *
392 * @par JSON-RPC请求示例
393 * {"jsonrpc":"2.0","method":"RegisterControl.setInt32Output","params":[0,100],"id":1}
394 *
395 * @par JSON-RPC响应示例
396 * {"id":1,"jsonrpc":"2.0","result":0}
397 *
398 */
399 int setInt32Output(uint32_t address, int value);
400
401 /**
402 * Reads the float from one of the output registers, which can also be
403 * accessed by a Field bus. Note, uses it’s own memory space.
404 *
405 * 从一个输出寄存器中读取浮点数,也可以通过现场总线进行访问。
406 * 注意,它使用自己的内存空间。
407 *
408 * @param address Address of the register (0:47)
409 * 寄存器地址(0:47)
410 * @return The value held by the register (float)
411 * 寄存器中保存的浮点数值(float)
412 *
413 * @note The lower range of the float output registers [0:23] is reserved
414 * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
415 * accessed by FieldBus/PLC interfaces, since it is reserved for external
416 * RTDE clients.
417 * 浮点数输出寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
418 * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
419 *
420 * @par Python函数原型
421 * getFloatOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
422 *
423 * @par Lua函数原型
424 * getFloatOutput(address: number) -> number
425 *
426 * @par JSON-RPC请求示例
427 * {"jsonrpc":"2.0","method":"RegisterControl.getFloatOutput","params":[0],"id":1}
428 *
429 * @par JSON-RPC响应示例
430 * {"id":1,"jsonrpc":"2.0","result":3.3}
431 *
432 */
433 float getFloatOutput(uint32_t address);
434
435 /**
436 *
437 * @param address
438 * @param value
439 * @return
440 *
441 * @par Python函数原型
442 * setFloatOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
443 * -> int
444 *
445 * @par Lua函数原型
446 * setFloatOutput(address: number, value: number) -> nil
447 *
448 * @par JSON-RPC请求示例
449 * {"jsonrpc":"2.0","method":"RegisterControl.setFloatOutput","params":[0,5.5],"id":1}
450 *
451 * @par JSON-RPC响应示例
452 * {"id":1,"jsonrpc":"2.0","result":0}
453 *
454 */
455 int setFloatOutput(uint32_t address, float value);
456
457 /**
458 *
459 * @param address
460 * @return
461 *
462 * @par Python函数原型
463 * getDoubleOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
464 *
465 * @par Lua函数原型
466 * getDoubleOutput(address: number) -> number
467 *
468 * @par JSON-RPC请求示例
469 * {"jsonrpc":"2.0","method":"RegisterControl.getDoubleOutput","params":[0],"id":1}
470 *
471 * @par JSON-RPC响应示例
472 * {"id":1,"jsonrpc":"2.0","result":0.0}
473 *
474 */
475 double getDoubleOutput(uint32_t address);
476
477 /**
478 *
479 * @param address
480 * @param value
481 * @return
482 *
483 * @par Python函数原型
484 * setDoubleOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
485 * -> int
486 *
487 * @par Lua函数原型
488 * setDoubleOutput(address: number, value: number) -> nil
489 *
490 * @par JSON-RPC请求示例
491 * {"jsonrpc":"2.0","method":"RegisterControl.setDoubleOutput","params":[0,4.4],"id":1}
492 *
493 * @par JSON-RPC响应示例
494 * {"id":1,"jsonrpc":"2.0","result":0}
495 *
496 */
497 int setDoubleOutput(uint32_t address, double value);
498
499 /**
500 * 用于 Modbus Slave
501 *
502 * @param address
503 * @return
504 *
505 * @par Python函数原型
506 * getInt16Register(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
507 *
508 * @par Lua函数原型
509 * getInt16Register(address: number) -> number
510 *
511 * @par JSON-RPC请求示例
512 * {"jsonrpc":"2.0","method":"RegisterControl.getInt16Register","params":[0],"id":1}
513 *
514 * @par JSON-RPC响应示例
515 * {"id":1,"jsonrpc":"2.0","result":0}
516 *
517 */
518 int16_t getInt16Register(uint32_t address);
519
520 /**
521 *
522 * @param address
523 * @param value
524 * @return
525 *
526 * @par Python函数原型
527 * setInt16Register(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int)
528 * -> int
529 *
530 * @par Lua函数原型
531 * setInt16Register(address: number, value: number) -> nil
532 *
533 * @par JSON-RPC请求示例
534 * {"jsonrpc":"2.0","method":"RegisterControl.setInt16Register","params":[0,0],"id":1}
535 *
536 * @par JSON-RPC响应示例
537 * {"id":1,"jsonrpc":"2.0","result":0}
538 *
539 */
540 int setInt16Register(uint32_t address, int16_t value);
541
542 /**
543 * 具名变量是否存在
544 *
545 * @param key 变量名
546 * @return
547 *
548 * @par JSON-RPC请求示例
549 * {"jsonrpc":"2.0","method":"RegisterControl.hasNamedVariable","params":["custom"],"id":1}
550 *
551 * @par JSON-RPC响应示例
552 * {"id":1,"jsonrpc":"2.0","result":false}
553 *
554 */
555 bool hasNamedVariable(const std::string &key);
556
557 /**
558 * 获取具名变量的类型
559 *
560 * @param key
561 * @return
562 *
563 * @par JSON-RPC请求示例
564 * {"jsonrpc":"2.0","method":"RegisterControl.getNamedVariableType","params":["custom"],"id":1}
565 *
566 * @par JSON-RPC响应示例
567 * {"id":1,"jsonrpc":"2.0","result":"NONE"}
568 *
569 */
570 std::string getNamedVariableType(const std::string &key);
571
572 /**
573 * 具名变量是否更新
574 *
575 * @param key
576 * @param since
577 * @return
578 *
579 * @par Python函数原型
580 * variableUpdated(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int)
581 * -> bool
582 *
583 * @par Lua函数原型
584 * variableUpdated(key: string, since: number) -> boolean
585 *
586 */
587 bool variableUpdated(const std::string &key, uint64_t since);
588
589 /**
590 * 获取变量值
591 *
592 * @param key
593 * @param default_value
594 * @return
595 *
596 * @par Python函数原型
597 * getBool(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: bool) -> bool
598 *
599 * @par Lua函数原型
600 * getBool(key: string, default_value: boolean) -> boolean
601 *
602 * @par JSON-RPC请求示例
603 * {"jsonrpc":"2.0","method":"RegisterControl.getBool","params":["custom",false],"id":1}
604 *
605 * @par JSON-RPC响应示例
606 * {"id":1,"jsonrpc":"2.0","result":true}
607 *
608 */
609 bool getBool(const std::string &key, bool default_value);
610
611 /**
612 * 设置/更新变量值
613 *
614 * @param key
615 * @param value
616 * @return
617 *
618 * @par Python函数原型
619 * setBool(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: bool) -> int
620 *
621 * @par Lua函数原型
622 * setBool(key: string, value: boolean) -> nil
623 *
624 * @par JSON-RPC请求示例
625 * {"jsonrpc":"2.0","method":"RegisterControl.setBool","params":["custom",true],"id":1}
626 *
627 * @par JSON-RPC响应示例
628 * {"id":1,"jsonrpc":"2.0","result":0}
629 *
630 */
631 int setBool(const std::string &key, bool value);
632
633 /**
634 * 获取变量值
635 *
636 * @param key
637 * @param default_value
638 * @return
639 *
640 * @par Python函数原型
641 * getVecChar(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[str])
642 * -> List[str]
643 *
644 * @par Lua函数原型
645 * getVecChar(key: string, default_value: table) -> table
646 *
647 * @par JSON-RPC请求示例
648 * {"jsonrpc":"2.0","method":"RegisterControl.getVecChar","params":["custom",[]],"id":1}
649 *
650 * @par JSON-RPC响应示例
651 * {"id":1,"jsonrpc":"2.0","result":[0,1,0]}
652 *
653 */
654 std::vector<char> getVecChar(const std::string &key,
655 const std::vector<char> &default_value);
656
657 /**
658 * 设置/更新变量值
659 *
660 * @param key
661 * @param value
662 * @return
663 *
664 * @par Python函数原型
665 * setVecChar(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[str])
666 * -> int
667 *
668 * @par Lua函数原型
669 * setVecChar(key: string, value: table) -> nil
670 *
671 * @par JSON-RPC请求示例
672 * {"jsonrpc":"2.0","method":"RegisterControl.setVecChar","params":["custom",[0,1,0]],"id":1}
673 *
674 * @par JSON-RPC响应示例
675 * {"id":1,"jsonrpc":"2.0","result":0}
676 *
677 */
678 int setVecChar(const std::string &key, const std::vector<char> &value);
679
680 /**
681 * 获取变量值
682 *
683 * @param key
684 * @param default_value
685 * @return
686 *
687 * @par Python函数原型
688 * getInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int) -> int
689 *
690 * @par Lua函数原型
691 * getInt32(key: string, default_value: number) -> number
692 *
693 * @par JSON-RPC请求示例
694 * {"jsonrpc":"2.0","method":"RegisterControl.getInt32","params":["custom",0],"id":1}
695 *
696 * @par JSON-RPC响应示例
697 * {"id":1,"jsonrpc":"2.0","result":6}
698 *
699 */
700 int getInt32(const std::string &key, int default_value);
701
702 /**
703 * 设置/更新变量值
704 *
705 * @param key
706 * @param value
707 * @return
708 *
709 * @par Python函数原型
710 * setInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int) -> int
711 *
712 * @par Lua函数原型
713 * setInt32(key: string, value: number) -> nil
714 *
715 * @par JSON-RPC请求示例
716 * {"jsonrpc":"2.0","method":"RegisterControl.setInt32","params":["custom",6],"id":1}
717 *
718 * @par JSON-RPC响应示例
719 * {"id":1,"jsonrpc":"2.0","result":0}
720 *
721 */
722 int setInt32(const std::string &key, int value);
723
724 /**
725 * 获取变量值
726 *
727 * @param key
728 * @param default_value
729 * @return
730 *
731 * @par Python函数原型
732 * getVecInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[int])
733 * -> List[int]
734 *
735 * @par Lua函数原型
736 * getVecInt32(key: string, default_value: table) -> table
737 *
738 * @par JSON-RPC请求示例
739 * {"jsonrpc":"2.0","method":"RegisterControl.getVecInt32","params":["custom",[]],"id":1}
740 *
741 * @par JSON-RPC响应示例
742 * {"id":1,"jsonrpc":"2.0","result":[1,2,3,4]}
743 *
744 */
745 std::vector<int32_t> getVecInt32(const std::string &key,
746 const std::vector<int32_t> &default_value);
747
748 /**
749 * 设置/更新变量值
750 *
751 * @param key
752 * @param value
753 * @return
754 *
755 * @par Python函数原型
756 * setVecInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[int])
757 * -> int
758 *
759 * @par Lua函数原型
760 * setVecInt32(key: string, value: table) -> nil
761 *
762 * @par JSON-RPC请求示例
763 * {"jsonrpc":"2.0","method":"RegisterControl.setVecInt32","params":["custom",[1,2,3,4]],"id":1}
764 *
765 * @par JSON-RPC响应示例
766 * {"id":1,"jsonrpc":"2.0","result":0}
767 *
768 */
769 int setVecInt32(const std::string &key, const std::vector<int32_t> &value);
770
771 /**
772 * 获取变量值
773 *
774 * @param key
775 * @param default_value
776 * @return
777 *
778 * @par Python函数原型
779 * getFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
780 * float
781 *
782 * @par Lua函数原型
783 * getFloat(key: string, default_value: number) -> number
784 *
785 * @par JSON-RPC请求示例
786 * {"jsonrpc":"2.0","method":"RegisterControl.getFloat","params":["custom",0.0],"id":1}
787 *
788 * @par JSON-RPC响应示例
789 * {"id":1,"jsonrpc":"2.0","result":4.400000095367432}
790 *
791 */
792 float getFloat(const std::string &key, float default_value);
793
794 /**
795 * 设置/更新变量值
796 *
797 * @param key
798 * @param value
799 * @return
800 *
801 * @par Python函数原型
802 * setFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) -> int
803 *
804 * @par Lua函数原型
805 * setFloat(key: string, value: number) -> nil
806 *
807 * @par JSON-RPC请求示例
808 * {"jsonrpc":"2.0","method":"RegisterControl.setFloat","params":["custom",4.4],"id":1}
809 *
810 * @par JSON-RPC响应示例
811 * {"id":1,"jsonrpc":"2.0","result":0}
812 *
813 */
814 int setFloat(const std::string &key, float value);
815
816 /**
817 * 获取变量值
818 *
819 * @param key
820 * @param default_value
821 * @return
822 *
823 * @par Python函数原型
824 * getVecFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
825 * List[float]) -> List[float]
826 *
827 * @par Lua函数原型
828 * getVecFloat(key: string, default_value: table) -> table
829 *
830 * @par JSON-RPC请求示例
831 * {"jsonrpc":"2.0","method":"RegisterControl.getVecFloat","params":["custom",[]],"id":1}
832 *
833 * @par JSON-RPC响应示例
834 * {"id":1,"jsonrpc":"2.0","result":[0.0,0.10000000149011612,3.299999952316284]}
835 *
836 */
837 std::vector<float> getVecFloat(const std::string &key,
838 const std::vector<float> &default_value);
839
840 /**
841 * 设置/更新变量值
842 *
843 * @param key
844 * @param value
845 * @return
846 *
847 * @par Python函数原型
848 * setVecFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
849 * List[float]) -> int
850 *
851 * @par Lua函数原型
852 * setVecFloat(key: string, value: table) -> nil
853 *
854 * @par JSON-RPC请求示例
855 * {"jsonrpc":"2.0","method":"RegisterControl.setVecFloat","params":["custom",[0.0,0.1,3.3]],"id":1}
856 *
857 * @par JSON-RPC响应示例
858 * {"id":1,"jsonrpc":"2.0","result":0}
859 *
860 */
861 int setVecFloat(const std::string &key, const std::vector<float> &value);
862
863 /**
864 * 获取变量值
865 *
866 * @param key
867 * @param default_value
868 * @return
869 *
870 * @par Python函数原型
871 * getDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
872 * float
873 *
874 * @par Lua函数原型
875 * getDouble(key: string, default_value: number) -> number
876 *
877 * @par JSON-RPC请求示例
878 * {"jsonrpc":"2.0","method":"RegisterControl.getDouble","params":["custom",0.0],"id":1}
879 *
880 * @par JSON-RPC响应示例
881 * {"id":1,"jsonrpc":"2.0","result":0.0}
882 *
883 */
884 double getDouble(const std::string &key, double default_value);
885
886 /**
887 * 设置/更新变量值
888 *
889 * @param key
890 * @param value
891 * @return
892 *
893 * @par Python函数原型
894 * setDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
895 * int
896 *
897 * @par Lua函数原型
898 * setDouble(key: string, value: number) -> nil
899 *
900 * @par JSON-RPC请求示例
901 * {"jsonrpc":"2.0","method":"RegisterControl.setDouble","params":["custom",6.6],"id":1}
902 *
903 * @par JSON-RPC响应示例
904 * {"id":1,"jsonrpc":"2.0","result":0}
905 *
906 */
907 int setDouble(const std::string &key, double value);
908
909 /**
910 * 获取变量值
911 *
912 * @param key
913 * @param default_value
914 * @return
915 *
916 * @par Python函数原型
917 * getVecDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
918 * List[float]) -> List[float]
919 *
920 * @par Lua函数原型
921 * getVecDouble(key: string, default_value: table) -> table
922 *
923 * @par JSON-RPC请求示例
924 * {"jsonrpc":"2.0","method":"RegisterControl.getVecDouble","params":["custom",[]],"id":1}
925 *
926 * @par JSON-RPC响应示例
927 * {"id":1,"jsonrpc":"2.0","result":[0.1,0.2,0.3]}
928 *
929 */
930 std::vector<double> getVecDouble(const std::string &key,
931 const std::vector<double> &default_value);
932
933 /**
934 * 设置/更新变量值
935 *
936 * @param key
937 * @param value
938 * @return
939 *
940 * @par Python函数原型
941 * setVecDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
942 * List[float]) -> int
943 *
944 * @par Lua函数原型
945 * setVecDouble(key: string, value: table) -> nil
946 *
947 * @par JSON-RPC请求示例
948 * {"jsonrpc":"2.0","method":"RegisterControl.setVecDouble","params":["custom",[0.1,0.2,0.3]],"id":1}
949 *
950 * @par JSON-RPC响应示例
951 * {"id":1,"jsonrpc":"2.0","result":0}
952 *
953 */
954 int setVecDouble(const std::string &key, const std::vector<double> &value);
955
956 /**
957 * 获取变量值
958 *
959 * @param key
960 * @param default_value
961 * @return
962 *
963 * @par Python函数原型
964 * getString(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: str) -> str
965 *
966 * @par Lua函数原型
967 * getString(key: string, default_value: string) -> string
968 *
969 * @par JSON-RPC请求示例
970 * {"jsonrpc":"2.0","method":"RegisterControl.getString","params":["custom",""],"id":1}
971 *
972 * @par JSON-RPC响应示例
973 * {"id":1,"jsonrpc":"2.0","result":"test"}
974 *
975 */
976 std::string getString(const std::string &key,
977 const std::string &default_value);
978
979 /**
980 * 设置/更新变量值
981 *
982 * @param key
983 * @param value
984 * @return
985 *
986 * @par Python函数原型
987 * setString(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: str) -> int
988 *
989 * @par Lua函数原型
990 * setString(key: string, value: string) -> nil
991 *
992 * @par JSON-RPC请求示例
993 * {"jsonrpc":"2.0","method":"RegisterControl.setString","params":["custom","test"],"id":1}
994 *
995 * @par JSON-RPC响应示例
996 * {"id":1,"jsonrpc":"2.0","result":0}
997 *
998 */
999 int setString(const std::string &key, const std::string &value);
1000
1001 /**
1002 * 清除变量
1003 *
1004 * @param key
1005 * @return
1006 *
1007 * @par Python函数原型
1008 * clearNamedVariable(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
1009 *
1010 * @par Lua函数原型
1011 * clearNamedVariable(key: string) -> nil
1012 *
1013 * @par JSON-RPC请求示例
1014 * {"jsonrpc":"2.0","method":"RegisterControl.clearNamedVariable","params":["custom"],"id":1}
1015 *
1016 * @par JSON-RPC响应示例
1017 * {"id":1,"jsonrpc":"2.0","result":1}
1018 *
1019 */
1020 int clearNamedVariable(const std::string &key);
1021
1022 /**
1023 * 设置看门狗
1024 *
1025 * 看门狗被触发之后控制器会执行对应的动作,并自动删除看门狗
1026 *
1027 * @param key
1028 * @param timeout 超时时间,单位秒(s),超时时间最小为 0.1s
1029 * @param action
1030 * NONE (0): 无动作
1031 * PAUSE(1): 暂停运行时
1032 * STOP (2): 停止运行时/停止机器人运动
1033 * PROTECTIVE_STOP (3): 触发防护停止
1034 * @return
1035 */
1036 int setWatchDog(const std::string &key, double timeout, int action);
1037
1038 /**
1039 * 获取看门狗动作
1040 *
1041 * @param key
1042 * @return
1043 */
1044 int getWatchDogAction(const std::string &key);
1045
1046 /**
1047 * 获取看门狗超时时间
1048 *
1049 * @param key
1050 * @return
1051 */
1052 int getWatchDogTimeout(const std::string &key);
1053
1054 /**
1055 * Adds a new modbus signal for the controller to supervise. Expects no
1056 * response.
1057 *
1058 * 添加一个新的Modbus信号以供控制器监视。不需要返回响应。
1059 *
1060 * @param device_info is rtu format.
1061 * eg,"serial_port,baud,parity,data_bit,stop_bit" \n (1)The serial_port
1062 * argument specifies the name of the serial port eg. On Linux ,"/dev/ttyS0"
1063 * or "/dev/ttyUSB0". On Windows,
1064 * \\.\COM10". \n
1065 * (2)The baud argument specifies the baud rate of the communication, eg.
1066 * 9600, 19200, 57600, 115200, etc. \n
1067 * (3)parity:N for none,E for even,O for odd. \n
1068 * (4)data_bit:The data_bits argument specifies the number of bits of data,
1069 * the allowed values are 5, 6, 7 and 8. \n
1070 * (5)stop_bit:The stop_bits argument
1071 * specifies the bits of stop, the allowed values are 1 and 2.
1072 *
1073 * device_info is tcp format.eg,"ip address,port" \n
1074 * (1)The ip address parameter specifies the ip address of the server \n
1075 * (2)The port parameter specifies the port number that the server is
1076 * listening on.
1077 *
1078 * 设备信息 \n
1079 * 设备信息是RTU格式,
1080 * 例如:"serial_port,baud,parity,data_bit,stop_bit" \n
1081 * (1)serial_port参数指定串口的名称,
1082 * 例如,在Linux上为"/dev/ttyS0"或"/dev/ttyUSB0",在Windows上为"\.\COM10"\n
1083 * (2)baud参数指定通信的波特率,例如9600、19200、57600、115200等 \n
1084 * (3)parity参数指定奇偶校验方式,N表示无校验,E表示偶校验,O表示奇校验 \n
1085 * (4)data_bit参数指定数据位数,允许的值为5、6、7和8 \n
1086 * (5)stop_bit参数指定停止位数,允许的值为1和2
1087 *
1088 * 设备信息是TCP格式,例如:"ip address,port" \n
1089 * (1)ip address参数指定服务器的IP地址 \n
1090 * (2)port参数指定服务器监听的端口号
1091 * @param slave_number An integer normally not used and set to 255, but is
1092 * a free choice between 0 and 255.
1093 * 通常不使用,设置为255即可,但可以在0到255之间自由选择
1094 * @param signal_address An integer specifying the address of the either
1095 * the coil or the register that this new signal should reflect. Consult
1096 * the configuration of the modbus unit for this information.
1097 * 指定新信号应该反映的线圈或寄存器的地址。
1098 * 请参考Modbus单元的配置以获取此信息。
1099 * @param signal_type An integer specifying the type of signal to add. 0 =
1100 * digital input, 1 = digital output, 2 = register input and 3 = register
1101 * output.
1102 * 指定要添加的信号类型。
1103 * 0 = 数字输入,1 = 数字输出,2 = 寄存器输入,3 = 寄存器输出。
1104 * @param signal_name A string uniquely identifying the signal. If a
1105 * string is supplied which is equal to an already added signal, the new
1106 * signal will replace the old one. The length of the string cannot exceed
1107 * 20 characters.
1108 * 唯一标识信号的名词。
1109 * 如果提供的字符串与已添加的信号相等,则新信号将替换旧信号。
1110 * 字符串的长度不能超过20个字符。
1111 * @param sequential_mode Setting to True forces the modbus client to wait
1112 * for a response before sending the next request. This mode is required by
1113 * some fieldbus units (Optional).
1114 * 设置为True会强制Modbus客户端在发送下一个请求之前等待响应。
1115 * 某些fieldbus单元需要此模式。
1116 * 可选参数。
1117 * @return
1118 *
1119 * @par Python函数原型
1120 * modbusAddSignal(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int,
1121 * arg2: int, arg3: int, arg4: str, arg5: bool) -> int
1122 *
1123 * @par Lua函数原型
1124 * modbusAddSignal(device_info: string, slave_number: number,
1125 * signal_address: number, signal_type: number, signal_name: string,
1126 * sequential_mode: boolean) -> nil
1127 *
1128 * @par JSON-RPC请求示例
1129 * {"jsonrpc":"2.0","method":"RegisterControl.modbusAddSignal","params":["/dev/ttyRobotTool,
1130 * 115200,N,8,1",1,264,3,"Modbus_0",false],"id":1}
1131 *
1132 * @par JSON-RPC响应示例
1133 * {"id":1,"jsonrpc":"2.0","result":0}
1134 *
1135 */
1136 int modbusAddSignal(const std::string &device_info, int slave_number,
1137 int signal_address, int signal_type,
1138 const std::string &signal_name, bool sequential_mode);
1139
1140 /**
1141 * Deletes the signal identified by the supplied signal name.
1142 * 删除指定名称的信号。
1143 *
1144 * @param signal_name A string equal to the name of the signal that should
1145 * be deleted.
1146 * 要删除的信号的名称
1147 * @return
1148 *
1149 * @par Python函数原型
1150 * modbusDeleteSignal(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
1151 *
1152 * @par Lua函数原型
1153 * modbusDeleteSignal(signal_name: string) -> nil
1154 *
1155 * @par JSON-RPC请求示例
1156 * {"jsonrpc":"2.0","method":"RegisterControl.modbusDeleteSignal","params":["Modbus_1"],"id":1}
1157 *
1158 * @par JSON-RPC响应示例
1159 * {"id":1,"jsonrpc":"2.0","result":0}
1160 *
1161 */
1162 int modbusDeleteSignal(const std::string &signal_name);
1163
1164 /**
1165 * Delete all modbus signals
1166 *
1167 * @return
1168 *
1169 * @par JSON-RPC请求示例
1170 * {"jsonrpc":"2.0","method":"RegisterControl.modbusDeleteAllSignals","params":[],"id":1}
1171 *
1172 * @par JSON-RPC响应示例
1173 * {"id":1,"jsonrpc":"2.0","result":0}
1174 *
1175 */
1177
1178 /**
1179 * Reads the current value of a specific signal.
1180 * 读取特定信号的当前值。
1181 *
1182 * @param signal_name A string equal to the name of the signal for which
1183 * the value should be gotten.
1184 * 要获取值的信号的名称
1185 * @return An integer or a boolean. For digital signals: 1 or 0. For
1186 * register signals: The register value expressed as an integer.If the
1187 * value is -1, it means the signal does not exist
1188 * 对于数字信号:1或0。
1189 * 对于寄存器信号:表示为整数的寄存器值。如果值为-1,则表示该信号不存在。
1190 *
1191 * @par Python函数原型
1192 * modbusGetSignalStatus(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
1193 *
1194 * @par Lua函数原型
1195 * modbusGetSignalStatus(signal_name: string) -> nil
1196 *
1197 * @par JSON-RPC请求示例
1198 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalStatus","params":["Modbus_0"],"id":1}
1199 *
1200 * @par JSON-RPC响应示例
1201 * {"id":1,"jsonrpc":"2.0","result":1}
1202 *
1203 */
1204 int modbusGetSignalStatus(const std::string &signal_name);
1205
1206 /**
1207 * 获取所有信号的名字集合
1208 *
1209 * @return 所有信号的名字集合
1210 *
1211 * @par JSON-RPC请求示例
1212 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalNames","params":[],"id":1}
1213 *
1214 * @par JSON-RPC响应示例
1215 * {"id":1,"jsonrpc":"2.0","result":["Modbus_0"]}
1216 *
1217 */
1218 std::vector<std::string> modbusGetSignalNames();
1219
1220 /**
1221 * 获取所有信号的类型集合
1222 *
1223 * @return 所有信号的类型集合
1224 *
1225 * @par JSON-RPC请求示例
1226 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalTypes","params":[],"id":1}
1227 *
1228 * @par JSON-RPC响应示例
1229 * {"id":1,"jsonrpc":"2.0","result":[1,0,2,3]}
1230 *
1231 */
1232 std::vector<int> modbusGetSignalTypes();
1233
1234 /**
1235 * 获取所有信号的数值集合
1236 *
1237 * @return 所有信号的数值集合
1238 *
1239 * @par JSON-RPC请求示例
1240 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalValues","params":[],"id":1}
1241 *
1242 * @par JSON-RPC响应示例
1243 * {"id":1,"jsonrpc":"2.0","result":[1,1,88,33]}
1244 *
1245 */
1246 std::vector<int> modbusGetSignalValues();
1247
1248 /**
1249 * 获取所有信号的请求是否有错误(0:无错误,其他:有错误)集合
1250 *
1251 * @return ModbusErrorNum
1252 *
1253 * @par JSON-RPC请求示例
1254 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalErrors","params":[],"id":1}
1255 *
1256 * @par JSON-RPC响应示例
1257 * {"id":1,"jsonrpc":"2.0","result":[6,6,6,6]}
1258 *
1259 */
1260 std::vector<int> modbusGetSignalErrors();
1261
1262 /**
1263 * Sends a command specified by the user to the modbus unit located on the
1264 * specified IP address. Cannot be used to request data, since the response
1265 * will not be received. The user is responsible for supplying data which
1266 * is meaningful to the supplied function code. The builtin function takes
1267 * care of constructing the modbus frame, so the user should not be
1268 * concerned with the length of the command.
1269 *
1270 * 将用户指定的命令发送到指定IP地址上的Modbus单元。
1271 * 由于不会接收到响应,因此不能用于请求数据。
1272 * 用户负责提供对所提供的功能码有意义的数据。
1273 * 内置函数负责构建Modbus帧,因此用户不需要关心命令的长度。
1274 *
1275 * @param device_info is rtu format.
1276 * eg,"serial_port,baud,parity,data_bit,stop_bit" \n
1277 * (1)The serial_port argument specifies the name of the serial port eg. On
1278 * Linux
1279 * ,"/dev/ttyS0" or "/dev/ttyUSB0". On Windows,
1280 * \\.\COM10". \n
1281 * (2)The baud argument specifies the baud rate of the communication, eg.
1282 * 9600, 19200, 57600, 115200, etc. \n
1283 * (3)parity:N for none,E for even,O for odd. \n
1284 * (4)data_bit:The data_bits argument specifies the number of bits of data,
1285 * the allowed values are 5, 6, 7 and 8. \n
1286 * (5)stop_bit:The stop_bits argument
1287 * specifies the bits of stop, the allowed values are 1 and 2.
1288 *
1289 * device_info is tcp format.eg,"ip address,port"
1290 *
1291 * 设备信息 \n
1292 * 设备信息是RTU格式,
1293 * 例如:"serial_port,baud,parity,data_bit,stop_bit" \n
1294 * (1)serial_port参数指定串口的名称,
1295 * 例如,在Linux上为"/dev/ttyS0"或"/dev/ttyUSB0",在Windows上为"\.\COM10"\n
1296 * (2)baud参数指定通信的波特率,例如9600、19200、57600、115200等 \n
1297 * (3)parity参数指定奇偶校验方式,N表示无校验,E表示偶校验,O表示奇校验 \n
1298 * (4)data_bit参数指定数据位数,允许的值为5、6、7和8 \n
1299 * (5)stop_bit参数指定停止位数,允许的值为1和2
1300 *
1301 * 设备信息是TCP格式,例如:"ip address,port" \n
1302 * (1)ip address参数指定服务器的IP地址 \n
1303 * (2)port参数指定服务器监听的端口号
1304 * @param slave_number An integer specifying the slave number to use for
1305 * the custom command.
1306 * 指定用于自定义命令的从站号
1307 * @param function_code An integer specifying the function code for the
1308 * custom command.
1309 * 指定自定义命令的功能码
1310 *
1311 * Modbus function codes
1312 * MODBUS_FC_READ_COILS 0x01
1313 * MODBUS_FC_READ_DISCRETE_INPUTS 0x02
1314 * MODBUS_FC_READ_HOLDING_REGISTERS 0x03
1315 * MODBUS_FC_READ_INPUT_REGISTERS 0x04
1316 * MODBUS_FC_WRITE_SINGLE_COIL 0x05
1317 * MODBUS_FC_WRITE_SINGLE_REGISTER 0x06
1318 * MODBUS_FC_READ_EXCEPTION_STATUS 0x07
1319 * MODBUS_FC_WRITE_MULTIPLE_COILS 0x0F
1320 * MODBUS_FC_WRITE_MULTIPLE_REGISTERS 0x10
1321 * MODBUS_FC_REPORT_SLAVE_ID 0x11
1322 * MODBUS_FC_MASK_WRITE_REGISTER 0x16
1323 * MODBUS_FC_WRITE_AND_READ_REGISTERS 0x17
1324 *
1325 * @param data An array of integers in which each entry must be a valid
1326 * byte (0-255) value.
1327 * 必须是有效的字节值(0-255)
1328 * @return
1329 *
1330 * @par Python函数原型
1331 * modbusSendCustomCommand(self: pyaubo_sdk.RegisterControl, arg0: str,
1332 * arg1: int, arg2: int, arg3: List[int]) -> int
1333 *
1334 * @par Lua函数原型
1335 * modbusSendCustomCommand(device_info: string, slave_number: number,
1336 * function_code: number, data: table) -> nil
1337 *
1338 * @par JSON-RPC请求示例
1339 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSendCustomCommand","params":["/dev/ttyRobotTool,115200,N,8,1",1,10,[1,2,0,2,4,0,0,0,0]],"id":1}
1340 *
1341 * @par JSON-RPC响应示例
1342 * {"id":1,"jsonrpc":"2.0","result":0}
1343 *
1344 */
1345 int modbusSendCustomCommand(const std::string &device_info,
1346 int slave_number, int function_code,
1347 const std::vector<uint8_t> &data);
1348
1349 /**
1350 * Sets the selected digital input signal to either a "default" or
1351 * "freedrive" action.
1352 * 将选择的数字输入信号设置为“default”或“freedrive”
1353 *
1354 * @param robot_name A string identifying a robot name that conncted robot
1355 * 连接的机器人名称
1356 * @param signal_name A string identifying a digital input signal that was
1357 * previously added.
1358 * 先前被添加的数字输入信号
1359 * @param action The type of action. The action can either be "default" or
1360 * "freedrive". (string)
1361 * 操作类型。操作可以是“default”或“freedrive”
1362 * @return
1363 *
1364 * @par Python函数原型
1365 * modbusSetDigitalInputAction(self: pyaubo_sdk.RegisterControl, arg0: str,
1366 * arg1: str, arg2: int)
1367 *
1368 * @par Lua函数原型
1369 * modbusSetDigitalInputAction(robot_name: string, signal_name: string,
1370 * action: number) -> nil
1371 *
1372 * @par JSON-RPC请求示例
1373 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSetDigitalInputAction","params":["rob1","Modbus_0","Handguide"],"id":1}
1374 *
1375 * @par JSON-RPC响应示例
1376 * {"id":1,"jsonrpc":"2.0","result":0}
1377 *
1378 */
1379 int modbusSetDigitalInputAction(const std::string &robot_name,
1380 const std::string &signal_name,
1381 StandardInputAction action);
1382
1383 /**
1384 * 设置 Modbus 信号输出动作
1385 *
1386 * @param robot_name
1387 * @param signal_name
1388 * @param runstate
1389 * @return
1390 *
1391 * @par JSON-RPC请求示例
1392 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSetOutputRunstate","params":["rob1","Modbus_0","None"],"id":1}
1393 *
1394 * @par JSON-RPC响应示例
1395 * {"id":1,"jsonrpc":"2.0","result":0}
1396 *
1397 */
1398 int modbusSetOutputRunstate(const std::string &robot_name,
1399 const std::string &signal_name,
1400 StandardOutputRunState runstate);
1401
1402 /**
1403 * Sets the output register signal identified by the given name to the
1404 * given value.
1405 * 将指定名称的输出寄存器信号设置为给定的值
1406 *
1407 * @param signal_name A string identifying an output register signal that
1408 * in advance has been added.
1409 * 提前被添加的输出寄存器信号
1410 * @param value An integer which must be a valid word (0-65535)
1411 * 必须是有效的整数,范围是 0-65535
1412 * @return
1413 *
1414 * @par Python函数原型
1415 * modbusSetOutputSignal(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
1416 * int) -> int
1417 *
1418 * @par Lua函数原型
1419 * modbusSetOutputSignal(signal_name: string, value: number) -> nil
1420 *
1421 * @par JSON-RPC请求示例
1422 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSetOutputSignal","params":["Modbus_0",0],"id":1}
1423 *
1424 * @par JSON-RPC响应示例
1425 * {"id":1,"jsonrpc":"2.0","result":0}
1426 *
1427 */
1428 int modbusSetOutputSignal(const std::string &signal_name, uint16_t value);
1429
1430 /**
1431 * 设置modbus信号输出脉冲(仅支持线圈输出类型)
1432 *
1433 * @param signal_name: A string identifying an output register signal that
1434 * in advance has been added.
1435 * 提前被添加的输出寄存器信号
1436 * @param value: An integer which must be a valid word (0-65535)
1437 * 必须是有效的整数,范围是 0-65535
1438 * @param duration: Duration of the signal, in seconds
1439 * @return
1440 *
1441 * @par Python函数原型
1442 * modbusSetOutputSignalPulse(self: pyaubo_sdk.RegisterControl, arg0: str,
1443 * arg1: int, arg2 double) -> int
1444 *
1445 * @par Lua函数原型
1446 * modbusSetOutputSignalPulse(signal_name: string, value: number, duration:
1447 * number) -> nil
1448 *
1449 * @par JSON-RPC请求示例
1450 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSetOutputSignalPulse","params":["Modbus_0",1,0.5],"id":1}
1451 *
1452 * @par JSON-RPC响应示例
1453 * {"id":1,"jsonrpc":"2.0","result":0}
1454 *
1455 */
1456 int modbusSetOutputSignalPulse(const std::string &signal_name,
1457 uint16_t value, double duration);
1458
1459 /**
1460 * Sets the frequency with which the robot will send requests to the Modbus
1461 * controller to either read or write the signal value.
1462 * 设置机器人向Modbus控制器发送请求的频率,用于读取或写入信号值
1463 *
1464 * @param signal_name A string identifying an output digital signal that
1465 * in advance has been added.
1466 * 提前被添加的输出数字信号
1467 * @param update_frequency An integer in the range 0-125 specifying the
1468 * update frequency in Hz.
1469 * 更新频率(以赫兹为单位),范围是0-125
1470 * @return
1471 *
1472 * @par Python函数原型
1473 * modbusSetSignalUpdateFrequency(self: pyaubo_sdk.RegisterControl, arg0:
1474 * str, arg1: int) -> int
1475 *
1476 * @par Lua函数原型
1477 * modbusSetSignalUpdateFrequency(signal_name: string, update_frequency:
1478 * number) -> nil
1479 *
1480 * @par JSON-RPC请求示例
1481 * {"jsonrpc":"2.0","method":"RegisterControl.modbusSetSignalUpdateFrequency","params":["Modbus_0",1],"id":1}
1482 *
1483 * @par JSON-RPC响应示例
1484 * {"id":1,"jsonrpc":"2.0","result":0}
1485 *
1486 */
1487 int modbusSetSignalUpdateFrequency(const std::string &signal_name,
1488 int update_frequency);
1489
1490 /**
1491 * 获取指定 modbus 信号索引,从0开始,不能存在则返回-1
1492 *
1493 * @param signal_name
1494 * @return
1495 *
1496 * @par JSON-RPC请求示例
1497 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalIndex","params":["Modbus_0"],"id":1}
1498 *
1499 * @par JSON-RPC响应示例
1500 * {"id":1,"jsonrpc":"2.0","result":0}
1501 *
1502 */
1503 int modbusGetSignalIndex(const std::string &signal_name);
1504
1505 /**
1506 * 获取指定 modbus 信号的错误状态
1507 *
1508 * @param signal_name
1509 * @return 返回错误代码 ModbusErrorNum
1510 *
1511 * @par JSON-RPC请求示例
1512 * {"jsonrpc":"2.0","method":"RegisterControl.modbusGetSignalError","params":["Modbus_0"],"id":1}
1513 *
1514 * @par JSON-RPC响应示例
1515 * {"id":1,"jsonrpc":"2.0","result":6}
1516 *
1517 */
1518 int modbusGetSignalError(const std::string &signal_name);
1519
1520 /**
1521 * 获取指定 modbus 设备的连接状态
1522 *
1523 * @param device_name
1524 * 设备名是TCP格式,"ip:port", 例如:"127.0.0.1:502" \n
1525 * 设备名是RTU格式,"serial_port", 例如:"/dev/ttyUSB0" \n
1526 *
1527 * @return
1528 * 0: 表示设备处于连接状态
1529 * -1: 表示设备不存在
1530 * -2: 表示设备处于断开状态
1531 *
1532 * @par JSON-RPC请求示例
1533 * {"jsonrpc":"2.0","method":"RegisterControl.getModbusDeviceStatus","params":["172.16.26.248:502"],"id":1}
1534 *
1535 * @par JSON-RPC响应示例
1536 * {"id":1,"jsonrpc":"2.0","result":0}
1537 *
1538 */
1539 int getModbusDeviceStatus(const std::string &device_name);
1540
1541 /**
1542 * 将某个 modbus 寄存器信号作为编码器
1543 *
1544 * @param encoder_id 不能为0
1545 * @param signal_name modbus 信号名字,必须为寄存器类型
1546 * @return
1547 */
1548 int addModbusEncoder(int encoder_id, int range_id,
1549 const std::string &signal_name);
1550
1551 /**
1552 * 添加Int32寄存器的虚拟编码器
1553 *
1554 * @param encoder_id
1555 * @param key
1556 * @return
1557 */
1558 int addInt32RegEncoder(int encoder_id, int range_id,
1559 const std::string &key);
1560
1561 /**
1562 * 删除虚拟编码器
1563 *
1564 * @param encoder_id
1565 * @return
1566 */
1567 int deleteVirtualEncoder(int encoder_id);
1568
1569protected:
1570 void *d_;
1571};
1572using RegisterControlPtr = std::shared_ptr<RegisterControl>;
1573
1574// clang-format off
1575#define RegisterControl_DECLARES \
1576 _FUNC(RegisterControl, 1, getBoolInput, address) \
1577 _INST(RegisterControl, 2, setBoolInput, address, value) \
1578 _FUNC(RegisterControl, 1, getInt32Input, address) \
1579 _INST(RegisterControl, 2, setInt32Input, address, value) \
1580 _FUNC(RegisterControl, 1, getFloatInput, address) \
1581 _INST(RegisterControl, 2, setFloatInput, address, value) \
1582 _FUNC(RegisterControl, 1, getDoubleInput, address) \
1583 _INST(RegisterControl, 2, setDoubleInput, address, value) \
1584 _FUNC(RegisterControl, 1, getBoolOutput, address) \
1585 _INST(RegisterControl, 2, setBoolOutput, address, value) \
1586 _FUNC(RegisterControl, 1, getInt32Output, address) \
1587 _INST(RegisterControl, 2, setInt32Output, address, value) \
1588 _FUNC(RegisterControl, 1, getFloatOutput, address) \
1589 _INST(RegisterControl, 2, setFloatOutput, address, value) \
1590 _FUNC(RegisterControl, 1, getDoubleOutput, address) \
1591 _INST(RegisterControl, 2, setDoubleOutput, address, value) \
1592 _FUNC(RegisterControl, 1, getInt16Register, address) \
1593 _INST(RegisterControl, 2, setInt16Register, address, value) \
1594 _FUNC(RegisterControl, 2, variableUpdated, key, since) \
1595 _FUNC(RegisterControl, 1, hasNamedVariable, key) \
1596 _FUNC(RegisterControl, 1, getNamedVariableType, key) \
1597 _FUNC(RegisterControl, 2, getBool, key, default_value) \
1598 _INST(RegisterControl, 2, setBool, key, value) \
1599 _FUNC(RegisterControl, 2, getVecChar, key, default_value) \
1600 _INST(RegisterControl, 2, setVecChar, key, value) \
1601 _FUNC(RegisterControl, 2, getInt32, key, default_value) \
1602 _INST(RegisterControl, 2, setInt32, key, value) \
1603 _FUNC(RegisterControl, 2, getVecInt32, key, default_value) \
1604 _INST(RegisterControl, 2, setVecInt32, key, value) \
1605 _FUNC(RegisterControl, 2, getFloat, key, default_value) \
1606 _INST(RegisterControl, 2, setFloat, key, value) \
1607 _FUNC(RegisterControl, 2, getVecFloat, key, default_value) \
1608 _INST(RegisterControl, 2, setVecFloat, key, value) \
1609 _FUNC(RegisterControl, 2, getDouble, key, default_value) \
1610 _INST(RegisterControl, 2, setDouble, key, value) \
1611 _FUNC(RegisterControl, 2, getVecDouble, key, default_value) \
1612 _INST(RegisterControl, 2, setVecDouble, key, value) \
1613 _FUNC(RegisterControl, 2, getString, key, default_value) \
1614 _INST(RegisterControl, 2, setString, key, value) \
1615 _INST(RegisterControl, 1, clearNamedVariable, key) \
1616 _INST(RegisterControl, 3, setWatchDog, key, timeout, action) \
1617 _FUNC(RegisterControl, 1, getWatchDogAction, key) \
1618 _FUNC(RegisterControl, 1, getWatchDogTimeout, key) \
1619 _INST(RegisterControl, 6, modbusAddSignal, device_info, slave_number, signal_address, signal_type, signal_name, sequential_mode) \
1620 _INST(RegisterControl, 1, modbusDeleteSignal, signal_name) \
1621 _INST(RegisterControl, 0, modbusDeleteAllSignals) \
1622 _FUNC(RegisterControl, 1, modbusGetSignalStatus, signal_name) \
1623 _FUNC(RegisterControl, 0, modbusGetSignalNames) \
1624 _FUNC(RegisterControl, 0, modbusGetSignalTypes) \
1625 _FUNC(RegisterControl, 0, modbusGetSignalValues) \
1626 _FUNC(RegisterControl, 0, modbusGetSignalErrors) \
1627 _INST(RegisterControl, 4, modbusSendCustomCommand, IP, slave_number, function_code, data) \
1628 _INST(RegisterControl, 3, modbusSetDigitalInputAction, robot_name, signal_name, action) \
1629 _INST(RegisterControl, 3, modbusSetOutputRunstate, robot_name, signal_name, runstate) \
1630 _INST(RegisterControl, 2, modbusSetOutputSignal, signal_name, value) \
1631 _INST(RegisterControl, 3, modbusSetOutputSignalPulse, signal_name, value, duration) \
1632 _INST(RegisterControl, 2, modbusSetSignalUpdateFrequency, signal_name, update_frequency) \
1633 _FUNC(RegisterControl, 1, modbusGetSignalIndex, signal_name) \
1634 _FUNC(RegisterControl, 1, modbusGetSignalError, signal_name) \
1635 _FUNC(RegisterControl, 1, getModbusDeviceStatus, device_name) \
1636 _FUNC(RegisterControl, 3, addModbusEncoder, encoder_id, range_id, signal_name) \
1637 _FUNC(RegisterControl, 3, addInt32RegEncoder, encoder_id, range_id, key) \
1638 _FUNC(RegisterControl, 1, deleteVirtualEncoder, encoder_id)
1639
1640// clang-format on
1641} // namespace common_interface
1642} // namespace arcs
1643
1644#endif // AUBO_SDK_REGISTER_CONTROL_INTERFACE_H
float getFloatOutput(uint32_t address)
Reads the float from one of the output registers, which can also be accessed by a Field bus.
int setVecChar(const std::string &key, const std::vector< char > &value)
设置/更新变量值
int getInt32Output(uint32_t address)
Reads the integer from one of the output registers, which can also be accessed by a Field bus.
int setBool(const std::string &key, bool value)
设置/更新变量值
int deleteVirtualEncoder(int encoder_id)
删除虚拟编码器
int setVecFloat(const std::string &key, const std::vector< float > &value)
设置/更新变量值
int setVecInt32(const std::string &key, const std::vector< int32_t > &value)
设置/更新变量值
int getModbusDeviceStatus(const std::string &device_name)
获取指定 modbus 设备的连接状态
bool getBoolInput(uint32_t address)
Reads the boolean from one of the input registers, which can also be accessed by a Field bus.
bool getBool(const std::string &key, bool default_value)
获取变量值
std::vector< double > getVecDouble(const std::string &key, const std::vector< double > &default_value)
获取变量值
int modbusDeleteAllSignals()
Delete all modbus signals
std::vector< int > modbusGetSignalErrors()
获取所有信号的请求是否有错误(0:无错误,其他:有错误)集合
double getDoubleOutput(uint32_t address)
std::vector< int32_t > getVecInt32(const std::string &key, const std::vector< int32_t > &default_value)
获取变量值
int modbusGetSignalIndex(const std::string &signal_name)
获取指定 modbus 信号索引,从0开始,不能存在则返回-1
int setInt32(const std::string &key, int value)
设置/更新变量值
std::vector< std::string > modbusGetSignalNames()
获取所有信号的名字集合
int modbusAddSignal(const std::string &device_info, int slave_number, int signal_address, int signal_type, const std::string &signal_name, bool sequential_mode)
Adds a new modbus signal for the controller to supervise.
int getWatchDogTimeout(const std::string &key)
获取看门狗超时时间
int getInt32Input(uint32_t address)
Reads the integer from one of the input registers, which can also be accessed by a Field bus.
int setVecDouble(const std::string &key, const std::vector< double > &value)
设置/更新变量值
int setInt16Register(uint32_t address, int16_t value)
float getFloatInput(uint32_t address)
Reads the float from one of the input registers, which can also be accessed by a Field bus.
bool hasNamedVariable(const std::string &key)
具名变量是否存在
int getWatchDogAction(const std::string &key)
获取看门狗动作
std::string getNamedVariableType(const std::string &key)
获取具名变量的类型
std::vector< int > modbusGetSignalTypes()
获取所有信号的类型集合
int16_t getInt16Register(uint32_t address)
用于 Modbus Slave
int setInt32Input(uint32_t address, int value)
int getInt32(const std::string &key, int default_value)
获取变量值
int modbusSetOutputSignal(const std::string &signal_name, uint16_t value)
Sets the output register signal identified by the given name to the given value.
int setString(const std::string &key, const std::string &value)
设置/更新变量值
int modbusGetSignalError(const std::string &signal_name)
获取指定 modbus 信号的错误状态
int setFloat(const std::string &key, float value)
设置/更新变量值
int setDouble(const std::string &key, double value)
设置/更新变量值
int setWatchDog(const std::string &key, double timeout, int action)
设置看门狗
int modbusSetOutputRunstate(const std::string &robot_name, const std::string &signal_name, StandardOutputRunState runstate)
设置 Modbus 信号输出动作
int modbusSetOutputSignalPulse(const std::string &signal_name, uint16_t value, double duration)
设置modbus信号输出脉冲(仅支持线圈输出类型)
double getDouble(const std::string &key, double default_value)
获取变量值
bool getBoolOutput(uint32_t address)
Reads the boolean from one of the output registers, which can also be accessed by a Field bus.
int setDoubleOutput(uint32_t address, double value)
int modbusSendCustomCommand(const std::string &device_info, int slave_number, int function_code, const std::vector< uint8_t > &data)
Sends a command specified by the user to the modbus unit located on the specified IP address.
bool variableUpdated(const std::string &key, uint64_t since)
具名变量是否更新
std::vector< float > getVecFloat(const std::string &key, const std::vector< float > &default_value)
获取变量值
std::vector< int > modbusGetSignalValues()
获取所有信号的数值集合
int addInt32RegEncoder(int encoder_id, int range_id, const std::string &key)
添加Int32寄存器的虚拟编码器
std::string getString(const std::string &key, const std::string &default_value)
获取变量值
int modbusGetSignalStatus(const std::string &signal_name)
Reads the current value of a specific signal.
int addModbusEncoder(int encoder_id, int range_id, const std::string &signal_name)
将某个 modbus 寄存器信号作为编码器
double getDoubleInput(uint32_t address)
int clearNamedVariable(const std::string &key)
清除变量
int modbusSetSignalUpdateFrequency(const std::string &signal_name, int update_frequency)
Sets the frequency with which the robot will send requests to the Modbus controller to either read or...
int setBoolInput(uint32_t address, bool value)
int setInt32Output(uint32_t address, int value)
int setFloatInput(uint32_t address, float value)
int setBoolOutput(uint32_t address, bool value)
int modbusDeleteSignal(const std::string &signal_name)
Deletes the signal identified by the supplied signal name.
int setDoubleInput(uint32_t address, double value)
int setFloatOutput(uint32_t address, float value)
int modbusSetDigitalInputAction(const std::string &robot_name, const std::string &signal_name, StandardInputAction action)
Sets the selected digital input signal to either a "default" or "freedrive" action.
std::vector< char > getVecChar(const std::string &key, const std::vector< char > &default_value)
获取变量值
float getFloat(const std::string &key, float default_value)
获取变量值
std::shared_ptr< RegisterControl > RegisterControlPtr
StandardInputAction
The StandardInputAction enum
Definition type_def.h:498
StandardOutputRunState
标准输出运行状态
Definition type_def.h:490
ModbusErrorNum
@ MB_ERR_NOT_INIT
MODBUS unit not initiallized
@ MB_ERR_SLAVE_DEVICE_BUSY
Specialized use in conjunction with programming commands sent to the remote MODBUS unit,...
@ MB_ERR_ILLEGAL_FUNCTION
The function code received in the query is not an allowable action for the server (or slave).
@ MB_ERR_ILLEGAL_DATA_ADDRESS
The function code received in the query is not an allowable action for the server (or slave),...
@ MB_ERR_DISCONNECTED
MODBUS unit disconnected
@ MB_ERR_SLAVE_DEVICE_FAILURE
An unrecoverable error occurred while the server (or slave) was attempting to perform the requested a...
@ MB_ERR_ILLEGAL_DATA_VALUE
A value contained in the query data field is not an allowable value for server (or slave),...
@ MB_ERR_ACKNOWLEDGE
Specialized use in conjunction with programming commands sent to the remote MODBUS unit.
数据类型的定义