INET Framework for OMNeT++/OMNEST
inet::power::EpEnergySourceBase Class Reference

#include <EpEnergySourceBase.h>

Inheritance diagram for inet::power::EpEnergySourceBase:
inet::power::EnergySourceBase inet::power::IEpEnergySource inet::power::IEnergySource inet::power::IEnergySource inet::power::EpEnergyStorageBase inet::power::IdealEpEnergyStorage inet::power::SimpleEpEnergyStorage

Public Member Functions

virtual W getTotalPowerConsumption () const override
 Returns the total power consumption in the range [0, +infinity). More...
 
virtual void addEnergyConsumer (const IEnergyConsumer *energyConsumer) override
 Adds a new energy consumer to the energy source. More...
 
virtual void removeEnergyConsumer (const IEnergyConsumer *energyConsumer) override
 Removes a previously added energy consumer from this energy source. More...
 
- Public Member Functions inherited from inet::power::EnergySourceBase
virtual int getNumEnergyConsumers () const override
 Returns the number of energy consumers in the range [0, +infinity). More...
 
virtual const IEnergyConsumergetEnergyConsumer (int index) const override
 Returns the energy consumer for the provided index. More...
 
- Public Member Functions inherited from inet::power::IEnergySource
virtual ~IEnergySource ()
 

Protected Member Functions

virtual W computeTotalPowerConsumption () const
 
virtual void updateTotalPowerConsumption ()
 

Protected Attributes

W totalPowerConsumption = W(NaN)
 
- Protected Attributes inherited from inet::power::EnergySourceBase
std::vector< const IEnergyConsumer * > energyConsumers
 

Additional Inherited Members

- Static Public Attributes inherited from inet::power::IEpEnergySource
static simsignal_t powerConsumptionChangedSignal = cComponent::registerSignal("powerConsumptionChanged")
 The signal that is used to publish power consumption changes. More...
 

Member Function Documentation

void inet::power::EpEnergySourceBase::addEnergyConsumer ( const IEnergyConsumer energyConsumer)
overridevirtual

Adds a new energy consumer to the energy source.

The energyConsumer parameter must not be nullptr.

Reimplemented from inet::power::EnergySourceBase.

Reimplemented in inet::power::EpEnergyStorageBase.

Referenced by inet::power::EpEnergyStorageBase::addEnergyConsumer().

38 {
40  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyConsumer));
41  module->subscribe(IEpEnergyConsumer::powerConsumptionChangedSignal, this);
43 }
virtual void updateTotalPowerConsumption()
Definition: EpEnergySourceBase.cc:32
static simsignal_t powerConsumptionChangedSignal
The signal that is used to publish power consumption changes.
Definition: IEpEnergyConsumer.h:43
virtual void addEnergyConsumer(const IEnergyConsumer *energyConsumer) override
Adds a new energy consumer to the energy source.
Definition: EnergySourceBase.cc:30
W inet::power::EpEnergySourceBase::computeTotalPowerConsumption ( ) const
protectedvirtual

Referenced by inet::power::EpEnergyStorageBase::initialize(), and updateTotalPowerConsumption().

25 {
27  for (auto energyConsumer : energyConsumers)
28  totalPowerConsumption += check_and_cast<const IEpEnergyConsumer *>(energyConsumer)->getPowerConsumption();
29  return totalPowerConsumption;
30 }
W totalPowerConsumption
Definition: EpEnergySourceBase.h:32
compose< J, pow< s,-1 > > W
Definition: Units.h:770
std::vector< const IEnergyConsumer * > energyConsumers
Definition: EnergySourceBase.h:30
virtual W inet::power::EpEnergySourceBase::getTotalPowerConsumption ( ) const
inlineoverridevirtual

Returns the total power consumption in the range [0, +infinity).

Implements inet::power::IEpEnergySource.

39 { return totalPowerConsumption; }
W totalPowerConsumption
Definition: EpEnergySourceBase.h:32
void inet::power::EpEnergySourceBase::removeEnergyConsumer ( const IEnergyConsumer energyConsumer)
overridevirtual

Removes a previously added energy consumer from this energy source.

This functions throws an exception if the consumer is not found.

Reimplemented from inet::power::EnergySourceBase.

Reimplemented in inet::power::EpEnergyStorageBase.

Referenced by inet::power::EpEnergyStorageBase::removeEnergyConsumer().

46 {
48  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyConsumer));
49  module->unsubscribe(IEpEnergyConsumer::powerConsumptionChangedSignal, this);
51 }
virtual void removeEnergyConsumer(const IEnergyConsumer *energyConsumer) override
Removes a previously added energy consumer from this energy source.
Definition: EnergySourceBase.cc:35
virtual void updateTotalPowerConsumption()
Definition: EpEnergySourceBase.cc:32
static simsignal_t powerConsumptionChangedSignal
The signal that is used to publish power consumption changes.
Definition: IEpEnergyConsumer.h:43
void inet::power::EpEnergySourceBase::updateTotalPowerConsumption ( )
protectedvirtual

Member Data Documentation


The documentation for this class was generated from the following files: