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

#include <EpEnergySinkBase.h>

Inheritance diagram for inet::power::EpEnergySinkBase:
inet::power::EnergySinkBase inet::power::IEpEnergySink inet::power::IEnergySink inet::power::IEnergySink inet::power::EpEnergyStorageBase inet::power::IdealEpEnergyStorage inet::power::SimpleEpEnergyStorage

Public Member Functions

virtual W getTotalPowerGeneration () const override
 Returns the total power generation in the range [0, +infinity). More...
 
virtual void addEnergyGenerator (const IEnergyGenerator *energyGenerator) override
 Adds a new energy generator to the energy sink. More...
 
virtual void removeEnergyGenerator (const IEnergyGenerator *energyGenerator) override
 Removes a previously added energy generator from this energy sink. More...
 
- Public Member Functions inherited from inet::power::EnergySinkBase
virtual int getNumEnergyGenerators () const override
 Returns the number of energy generators in the range [0, +infinity). More...
 
virtual const IEnergyGeneratorgetEnergyGenerator (int index) const override
 Returns the energy generator for the provided index. More...
 
- Public Member Functions inherited from inet::power::IEnergySink
virtual ~IEnergySink ()
 

Protected Member Functions

virtual W computeTotalPowerGeneration () const
 
virtual void updateTotalPowerGeneration ()
 

Protected Attributes

W totalPowerGeneration = W(NaN)
 
- Protected Attributes inherited from inet::power::EnergySinkBase
std::vector< const IEnergyGenerator * > energyGenerators
 

Additional Inherited Members

- Static Public Attributes inherited from inet::power::IEpEnergySink
static simsignal_t powerGenerationChangedSignal = cComponent::registerSignal("powerGenerationChanged")
 The signal that is used to publish power generation changes. More...
 

Member Function Documentation

void inet::power::EpEnergySinkBase::addEnergyGenerator ( const IEnergyGenerator energyGenerator)
overridevirtual

Adds a new energy generator to the energy sink.

The energyGenerator parameter must not be nullptr.

Reimplemented from inet::power::EnergySinkBase.

Reimplemented in inet::power::EpEnergyStorageBase.

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

38 {
39  EnergySinkBase::addEnergyGenerator(energyGenerator);
40  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyGenerator));
41  module->subscribe(IEpEnergyGenerator::powerGenerationChangedSignal, this);
43 }
virtual void addEnergyGenerator(const IEnergyGenerator *energyGenerator) override
Adds a new energy generator to the energy sink.
Definition: EnergySinkBase.cc:30
virtual void updateTotalPowerGeneration()
Definition: EpEnergySinkBase.cc:32
static simsignal_t powerGenerationChangedSignal
The signal that is used to publish power generation changes.
Definition: IEpEnergyGenerator.h:40
W inet::power::EpEnergySinkBase::computeTotalPowerGeneration ( ) const
protectedvirtual

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

25 {
27  for (auto energyGenerator : energyGenerators)
28  totalPowerGeneration += check_and_cast<const IEpEnergyGenerator *>(energyGenerator)->getPowerGeneration();
29  return totalPowerGeneration;
30 }
compose< J, pow< s,-1 > > W
Definition: Units.h:770
W totalPowerGeneration
Definition: EpEnergySinkBase.h:32
std::vector< const IEnergyGenerator * > energyGenerators
Definition: EnergySinkBase.h:30
virtual W inet::power::EpEnergySinkBase::getTotalPowerGeneration ( ) const
inlineoverridevirtual

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

Implements inet::power::IEpEnergySink.

39 { return totalPowerGeneration; }
W totalPowerGeneration
Definition: EpEnergySinkBase.h:32
void inet::power::EpEnergySinkBase::removeEnergyGenerator ( const IEnergyGenerator energyGenerator)
overridevirtual

Removes a previously added energy generator from this energy sink.

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

Reimplemented from inet::power::EnergySinkBase.

Reimplemented in inet::power::EpEnergyStorageBase.

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

46 {
48  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(energyGenerator));
49  module->unsubscribe(IEpEnergyGenerator::powerGenerationChangedSignal, this);
51 }
virtual void removeEnergyGenerator(const IEnergyGenerator *energyGenerator) override
Removes a previously added energy generator from this energy sink.
Definition: EnergySinkBase.cc:35
virtual void updateTotalPowerGeneration()
Definition: EpEnergySinkBase.cc:32
static simsignal_t powerGenerationChangedSignal
The signal that is used to publish power generation changes.
Definition: IEpEnergyGenerator.h:40
void inet::power::EpEnergySinkBase::updateTotalPowerGeneration ( )
protectedvirtual

Member Data Documentation


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