MIRA
FixedVoltageOutput.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) MetraLabs GmbH (MLAB), GERMANY.
3  * All rights reserved.
4  * Contact: info@MetraLabs.com
5  *
6  * Commercial Usage:
7  * Licensees holding valid commercial licenses may use this file in
8  * accordance with the commercial license agreement provided with the
9  * software or, alternatively, in accordance with the terms contained in
10  * a written agreement between you and MetraLabs.
11  *
12  * GNU General Public License Usage:
13  * Alternatively, this file may be used under the terms of the GNU
14  * General Public License version 3.0 as published by the Free Software
15  * Foundation and appearing in the file LICENSE.GPL3 included in the
16  * packaging of this file. Please review the following information to
17  * ensure the GNU General Public License version 3.0 requirements will be
18  * met: http://www.gnu.org/copyleft/gpl.html.
19  * Alternatively you may (at your option) use any later version of the GNU
20  * General Public License if such license has been publicly approved by
21  * MetraLabs (or its successors, if any).
22  *
23  * IN NO EVENT SHALL "MLAB" BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
24  * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
25  * OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLABS" HAS BEEN
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * "MLAB" SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
31  * "AS IS" BASIS, AND "MLAB" HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
32  * SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
33  */
34 
43 #ifndef _MLAB_SCITOS_FUNCTION_BLOCK_FIXED_VOLTAGE_OUTPUT_H_
44 #define _MLAB_SCITOS_FUNCTION_BLOCK_FIXED_VOLTAGE_OUTPUT_H_
45 
46 #include <FunctionBlock.h>
47 
48 namespace mira { namespace robot {
49 
51 
56 {
58 public:
61 
64  subIndexEnable(0x07),
65  subIndexMaxCurrent(0x09),
66  subIndexCurrent(0x0b),
67  subIndexVoltage(0x0a),
68  subIndexStatus(0x08),
69  subIndexInitState(0x0c)
70  {
71  functionBlockID = 0x01010002;
72  }
73 
76 
78  template <typename Reflector>
79  void reflect(Reflector& r)
80  {
82 
83  r.property("MaxCurrent",
84  getter<float>(boost::bind(&FixedVoltageOutput_v0_2::getMaxCurrent, this)),
85  setter<float>(boost::bind(&FixedVoltageOutput_v0_2::setMaxCurrent, this, _1)),
86  "Max current [A]", serialization::IgnoreMissing());
87 
88  r.property("Enabled",
89  getter<bool>(boost::bind(&FixedVoltageOutput_v0_2::isEnabled, this)),
90  setter<bool>(boost::bind(&FixedVoltageOutput_v0_2::enable, this, _1)),
91  "Is power enabled", serialization::IgnoreMissing());
92 
93  r.roproperty("Current",
94  getter<float>(boost::bind(&FixedVoltageOutput_v0_2::getCurrent, this)),
95  "Current current [A]");
96 
97  r.roproperty("Voltage",
98  getter<float>(boost::bind(&FixedVoltageOutput_v0_2::getVoltage, this)),
99  "Current voltage [V]");
100 
101  r.roproperty("Status",
102  getter<std::string>(boost::bind(&FixedVoltageOutput_v0_2::getStatus, this)),
103  "Current status");
104 
105  r.roproperty("InitState",
106  getter<uint32>(boost::bind(&FixedVoltageOutput_v0_2::getInitState, this)),
107  "Initial state after power on.",
108  PropertyHints::enumeration("0=off;1=on"));
109  }
110 
112 
113 public:
116 
120  void setMaxCurrent(float current)
121  {
122  uint32 maxCurrent = (uint32)(current*1000.0f);
123  sdoClient->writeSync<uint32>(nodeID, index, subIndexMaxCurrent, maxCurrent);
124  }
125 
130  {
131  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexMaxCurrent);
132  }
133 
137  void enable(bool enable)
138  {
139  sdoClient->writeSync<uint32>(nodeID, index, subIndexEnable, enable ? 0x01 : 0x00);
140  }
141 
145  bool isEnabled()
146  {
147  return sdoClient->readSync<uint32>(nodeID, index, subIndexEnable) > 0x00;
148  }
149 
153  float getCurrent()
154  {
155  return 0.001f * sdoClient->readSync<int32>(nodeID, index, subIndexCurrent);
156  }
157 
161  float getVoltage()
162  {
163  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexVoltage);
164  }
165 
169  virtual std::string getStatus()
170  {
171  uint8 status = sdoClient->readSync<uint8>(nodeID, index, subIndexStatus);
172  std::string r = (status & 0x01) ? "on" : "off";
173  if ((status & 0x01) && (status & 0x02))
174  r += ", error";
175  return r;
176  }
177 
181  uint32 getInitState()
182  {
183  return sdoClient->readSync<uint32>(nodeID, index, subIndexInitState);
184  }
185 
187 
188 protected:
191 
194 
197 
200 
203 
206 };
207 
209 
214 {
216 public:
219  {
220  subIndexCurrent = 0x0c;
221  subIndexVoltage = 0x0b;
222  subIndexInitState = 0x0d;
223  functionBlockID = 0x01010003;
224  }
225 };
226 
228 
233 {
235 public:
238  {
239  subIndexCurrent = 0x0f;
240  subIndexVoltage = 0x0e;
241  subIndexInitState = 0x10;
242  functionBlockID = 0x01010004;
243 
244  subIndexMinCurrent = 0x0a;
245  }
246 
248  template <typename Reflector>
249  void reflect(Reflector& r)
250  {
252 
253  r.property("MinCurrent",
254  getter<float>(boost::bind(&FixedVoltageOutput_v0_4::getMinCurrent, this)),
255  setter<float>(boost::bind(&FixedVoltageOutput_v0_4::setMinCurrent, this, _1)),
256  "Min current [A]", serialization::IgnoreMissing());
257  }
258 
259 public:
262 
266  void setMinCurrent(float current)
267  {
268  uint32 minCurrent = (uint32)(current*1000.0f);
269  sdoClient->writeSync<uint32>(nodeID, index, subIndexMinCurrent, minCurrent);
270  }
271 
276  {
277  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexMinCurrent);
278  }
279 
281 
282 protected:
285 };
286 
288 
293 {
295 public:
298  {
299  functionBlockID = 0x01010101;
300  }
301 };
302 
304 
309 {
311 public:
314 
317  subIndexEnable(0x07),
318  subIndexMinCurrent(0x0F),
319  subIndexMaxCurrent(0x0C),
320  subIndexCurrent(0x06),
321  subIndexVoltage(0x05),
322  subIndexStatus(0x07),
323  subIndexInitState(0x08)
324  {
325  functionBlockID = 0x01010200;
326  }
327 
330 
332  template <typename Reflector>
333  void reflect(Reflector& r)
334  {
336 
337  r.property("MinCurrent",
338  getter<float>(boost::bind(&FixedVoltageOutput_v2::getMinCurrent, this)),
339  setter<float>(boost::bind(&FixedVoltageOutput_v2::setMinCurrent, this, _1)),
340  "Min current [A]", serialization::IgnoreMissing());
341 
342  r.property("MaxCurrent",
343  getter<float>(boost::bind(&FixedVoltageOutput_v2::getMaxCurrent, this)),
344  setter<float>(boost::bind(&FixedVoltageOutput_v2::setMaxCurrent, this, _1)),
345  "Max current [A]", serialization::IgnoreMissing());
346 
347  r.property("Enabled",
348  getter<bool>(boost::bind(&FixedVoltageOutput_v2::isEnabled, this)),
349  setter<bool>(boost::bind(&FixedVoltageOutput_v2::enable, this, _1)),
350  "Is power enabled", serialization::IgnoreMissing());
351 
352  r.roproperty("Current",
353  getter<float>(boost::bind(&FixedVoltageOutput_v2::getCurrent, this)),
354  "Current current [A]");
355 
356  r.roproperty("Voltage",
357  getter<float>(boost::bind(&FixedVoltageOutput_v2::getVoltage, this)),
358  "Current voltage [V]");
359 
360  r.roproperty("Status",
361  getter<std::string>(boost::bind(&FixedVoltageOutput_v2::getStatus, this)),
362  "Current status");
363 
364  r.roproperty("InitState",
365  getter<uint32>(boost::bind(&FixedVoltageOutput_v2::getInitState, this)),
366  "Initial state after power on.",
367  PropertyHints::enumeration("0=off;1=on"));
368  }
369 
371 
372 public:
375 
379  void setMinCurrent(float current)
380  {
381  int32 minCurrent = (int32)(current*1000.0f);
382  sdoClient->writeSync<int32>(nodeID, index, subIndexMinCurrent, minCurrent);
383  }
384 
389  {
390  return 0.001f * sdoClient->readSync<int32>(nodeID, index, subIndexMinCurrent);
391  }
392 
396  void setMaxCurrent(float current)
397  {
398  int32 maxCurrent = (int32)(current*1000.0f);
399  sdoClient->writeSync<int32>(nodeID, index, subIndexMaxCurrent, maxCurrent);
400  }
401 
406  {
407  return 0.001f * sdoClient->readSync<int32>(nodeID, index, subIndexMaxCurrent);
408  }
409 
413  void enable(bool enable)
414  {
415  sdoClient->writeSync<uint32>(nodeID, index, subIndexEnable, enable ? 0x01 : 0x00);
416  }
417 
421  bool isEnabled()
422  {
423  return sdoClient->readSync<uint32>(nodeID, index, subIndexEnable) > 0x00;
424  }
425 
429  float getCurrent()
430  {
431  return 0.001f * sdoClient->readSync<int32>(nodeID, index, subIndexCurrent);
432  }
433 
437  float getVoltage()
438  {
439  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexVoltage);
440  }
441 
445  virtual std::string getStatus()
446  {
447  uint32 state = sdoClient->readSync<uint32>(nodeID, index, subIndexEnable);
448  std::string r = (state & 0x01) ? "on" : "off";
449 
450  uint32 error = sdoClient->readSync<uint32>(nodeID, index, 0x13);
451  if (error & 0x01)
452  r += ", OverVoltage";
453  if (error & 0x02)
454  r += ", UnderVoltage";
455  if (error & 0x04)
456  r += ", OverCurrent";
457  if (error & 0x08)
458  r += ", UnderCurrent";
459  if (error & 0x10)
460  r += ", ExternalError";
461  if (error & 0x20)
462  r += ", UnderCurrentTimeout";
463  if (error & 0x40)
464  r += ", WaitForStartup";
465 
466  return r;
467  }
468 
472  uint8 getInitState()
473  {
474  return sdoClient->readSync<uint8>(nodeID, index, subIndexInitState);
475  }
476 
478 
479 protected:
482 
485 
488 
491 
494 
497 
500 };
501 
503 
504 }}
505 
506 #endif
void reflect(Reflector &r)
Reflect for serialization.
Definition: FixedVoltageOutput.h:79
void setMinCurrent(float current)
Set the minimum current.
Definition: FixedVoltageOutput.h:379
float getCurrent()
Return the current current.
Definition: FixedVoltageOutput.h:153
mira::can::CANOpenSDOClientPtr sdoClient
Definition: FunctionBlock.h:93
FixedVoltageOutput_v0_3()
Constructor.
Definition: FixedVoltageOutput.h:218
uint8 subIndexMaxCurrent
Subindex for setting/retrieving max current.
Definition: FixedVoltageOutput.h:487
void setMinCurrent(float current)
Set the minimum current.
Definition: FixedVoltageOutput.h:266
float getMaxCurrent()
Return the maximum value for current.
Definition: FixedVoltageOutput.h:129
void reflect(Reflector &r)
Reflect for serialization.
Definition: FixedVoltageOutput.h:249
void reflect(Reflector &r)
Reflect for serialization.
Definition: FixedVoltageOutput.h:333
void setMaxCurrent(float current)
Set the maximum current.
Definition: FixedVoltageOutput.h:396
uint8 subIndexInitState
Subindex for retrieving the initial state.
Definition: FixedVoltageOutput.h:205
uint8 subIndexCurrent
Subindex for retrieving the current.
Definition: FixedVoltageOutput.h:490
PropertyHint enumeration(const std::string &values)
#define MIRA_REFLECT_BASE(reflector, BaseClass)
uint8 subIndexVoltage
Subindex for retrieving the voltage.
Definition: FixedVoltageOutput.h:199
uint32 getInitState()
Return the initial state of the port.
Definition: FixedVoltageOutput.h:181
bool isEnabled()
Is the power supply enabled.
Definition: FixedVoltageOutput.h:421
Function block for fixed voltage v2.0 (0x01010200)
Definition: FixedVoltageOutput.h:308
void enable(bool enable)
Enable the power supply.
Definition: FixedVoltageOutput.h:413
uint8 subIndexInitState
Subindex for retrieving the initial state.
Definition: FixedVoltageOutput.h:499
Function block for fixed voltage v1.1 (since 0x01010101)
Definition: FixedVoltageOutput.h:292
uint8 nodeID
ID of the can node.
Definition: FunctionBlock.h:87
uint8 subIndexEnable
Subindex for enabling the power supply.
Definition: FixedVoltageOutput.h:481
FixedVoltageOutput_v1_1()
Constructor.
Definition: FixedVoltageOutput.h:297
void enable(bool enable)
Enable the power supply.
Definition: FixedVoltageOutput.h:137
virtual ~FixedVoltageOutput_v0_2()
Destructor.
Definition: FixedVoltageOutput.h:75
virtual ~FixedVoltageOutput_v2()
Destructor.
Definition: FixedVoltageOutput.h:329
virtual std::string getStatus()
Return the status [(on,off)|error] of the power supply.
Definition: FixedVoltageOutput.h:169
Function block for fixed voltage v0.2 (0x01010002)
Definition: FixedVoltageOutput.h:55
float getMinCurrent()
Return the minimum value for current.
Definition: FixedVoltageOutput.h:388
FixedVoltageOutput_v0_2()
Constructor.
Definition: FixedVoltageOutput.h:63
float getMaxCurrent()
Return the maximum value for current.
Definition: FixedVoltageOutput.h:405
#define MIRA_OBJECT(classIdentifier)
void setMaxCurrent(float current)
Set the maximum current.
Definition: FixedVoltageOutput.h:120
Function block for fixed voltage v0.3 (since 0x01010003)
Definition: FixedVoltageOutput.h:213
virtual std::string getStatus()
Return the status [(on,off)|error(s)] of the power supply.
Definition: FixedVoltageOutput.h:445
uint8 subIndexVoltage
Subindex for retrieving the voltage.
Definition: FixedVoltageOutput.h:493
uint8 subIndexCurrent
Subindex for retrieving the current.
Definition: FixedVoltageOutput.h:196
uint8 subIndexStatus
Subindex for retrieving the status.
Definition: FixedVoltageOutput.h:496
uint8 subIndexMinCurrent
Subindex for setting/retrieving min current.
Definition: FixedVoltageOutput.h:284
uint32 functionBlockID
ID of the function block.
Definition: FunctionBlock.h:84
Definition: FunctionBlock.h:53
float getVoltage()
Return the current voltage.
Definition: FixedVoltageOutput.h:161
uint8 getInitState()
Return the initial state of the port.
Definition: FixedVoltageOutput.h:472
uint8 subIndexMaxCurrent
Subindex for setting/retrieving max current.
Definition: FixedVoltageOutput.h:193
uint8 subIndexStatus
Subindex for retrieving the status.
Definition: FixedVoltageOutput.h:202
Base class for different SCITOS CAN function blocks.
uint8 subIndexMinCurrent
Subindex for setting/retrieving min current.
Definition: FixedVoltageOutput.h:484
bool isEnabled()
Is the power supply enabled.
Definition: FixedVoltageOutput.h:145
float getVoltage()
Return the current voltage.
Definition: FixedVoltageOutput.h:437
Function block for fixed voltage v0.4 (0x01010004)
Definition: FixedVoltageOutput.h:232
uint8 subIndexEnable
Subindex for enabling the power supply.
Definition: FixedVoltageOutput.h:190
FixedVoltageOutput_v0_4()
Constructor.
Definition: FixedVoltageOutput.h:237
uint16 index
Index.
Definition: FunctionBlock.h:90
float getMinCurrent()
Return the minimum value for current.
Definition: FixedVoltageOutput.h:275
FixedVoltageOutput_v2()
Constructor.
Definition: FixedVoltageOutput.h:316
float getCurrent()
Return the current current.
Definition: FixedVoltageOutput.h:429