Ignition Common

API Reference

3.0.0
Battery.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_BATTERY_HH_
18 #define IGNITION_COMMON_BATTERY_HH_
19 
20 #include <map>
21 #include <string>
22 #include <functional>
23 #include <memory>
24 #include <ignition/common/Export.hh>
26 
27 namespace ignition
28 {
29  namespace common
30  {
31  // Forward declare private data class.
32  class BatteryPrivate;
33 
44  class IGNITION_COMMON_VISIBLE Battery
45  {
49 
51  public: explicit Battery();
52 
56  public: Battery(const std::string &_name, const double _voltage);
57 
59  public: virtual ~Battery();
60 
62  public: virtual void Init();
63 
67  public: virtual void ResetVoltage();
68 
71  public: virtual void SetInitVoltage(const double _voltage);
72 
75  public: std::string Name() const;
76 
79  public: void SetName(const std::string &_name) const;
80 
83  public: uint32_t AddConsumer();
84 
89  public: bool RemoveConsumer(const uint32_t _consumerId);
90 
95  public: bool SetPowerLoad(const uint32_t _consumerId,
96  const double _powerLoad);
97 
102  public: bool PowerLoad(const uint32_t _consumerId,
103  double &_powerLoad) const;
104 
107  public: const PowerLoad_M &PowerLoads() const;
108 
111  public: double Voltage() const;
112 
120  public: void SetUpdateFunc(
121  std::function<double (Battery *)> _updateFunc);
122 
126  public: void Update();
127 
129  protected: void InitConsumers();
130 
134  private: double UpdateDefault(Battery *_battery);
135 
139  private: std::unique_ptr<BatteryPrivate> dataPtr;
141  };
142  }
143 }
144 #endif
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
STL class.
A battery abstraction.
Definition: Battery.hh:44
Forward declarations for the common classes.
std::map< uint32_t, double > PowerLoad_M
Typedef the powerload map.
Definition: Battery.hh:48
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64