tool_communication.h
Go to the documentation of this file.
1 
2 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
3 
4 // -- BEGIN LICENSE BLOCK ----------------------------------------------
5 // Copyright 2019 FZI Forschungszentrum Informatik
6 // Created on behalf of Universal Robots A/S
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 // -- END LICENSE BLOCK ------------------------------------------------
20 
21 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
29 
30 #ifndef UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
31 #define UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
32 
34 #include <set>
35 
36 namespace urcl
37 {
41 enum class ToolVoltage : int
42 {
43  OFF = 0,
44  _12V = 12,
45  _24V = 24
46 };
47 
51 enum class Parity : int
52 {
53  NONE = 0,
54  ODD = 1,
55  EVEN = 2
56 };
57 
63 template <class T>
64 class Limited
65 {
66 public:
67  Limited() = delete;
68  ~Limited() = default;
69 
70  using Datatype = T;
71 
78  Limited(const T lower, const T upper) : lower_(lower), upper_(upper)
79  {
80  data_ = lower_;
81  }
82 
90  void setData(const T data)
91  {
92  if (data >= lower_ && data <= upper_)
93  {
94  data_ = data;
95  }
96  else
97  {
98  throw std::runtime_error("Given data is out of range");
99  }
100  }
101 
105  T getData() const
106  {
107  return data_;
108  }
109 
110 private:
111  T data_;
112  const T lower_;
113  const T upper_;
114 };
115 
120 {
121 public:
122  ToolCommSetup();
123  ~ToolCommSetup() = default;
124 
128 
133  void setToolVoltage(const ToolVoltage tool_voltage)
134  {
135  tool_voltage_ = tool_voltage;
136  }
137 
142  {
143  return tool_voltage_;
144  }
145 
150  void setParity(const Parity parity)
151  {
152  parity_ = parity;
153  }
158  {
159  return parity_;
160  }
161 
168  void setBaudRate(const uint32_t baud_rate);
172  uint32_t getBaudRate() const
173  {
174  return baud_rate_;
175  };
176 
183  void setStopBits(const StopBitsT::Datatype stop_bits)
184  {
185  stop_bits_.setData(stop_bits);
186  }
191  {
192  return stop_bits_.getData();
193  }
194 
201  void setRxIdleChars(const RxIdleCharsT::Datatype rx_idle_chars)
202  {
203  rx_idle_chars_.setData(rx_idle_chars);
204  }
209  {
210  return rx_idle_chars_.getData();
211  }
212 
219  void setTxIdleChars(const TxIdleCharsT::Datatype tx_idle_chars)
220  {
221  tx_idle_chars_.setData(tx_idle_chars);
222  }
227  {
228  return tx_idle_chars_.getData();
229  }
230 
231 private:
232  const std::set<uint32_t> baud_rates_allowed_{ 9600,
233  19200,
234  38400,
235  57600,
236  115200,
237  static_cast<uint32_t>(1e6),
238  static_cast<uint32_t>(2e6),
239  static_cast<uint32_t>(5e6) };
240 
243  uint32_t baud_rate_;
247 };
248 } // namespace urcl
249 #endif // ifndef UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
Helper class that represents a numeric value with a lower and an upper boundary.
void setToolVoltage(const ToolVoltage tool_voltage)
Setup the tool voltage that will be configured on the robot. This will not immediately change values ...
TxIdleCharsT::Datatype getTxIdleChars() const
Return the number of tx idle chars currently stored.
ToolVoltage
Possible values for the tool voltage.
void setStopBits(const StopBitsT::Datatype stop_bits)
Setup the tool communication number of stop bits that will be configured on the robot. This will not immediately change values on the robot, it will only be stored inside the ToolCommSetup object.
Parity getParity() const
Return the parity currently stored.
Limited(const T lower, const T upper)
Create a new Limited object.
void setTxIdleChars(const TxIdleCharsT::Datatype tx_idle_chars)
Setup the tool communication number of idle chars for the tx channel that will be configured on the r...
void setParity(const Parity parity)
Setup the tool communication parity that will be configured on the robot. This will not immediately c...
RxIdleCharsT::Datatype getRxIdleChars() const
Return the number of rx idle chars currently stored.
void setRxIdleChars(const RxIdleCharsT::Datatype rx_idle_chars)
Setup the tool communication number of idle chars for the rx channel that will be configured on the r...
T getData() const
Returns the data stored in this object.
uint32_t getBaudRate() const
Return the baud rate currently stored.
Parity
Possible values for th parity flag.
void setData(const T data)
Set the data field with a given value.
ToolVoltage getToolVoltage() const
Return the tool voltage currently stored.
Class holding a tool communication configuration.
StopBitsT::Datatype getStopBits() const
Return the number of stop bits currently stored.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Tue Jul 4 2023 02:09:47