A battery abstraction.
More...
#include <Battery.hh>
Inherits enable_shared_from_this< Battery >.
|
typedef std::map< uint32_t, double > | PowerLoad_M |
| Typedef the powerload map.
|
|
|
| Battery () |
| Constructor.
|
|
virtual | ~Battery () |
| Destructor.
|
|
uint32_t | AddConsumer () |
| Create a unique consumer.
|
|
virtual void | Init () |
| Initialize.
|
|
virtual void | Load (sdf::ElementPtr _sdf) |
| Load the battery.
|
|
std::string | Name () const |
| Return the name of the battery.
|
|
bool | PowerLoad (const uint32_t _consumerId, double &_powerLoad) const |
| Get consumer power load in watts.
|
|
const PowerLoad_M & | PowerLoads () const |
| Get list of power loads in watts.
|
|
bool | RemoveConsumer (const uint32_t _consumerId) |
| Remove a consumer.
|
|
virtual void | ResetVoltage () |
| Reset the battery voltage to the initial value.
|
|
bool | SetPowerLoad (const uint32_t _consumerId, const double _powerLoad) |
| Set consumer power load in watts.
|
|
void | SetUpdateFunc (std::function< double(const BatteryPtr &)> _updateFunc) |
| Setup function to update voltage.
|
|
void | Update () |
| Update the battery.
|
|
virtual void | UpdateParameters (const sdf::ElementPtr _sdf) |
| Update the parameters using new sdf values.
|
|
double | Voltage () const |
| Get the real voltage in volts.
|
|
A battery abstraction.
The default battery model is ideal: It just takes the initial voltage value as its constant voltage value. This behavior can be changed by specifying a custom update function.
The battery handles a list of consumers. It updates itself after each simulation iteration. The update function takes the power loads for each consumer and current voltage value as inputs and returns a new voltage value.
◆ PowerLoad_M
◆ Battery()
◆ ~Battery()
◆ AddConsumer()
Create a unique consumer.
- Returns
- Unique consumer identifier.
◆ Init()
◆ InitConsumers()
Initialize the list of consumers.
◆ Load()
virtual void Load |
( |
sdf::ElementPtr | _sdf | ) |
|
|
virtual |
Load the battery.
- Parameters
-
[in] | _sdf | Shared point to an sdf element. |
◆ Name()
std::string Name |
( |
| ) |
const |
Return the name of the battery.
- Returns
- The name of the battery.
◆ PowerLoad()
bool PowerLoad |
( |
const uint32_t | _consumerId, |
|
|
double & | _powerLoad ) const |
Get consumer power load in watts.
- Parameters
-
[in] | _consumerId | Unique consumer identifier. |
[out] | _powerLoad | Power load consumption in watts. |
- Returns
- True if getting the power load consumption was successful.
◆ PowerLoads()
Get list of power loads in watts.
- Returns
- List of power loads in watts.
◆ RemoveConsumer()
bool RemoveConsumer |
( |
const uint32_t | _consumerId | ) |
|
Remove a consumer.
- Parameters
-
[in] | _consumerId | Unique consumer identifier. |
- Returns
- True if the consumer was removed. False if the consumer id was not found.
◆ ResetVoltage()
virtual void ResetVoltage |
( |
| ) |
|
|
virtual |
Reset the battery voltage to the initial value.
The initial value might have been loaded from an sdf element.
- See also
- Load
◆ SetPowerLoad()
bool SetPowerLoad |
( |
const uint32_t | _consumerId, |
|
|
const double | _powerLoad ) |
Set consumer power load in watts.
- Parameters
-
[in] | _consumerId | Unique consumer identifier. |
[in] | _powerLoad | Power load in watts. |
- Returns
- True if setting the power load consumption was successful.
◆ SetUpdateFunc()
void SetUpdateFunc |
( |
std::function< double(const BatteryPtr &)> | _updateFunc | ) |
|
Setup function to update voltage.
- Parameters
-
[in] | _updateFunc | The update function callback that is used to modify the battery's voltage. The parameter to the update function callback is a reference to an instance of Battery::UpdateData. The update function must return the new battery voltage as a double. |
- See also
- UpdateData
◆ Update()
Update the battery.
This will in turn trigger the function set using the SetUpdateFunc function.
- See also
- SetUpdateFunc.
◆ UpdateParameters()
virtual void UpdateParameters |
( |
const sdf::ElementPtr | _sdf | ) |
|
|
virtual |
Update the parameters using new sdf values.
- Parameters
-
[in] | _sdf | SDF values to update from. |
◆ Voltage()
Get the real voltage in volts.
- Returns
- Voltage.
The documentation for this class was generated from the following file: