INET Framework for OMNeT++/OMNEST
inet::physicallayer::StateBasedCcEnergyConsumer Class Reference

This is a simple radio energy consumer model. More...

#include <StateBasedCcEnergyConsumer.h>

Inheritance diagram for inet::physicallayer::StateBasedCcEnergyConsumer:
inet::power::ICcEnergyConsumer inet::power::IEnergyConsumer

Public Member Functions

virtual power::IEnergySourcegetEnergySource () const override
 Returns the energy source that provides energy for this energy consumer. More...
 
virtual A getCurrentConsumption () const override
 Returns the current consumption in the range [0, +infinity). More...
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, intval_t value, cObject *details) override
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, double value, cObject *details) override
 
- Public Member Functions inherited from inet::power::IEnergyConsumer
virtual ~IEnergyConsumer ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual A computeCurrentConsumption () const
 

Protected Attributes

V minSupplyVoltage = V(NaN)
 
V maxSupplyVoltage = V(NaN)
 
A offCurrentConsumption = A(NaN)
 
A sleepCurrentConsumption = A(NaN)
 
A switchingCurrentConsumption = A(NaN)
 
A receiverIdleCurrentConsumption = A(NaN)
 
A receiverBusyCurrentConsumption = A(NaN)
 
A receiverReceivingCurrentConsumption = A(NaN)
 
A receiverReceivingPreambleCurrentConsumption = A(NaN)
 
A receiverReceivingHeaderCurrentConsumption = A(NaN)
 
A receiverReceivingDataCurrentConsumption = A(NaN)
 
A transmitterIdleCurrentConsumption = A(NaN)
 
A transmitterTransmittingCurrentConsumption = A(NaN)
 
A transmitterTransmittingPreambleCurrentConsumption = A(NaN)
 
A transmitterTransmittingHeaderCurrentConsumption = A(NaN)
 
A transmitterTransmittingDataCurrentConsumption = A(NaN)
 
IRadioradio = nullptr
 
power::ICcEnergySourceenergySource = nullptr
 
A currentConsumption = A(NaN)
 

Additional Inherited Members

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

Detailed Description

This is a simple radio energy consumer model.

The current consumption is determined by the radio mode, the transmitter state and the receiver state using constant parameters.

Member Function Documentation

◆ computeCurrentConsumption()

A inet::physicallayer::StateBasedCcEnergyConsumer::computeCurrentConsumption ( ) const
protectedvirtual
87 {
88  IRadio::RadioMode radioMode = radio->getRadioMode();
89  if (radioMode == IRadio::RADIO_MODE_OFF)
90  return offCurrentConsumption;
91  else if (radioMode == IRadio::RADIO_MODE_SLEEP)
93  else if (radioMode == IRadio::RADIO_MODE_SWITCHING)
95  A currentConsumption = A(0);
98  if (radioMode == IRadio::RADIO_MODE_RECEIVER || radioMode == IRadio::RADIO_MODE_TRANSCEIVER) {
99  if (receptionState == IRadio::RECEPTION_STATE_IDLE)
101  else if (receptionState == IRadio::RECEPTION_STATE_BUSY)
103  else if (receptionState == IRadio::RECEPTION_STATE_RECEIVING) {
104  auto part = radio->getReceivedSignalPart();
105  if (part == IRadioSignal::SIGNAL_PART_NONE)
106  ;
107  else if (part == IRadioSignal::SIGNAL_PART_WHOLE)
109  else if (part == IRadioSignal::SIGNAL_PART_PREAMBLE)
111  else if (part == IRadioSignal::SIGNAL_PART_HEADER)
113  else if (part == IRadioSignal::SIGNAL_PART_DATA)
115  else
116  throw cRuntimeError("Unknown received signal part");
117  }
118  else if (receptionState != IRadio::RECEPTION_STATE_UNDEFINED)
119  throw cRuntimeError("Unknown radio reception state");
120  }
121  if (radioMode == IRadio::RADIO_MODE_TRANSMITTER || radioMode == IRadio::RADIO_MODE_TRANSCEIVER) {
122  if (transmissionState == IRadio::TRANSMISSION_STATE_IDLE)
124  else if (transmissionState == IRadio::TRANSMISSION_STATE_TRANSMITTING) {
125  // TODO add transmission power?
126  auto part = radio->getTransmittedSignalPart();
127  if (part == IRadioSignal::SIGNAL_PART_NONE)
128  ;
129  else if (part == IRadioSignal::SIGNAL_PART_WHOLE)
131  else if (part == IRadioSignal::SIGNAL_PART_PREAMBLE)
133  else if (part == IRadioSignal::SIGNAL_PART_HEADER)
135  else if (part == IRadioSignal::SIGNAL_PART_DATA)
137  else
138  throw cRuntimeError("Unknown transmitted signal part");
139  }
140  else if (transmissionState != IRadio::TRANSMISSION_STATE_UNDEFINED)
141  throw cRuntimeError("Unknown radio transmission state");
142  }
143  return currentConsumption;
144 }

◆ getCurrentConsumption()

virtual A inet::physicallayer::StateBasedCcEnergyConsumer::getCurrentConsumption ( ) const
inlineoverridevirtual

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

Implements inet::power::ICcEnergyConsumer.

60 { return currentConsumption; }

◆ getEnergySource()

virtual power::IEnergySource* inet::physicallayer::StateBasedCcEnergyConsumer::getEnergySource ( ) const
inlineoverridevirtual

Returns the energy source that provides energy for this energy consumer.

This function never returns nullptr.

Implements inet::power::IEnergyConsumer.

59 { return energySource; }

◆ initialize()

void inet::physicallayer::StateBasedCcEnergyConsumer::initialize ( int  stage)
overrideprotectedvirtual
21 {
22  cSimpleModule::initialize(stage);
23  if (stage == INITSTAGE_LOCAL) {
24  minSupplyVoltage = V(par("minSupplyVoltage"));
25  maxSupplyVoltage = V(par("maxSupplyVoltage"));
26  offCurrentConsumption = A(par("offCurrentConsumption"));
27  sleepCurrentConsumption = A(par("sleepCurrentConsumption"));
28  switchingCurrentConsumption = A(par("switchingCurrentConsumption"));
29  receiverIdleCurrentConsumption = A(par("receiverIdleCurrentConsumption"));
30  receiverBusyCurrentConsumption = A(par("receiverBusyCurrentConsumption"));
31  receiverReceivingCurrentConsumption = A(par("receiverReceivingCurrentConsumption"));
32  receiverReceivingPreambleCurrentConsumption = A(par("receiverReceivingPreambleCurrentConsumption"));
33  receiverReceivingHeaderCurrentConsumption = A(par("receiverReceivingHeaderCurrentConsumption"));
34  receiverReceivingDataCurrentConsumption = A(par("receiverReceivingDataCurrentConsumption"));
35  transmitterIdleCurrentConsumption = A(par("transmitterIdleCurrentConsumption"));
36  transmitterTransmittingCurrentConsumption = A(par("transmitterTransmittingCurrentConsumption"));
37  transmitterTransmittingPreambleCurrentConsumption = A(par("transmitterTransmittingPreambleCurrentConsumption"));
38  transmitterTransmittingHeaderCurrentConsumption = A(par("transmitterTransmittingHeaderCurrentConsumption"));
39  transmitterTransmittingDataCurrentConsumption = A(par("transmitterTransmittingDataCurrentConsumption"));
40  cModule *radioModule = getParentModule();
41  radioModule->subscribe(IRadio::radioModeChangedSignal, this);
42  radioModule->subscribe(IRadio::receptionStateChangedSignal, this);
43  radioModule->subscribe(IRadio::transmissionStateChangedSignal, this);
44  radioModule->subscribe(IRadio::receivedSignalPartChangedSignal, this);
45  radioModule->subscribe(IRadio::transmittedSignalPartChangedSignal, this);
46  radio = check_and_cast<IRadio *>(radioModule);
47  const char *energySourceModule = par("energySourceModule");
48  energySource = check_and_cast<ICcEnergySource *>(getModuleByPath(energySourceModule));
49  check_and_cast<cModule *>(energySource)->subscribe(ICcEnergySource::currentConsumptionChangedSignal, this);
50  currentConsumption = A(0);
51  WATCH(currentConsumption);
52  }
53  else if (stage == INITSTAGE_POWER)
55 }

◆ numInitStages()

virtual int inet::physicallayer::StateBasedCcEnergyConsumer::numInitStages ( ) const
inlineoverrideprotectedvirtual
54 { return NUM_INIT_STAGES; }

◆ receiveSignal() [1/2]

void inet::physicallayer::StateBasedCcEnergyConsumer::receiveSignal ( cComponent *  source,
simsignal_t  signal,
double  value,
cObject *  details 
)
overridevirtual
75 {
76  Enter_Method("%s", cComponent::getSignalName(signal));
77 
81  }
82  else
83  throw cRuntimeError("Unknown signal");
84 }

◆ receiveSignal() [2/2]

void inet::physicallayer::StateBasedCcEnergyConsumer::receiveSignal ( cComponent *  source,
simsignal_t  signal,
intval_t  value,
cObject *  details 
)
overridevirtual
58 {
59  Enter_Method("%s", cComponent::getSignalName(signal));
60 
61  if (signal == IRadio::radioModeChangedSignal ||
66  {
69  }
70  else
71  throw cRuntimeError("Unknown signal");
72 }

Member Data Documentation

◆ currentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::currentConsumption = A(NaN)
protected

◆ energySource

power::ICcEnergySource* inet::physicallayer::StateBasedCcEnergyConsumer::energySource = nullptr
protected

◆ maxSupplyVoltage

V inet::physicallayer::StateBasedCcEnergyConsumer::maxSupplyVoltage = V(NaN)
protected

◆ minSupplyVoltage

V inet::physicallayer::StateBasedCcEnergyConsumer::minSupplyVoltage = V(NaN)
protected

◆ offCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::offCurrentConsumption = A(NaN)
protected

◆ radio

IRadio* inet::physicallayer::StateBasedCcEnergyConsumer::radio = nullptr
protected

◆ receiverBusyCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverBusyCurrentConsumption = A(NaN)
protected

◆ receiverIdleCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverIdleCurrentConsumption = A(NaN)
protected

◆ receiverReceivingCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingCurrentConsumption = A(NaN)
protected

◆ receiverReceivingDataCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingDataCurrentConsumption = A(NaN)
protected

◆ receiverReceivingHeaderCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingHeaderCurrentConsumption = A(NaN)
protected

◆ receiverReceivingPreambleCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingPreambleCurrentConsumption = A(NaN)
protected

◆ sleepCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::sleepCurrentConsumption = A(NaN)
protected

◆ switchingCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::switchingCurrentConsumption = A(NaN)
protected

◆ transmitterIdleCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::transmitterIdleCurrentConsumption = A(NaN)
protected

◆ transmitterTransmittingCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingCurrentConsumption = A(NaN)
protected

◆ transmitterTransmittingDataCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingDataCurrentConsumption = A(NaN)
protected

◆ transmitterTransmittingHeaderCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingHeaderCurrentConsumption = A(NaN)
protected

◆ transmitterTransmittingPreambleCurrentConsumption

A inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingPreambleCurrentConsumption = A(NaN)
protected

The documentation for this class was generated from the following files:
inet::physicallayer::IRadio::setRadioMode
virtual void setRadioMode(RadioMode radioMode)=0
Changes the current radio mode.
inet::physicallayer::StateBasedCcEnergyConsumer::minSupplyVoltage
V minSupplyVoltage
Definition: StateBasedCcEnergyConsumer.h:29
inet::physicallayer::IRadioSignal::SIGNAL_PART_WHOLE
@ SIGNAL_PART_WHOLE
Definition: IRadioSignal.h:26
inet::physicallayer::IRadio::RECEPTION_STATE_IDLE
@ RECEPTION_STATE_IDLE
The radio medium is free, no signal is detected.
Definition: IRadio.h:136
inet::physicallayer::IRadio::RADIO_MODE_TRANSCEIVER
@ RADIO_MODE_TRANSCEIVER
The radio is prepared for simultaneous frame reception and transmission, power consumption is low whe...
Definition: IRadio.h:111
inet::INITSTAGE_POWER
INET_API InitStage INITSTAGE_POWER
Initialization of the power model: energy storage, energy consumer, energy generator,...
inet::physicallayer::StateBasedCcEnergyConsumer::energySource
power::ICcEnergySource * energySource
Definition: StateBasedCcEnergyConsumer.h:48
inet::physicallayer::IRadioSignal::SIGNAL_PART_NONE
@ SIGNAL_PART_NONE
Definition: IRadioSignal.h:25
inet::physicallayer::IRadio::RADIO_MODE_OFF
@ RADIO_MODE_OFF
The radio is turned off, frame reception or transmission is not possible, power consumption is zero,...
Definition: IRadio.h:84
inet::physicallayer::IRadio::RADIO_MODE_SWITCHING
@ RADIO_MODE_SWITCHING
The radio is switching from one mode to another, frame reception or transmission is not possible,...
Definition: IRadio.h:117
inet::physicallayer::IRadio::RADIO_MODE_SLEEP
@ RADIO_MODE_SLEEP
The radio is sleeping, frame reception or transmission is not possible, power consumption is minimal,...
Definition: IRadio.h:90
inet::power::IEnergySource::addEnergyConsumer
virtual void addEnergyConsumer(const IEnergyConsumer *energyConsumer)=0
Adds a new energy consumer to the energy source.
inet::units::units::V
compose< W, pow< A, -1 > > V
Definition: Units.h:942
inet::physicallayer::IRadio::RECEPTION_STATE_RECEIVING
@ RECEPTION_STATE_RECEIVING
The radio medium is busy, a signal strong enough to receive is detected.
Definition: IRadio.h:149
inet::physicallayer::StateBasedCcEnergyConsumer::receiverBusyCurrentConsumption
A receiverBusyCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:35
inet::power::ICcEnergyConsumer::currentConsumptionChangedSignal
static simsignal_t currentConsumptionChangedSignal
The signal that is used to publish current consumption changes.
Definition: ICcEnergyConsumer.h:29
inet::physicallayer::StateBasedCcEnergyConsumer::sleepCurrentConsumption
A sleepCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:32
inet::physicallayer::IRadio::RECEPTION_STATE_UNDEFINED
@ RECEPTION_STATE_UNDEFINED
The radio medium state is unknown, reception state is meaningless, signal detection is not possible.
Definition: IRadio.h:130
inet::physicallayer::IRadio::transmissionStateChangedSignal
static simsignal_t transmissionStateChangedSignal
This signal is emitted when the radio transmission state of the radio is changed.
Definition: IRadio.h:60
inet::physicallayer::IRadio::RADIO_MODE_TRANSMITTER
@ RADIO_MODE_TRANSMITTER
The radio is prepared for frame transmission, frame reception is not possible, power consumption is l...
Definition: IRadio.h:104
inet::physicallayer::IRadio::getTransmissionState
virtual TransmissionState getTransmissionState() const =0
Returns the current radio transmission state.
inet::physicallayer::IRadio::ReceptionState
ReceptionState
This enumeration specifies the reception state of the radio.
Definition: IRadio.h:124
inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingCurrentConsumption
A transmitterTransmittingCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:41
inet::units::values::A
value< double, units::A > A
Definition: Units.h:1238
inet::physicallayer::IRadio::receivedSignalPartChangedSignal
static simsignal_t receivedSignalPartChangedSignal
This signal is emitted when the received part is changed by the radio.
Definition: IRadio.h:66
inet::physicallayer::IRadio::transmittedSignalPartChangedSignal
static simsignal_t transmittedSignalPartChangedSignal
This signal is emitted when the transmitted part is changed by the radio.
Definition: IRadio.h:72
inet::physicallayer::StateBasedCcEnergyConsumer::switchingCurrentConsumption
A switchingCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:33
inet::physicallayer::IRadioSignal::SIGNAL_PART_HEADER
@ SIGNAL_PART_HEADER
Definition: IRadioSignal.h:28
inet::physicallayer::StateBasedCcEnergyConsumer::offCurrentConsumption
A offCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:31
inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingPreambleCurrentConsumption
A receiverReceivingPreambleCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:37
inet::physicallayer::IRadioSignal::SIGNAL_PART_PREAMBLE
@ SIGNAL_PART_PREAMBLE
Definition: IRadioSignal.h:27
inet::physicallayer::IRadio::getRadioMode
virtual RadioMode getRadioMode() const =0
Returns the current radio mode, This is the same mode as the one emitted with the last radioModeChang...
inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingHeaderCurrentConsumption
A transmitterTransmittingHeaderCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:43
inet::physicallayer::IRadio::RADIO_MODE_RECEIVER
@ RADIO_MODE_RECEIVER
The radio is prepared for frame reception, frame transmission is not possible, power consumption is l...
Definition: IRadio.h:97
inet::physicallayer::IRadio::getReceivedSignalPart
virtual IRadioSignal::SignalPart getReceivedSignalPart() const =0
Returns the signal part of the ongoing reception that the receiver is currently receiving or -1 if no...
inet::physicallayer::StateBasedCcEnergyConsumer::computeCurrentConsumption
virtual A computeCurrentConsumption() const
Definition: StateBasedCcEnergyConsumer.cc:86
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicallayer::IRadio::TRANSMISSION_STATE_TRANSMITTING
@ TRANSMISSION_STATE_TRANSMITTING
The radio medium is busy, the radio is currently transmitting a signal.
Definition: IRadio.h:171
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::physicallayer::IRadioSignal::SIGNAL_PART_DATA
@ SIGNAL_PART_DATA
Definition: IRadioSignal.h:29
inet::physicallayer::IRadio::getTransmittedSignalPart
virtual IRadioSignal::SignalPart getTransmittedSignalPart() const =0
Returns the signal part of the ongoing transmission that the transmitter is currently transmitting or...
inet::physicallayer::IRadio::RECEPTION_STATE_BUSY
@ RECEPTION_STATE_BUSY
The radio medium is busy, a signal is detected but it is not strong enough to receive.
Definition: IRadio.h:143
inet::physicallayer::StateBasedCcEnergyConsumer::maxSupplyVoltage
V maxSupplyVoltage
Definition: StateBasedCcEnergyConsumer.h:30
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::physicallayer::IRadio::TransmissionState
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
inet::units::value::get
const value_type & get() const
Definition: Units.h:108
inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingDataCurrentConsumption
A receiverReceivingDataCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:39
inet::physicallayer::IRadio::RadioMode
RadioMode
This enumeration specifies the requested operational mode of the radio.
Definition: IRadio.h:79
inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingCurrentConsumption
A receiverReceivingCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:36
inet::physicallayer::StateBasedCcEnergyConsumer::radio
IRadio * radio
Definition: StateBasedCcEnergyConsumer.h:47
inet::physicallayer::StateBasedCcEnergyConsumer::transmitterIdleCurrentConsumption
A transmitterIdleCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:40
inet::physicallayer::IRadio::TRANSMISSION_STATE_UNDEFINED
@ TRANSMISSION_STATE_UNDEFINED
The transmission state is undefined or meaningless.
Definition: IRadio.h:160
inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingPreambleCurrentConsumption
A transmitterTransmittingPreambleCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:42
inet::physicallayer::IRadio::TRANSMISSION_STATE_IDLE
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
inet::power::ICcEnergySource::getOutputVoltage
virtual V getOutputVoltage() const =0
Returns the output voltage in the ragne [0, +infinity).
inet::physicallayer::StateBasedCcEnergyConsumer::transmitterTransmittingDataCurrentConsumption
A transmitterTransmittingDataCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:44
inet::physicallayer::IRadio::getReceptionState
virtual ReceptionState getReceptionState() const =0
Returns the current radio reception state.
inet::physicallayer::StateBasedCcEnergyConsumer::currentConsumption
A currentConsumption
Definition: StateBasedCcEnergyConsumer.h:51
inet::physicallayer::StateBasedCcEnergyConsumer::receiverIdleCurrentConsumption
A receiverIdleCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:34
inet::power::ICcEnergySource::currentConsumptionChangedSignal
static simsignal_t currentConsumptionChangedSignal
The signal that is used to publish current consumption changes.
Definition: ICcEnergySource.h:29
inet::physicallayer::IRadio::receptionStateChangedSignal
static simsignal_t receptionStateChangedSignal
This signal is emitted when the radio reception state of the radio is changed.
Definition: IRadio.h:54
inet::physicallayer::StateBasedCcEnergyConsumer::receiverReceivingHeaderCurrentConsumption
A receiverReceivingHeaderCurrentConsumption
Definition: StateBasedCcEnergyConsumer.h:38
inet::physicallayer::IRadio::radioModeChangedSignal
static simsignal_t radioModeChangedSignal
This signal is emitted when the radio mode of the radio is changed.
Definition: IRadio.h:42