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 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // -- END LICENSE BLOCK ------------------------------------------------
19 
20 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 
29 #ifndef UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
30 #define UR_CLIENT_LIBRARY_UR_TOOL_COMMUNICATION_H_INCLUDED
31 
33 #include <set>
34 
35 namespace urcl
36 {
40 enum class ToolVoltage : int
41 {
42  OFF = 0,
43  _12V = 12,
44  _24V = 24
45 };
46 
50 enum class Parity : int
51 {
52  NONE = 0,
53  ODD = 1,
54  EVEN = 2
55 };
56 
62 template <class T>
63 class Limited
64 {
65 public:
66  Limited() = delete;
67  ~Limited() = default;
68 
69  using Datatype = T;
70 
77  Limited(const T lower, const T upper) : lower_(lower), upper_(upper)
78  {
79  data_ = lower_;
80  }
81 
89  void setData(const T data)
90  {
91  if (data >= lower_ && data <= upper_)
92  {
93  data_ = data;
94  }
95  else
96  {
97  throw std::runtime_error("Given data is out of range");
98  }
99  }
100 
104  T getData() const
105  {
106  return data_;
107  }
108 
109 private:
110  T data_;
111  const T lower_;
112  const T upper_;
113 };
114 
119 {
120 public:
121  ToolCommSetup();
122  ~ToolCommSetup() = default;
123 
127 
132  void setToolVoltage(const ToolVoltage tool_voltage)
133  {
134  tool_voltage_ = tool_voltage;
135  }
136 
141  {
142  return tool_voltage_;
143  }
144 
149  void setParity(const Parity parity)
150  {
151  parity_ = parity;
152  }
157  {
158  return parity_;
159  }
160 
167  void setBaudRate(const uint32_t baud_rate);
171  uint32_t getBaudRate() const
172  {
173  return baud_rate_;
174  };
175 
182  void setStopBits(const StopBitsT::Datatype stop_bits)
183  {
184  stop_bits_.setData(stop_bits);
185  }
190  {
191  return stop_bits_.getData();
192  }
193 
200  void setRxIdleChars(const RxIdleCharsT::Datatype rx_idle_chars)
201  {
202  rx_idle_chars_.setData(rx_idle_chars);
203  }
208  {
209  return rx_idle_chars_.getData();
210  }
211 
218  void setTxIdleChars(const TxIdleCharsT::Datatype tx_idle_chars)
219  {
220  tx_idle_chars_.setData(tx_idle_chars);
221  }
226  {
227  return tx_idle_chars_.getData();
228  }
229 
230 private:
231  const std::set<uint32_t> baud_rates_allowed_{ 9600,
232  19200,
233  38400,
234  57600,
235  115200,
236  static_cast<uint32_t>(1e6),
237  static_cast<uint32_t>(2e6),
238  static_cast<uint32_t>(5e6) };
239 
242  uint32_t baud_rate_;
246 };
247 } // namespace urcl
248 #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 ...
StopBitsT::Datatype getStopBits() const
Return the number of stop bits currently stored.
ToolVoltage
Possible values for the tool voltage.
ToolVoltage getToolVoltage() const
Return the tool voltage currently stored.
Parity getParity() const
Return the parity currently stored.
TxIdleCharsT::Datatype getTxIdleChars() const
Return the number of tx idle chars currently stored.
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.
uint32_t getBaudRate() const
Return the baud rate 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...
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.
Parity
Possible values for th parity flag.
void setData(const T data)
Set the data field with a given value.
RxIdleCharsT::Datatype getRxIdleChars() const
Return the number of rx idle chars currently stored.
Class holding a tool communication configuration.


ur_client_library
Author(s): Thomas Timm Andersen, Simon Rasmussen, Felix Exner, Lea Steffen, Tristan Schnell
autogenerated on Sun May 9 2021 02:16:26