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

#include <NoiseSource.h>

Inheritance diagram for inet::physicallayer::NoiseSource:
inet::physicallayer::IRadio inet::IPhysicalLayer inet::IPrintableObject

Public Member Functions

virtual ~NoiseSource ()
 
virtual const cGate * getRadioGate () const override
 Returns the gate of the radio that receives incoming signals. More...
 
virtual RadioMode getRadioMode () const override
 Returns the current radio mode, This is the same mode as the one emitted with the last radioModeChangedSignal. More...
 
virtual void setRadioMode (RadioMode radioMode) override
 Changes the current radio mode. More...
 
virtual ReceptionState getReceptionState () const override
 Returns the current radio reception state. More...
 
virtual TransmissionState getTransmissionState () const override
 Returns the current radio transmission state. More...
 
virtual int getId () const override
 Returns an identifier for this radio which is globally unique for the whole lifetime of the simulation among all radios. More...
 
virtual const IAntennagetAntenna () const override
 Returns the antenna used by the transceiver of this radio. More...
 
virtual const ITransmittergetTransmitter () const override
 Returns the transmitter part of this radio. More...
 
virtual const IReceivergetReceiver () const override
 Returns the receiver part of this radio. More...
 
virtual const IRadioMediumgetMedium () const override
 Returns the radio medium where this radio is transmitting and receiving radio signals. More...
 
virtual const ITransmissiongetTransmissionInProgress () const override
 Returns the ongoing transmission that the transmitter is currently transmitting or nullptr. More...
 
virtual const ITransmissiongetReceptionInProgress () const override
 Returns the ongoing reception that the receiver is currently receiving or nullptr. More...
 
virtual IRadioSignal::SignalPart getTransmittedSignalPart () const override
 Returns the signal part of the ongoing transmission that the transmitter is currently transmitting or -1 if no transmission is in progress. More...
 
virtual IRadioSignal::SignalPart getReceivedSignalPart () const override
 Returns the signal part of the ongoing reception that the receiver is currently receiving or -1 if no reception is in progress. More...
 
- Public Member Functions inherited from inet::IPhysicalLayer
virtual ~IPhysicalLayer ()
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const
 Prints this object to the provided output stream. More...
 
virtual std::string printToString () const
 
virtual std::string printToString (int level, int evFlags=0) const
 
virtual std::string getInfoStringRepresentation (int evFlags=0) const
 
virtual std::string getDetailStringRepresentation (int evFlags=0) const
 
virtual std::string getDebugStringRepresentation (int evFlags=0) const
 
virtual std::string getTraceStringRepresentation (int evFlags=0) const
 
virtual std::string getCompleteStringRepresentation (int evFlags=0) const
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void startTransmission ()
 
virtual void endTransmission ()
 
virtual void scheduleSleepTimer ()
 
virtual void scheduleTransmissionTimer (const ITransmission *transmission)
 

Protected Attributes

const int id = nextId++
 
cGate * radioIn = nullptr
 
int mediumModuleId = -1
 
ModuleRefByPar< IRadioMediummedium
 
const IAntennaantenna = nullptr
 
const ITransmittertransmitter = nullptr
 
cMessage * transmissionTimer = nullptr
 
cMessage * sleepTimer = nullptr
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IRadio
enum  RadioMode {
  RADIO_MODE_OFF, RADIO_MODE_SLEEP, RADIO_MODE_RECEIVER, RADIO_MODE_TRANSMITTER,
  RADIO_MODE_TRANSCEIVER, RADIO_MODE_SWITCHING
}
 This enumeration specifies the requested operational mode of the radio. More...
 
enum  ReceptionState { RECEPTION_STATE_UNDEFINED, RECEPTION_STATE_IDLE, RECEPTION_STATE_BUSY, RECEPTION_STATE_RECEIVING }
 This enumeration specifies the reception state of the radio. More...
 
enum  TransmissionState { TRANSMISSION_STATE_UNDEFINED, TRANSMISSION_STATE_IDLE, TRANSMISSION_STATE_TRANSMITTING }
 This enumeration specifies the transmission state of the radio. More...
 
- Public Types inherited from inet::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 
- Static Public Member Functions inherited from inet::physicallayer::IRadio
static const char * getRadioModeName (RadioMode radioMode)
 Returns the name of the provided radio mode. More...
 
static const char * getRadioReceptionStateName (ReceptionState receptionState)
 Returns the name of the provided radio reception state. More...
 
static const char * getRadioTransmissionStateName (TransmissionState transmissionState)
 Returns the name of the provided radio transmission state. More...
 
- Static Public Attributes inherited from inet::physicallayer::IRadio
static simsignal_t radioModeChangedSignal = cComponent::registerSignal("radioModeChanged")
 This signal is emitted when the radio mode of the radio is changed. More...
 
static simsignal_t listeningChangedSignal = cComponent::registerSignal("listeningChanged")
 This signal is emitted when the radio listening of the radio is changed. More...
 
static simsignal_t receptionStateChangedSignal = cComponent::registerSignal("receptionStateChanged")
 This signal is emitted when the radio reception state of the radio is changed. More...
 
static simsignal_t transmissionStateChangedSignal = cComponent::registerSignal("transmissionStateChanged")
 This signal is emitted when the radio transmission state of the radio is changed. More...
 
static simsignal_t receivedSignalPartChangedSignal = cComponent::registerSignal("receivedSignalPartChanged")
 This signal is emitted when the received part is changed by the radio. More...
 
static simsignal_t transmittedSignalPartChangedSignal = cComponent::registerSignal("transmittedSignalPartChanged")
 This signal is emitted when the transmitted part is changed by the radio. More...
 
- Static Protected Attributes inherited from inet::physicallayer::IRadio
static int nextId = 0
 
static cEnum * radioModeEnum = nullptr
 The enumeration registered for radio mode. More...
 
static cEnum * receptionStateEnum = nullptr
 The enumeration registered for radio reception state. More...
 
static cEnum * transmissionStateEnum = nullptr
 The enumeration registered for radio transmission state. More...
 

Constructor & Destructor Documentation

◆ ~NoiseSource()

inet::physicallayer::NoiseSource::~NoiseSource ( )
virtual
19 {
20  // NOTE: can't use the medium module here, because it may have been already deleted
21  cModule *medium = getSimulation()->getModule(mediumModuleId);
22  if (medium != nullptr)
23  check_and_cast<IRadioMedium *>(medium)->removeRadio(this);
24  cancelAndDelete(sleepTimer);
25  cancelAndDelete(transmissionTimer);
26 }

Member Function Documentation

◆ endTransmission()

void inet::physicallayer::NoiseSource::endTransmission ( )
protectedvirtual
64 {
65  transmissionTimer->setContextPointer(nullptr);
67 }

Referenced by handleMessage().

◆ getAntenna()

virtual const IAntenna* inet::physicallayer::NoiseSource::getAntenna ( ) const
inlineoverridevirtual

Returns the antenna used by the transceiver of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

56 { return antenna; }

◆ getId()

virtual int inet::physicallayer::NoiseSource::getId ( ) const
inlineoverridevirtual

Returns an identifier for this radio which is globally unique for the whole lifetime of the simulation among all radios.

Implements inet::physicallayer::IRadio.

54 { return id; } // TODO

◆ getMedium()

virtual const IRadioMedium* inet::physicallayer::NoiseSource::getMedium ( ) const
inlineoverridevirtual

Returns the radio medium where this radio is transmitting and receiving radio signals.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

59 { return medium; }

◆ getRadioGate()

virtual const cGate* inet::physicallayer::NoiseSource::getRadioGate ( ) const
inlineoverridevirtual

Returns the gate of the radio that receives incoming signals.

Implements inet::physicallayer::IRadio.

46 { return radioIn; }

◆ getRadioMode()

virtual RadioMode inet::physicallayer::NoiseSource::getRadioMode ( ) const
inlineoverridevirtual

Returns the current radio mode, This is the same mode as the one emitted with the last radioModeChangedSignal.

Implements inet::physicallayer::IRadio.

48 { return RADIO_MODE_TRANSMITTER; }

◆ getReceivedSignalPart()

virtual IRadioSignal::SignalPart inet::physicallayer::NoiseSource::getReceivedSignalPart ( ) const
inlineoverridevirtual

Returns the signal part of the ongoing reception that the receiver is currently receiving or -1 if no reception is in progress.

This is the same part as the one emitted with the last receivedPartChangedSignal.

Implements inet::physicallayer::IRadio.

◆ getReceiver()

virtual const IReceiver* inet::physicallayer::NoiseSource::getReceiver ( ) const
inlineoverridevirtual

Returns the receiver part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

58 { return nullptr; }

◆ getReceptionInProgress()

virtual const ITransmission* inet::physicallayer::NoiseSource::getReceptionInProgress ( ) const
inlineoverridevirtual

Returns the ongoing reception that the receiver is currently receiving or nullptr.

Implements inet::physicallayer::IRadio.

62 { return nullptr; }

◆ getReceptionState()

virtual ReceptionState inet::physicallayer::NoiseSource::getReceptionState ( ) const
inlineoverridevirtual

Returns the current radio reception state.

This is the same state as the one emitted with the last receptionStateChangedSignal.

Implements inet::physicallayer::IRadio.

51 { return RECEPTION_STATE_UNDEFINED; }

◆ getTransmissionInProgress()

const ITransmission * inet::physicallayer::NoiseSource::getTransmissionInProgress ( ) const
overridevirtual

Returns the ongoing transmission that the transmitter is currently transmitting or nullptr.

Implements inet::physicallayer::IRadio.

80 {
81  if (!transmissionTimer->isScheduled())
82  return nullptr;
83  else
84  return static_cast<WirelessSignal *>(transmissionTimer->getContextPointer())->getTransmission();
85 }

◆ getTransmissionState()

virtual TransmissionState inet::physicallayer::NoiseSource::getTransmissionState ( ) const
inlineoverridevirtual

Returns the current radio transmission state.

This is the same state as the one emitted with the last transmissionStateChangedSignal.

Implements inet::physicallayer::IRadio.

◆ getTransmittedSignalPart()

virtual IRadioSignal::SignalPart inet::physicallayer::NoiseSource::getTransmittedSignalPart ( ) const
inlineoverridevirtual

Returns the signal part of the ongoing transmission that the transmitter is currently transmitting or -1 if no transmission is in progress.

This is the same part as the one emitted with the last transmittedPartChangedSignal.

Implements inet::physicallayer::IRadio.

◆ getTransmitter()

virtual const ITransmitter* inet::physicallayer::NoiseSource::getTransmitter ( ) const
inlineoverridevirtual

Returns the transmitter part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

57 { return transmitter; }

◆ handleMessage()

void inet::physicallayer::NoiseSource::handleMessage ( cMessage *  message)
overrideprotectedvirtual
47 {
48  if (message == sleepTimer)
50  else if (message == transmissionTimer)
52  else
53  delete message;
54 }

◆ initialize()

void inet::physicallayer::NoiseSource::initialize ( int  stage)
overrideprotectedvirtual
29 {
30  if (stage == INITSTAGE_LOCAL) {
31  sleepTimer = new cMessage("sleepTimer");
32  transmissionTimer = new cMessage("transmissionTimer");
33  antenna = check_and_cast<IAntenna *>(getSubmodule("antenna"));
34  transmitter = check_and_cast<ITransmitter *>(getSubmodule("transmitter"));
35  medium.reference(this, "radioMediumModule", true);
36  mediumModuleId = check_and_cast<cModule *>(medium.get())->getId();
37  radioIn = gate("radioIn");
38  radioIn->setDeliverImmediately(true);
39  }
40  else if (stage == INITSTAGE_PHYSICAL_LAYER) {
41  medium->addRadio(this);
43  }
44 }

◆ numInitStages()

virtual int inet::physicallayer::NoiseSource::numInitStages ( ) const
inlineoverrideprotectedvirtual
33 { return NUM_INIT_STAGES; }

◆ scheduleSleepTimer()

void inet::physicallayer::NoiseSource::scheduleSleepTimer ( )
protectedvirtual
70 {
71  scheduleAfter(par("sleepInterval"), sleepTimer);
72 }

Referenced by endTransmission(), and initialize().

◆ scheduleTransmissionTimer()

void inet::physicallayer::NoiseSource::scheduleTransmissionTimer ( const ITransmission transmission)
protectedvirtual
75 {
76  scheduleAfter(transmission->getDuration(), transmissionTimer);
77 }

Referenced by startTransmission().

◆ setRadioMode()

virtual void inet::physicallayer::NoiseSource::setRadioMode ( RadioMode  radioMode)
inlineoverridevirtual

Changes the current radio mode.

The actual change may take zero or more time. The new radio mode will be emitted with a radioModeChangedSignal.

Implements inet::physicallayer::IRadio.

49 { throw cRuntimeError("Invalid operation"); }

◆ startTransmission()

void inet::physicallayer::NoiseSource::startTransmission ( )
protectedvirtual
57 {
58  WirelessSignal *signal = check_and_cast<WirelessSignal *>(medium->transmitPacket(this, nullptr));
59  transmissionTimer->setContextPointer(const_cast<WirelessSignal *>(signal));
60  scheduleTransmissionTimer(signal->getTransmission());
61 }

Referenced by handleMessage().

Member Data Documentation

◆ antenna

const IAntenna* inet::physicallayer::NoiseSource::antenna = nullptr
protected

Referenced by initialize().

◆ id

const int inet::physicallayer::NoiseSource::id = nextId++
protected

◆ medium

ModuleRefByPar<IRadioMedium> inet::physicallayer::NoiseSource::medium
protected

◆ mediumModuleId

int inet::physicallayer::NoiseSource::mediumModuleId = -1
protected

Referenced by initialize(), and ~NoiseSource().

◆ radioIn

cGate* inet::physicallayer::NoiseSource::radioIn = nullptr
protected

Referenced by initialize().

◆ sleepTimer

cMessage* inet::physicallayer::NoiseSource::sleepTimer = nullptr
protected

◆ transmissionTimer

cMessage* inet::physicallayer::NoiseSource::transmissionTimer = nullptr
protected

◆ transmitter

const ITransmitter* inet::physicallayer::NoiseSource::transmitter = nullptr
protected

Referenced by initialize().


The documentation for this class was generated from the following files:
inet::physicallayer::IRadioSignal::SIGNAL_PART_WHOLE
@ SIGNAL_PART_WHOLE
Definition: IRadioSignal.h:26
inet::physicallayer::NoiseSource::antenna
const IAntenna * antenna
Definition: NoiseSource.h:26
inet::physicallayer::NoiseSource::startTransmission
virtual void startTransmission()
Definition: NoiseSource.cc:56
inet::physicallayer::NoiseSource::transmitter
const ITransmitter * transmitter
Definition: NoiseSource.h:27
inet::physicallayer::IRadioSignal::SIGNAL_PART_NONE
@ SIGNAL_PART_NONE
Definition: IRadioSignal.h:25
inet::physicallayer::NoiseSource::medium
ModuleRefByPar< IRadioMedium > medium
Definition: NoiseSource.h:25
inet::physicallayer::NoiseSource::mediumModuleId
int mediumModuleId
Definition: NoiseSource.h:24
inet::physicallayer::NoiseSource::transmissionTimer
cMessage * transmissionTimer
Definition: NoiseSource.h:29
inet::physicallayer::NoiseSource::id
const int id
Definition: NoiseSource.h:22
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::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::NoiseSource::radioIn
cGate * radioIn
Definition: NoiseSource.h:23
inet::physicallayer::NoiseSource::scheduleTransmissionTimer
virtual void scheduleTransmissionTimer(const ITransmission *transmission)
Definition: NoiseSource.cc:74
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
inet::INITSTAGE_PHYSICAL_LAYER
INET_API InitStage INITSTAGE_PHYSICAL_LAYER
Initialization of physical layer protocols includes:
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::physicallayer::NoiseSource::endTransmission
virtual void endTransmission()
Definition: NoiseSource.cc:63
inet::physicallayer::NoiseSource::sleepTimer
cMessage * sleepTimer
Definition: NoiseSource.h:30
inet::physicallayer::NoiseSource::scheduleSleepTimer
virtual void scheduleSleepTimer()
Definition: NoiseSource.cc:69