ARCS SDK API  0.24.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 
57 namespace arcs {
58 namespace common_interface {
59 
60 /**
61  * 通用寄存器
62  */
63 class ARCS_ABI_EXPORT RegisterControl
64 {
65 public:
67  virtual ~RegisterControl();
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  */
95  bool getBoolInput(uint32_t address);
96 
97  /**
98  *
99  * @param address
100  * @param value
101  * @return
102  *
103  * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
104  *
105  * @par Python函数原型
106  * setBoolInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: bool) ->
107  * int
108  *
109  * @par Lua函数原型
110  * setBoolInput(address: number, value: boolean) -> nil
111  *
112  */
113  int setBoolInput(uint32_t address, bool value);
114 
115  /**
116  * Reads the integer from one of the input registers, which can also be
117  * accessed by a Field bus. Note, uses it’s own memory space.
118  *
119  * 从一个输入寄存器中读取整数值,也可以通过现场总线进行访问。
120  * 注意,它使用自己的内存空间。
121  *
122  * @param address Address of the register (0:47)
123  * 寄存器的地址(0:47)
124  * @return The value held by the register [-2,147,483,648 : 2,147,483,647]
125  * 寄存器中保存的整数值[-2,147,483,648 : 2,147,483,647]
126  *
127  * @note The lower range of the integer input registers [0:23] is reserved
128  * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
129  * accessed by FieldBus/PLC interfaces, since it is reserved for external
130  * RTDE clients.
131  * 整数输入寄存器的较低范围[0:23]保留供FieldBus/PLC接口使用。
132  * 较高范围[24:47]无法通过FieldBus/PLC接口访问,因为它保留供外部RTDE客户端使用。
133  *
134  * @par Python函数原型
135  * getInt32Input(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
136  *
137  * @par Lua函数原型
138  * getInt32Input(address: number) -> number
139  *
140  */
141  int getInt32Input(uint32_t address);
142 
143  /**
144  *
145  * @param address
146  * @param value
147  * @return
148  *
149  * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
150  *
151  * @par Python函数原型
152  * setInt32Input(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int) ->
153  * int
154  *
155  * @par Lua函数原型
156  * setInt32Input(address: number, value: number) -> nil
157  *
158  */
159  int setInt32Input(uint32_t address, int value);
160 
161  /**
162  * Reads the float from one of the input registers, which can also be
163  * accessed by a Field bus. Note, uses it’s own memory space.
164  *
165  * 从一个输入寄存器中读取浮点数,也可以通过现场总线进行访问。
166  * 注意,它使用自己的内存空间。
167  *
168  * @param address Address of the register (0:47)
169  * 寄存器地址(0:47)
170  * @return The value held by the register (float)
171  * 寄存器中保存的浮点数值
172  *
173  * @note The lower range of the float input registers [0:23] is reserved
174  * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
175  * accessed by FieldBus/PLC interfaces, since it is reserved for external
176  * RTDE clients.
177  * 浮点数输入寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
178  * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
179  *
180  * @par Python函数原型
181  * getFloatInput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
182  *
183  * @par Lua函数原型
184  * getFloatInput(address: number) -> number
185  *
186  */
187  float getFloatInput(uint32_t address);
188 
189  /**
190  *
191  * @param address
192  * @param value
193  * @return
194  *
195  * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
196  *
197  * @par Python函数原型
198  * setFloatInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
199  * -> int
200  *
201  * @par Lua函数原型
202  * setFloatInput(address: number, value: number) -> nil
203  *
204  */
205  int setFloatInput(uint32_t address, float value);
206 
207  /**
208  *
209  * @param address
210  * @return
211  *
212  * @par Python函数原型
213  * getDoubleInput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
214  *
215  * @par Lua函数原型
216  * getDoubleInput(address: number) -> number
217  *
218  */
219  double getDoubleInput(uint32_t address);
220 
221  /**
222  *
223  * @param address
224  * @param value
225  * @return
226  *
227  * @note 只有在实现 RTDE/Modbus Slave/PLC 服务端时使用
228  *
229  * @par Python函数原型
230  * setDoubleInput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
231  * -> int
232  *
233  * @par Lua函数原型
234  * setDoubleInput(address: number, value: number) -> nil
235  *
236  */
237  int setDoubleInput(uint32_t address, double value);
238 
239  /**
240  * Reads the boolean from one of the output registers, which can also be
241  * accessed by a Field bus.
242  * Note, uses it’s own memory space.
243  *
244  * 从一个输出寄存器中读取布尔值,也可以通过现场总线进行访问。
245  * 注意,它使用自己的内存空间。
246  *
247  * @param address Address of the register (0:127)
248  * 寄存器地址(0:127)
249  * @return The boolean value held by the register (true, false)
250  * 寄存器中保存的布尔值(true, false)
251  *
252  * @note The lower range of the boolean output registers [0:63] is reserved
253  * for FieldBus/PLC interface usage. The upper range [64:127] cannot be
254  * accessed by FieldBus/PLC interfaces, since it is reserved for external
255  * RTDE clients
256  * 布尔输出寄存器的较低范围[0:63]保留供现场总线/PLC接口使用。
257  * 较高范围[64:127]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
258  *
259  * @par Python函数原型
260  * getBoolOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> bool
261  *
262  * @par Lua函数原型
263  * getBoolOutput(address: number) -> boolean
264  *
265  */
266  bool getBoolOutput(uint32_t address);
267 
268  /**
269  *
270  * @param address
271  * @param value
272  * @return
273  *
274  * @par Python函数原型
275  * setBoolOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: bool) ->
276  * int
277  *
278  * @par Lua函数原型
279  * setBoolOutput(address: number, value: boolean) -> nil
280  *
281  */
282  int setBoolOutput(uint32_t address, bool value);
283 
284  /**
285  * Reads the integer from one of the output registers, which can also be
286  * accessed by a Field bus. Note, uses it’s own memory space.
287  *
288  * 从一个输出寄存器中读取整数值,也可以通过现场总线进行访问。
289  * 注意,它使用自己的内存空间。
290  *
291  * @param address Address of the register (0:47)
292  * 寄存器地址(0:47)
293  * @return The int value held by the register [-2,147,483,648 :
294  * 2,147,483,647]
295  * 寄存器中保存的整数值(-2,147,483,648 : 2,147,483,647)
296  *
297  * @note The lower range of the integer output registers [0:23] is reserved
298  * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
299  * accessed by FieldBus/PLC interfaces, since it is reserved for external
300  * RTDE clients.
301  * 整数输出寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
302  * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
303  *
304  * @par Python函数原型
305  * getInt32Output(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
306  *
307  * @par Lua函数原型
308  * getInt32Output(address: number) -> number
309  *
310  */
311  int getInt32Output(uint32_t address);
312 
313  /**
314  *
315  * @param address
316  * @param value
317  * @return
318  *
319  * @par Python函数原型
320  * setInt32Output(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int) ->
321  * int
322  *
323  * @par Lua函数原型
324  * setInt32Output(address: number, value: number) -> nil
325  *
326  */
327  int setInt32Output(uint32_t address, int value);
328 
329  /**
330  * Reads the float from one of the output registers, which can also be
331  * accessed by a Field bus. Note, uses it’s own memory space.
332  *
333  * 从一个输出寄存器中读取浮点数,也可以通过现场总线进行访问。
334  * 注意,它使用自己的内存空间。
335  *
336  * @param address Address of the register (0:47)
337  * 寄存器地址(0:47)
338  * @return The value held by the register (float)
339  * 寄存器中保存的浮点数值(float)
340  *
341  * @note The lower range of the float output registers [0:23] is reserved
342  * for FieldBus/PLC interface usage. The upper range [24:47] cannot be
343  * accessed by FieldBus/PLC interfaces, since it is reserved for external
344  * RTDE clients.
345  * 浮点数输出寄存器的较低范围[0:23]保留供现场总线/PLC接口使用。
346  * 较高范围[24:47]不能通过现场总线/PLC接口访问,因为它们是为外部RTDE客户端保留的。
347  *
348  * @par Python函数原型
349  * getFloatOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
350  *
351  * @par Lua函数原型
352  * getFloatOutput(address: number) -> number
353  *
354  */
355  float getFloatOutput(uint32_t address);
356 
357  /**
358  *
359  * @param address
360  * @param value
361  * @return
362  *
363  * @par Python函数原型
364  * setFloatOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
365  * -> int
366  *
367  * @par Lua函数原型
368  * setFloatOutput(address: number, value: number) -> nil
369  *
370  */
371  int setFloatOutput(uint32_t address, float value);
372 
373  /**
374  *
375  * @param address
376  * @return
377  *
378  * @par Python函数原型
379  * getDoubleOutput(self: pyaubo_sdk.RegisterControl, arg0: int) -> float
380  *
381  * @par Lua函数原型
382  * getDoubleOutput(address: number) -> number
383  *
384  */
385  double getDoubleOutput(uint32_t address);
386 
387  /**
388  *
389  * @param address
390  * @param value
391  * @return
392  *
393  * @par Python函数原型
394  * setDoubleOutput(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: float)
395  * -> int
396  *
397  * @par Lua函数原型
398  * setDoubleOutput(address: number, value: number) -> nil
399  *
400  */
401  int setDoubleOutput(uint32_t address, double value);
402 
403  /**
404  * 用于 Modbus Slave
405  *
406  * @param address
407  * @return
408  *
409  * @par Python函数原型
410  * getInt16Register(self: pyaubo_sdk.RegisterControl, arg0: int) -> int
411  *
412  * @par Lua函数原型
413  * getInt16Register(address: number) -> number
414  *
415  */
416  int16_t getInt16Register(uint32_t address);
417 
418  /**
419  *
420  * @param address
421  * @param value
422  * @return
423  *
424  * @par Python函数原型
425  * setInt16Register(self: pyaubo_sdk.RegisterControl, arg0: int, arg1: int)
426  * -> int
427  *
428  * @par Lua函数原型
429  * setInt16Register(address: number, value: number) -> nil
430  *
431  */
432  int setInt16Register(uint32_t address, int16_t value);
433 
434  /**
435  * 具名变量是否存在
436  *
437  * @param key 变量名
438  * @return
439  */
440  bool hasNamedVariable(const std::string &key);
441 
442  /**
443  * 获取具名变量的类型
444  *
445  * @param key
446  * @return
447  */
448  std::string getNamedVariableType(const std::string &key);
449 
450  /**
451  * 具名变量是否更新
452  *
453  * @param key
454  * @param since
455  * @return
456  *
457  * @par Python函数原型
458  * variableUpdated(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int)
459  * -> bool
460  *
461  * @par Lua函数原型
462  * variableUpdated(key: string, since: number) -> boolean
463  *
464  */
465  bool variableUpdated(const std::string &key, uint64_t since);
466 
467  /**
468  * 获取变量值
469  *
470  * @param key
471  * @param default_value
472  * @return
473  *
474  * @par Python函数原型
475  * getBool(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: bool) -> bool
476  *
477  * @par Lua函数原型
478  * getBool(key: string, default_value: boolean) -> boolean
479  *
480  */
481  bool getBool(const std::string &key, bool default_value);
482 
483  /**
484  * 设置/更新变量值
485  *
486  * @param key
487  * @param value
488  * @return
489  *
490  * @par Python函数原型
491  * setBool(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: bool) -> int
492  *
493  * @par Lua函数原型
494  * setBool(key: string, value: boolean) -> nil
495  *
496  */
497  int setBool(const std::string &key, bool value);
498 
499  /**
500  * 获取变量值
501  *
502  * @param key
503  * @param default_value
504  * @return
505  *
506  * @par Python函数原型
507  * getVecChar(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[str])
508  * -> List[str]
509  *
510  * @par Lua函数原型
511  * getVecChar(key: string, default_value: table) -> table
512  *
513  */
514  std::vector<char> getVecChar(const std::string &key,
515  const std::vector<char> &default_value);
516 
517  /**
518  * 设置/更新变量值
519  *
520  * @param key
521  * @param value
522  * @return
523  *
524  * @par Python函数原型
525  * setVecChar(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[str])
526  * -> int
527  *
528  * @par Lua函数原型
529  * setVecChar(key: string, value: table) -> nil
530  *
531  */
532  int setVecChar(const std::string &key, const std::vector<char> &value);
533 
534  /**
535  * 获取变量值
536  *
537  * @param key
538  * @param default_value
539  * @return
540  *
541  * @par Python函数原型
542  * getInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int) -> int
543  *
544  * @par Lua函数原型
545  * getInt32(key: string, default_value: number) -> number
546  *
547  */
548  int getInt32(const std::string &key, int default_value);
549 
550  /**
551  * 设置/更新变量值
552  *
553  * @param key
554  * @param value
555  * @return
556  *
557  * @par Python函数原型
558  * setInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int) -> int
559  *
560  * @par Lua函数原型
561  * setInt32(key: string, value: number) -> nil
562  *
563  */
564  int setInt32(const std::string &key, int value);
565 
566  /**
567  * 获取变量值
568  *
569  * @param key
570  * @param default_value
571  * @return
572  *
573  * @par Python函数原型
574  * getVecInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[int])
575  * -> List[int]
576  *
577  * @par Lua函数原型
578  * getVecInt32(key: string, default_value: table) -> table
579  *
580  */
581  std::vector<int32_t> getVecInt32(const std::string &key,
582  const std::vector<int32_t> &default_value);
583 
584  /**
585  * 设置/更新变量值
586  *
587  * @param key
588  * @param value
589  * @return
590  *
591  * @par Python函数原型
592  * setVecInt32(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: List[int])
593  * -> int
594  *
595  * @par Lua函数原型
596  * setVecInt32(key: string, value: table) -> nil
597  *
598  */
599  int setVecInt32(const std::string &key, const std::vector<int32_t> &value);
600 
601  /**
602  * 获取变量值
603  *
604  * @param key
605  * @param default_value
606  * @return
607  *
608  * @par Python函数原型
609  * getFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
610  * float
611  *
612  * @par Lua函数原型
613  * getFloat(key: string, default_value: number) -> number
614  *
615  */
616  float getFloat(const std::string &key, float default_value);
617 
618  /**
619  * 设置/更新变量值
620  *
621  * @param key
622  * @param value
623  * @return
624  *
625  * @par Python函数原型
626  * setFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) -> int
627  *
628  * @par Lua函数原型
629  * setFloat(key: string, value: number) -> nil
630  *
631  */
632  int setFloat(const std::string &key, float value);
633 
634  /**
635  * 获取变量值
636  *
637  * @param key
638  * @param default_value
639  * @return
640  *
641  * @par Python函数原型
642  * getVecFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
643  * List[float]) -> List[float]
644  *
645  * @par Lua函数原型
646  * getVecFloat(key: string, default_value: table) -> table
647  *
648  */
649  std::vector<float> getVecFloat(const std::string &key,
650  const std::vector<float> &default_value);
651 
652  /**
653  * 设置/更新变量值
654  *
655  * @param key
656  * @param value
657  * @return
658  *
659  * @par Python函数原型
660  * setVecFloat(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
661  * List[float]) -> int
662  *
663  * @par Lua函数原型
664  * setVecFloat(key: string, value: table) -> nil
665  *
666  */
667  int setVecFloat(const std::string &key, const std::vector<float> &value);
668 
669  /**
670  * 获取变量值
671  *
672  * @param key
673  * @param default_value
674  * @return
675  *
676  * @par Python函数原型
677  * getDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
678  * float
679  *
680  * @par Lua函数原型
681  * getDouble(key: string, default_value: number) -> number
682  *
683  */
684  double getDouble(const std::string &key, double default_value);
685 
686  /**
687  * 设置/更新变量值
688  *
689  * @param key
690  * @param value
691  * @return
692  *
693  * @par Python函数原型
694  * setDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: float) ->
695  * int
696  *
697  * @par Lua函数原型
698  * setDouble(key: string, value: number) -> nil
699  *
700  */
701  int setDouble(const std::string &key, double value);
702 
703  /**
704  * 获取变量值
705  *
706  * @param key
707  * @param default_value
708  * @return
709  *
710  * @par Python函数原型
711  * getVecDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
712  * List[float]) -> List[float]
713  *
714  * @par Lua函数原型
715  * getVecDouble(key: string, default_value: table) -> table
716  *
717  */
718  std::vector<double> getVecDouble(const std::string &key,
719  const std::vector<double> &default_value);
720 
721  /**
722  * 设置/更新变量值
723  *
724  * @param key
725  * @param value
726  * @return
727  *
728  * @par Python函数原型
729  * setVecDouble(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
730  * List[float]) -> int
731  *
732  * @par Lua函数原型
733  * setVecDouble(key: string, value: table) -> nil
734  *
735  */
736  int setVecDouble(const std::string &key, const std::vector<double> &value);
737 
738  /**
739  * 获取变量值
740  *
741  * @param key
742  * @param default_value
743  * @return
744  *
745  * @par Python函数原型
746  * getString(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: str) -> str
747  *
748  * @par Lua函数原型
749  * getString(key: string, default_value: string) -> string
750  *
751  */
752  std::string getString(const std::string &key,
753  const std::string &default_value);
754 
755  /**
756  * 设置/更新变量值
757  *
758  * @param key
759  * @param value
760  * @return
761  *
762  * @par Python函数原型
763  * setString(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: str) -> int
764  *
765  * @par Lua函数原型
766  * setString(key: string, value: string) -> nil
767  *
768  */
769  int setString(const std::string &key, const std::string &value);
770 
771  /**
772  * 清除变量
773  *
774  * @param key
775  * @return
776  *
777  * @par Python函数原型
778  * clearNamedVariable(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
779  *
780  * @par Lua函数原型
781  * clearNamedVariable(key: string) -> nil
782  *
783  */
784  int clearNamedVariable(const std::string &key);
785 
786  /**
787  * 设置看门狗
788  *
789  * 看门狗被触发之后控制器会执行对应的动作,并自动删除看门狗
790  *
791  * @param key
792  * @param timeout 超时时间,单位秒(s),超时时间最小为 0.1s
793  * @param action
794  * NONE (0): 无动作
795  * PAUSE(1): 暂停运行时
796  * STOP (2): 停止运行时/停止机器人运动
797  * PROTECTIVE_STOP (3): 触发防护停止
798  * @return
799  */
800  int setWatchDog(const std::string &key, double timeout, int action);
801 
802  /**
803  * 获取看门狗动作
804  *
805  * @param key
806  * @return
807  */
808  int getWatchDogAction(const std::string &key);
809 
810  /**
811  * 获取看门狗超时时间
812  *
813  * @param key
814  * @return
815  */
816  int getWatchDogTimeout(const std::string &key);
817 
818  /**
819  * Adds a new modbus signal for the controller to supervise. Expects no
820  * response.
821  *
822  * 添加一个新的Modbus信号以供控制器监视。不需要返回响应。
823  *
824  * @param device_info is rtu format.
825  * eg,"serial_port,baud,parity,data_bit,stop_bit" \n (1)The serial_port
826  * argument specifies the name of the serial port eg. On Linux ,"/dev/ttyS0"
827  * or "/dev/ttyUSB0". On Windows,
828  * \\.\COM10". \n
829  * (2)The baud argument specifies the baud rate of the communication, eg.
830  * 9600, 19200, 57600, 115200, etc. \n
831  * (3)parity:N for none,E for even,O for odd. \n
832  * (4)data_bit:The data_bits argument specifies the number of bits of data,
833  * the allowed values are 5, 6, 7 and 8. \n
834  * (5)stop_bit:The stop_bits argument
835  * specifies the bits of stop, the allowed values are 1 and 2.
836  *
837  * device_info is tcp format.eg,"ip address,port" \n
838  * (1)The ip address parameter specifies the ip address of the server \n
839  * (2)The port parameter specifies the port number that the server is
840  * listening on.
841  *
842  * 设备信息 \n
843  * 设备信息是RTU格式,
844  * 例如:"serial_port,baud,parity,data_bit,stop_bit" \n
845  * (1)serial_port参数指定串口的名称,
846  * 例如,在Linux上为"/dev/ttyS0"或"/dev/ttyUSB0",在Windows上为"\.\COM10"\n
847  * (2)baud参数指定通信的波特率,例如9600、19200、57600、115200等 \n
848  * (3)parity参数指定奇偶校验方式,N表示无校验,E表示偶校验,O表示奇校验 \n
849  * (4)data_bit参数指定数据位数,允许的值为5、6、7和8 \n
850  * (5)stop_bit参数指定停止位数,允许的值为1和2
851  *
852  * 设备信息是TCP格式,例如:"ip address,port" \n
853  * (1)ip address参数指定服务器的IP地址 \n
854  * (2)port参数指定服务器监听的端口号
855  * @param slave_number An integer normally not used and set to 255, but is
856  * a free choice between 0 and 255.
857  * 通常不使用,设置为255即可,但可以在0到255之间自由选择
858  * @param signal_address An integer specifying the address of the either
859  * the coil or the register that this new signal should reflect. Consult
860  * the configuration of the modbus unit for this information.
861  * 指定新信号应该反映的线圈或寄存器的地址。
862  * 请参考Modbus单元的配置以获取此信息。
863  * @param signal_type An integer specifying the type of signal to add. 0 =
864  * digital input, 1 = digital output, 2 = register input and 3 = register
865  * output.
866  * 指定要添加的信号类型。
867  * 0 = 数字输入,1 = 数字输出,2 = 寄存器输入,3 = 寄存器输出。
868  * @param signal_name A string uniquely identifying the signal. If a
869  * string is supplied which is equal to an already added signal, the new
870  * signal will replace the old one. The length of the string cannot exceed
871  * 20 characters.
872  * 唯一标识信号的名词。
873  * 如果提供的字符串与已添加的信号相等,则新信号将替换旧信号。
874  * 字符串的长度不能超过20个字符。
875  * @param sequential_mode Setting to True forces the modbus client to wait
876  * for a response before sending the next request. This mode is required by
877  * some fieldbus units (Optional).
878  * 设置为True会强制Modbus客户端在发送下一个请求之前等待响应。
879  * 某些fieldbus单元需要此模式。
880  * 可选参数。
881  * @return
882  *
883  * @par Python函数原型
884  * modbusAddSignal(self: pyaubo_sdk.RegisterControl, arg0: str, arg1: int,
885  * arg2: int, arg3: int, arg4: str, arg5: bool) -> int
886  *
887  * @par Lua函数原型
888  * modbusAddSignal(device_info: string, slave_number: number,
889  * signal_address: number, signal_type: number, signal_name: string,
890  * sequential_mode: boolean) -> nil
891  *
892  */
893  int modbusAddSignal(const std::string &device_info, int slave_number,
894  int signal_address, int signal_type,
895  const std::string &signal_name, bool sequential_mode);
896 
897  /**
898  * Deletes the signal identified by the supplied signal name.
899  * 删除指定名称的信号。
900  *
901  * @param signal_name A string equal to the name of the signal that should
902  * be deleted.
903  * 要删除的信号的名称
904  * @return
905  *
906  * @par Python函数原型
907  * modbusDeleteSignal(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
908  *
909  * @par Lua函数原型
910  * modbusDeleteSignal(signal_name: string) -> nil
911  *
912  */
913  int modbusDeleteSignal(const std::string &signal_name);
914 
915  /**
916  * Delete all modbus signals
917  *
918  * @return
919  */
920  int modbusDeleteAllSignals();
921 
922  /**
923  * Reads the current value of a specific signal.
924  * 读取特定信号的当前值。
925  *
926  * @param signal_name A string equal to the name of the signal for which
927  * the value should be gotten.
928  * 要获取值的信号的名称
929  * @return An integer or a boolean. For digital signals: 1 or 0. For
930  * register signals: The register value expressed as an integer.If the
931  * value is -1, it means the signal does not exist
932  * 对于数字信号:1或0。
933  * 对于寄存器信号:表示为整数的寄存器值。如果值为-1,则表示该信号不存在。
934  *
935  * @par Python函数原型
936  * modbusGetSignalStatus(self: pyaubo_sdk.RegisterControl, arg0: str) -> int
937  *
938  * @par Lua函数原型
939  * modbusGetSignalStatus(signal_name: string) -> nil
940  *
941  */
942  int modbusGetSignalStatus(const std::string &signal_name);
943 
944  /**
945  * 获取所有信号的名字集合
946  *
947  * @return 所有信号的名字集合
948  */
949  std::vector<std::string> modbusGetSignalNames();
950 
951  /**
952  * 获取所有信号的类型集合
953  *
954  * @return 所有信号的类型集合
955  */
956  std::vector<int> modbusGetSignalTypes();
957 
958  /**
959  * 获取所有信号的数值集合
960  *
961  * @return 所有信号的数值集合
962  */
963  std::vector<int> modbusGetSignalValues();
964 
965  /**
966  * 获取所有信号的请求是否有错误(0:无错误,其他:有错误)集合
967  *
968  * @return ModbusErrorNum
969  */
970  std::vector<int> modbusGetSignalErrors();
971 
972  /**
973  * Sends a command specified by the user to the modbus unit located on the
974  * specified IP address. Cannot be used to request data, since the response
975  * will not be received. The user is responsible for supplying data which
976  * is meaningful to the supplied function code. The builtin function takes
977  * care of constructing the modbus frame, so the user should not be
978  * concerned with the length of the command.
979  *
980  * 将用户指定的命令发送到指定IP地址上的Modbus单元。
981  * 由于不会接收到响应,因此不能用于请求数据。
982  * 用户负责提供对所提供的功能码有意义的数据。
983  * 内置函数负责构建Modbus帧,因此用户不需要关心命令的长度。
984  *
985  * @param device_info is rtu format.
986  * eg,"serial_port,baud,parity,data_bit,stop_bit" \n
987  * (1)The serial_port argument specifies the name of the serial port eg. On
988  * Linux
989  * ,"/dev/ttyS0" or "/dev/ttyUSB0". On Windows,
990  * \\.\COM10". \n
991  * (2)The baud argument specifies the baud rate of the communication, eg.
992  * 9600, 19200, 57600, 115200, etc. \n
993  * (3)parity:N for none,E for even,O for odd. \n
994  * (4)data_bit:The data_bits argument specifies the number of bits of data,
995  * the allowed values are 5, 6, 7 and 8. \n
996  * (5)stop_bit:The stop_bits argument
997  * specifies the bits of stop, the allowed values are 1 and 2.
998  *
999  * device_info is tcp format.eg,"ip address,port"
1000  *
1001  * 设备信息 \n
1002  * 设备信息是RTU格式,
1003  * 例如:"serial_port,baud,parity,data_bit,stop_bit" \n
1004  * (1)serial_port参数指定串口的名称,
1005  * 例如,在Linux上为"/dev/ttyS0"或"/dev/ttyUSB0",在Windows上为"\.\COM10"\n
1006  * (2)baud参数指定通信的波特率,例如9600、19200、57600、115200等 \n
1007  * (3)parity参数指定奇偶校验方式,N表示无校验,E表示偶校验,O表示奇校验 \n
1008  * (4)data_bit参数指定数据位数,允许的值为5、6、7和8 \n
1009  * (5)stop_bit参数指定停止位数,允许的值为1和2
1010  *
1011  * 设备信息是TCP格式,例如:"ip address,port" \n
1012  * (1)ip address参数指定服务器的IP地址 \n
1013  * (2)port参数指定服务器监听的端口号
1014  * @param slave_number An integer specifying the slave number to use for
1015  * the custom command.
1016  * 指定用于自定义命令的从站号
1017  * @param function_code An integer specifying the function code for the
1018  * custom command.
1019  * 指定自定义命令的功能码
1020  *
1021  * Modbus function codes
1022  * MODBUS_FC_READ_COILS 0x01
1023  * MODBUS_FC_READ_DISCRETE_INPUTS 0x02
1024  * MODBUS_FC_READ_HOLDING_REGISTERS 0x03
1025  * MODBUS_FC_READ_INPUT_REGISTERS 0x04
1026  * MODBUS_FC_WRITE_SINGLE_COIL 0x05
1027  * MODBUS_FC_WRITE_SINGLE_REGISTER 0x06
1028  * MODBUS_FC_READ_EXCEPTION_STATUS 0x07
1029  * MODBUS_FC_WRITE_MULTIPLE_COILS 0x0F
1030  * MODBUS_FC_WRITE_MULTIPLE_REGISTERS 0x10
1031  * MODBUS_FC_REPORT_SLAVE_ID 0x11
1032  * MODBUS_FC_MASK_WRITE_REGISTER 0x16
1033  * MODBUS_FC_WRITE_AND_READ_REGISTERS 0x17
1034  *
1035  * @param data An array of integers in which each entry must be a valid
1036  * byte (0-255) value.
1037  * 必须是有效的字节值(0-255)
1038  * @return
1039  *
1040  * @par Python函数原型
1041  * modbusSendCustomCommand(self: pyaubo_sdk.RegisterControl, arg0: str,
1042  * arg1: int, arg2: int, arg3: List[int]) -> int
1043  *
1044  * @par Lua函数原型
1045  * modbusSendCustomCommand(device_info: string, slave_number: number,
1046  * function_code: number, data: table) -> nil
1047  *
1048  */
1049  int modbusSendCustomCommand(const std::string &device_info,
1050  int slave_number, int function_code,
1051  const std::vector<uint8_t> &data);
1052 
1053  /**
1054  * Sets the selected digital input signal to either a "default" or
1055  * "freedrive" action.
1056  * 将选择的数字输入信号设置为“default”或“freedrive”
1057  *
1058  * @param robot_name A string identifying a robot name that conncted robot
1059  * 连接的机器人名称
1060  * @param signal_name A string identifying a digital input signal that was
1061  * previously added.
1062  * 先前被添加的数字输入信号
1063  * @param action The type of action. The action can either be "default" or
1064  * "freedrive". (string)
1065  * 操作类型。操作可以是“default”或“freedrive”
1066  * @return
1067  *
1068  * @par Python函数原型
1069  * modbusSetDigitalInputAction(self: pyaubo_sdk.RegisterControl, arg0: str,
1070  * arg1: str, arg2: int)
1071  *
1072  * @par Lua函数原型
1073  * modbusSetDigitalInputAction(robot_name: string, signal_name: string,
1074  * action: number) -> nil
1075  *
1076  */
1077  int modbusSetDigitalInputAction(const std::string &robot_name,
1078  const std::string &signal_name,
1079  StandardInputAction action);
1080 
1081  /**
1082  * 设置 Modbus 信号输出动作
1083  *
1084  * @param robot_name
1085  * @param signal_name
1086  * @param runstate
1087  * @return
1088  */
1089  int modbusSetOutputRunstate(const std::string &robot_name,
1090  const std::string &signal_name,
1091  StandardOutputRunState runstate);
1092 
1093  /**
1094  * Sets the output register signal identified by the given name to the
1095  * given value.
1096  * 将指定名称的输出寄存器信号设置为给定的值
1097  *
1098  * @param signal_name A string identifying an output register signal that
1099  * in advance has been added.
1100  * 提前被添加的输出寄存器信号
1101  * @param value An integer which must be a valid word (0-65535)
1102  * 必须是有效的整数,范围是 0-65535
1103  * @return
1104  *
1105  * @par Python函数原型
1106  * modbusSetOutputSignal(self: pyaubo_sdk.RegisterControl, arg0: str, arg1:
1107  * int) -> int
1108  *
1109  * @par Lua函数原型
1110  * modbusSetOutputSignal(signal_name: string, value: number) -> nil
1111  *
1112  */
1113  int modbusSetOutputSignal(const std::string &signal_name, uint16_t value);
1114 
1115  /**
1116  * 设置modbus信号输出脉冲(仅支持线圈输出类型)
1117  *
1118  * @param signal_name: A string identifying an output register signal that
1119  * in advance has been added.
1120  * 提前被添加的输出寄存器信号
1121  * @param value: An integer which must be a valid word (0-65535)
1122  * 必须是有效的整数,范围是 0-65535
1123  * @param duration: Duration of the signal, in seconds
1124  * @return
1125  *
1126  * @par Python函数原型
1127  * modbusSetOutputSignalPulse(self: pyaubo_sdk.RegisterControl, arg0: str,
1128  * arg1: int, arg2 double) -> int
1129  *
1130  * @par Lua函数原型
1131  * modbusSetOutputSignalPulse(signal_name: string, value: number, duration:
1132  * number) -> nil
1133  *
1134  */
1135  int modbusSetOutputSignalPulse(const std::string &signal_name,
1136  uint16_t value, double duration);
1137 
1138  /**
1139  * Sets the frequency with which the robot will send requests to the Modbus
1140  * controller to either read or write the signal value.
1141  * 设置机器人向Modbus控制器发送请求的频率,用于读取或写入信号值
1142  *
1143  * @param signal_name A string identifying an output digital signal that
1144  * in advance has been added.
1145  * 提前被添加的输出数字信号
1146  * @param update_frequency An integer in the range 0-125 specifying the
1147  * update frequency in Hz.
1148  * 更新频率(以赫兹为单位),范围是0-125
1149  * @return
1150  *
1151  * @par Python函数原型
1152  * modbusSetSignalUpdateFrequency(self: pyaubo_sdk.RegisterControl, arg0:
1153  * str, arg1: int) -> int
1154  *
1155  * @par Lua函数原型
1156  * modbusSetSignalUpdateFrequency(signal_name: string, update_frequency:
1157  * number) -> nil
1158  *
1159  */
1160  int modbusSetSignalUpdateFrequency(const std::string &signal_name,
1161  int update_frequency);
1162 
1163  /**
1164  * 获取指定 modbus 信号索引,从0开始,不能存在则返回-1
1165  *
1166  * @param signal_name
1167  * @return
1168  */
1169  int modbusGetSignalIndex(const std::string &signal_name);
1170 
1171  /**
1172  * 获取指定 modbus 信号的错误状态
1173  *
1174  * @param signal_name
1175  * @return 返回错误代码 ModbusErrorNum
1176  */
1177  int modbusGetSignalError(const std::string &signal_name);
1178 
1179  /**
1180  * 获取指定 modbus 设备的连接状态
1181  *
1182  * @param device_name
1183  * 设备名是TCP格式,"ip:port", 例如:"127.0.0.1:502" \n
1184  * 设备名是RTU格式,"serial_port", 例如:"/dev/ttyUSB0" \n
1185  *
1186  * @return
1187  * 0: 表示设备处于连接状态
1188  * -1: 表示设备不存在
1189  * -2: 表示设备处于断开状态
1190  *
1191  */
1192  int getModbusDeviceStatus(const std::string &device_name);
1193 
1194 protected:
1195  void *d_;
1196 };
1197 using RegisterControlPtr = std::shared_ptr<RegisterControl>;
1198 
1199 // clang-format off
1200 #define RegisterControl_DECLARES \
1201  _FUNC(RegisterControl, 1, getBoolInput, address) \
1202  _INST(RegisterControl, 2, setBoolInput, address, value) \
1203  _FUNC(RegisterControl, 1, getInt32Input, address) \
1204  _INST(RegisterControl, 2, setInt32Input, address, value) \
1205  _FUNC(RegisterControl, 1, getFloatInput, address) \
1206  _INST(RegisterControl, 2, setFloatInput, address, value) \
1207  _FUNC(RegisterControl, 1, getDoubleInput, address) \
1208  _INST(RegisterControl, 2, setDoubleInput, address, value) \
1209  _FUNC(RegisterControl, 1, getBoolOutput, address) \
1210  _INST(RegisterControl, 2, setBoolOutput, address, value) \
1211  _FUNC(RegisterControl, 1, getInt32Output, address) \
1212  _INST(RegisterControl, 2, setInt32Output, address, value) \
1213  _FUNC(RegisterControl, 1, getFloatOutput, address) \
1214  _INST(RegisterControl, 2, setFloatOutput, address, value) \
1215  _FUNC(RegisterControl, 1, getDoubleOutput, address) \
1216  _INST(RegisterControl, 2, setDoubleOutput, address, value) \
1217  _FUNC(RegisterControl, 1, getInt16Register, address) \
1218  _INST(RegisterControl, 2, setInt16Register, address, value) \
1219  _FUNC(RegisterControl, 2, variableUpdated, key, since) \
1220  _FUNC(RegisterControl, 1, hasNamedVariable, key) \
1221  _FUNC(RegisterControl, 1, getNamedVariableType, key) \
1222  _FUNC(RegisterControl, 2, getBool, key, default_value) \
1223  _INST(RegisterControl, 2, setBool, key, value) \
1224  _FUNC(RegisterControl, 2, getVecChar, key, default_value) \
1225  _INST(RegisterControl, 2, setVecChar, key, value) \
1226  _FUNC(RegisterControl, 2, getInt32, key, default_value) \
1227  _INST(RegisterControl, 2, setInt32, key, value) \
1228  _FUNC(RegisterControl, 2, getVecInt32, key, default_value) \
1229  _INST(RegisterControl, 2, setVecInt32, key, value) \
1230  _FUNC(RegisterControl, 2, getFloat, key, default_value) \
1231  _INST(RegisterControl, 2, setFloat, key, value) \
1232  _FUNC(RegisterControl, 2, getVecFloat, key, default_value) \
1233  _INST(RegisterControl, 2, setVecFloat, key, value) \
1234  _FUNC(RegisterControl, 2, getDouble, key, default_value) \
1235  _INST(RegisterControl, 2, setDouble, key, value) \
1236  _FUNC(RegisterControl, 2, getVecDouble, key, default_value) \
1237  _INST(RegisterControl, 2, setVecDouble, key, value) \
1238  _FUNC(RegisterControl, 2, getString, key, default_value) \
1239  _INST(RegisterControl, 2, setString, key, value) \
1240  _INST(RegisterControl, 1, clearNamedVariable, key) \
1241  _INST(RegisterControl, 3, setWatchDog, key, timeout, action) \
1242  _FUNC(RegisterControl, 1, getWatchDogAction, key) \
1243  _FUNC(RegisterControl, 1, getWatchDogTimeout, key) \
1244  _INST(RegisterControl, 6, modbusAddSignal, device_info, slave_number, signal_address, signal_type, signal_name, sequential_mode) \
1245  _INST(RegisterControl, 1, modbusDeleteSignal, signal_name) \
1246  _INST(RegisterControl, 0, modbusDeleteAllSignals) \
1247  _FUNC(RegisterControl, 1, modbusGetSignalStatus, signal_name) \
1248  _FUNC(RegisterControl, 0, modbusGetSignalNames) \
1249  _FUNC(RegisterControl, 0, modbusGetSignalTypes) \
1250  _FUNC(RegisterControl, 0, modbusGetSignalValues) \
1251  _FUNC(RegisterControl, 0, modbusGetSignalErrors) \
1252  _INST(RegisterControl, 4, modbusSendCustomCommand, IP, slave_number, function_code, data) \
1253  _INST(RegisterControl, 3, modbusSetDigitalInputAction, robot_name, signal_name, action) \
1254  _INST(RegisterControl, 3, modbusSetOutputRunstate, robot_name, signal_name, runstate) \
1255  _INST(RegisterControl, 2, modbusSetOutputSignal, signal_name, value) \
1256  _INST(RegisterControl, 3, modbusSetOutputSignalPulse, signal_name, value, duration) \
1257  _INST(RegisterControl, 2, modbusSetSignalUpdateFrequency, signal_name, update_frequency) \
1258  _FUNC(RegisterControl, 1, modbusGetSignalIndex, signal_name) \
1259  _FUNC(RegisterControl, 1, modbusGetSignalError, signal_name) \
1260  _FUNC(RegisterControl, 1, getModbusDeviceStatus, device_name)
1261 // clang-format on
1262 } // namespace common_interface
1263 } // namespace arcs
1264 
1265 #endif // AUBO_SDK_REGISTER_CONTROL_INTERFACE_H
数据类型的定义
MODBUS unit disconnected.
Specialized use in conjunction with programming commands sent to the remote MODBUS unit...
ModbusErrorNum
Specialized use in conjunction with programming commands sent to the remote MODBUS unit...
StandardOutputRunState
标准输出运行状态
Definition: type_def.h:487
The function code received in the query is not an allowable action for the server (or slave)...
MODBUS unit not initiallized.
A value contained in the query data field is not an allowable value for server (or slave)...
An unrecoverable error occurred while the server (or slave) was attempting to perform the requested a...
std::shared_ptr< RegisterControl > RegisterControlPtr
StandardInputAction
The StandardInputAction enum.
Definition: type_def.h:495
The function code received in the query is not an allowable action for the server (or slave)...
Definition: aubo_api.h:17