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

This class implements a simple power based alternating energy generator. More...

#include <AlternatingEpEnergyGenerator.h>

Inheritance diagram for inet::power::AlternatingEpEnergyGenerator:
inet::power::IEpEnergyGenerator inet::power::IEnergyGenerator

Public Member Functions

virtual ~AlternatingEpEnergyGenerator ()
 
virtual IEnergySinkgetEnergySink () const override
 Returns the energy sink that absorbs energy from this energy generator. More...
 
virtual W getPowerGeneration () const override
 Returns the power generation in the range [0, +infinity). More...
 
- Public Member Functions inherited from inet::power::IEnergyGenerator
virtual ~IEnergyGenerator ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void updatePowerGeneration ()
 
virtual void scheduleIntervalTimer ()
 

Protected Attributes

IEpEnergySinkenergySink = nullptr
 
cMessage * timer = nullptr
 
bool isSleeping = false
 
W powerGeneration = W(NaN)
 

Additional Inherited Members

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

Detailed Description

This class implements a simple power based alternating energy generator.

See the corresponding NED file for more details.

Author
Levente Meszaros

Constructor & Destructor Documentation

inet::power::AlternatingEpEnergyGenerator::~AlternatingEpEnergyGenerator ( )
virtual
27 {
28  cancelAndDelete(timer);
29 }
cMessage * timer
Definition: AlternatingEpEnergyGenerator.h:40

Member Function Documentation

virtual IEnergySink* inet::power::AlternatingEpEnergyGenerator::getEnergySink ( ) const
inlineoverridevirtual

Returns the energy sink that absorbs energy from this energy generator.

This function never returns nullptr.

Implements inet::power::IEnergyGenerator.

56 { return energySink; }
IEpEnergySink * energySink
Definition: AlternatingEpEnergyGenerator.h:39
virtual W inet::power::AlternatingEpEnergyGenerator::getPowerGeneration ( ) const
inlineoverridevirtual

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

Implements inet::power::IEpEnergyGenerator.

57 { return powerGeneration; }
W powerGeneration
Definition: AlternatingEpEnergyGenerator.h:44
void inet::power::AlternatingEpEnergyGenerator::handleMessage ( cMessage *  message)
overrideprotectedvirtual
48 {
49  if (message == timer) {
53  }
54  else
55  throw cRuntimeError("Unknown message");
56 }
virtual void scheduleIntervalTimer()
Definition: AlternatingEpEnergyGenerator.cc:64
virtual void updatePowerGeneration()
Definition: AlternatingEpEnergyGenerator.cc:58
bool isSleeping
Definition: AlternatingEpEnergyGenerator.h:43
cMessage * timer
Definition: AlternatingEpEnergyGenerator.h:40
void inet::power::AlternatingEpEnergyGenerator::initialize ( int  stage)
overrideprotectedvirtual
32 {
33  if (stage == INITSTAGE_LOCAL) {
34  const char *energySinkModule = par("energySinkModule");
35  energySink = dynamic_cast<IEpEnergySink *>(getModuleByPath(energySinkModule));
36  if (!energySink)
37  throw cRuntimeError("Energy sink module '%s' not found", energySinkModule);
38  timer = new cMessage("timer");
42  WATCH(isSleeping);
43  WATCH(powerGeneration);
44  }
45 }
W powerGeneration
Definition: AlternatingEpEnergyGenerator.h:44
IEpEnergySink * energySink
Definition: AlternatingEpEnergyGenerator.h:39
virtual void scheduleIntervalTimer()
Definition: AlternatingEpEnergyGenerator.cc:64
virtual void updatePowerGeneration()
Definition: AlternatingEpEnergyGenerator.cc:58
bool isSleeping
Definition: AlternatingEpEnergyGenerator.h:43
Local initializations.
Definition: InitStages.h:35
virtual void addEnergyGenerator(const IEnergyGenerator *energyGenerator)=0
Adds a new energy generator to the energy sink.
cMessage * timer
Definition: AlternatingEpEnergyGenerator.h:40
void inet::power::AlternatingEpEnergyGenerator::scheduleIntervalTimer ( )
protectedvirtual

Referenced by handleMessage(), and initialize().

65 {
66  scheduleAt(simTime() + (isSleeping ? par("sleepInterval") : par("generationInterval")), timer);
67 }
bool isSleeping
Definition: AlternatingEpEnergyGenerator.h:43
cMessage * timer
Definition: AlternatingEpEnergyGenerator.h:40
void inet::power::AlternatingEpEnergyGenerator::updatePowerGeneration ( )
protectedvirtual

Referenced by handleMessage(), and initialize().

59 {
60  powerGeneration = isSleeping ? W(0) : W(par("powerGeneration"));
62 }
W powerGeneration
Definition: AlternatingEpEnergyGenerator.h:44
const value_type & get() const
Definition: Units.h:89
compose< J, pow< s,-1 > > W
Definition: Units.h:770
bool isSleeping
Definition: AlternatingEpEnergyGenerator.h:43
static simsignal_t powerGenerationChangedSignal
The signal that is used to publish power generation changes.
Definition: IEpEnergySink.h:40

Member Data Documentation

IEpEnergySink* inet::power::AlternatingEpEnergyGenerator::energySink = nullptr
protected

Referenced by initialize().

bool inet::power::AlternatingEpEnergyGenerator::isSleeping = false
protected
W inet::power::AlternatingEpEnergyGenerator::powerGeneration = W(NaN)
protected
cMessage* inet::power::AlternatingEpEnergyGenerator::timer = nullptr
protected

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