MIRA
PowerSupplyPort.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_POWER_SUPPLY_PORT_H_
44 #define _MLAB_SCITOS_FUNCTION_BLOCK_POWER_SUPPLY_PORT_H_
45 
46 #include <FunctionBlock.h>
47 
48 namespace mira { namespace robot {
49 
51 
56 {
58 
59 public:
60 
63  subIndexIsCharging(0x08),
64  subIndexVoltage(0xA),
65  subIndexCurrent(0x0B)
66  {
67  functionBlockID = 0x02010001; // firmware < 1.2.0
68  }
69 
71  virtual ~PowerSupplyPort_v0() {}
72 
74  template <typename Reflector>
75  void reflect(Reflector& r)
76  {
78 
79  r.roproperty("Charging",
80  getter<bool>(boost::bind(&PowerSupplyPort_v0::isCharging, this)),
81  "Current status");
82 
83  r.roproperty("Voltage",
84  getter<float>(boost::bind(&PowerSupplyPort_v0::getVoltage, this)),
85  "Current voltage [V]");
86 
87  r.roproperty("Current",
88  getter<float>(boost::bind(&PowerSupplyPort_v0::getCurrent, this)),
89  "Current current [A]");
90  }
91 
92 public:
94  bool isCharging()
95  {
96  return sdoClient->readSync<uint32>(nodeID, index, subIndexIsCharging) > 0x00;
97  }
98 
100  float getVoltage()
101  {
102  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexVoltage);
103  }
104 
106  float getCurrent()
107  {
108  return 0.001f * sdoClient->readSync<int32>(nodeID, index, subIndexCurrent);
109  }
110 
111 protected:
114 
117 
120 };
121 
123 
128 {
130 public:
132  {
133  functionBlockID = 0x01040001; // firmware >= 1.2.0
134  }
135 };
136 
138 
143 {
145 public:
147  {
148  functionBlockID = 0x01040101;
149  }
150 };
151 
153 
158 {
160 public:
162  {
163  functionBlockID = 0x01040201;
164  }
165 };
166 
168 
171 {
173 
174 public:
175 
178  {
179  subIndexIsCharging = 0x08;
180  subIndexVoltage = 0x04,
181  subIndexCurrent = 0x05;
182  subIndexMaxCurrent = 0x0A;
183  subIndexEnable = 0x06;
185 
186  functionBlockID = 0x01040300;
187  }
188 
190  virtual ~PowerSupplyPort_v3() {}
191 
193  template <typename Reflector>
194  void reflect(Reflector& r)
195  {
197 
198  r.roproperty("MaxCurrent",
199  getter<float>(boost::bind(&PowerSupplyPort_v3::getMaxCurrent, this)),
200  "Maximum current [A]");
201 
202  r.property("Enabled",
203  getter<bool>(boost::bind(&PowerSupplyPort_v3::isEnabled, this)),
204  setter<bool>(boost::bind(&PowerSupplyPort_v3::enable, this, _1)),
205  "Is port enabled", serialization::IgnoreMissing());
206 
207  r.roproperty("MaxDissipatedPower",
208  getter<float>(boost::bind(&PowerSupplyPort_v3::getMaxDissipatedPower, this)),
209  "Maximum allowed dissipated power in [W]");
210  }
211 
212 public:
215  {
216  return 0.001f * sdoClient->readSync<uint32>(nodeID, index, subIndexMaxCurrent);
217  }
218 
222  void enable(bool enable)
223  {
224  sdoClient->writeSync<uint32>(nodeID, index, subIndexEnable, enable ? 0x01 : 0x00);
225  }
226 
230  bool isEnabled()
231  {
232  return sdoClient->readSync<uint32>(nodeID, index, subIndexEnable) > 0x00;
233  }
234 
237  {
238  return 1.0f * sdoClient->readSync<uint16>(nodeID, index, subIndexMaxDissipatedPower);
239  }
240 
241 protected:
244 
247 
250 };
251 
253 
256 {
258 
259 public:
260 
263  {
265 
266  functionBlockID = 0x01040302;
267  }
268 
270  virtual ~PowerSupplyPort_v4() {}
271 
272 public:
274  template <typename Reflector>
275  void reflect(Reflector& r)
276  {
278 
279  r.roproperty("CurrentDissipatedPower",
280  getter<float>(boost::bind(&PowerSupplyPort_v4::getCurrentDissipatedPower, this)),
281  "Current dissipated power in [W]");
282  }
283 
284 public:
287  {
288  return 0.001f * sdoClient->readSync<uint16>(nodeID, index, subIndexCurrentDissipatedPower);
289  }
290 
291 public:
293 };
294 
296 
297 }}
298 
299 #endif
mira::can::CANOpenSDOClientPtr sdoClient
Definition: FunctionBlock.h:93
Function block for charger power supply ports (0x01040001)
Definition: PowerSupplyPort.h:127
uint8 subIndexEnable
Subindex for enable-flag.
Definition: PowerSupplyPort.h:246
float getVoltage()
Return the current voltage.
Definition: PowerSupplyPort.h:100
uint8 subIndexCurrent
Subindex for retrieving the current.
Definition: PowerSupplyPort.h:119
uint8 subIndexIsCharging
Subindex for charging flag.
Definition: PowerSupplyPort.h:113
void reflect(Reflector &r)
Reflect for serialization.
Definition: PowerSupplyPort.h:275
uint8 subIndexCurrentDissipatedPower
Definition: PowerSupplyPort.h:292
uint8 subIndexMaxDissipatedPower
Subindex for max dissipated power.
Definition: PowerSupplyPort.h:249
Function block for charger power supply ports, v4.0.
Definition: PowerSupplyPort.h:255
void reflect(Reflector &r)
Reflect for serialization.
Definition: PowerSupplyPort.h:75
PowerSupplyPort_v01()
Definition: PowerSupplyPort.h:131
#define MIRA_REFLECT_BASE(reflector, BaseClass)
bool isEnabled()
Is the power supply enabled.
Definition: PowerSupplyPort.h:230
PowerSupplyPort_v3()
Constructor.
Definition: PowerSupplyPort.h:177
PowerSupplyPort_v0()
Constructor.
Definition: PowerSupplyPort.h:62
Function block for charger power supply ports (since 0x01040201)
Definition: PowerSupplyPort.h:157
PowerSupplyPort_v2()
Definition: PowerSupplyPort.h:161
Function block for charger power supply ports, v3.0.
Definition: PowerSupplyPort.h:170
uint8 nodeID
ID of the can node.
Definition: FunctionBlock.h:87
PowerSupplyPort_v1()
Definition: PowerSupplyPort.h:146
PowerSupplyPort_v4()
Constructor.
Definition: PowerSupplyPort.h:262
float getCurrent()
Return the current current.
Definition: PowerSupplyPort.h:106
void reflect(Reflector &r)
Reflect for serialization.
Definition: PowerSupplyPort.h:194
virtual ~PowerSupplyPort_v4()
Destructor.
Definition: PowerSupplyPort.h:270
Function block for charger power supply ports (since 0x01040101)
Definition: PowerSupplyPort.h:142
#define MIRA_OBJECT(classIdentifier)
float getCurrentDissipatedPower()
Return the maximum dissipated power.
Definition: PowerSupplyPort.h:286
uint32 functionBlockID
ID of the function block.
Definition: FunctionBlock.h:84
Definition: FunctionBlock.h:53
virtual ~PowerSupplyPort_v3()
Destructor.
Definition: PowerSupplyPort.h:190
Function block for charger power supply ports (0x02010001)
Definition: PowerSupplyPort.h:55
bool isCharging()
Is the power supply enabled.
Definition: PowerSupplyPort.h:94
Base class for different SCITOS CAN function blocks.
virtual ~PowerSupplyPort_v0()
Destructor.
Definition: PowerSupplyPort.h:71
uint8 subIndexVoltage
Subindex for retrieving the voltage.
Definition: PowerSupplyPort.h:116
float getMaxDissipatedPower()
Return the maximum dissipated power.
Definition: PowerSupplyPort.h:236
uint8 subIndexMaxCurrent
Subindex for retrieving the max-current.
Definition: PowerSupplyPort.h:243
uint16 index
Index.
Definition: FunctionBlock.h:90
void enable(bool enable)
Enable the power supply.
Definition: PowerSupplyPort.h:222
float getMaxCurrent()
Return the maximum current.
Definition: PowerSupplyPort.h:214