rec::robotino::api2 C++ interface
Factory4RobotInfo.h
1 // Copyright (C) 2004-2015, Robotics Equipment Corporation GmbH
2 
3 //Copyright (c) ...
4 //
5 //REC Robotics Equipment Corporation GmbH, Planegg, Germany. All rights reserved.
6 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 //1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 //2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 //
10 //THIS SOFTWARE IS PROVIDED BY REC ROBOTICS EQUIPMENT CORPORATION GMBH ?AS IS? AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
11 //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REC ROBOTICS EQUIPMENT CORPORATION GMBH
12 //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
13 //GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14 //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 //
16 //Copyright (c) ...
17 //
18 //REC Robotics Equipment Corporation GmbH, Planegg, Germany. Alle Rechte vorbehalten.
19 //Weiterverbreitung und Verwendung in nichtkompilierter oder kompilierter Form, mit oder ohne Ver?nderung, sind unter den folgenden Bedingungen zul?ssig:
20 //1) Weiterverbreitete nichtkompilierte Exemplare m?ssen das obige Copyright, diese Liste der Bedingungen und den folgenden Haftungsausschluss im Quelltext enthalten.
21 //2) Weiterverbreitete kompilierte Exemplare m?ssen das obige Copyright, diese Liste der Bedingungen und den folgenden Haftungsausschluss in der Dokumentation und/oder anderen Materialien, die mit dem Exemplar verbreitet werden, enthalten.
22 //
23 //DIESE SOFTWARE WIRD VON REC ROBOTICS EQUIPMENT CORPORATION GMBH OHNE JEGLICHE SPEZIELLE ODER IMPLIZIERTE GARANTIEN ZUR VERF?GUNG GESTELLT, DIE UNTER
24 //ANDEREM EINSCHLIESSEN: DIE IMPLIZIERTE GARANTIE DER VERWENDBARKEIT DER SOFTWARE F?R EINEN BESTIMMTEN ZWECK. AUF KEINEN FALL IST REC ROBOTICS EQUIPMENT CORPORATION GMBH
25 //F?R IRGENDWELCHE DIREKTEN, INDIREKTEN, ZUF?LLIGEN, SPEZIELLEN, BEISPIELHAFTEN ODER FOLGESCH?DEN (UNTER ANDEREM VERSCHAFFEN VON ERSATZG?TERN ODER -DIENSTLEISTUNGEN;
26 //EINSCHR?NKUNG DER NUTZUNGSF?HIGKEIT; VERLUST VON NUTZUNGSF?HIGKEIT; DATEN; PROFIT ODER GESCH?FTSUNTERBRECHUNG), WIE AUCH IMMER VERURSACHT UND UNTER WELCHER VERPFLICHTUNG
27 //AUCH IMMER, OB IN VERTRAG, STRIKTER VERPFLICHTUNG ODER UNERLAUBTER HANDLUNG (INKLUSIVE FAHRL?SSIGKEIT) VERANTWORTLICH, AUF WELCHEM WEG SIE AUCH IMMER DURCH DIE BENUTZUNG
28 //DIESER SOFTWARE ENTSTANDEN SIND, SOGAR, WENN SIE AUF DIE M?GLICHKEIT EINES SOLCHEN SCHADENS HINGEWIESEN WORDEN SIND.
29 
30 #ifndef FACTORY4ROBOTINFO_H
31 #define FACTORY4ROBOTINFO_H
32 
33 #include <string.h>
34 
35 namespace rec
36 {
37  namespace robotino
38  {
39  namespace api2
40  {
42  {
43  public:
44  enum
45  {
46  STATE_Unknown,
47  STATE_Idle,
48  STATE_Busy,
49  STATE_Error
50  };
51 
53  : robotinoId(-1)
54  , x(0.0)
55  , y(0.0)
56  , phi(0.0)
57  , batteryVoltage(0.0)
58  , laserWarning(false)
59  , laserSafety(false)
60  , boxPresent(false)
61  , state(STATE_Unknown)
62  , _ipAddress(NULL)
63  {
64  _ipAddress = new char[1];
65  _ipAddress[0] = 0;
66  }
67 
69  : robotinoId(other.robotinoId)
70  , x(other.x)
71  , y(other.y)
72  , phi(other.phi)
73  , batteryVoltage(other.batteryVoltage)
74  , laserWarning(other.laserWarning)
75  , laserSafety(other.laserSafety)
76  , boxPresent(other.boxPresent)
77  , state(other.state)
78  , _ipAddress(NULL)
79  {
80  setIpAddress(other._ipAddress);
81  }
82 
84  {
85  delete [] _ipAddress;
86  }
87 
88  Factory4RobotInfo& operator=(const Factory4RobotInfo& other)
89  {
90  robotinoId = other.robotinoId;
91  x = other.x;
92  y = other.y;
93  phi = other.phi;
94  batteryVoltage = other.batteryVoltage;
95  laserWarning = other.laserWarning;
96  laserSafety = other.laserSafety;
97  boxPresent = other.boxPresent;
98  state = other.state;
99 
100  setIpAddress(other._ipAddress);
101 
102  return *this;
103  }
104 
105  const char* ipAddress() const
106  {
107  return _ipAddress;
108  }
109 
114  void setIpAddress(const char* ipAddress)
115  {
116  delete[] _ipAddress;
117  _ipAddress = NULL;
118  if (0 == ipAddress)
119  {
120  _ipAddress = new char[1];
121  _ipAddress[0] = 0;
122  }
123  else
124  {
125  size_t len = strlen(ipAddress);
126  _ipAddress = new char[len + 1];
127  strncpy(_ipAddress, ipAddress, len + 1);
128  }
129  }
130 
131  int robotinoId;
132  float x;
133  float y;
134  float phi;
135  float batteryVoltage;
136  bool laserWarning;
137  bool laserSafety;
138  bool boxPresent;
139  int state;
140 
141  private:
142  char* _ipAddress;
143  };
144 
146  {
147  public:
149  : _size(0)
150  , _data(0)
151  {
152  }
153 
154  Factory4RobotInfoList(const unsigned int size)
155  : _size(size)
156  , _data(0)
157  {
158  if(_size > 0 )
159  {
160  _data = new Factory4RobotInfo[_size];
161  }
162  }
163 
165  : _size(other._size)
166  , _data(0)
167  {
168  if(_size > 0 )
169  {
170  _data = new Factory4RobotInfo[_size];
171  for (int i = 0; i < _size; ++i)
172  {
173  _data[i] = other._data[i];
174  }
175  }
176  }
177 
179  {
180  delete[] _data;
181  }
182 
183  const unsigned int size() const
184  {
185  return _size;
186  }
187 
189  const Factory4RobotInfo& operator[](int index) const
190  {
191  return _data[index];
192  }
193 
194  Factory4RobotInfo& operator[](int index)
195  {
196  return _data[index];
197  }
198 
199  Factory4RobotInfoList& operator=(const Factory4RobotInfoList& other)
200  {
201  delete [] _data;
202  _data = 0;
203  _size = 0;
204  if( other._size > 0 )
205  {
206  _size = other._size;
207  _data = new Factory4RobotInfo[_size];
208  for (int i = 0; i < _size; ++i)
209  {
210  _data[i] = other._data[i];
211  }
212  }
213  return *this;
214  }
215 
216  private:
217  unsigned int _size;
218  Factory4RobotInfo* _data;
219  };
220  }
221  }
222 }
223 
224 #endif // FACTORY4STATE_H
void setIpAddress(const char *ipAddress)
Definition: Factory4RobotInfo.h:114
const Factory4RobotInfo & operator[](int index) const
Enables access via index.
Definition: Factory4RobotInfo.h:189
Definition: AnalogInput.h:36
Definition: Factory4RobotInfo.h:41
Definition: Factory4RobotInfo.h:145