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

#include <CcEnergySourceBase.h>

Inheritance diagram for inet::power::CcEnergySourceBase:
inet::power::EnergySourceBase inet::power::ICcEnergySource inet::power::IEnergySource inet::power::IEnergySource inet::power::CcEnergyStorageBase inet::power::SimpleCcBattery

Public Member Functions

virtual A getTotalCurrentConsumption () const override
 Returns the total current 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 ()
 
- Public Member Functions inherited from inet::power::ICcEnergySource
virtual V getNominalVoltage () const =0
 Returns the open circuit voltage in the range [0, +infinity). More...
 
virtual V getOutputVoltage () const =0
 Returns the output voltage in the ragne [0, +infinity). More...
 

Protected Member Functions

virtual A computeTotalCurrentConsumption () const
 
virtual void updateTotalCurrentConsumption ()
 

Protected Attributes

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

Additional Inherited Members

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

Member Function Documentation

◆ addEnergyConsumer()

void inet::power::CcEnergySourceBase::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::CcEnergyStorageBase.

28 {
30  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyConsumer));
33 }

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

◆ computeTotalCurrentConsumption()

A inet::power::CcEnergySourceBase::computeTotalCurrentConsumption ( ) const
protectedvirtual
15 {
17  for (auto energyConsumer : energyConsumers)
18  totalCurrentConsumption += check_and_cast<const ICcEnergyConsumer *>(energyConsumer)->getCurrentConsumption();
20 }

Referenced by inet::power::CcEnergyStorageBase::initialize(), and updateTotalCurrentConsumption().

◆ getTotalCurrentConsumption()

virtual A inet::power::CcEnergySourceBase::getTotalCurrentConsumption ( ) const
inlineoverridevirtual

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

Implements inet::power::ICcEnergySource.

Reimplemented in inet::power::SimpleCcBattery.

29 { return totalCurrentConsumption; }

◆ removeEnergyConsumer()

void inet::power::CcEnergySourceBase::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::CcEnergyStorageBase.

36 {
38  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyConsumer));
39  module->unsubscribe(ICcEnergyConsumer::currentConsumptionChangedSignal, this);
41 }

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

◆ updateTotalCurrentConsumption()

void inet::power::CcEnergySourceBase::updateTotalCurrentConsumption ( )
protectedvirtual

Member Data Documentation

◆ totalCurrentConsumption


The documentation for this class was generated from the following files:
inet::power::CcEnergySourceBase::updateTotalCurrentConsumption
virtual void updateTotalCurrentConsumption()
Definition: CcEnergySourceBase.cc:22
inet::power::ICcEnergyConsumer::currentConsumptionChangedSignal
static simsignal_t currentConsumptionChangedSignal
The signal that is used to publish current consumption changes.
Definition: ICcEnergyConsumer.h:29
inet::power::EnergySourceBase::addEnergyConsumer
virtual void addEnergyConsumer(const IEnergyConsumer *energyConsumer) override
Adds a new energy consumer to the energy source.
Definition: EnergySourceBase.cc:23
inet::units::values::A
value< double, units::A > A
Definition: Units.h:1238
inet::power::EnergySourceBase::removeEnergyConsumer
virtual void removeEnergyConsumer(const IEnergyConsumer *energyConsumer) override
Removes a previously added energy consumer from this energy source.
Definition: EnergySourceBase.cc:28
inet::power::CcEnergySourceBase::computeTotalCurrentConsumption
virtual A computeTotalCurrentConsumption() const
Definition: CcEnergySourceBase.cc:14
inet::power::CcEnergySourceBase::totalCurrentConsumption
A totalCurrentConsumption
Definition: CcEnergySourceBase.h:22
inet::power::EnergySourceBase::energyConsumers
std::vector< const IEnergyConsumer * > energyConsumers
Definition: EnergySourceBase.h:20