INET Framework for OMNeT++/OMNEST
inet::visualizer::RadioVisualizerBase Class Referenceabstract

#include <RadioVisualizerBase.h>

Inheritance diagram for inet::visualizer::RadioVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::RadioCanvasVisualizer inet::visualizer::RadioOsgVisualizer

Classes

class  RadioVisualization
 

Public Member Functions

virtual ~RadioVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, long value, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual RadioVisualizationcreateRadioVisualization (const IRadio *radio) const =0
 
virtual const RadioVisualizationgetRadioVisualization (int radioModuleId)
 
virtual void addRadioVisualization (const RadioVisualization *radioVisualization)
 
virtual void removeRadioVisualization (const RadioVisualization *radioVisualization)
 
virtual void refreshRadioVisualization (const RadioVisualization *radioVisualization) const =0
 
- Protected Member Functions inherited from inet::visualizer::VisualizerBase
virtual int numInitStages () const override
 
virtual Coord getPosition (const cModule *networkNode) const
 
virtual Coord getContactPosition (const cModule *networkNode, const Coord &fromPosition, const char *contactMode, double contactSpacing) const
 
virtual InterfaceEntrygetInterfaceEntry (cModule *networkNode, cModule *module) const
 

Protected Attributes

std::map< int, const RadioVisualization * > radioVisualizations
 
Parameters
bool displayRadios = false
 
bool displayRadioMode = false
 
bool displayReceptionState = false
 
bool displayTransmissionState = false
 
std::vector< std::string > radioModeImages
 
std::vector< std::string > receptionStateImages
 
std::vector< std::string > transmissionStateImages
 
ModuleFilter radioFilter
 
double width
 
double height
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Constructor & Destructor Documentation

inet::visualizer::RadioVisualizerBase::~RadioVisualizerBase ( )
virtual
31 {
32  if (displayRadios)
33  unsubscribe();
34 }
bool displayRadios
Definition: RadioVisualizerBase.h:48
virtual void unsubscribe()
Definition: RadioVisualizerBase.cc:80

Member Function Documentation

void inet::visualizer::RadioVisualizerBase::addRadioVisualization ( const RadioVisualization radioVisualization)
protectedvirtual

Reimplemented in inet::visualizer::RadioCanvasVisualizer.

Referenced by inet::visualizer::RadioCanvasVisualizer::addRadioVisualization(), and receiveSignal().

107 {
108  radioVisualizations[radioVisualization->radioModuleId] = radioVisualization;
109 }
std::map< int, const RadioVisualization * > radioVisualizations
Definition: RadioVisualizerBase.h:62
virtual RadioVisualization* inet::visualizer::RadioVisualizerBase::createRadioVisualization ( const IRadio radio) const
protectedpure virtual
const RadioVisualizerBase::RadioVisualization * inet::visualizer::RadioVisualizerBase::getRadioVisualization ( int  radioModuleId)
protectedvirtual

Referenced by receiveSignal().

98 {
99  auto it = radioVisualizations.find(radioModuleId);
100  if (it == radioVisualizations.end())
101  return nullptr;
102  else
103  return it->second;
104 }
std::map< int, const RadioVisualization * > radioVisualizations
Definition: RadioVisualizerBase.h:62
void inet::visualizer::RadioVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
65 {
66  if (name != nullptr) {
67  if (!strcmp(name, "radioFilter"))
68  radioFilter.setPattern(par("radioFilter"));
69  }
70 }
void setPattern(const char *pattern)
Definition: ModuleFilter.cc:24
ModuleFilter radioFilter
Definition: RadioVisualizerBase.h:55
void inet::visualizer::RadioVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::RadioOsgVisualizer, and inet::visualizer::RadioCanvasVisualizer.

Referenced by inet::visualizer::RadioCanvasVisualizer::initialize().

37 {
39  if (!hasGUI()) return;
40  if (stage == INITSTAGE_LOCAL) {
41  displayRadios = par("displayRadios");
42  displayRadioMode = par("displayRadioMode");
43  displayReceptionState = par("displayReceptionState");
44  displayTransmissionState = par("displayTransmissionState");
45  cStringTokenizer radioModeImagesTokenizer(par("radioModeImages"));
46  while (radioModeImagesTokenizer.hasMoreTokens())
47  radioModeImages.push_back(radioModeImagesTokenizer.nextToken());
48  cStringTokenizer receptionStateImagesTokenizer(par("receptionStateImages"));
49  while (receptionStateImagesTokenizer.hasMoreTokens())
50  receptionStateImages.push_back(receptionStateImagesTokenizer.nextToken());
51  cStringTokenizer transmissionStateImagesTokenizer(par("transmissionStateImages"));
52  while (transmissionStateImagesTokenizer.hasMoreTokens())
53  transmissionStateImages.push_back(transmissionStateImagesTokenizer.nextToken());
54  radioFilter.setPattern(par("radioFilter"));
55  width = par("width");
56  height = par("height");
57  displacementHint = parseDisplacement(par("displacementHint"));
58  displacementPriority = par("displacementPriority");
59  if (displayRadios)
60  subscribe();
61  }
62 }
bool displayRadios
Definition: RadioVisualizerBase.h:48
double displacementPriority
Definition: RadioVisualizerBase.h:59
bool displayRadioMode
Definition: RadioVisualizerBase.h:49
std::vector< std::string > transmissionStateImages
Definition: RadioVisualizerBase.h:54
bool displayReceptionState
Definition: RadioVisualizerBase.h:50
void setPattern(const char *pattern)
Definition: ModuleFilter.cc:24
std::vector< std::string > receptionStateImages
Definition: RadioVisualizerBase.h:53
virtual void subscribe()
Definition: RadioVisualizerBase.cc:72
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
bool displayTransmissionState
Definition: RadioVisualizerBase.h:51
ModuleFilter radioFilter
Definition: RadioVisualizerBase.h:55
Local initializations.
Definition: InitStages.h:35
double width
Definition: RadioVisualizerBase.h:56
std::vector< std::string > radioModeImages
Definition: RadioVisualizerBase.h:52
double height
Definition: RadioVisualizerBase.h:57
Displacement displacementHint
Definition: RadioVisualizerBase.h:58
void inet::visualizer::RadioVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
long  value,
cObject *  details 
)
overridevirtual
117 {
118  Enter_Method_Silent();
120  auto module = check_and_cast<cModule *>(source);
121  auto radio = check_and_cast<IRadio *>(module);
122  if (getRadioVisualization(module->getId()) == nullptr && radioFilter.matches(module))
124  }
125  else
126  throw cRuntimeError("Unknown signal");
127 }
virtual RadioVisualization * createRadioVisualization(const IRadio *radio) const =0
ModuleFilter radioFilter
Definition: RadioVisualizerBase.h:55
virtual const RadioVisualization * getRadioVisualization(int radioModuleId)
Definition: RadioVisualizerBase.cc:97
static simsignal_t receptionStateChangedSignal
This signal is emitted every time the radio reception state changes.
Definition: IRadio.h:66
bool matches(const cModule *module) const
Definition: ModuleFilter.cc:29
static simsignal_t transmissionStateChangedSignal
This signal is emitted every time the radio transmission state changes.
Definition: IRadio.h:72
virtual void addRadioVisualization(const RadioVisualization *radioVisualization)
Definition: RadioVisualizerBase.cc:106
static simsignal_t radioModeChangedSignal
This signal is emitted every time the radio mode changes.
Definition: IRadio.h:54
void inet::visualizer::RadioVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual
92 {
93  for (auto it : radioVisualizations)
94  refreshRadioVisualization(it.second);
95 }
std::map< int, const RadioVisualization * > radioVisualizations
Definition: RadioVisualizerBase.h:62
virtual void refreshRadioVisualization(const RadioVisualization *radioVisualization) const =0
virtual void inet::visualizer::RadioVisualizerBase::refreshRadioVisualization ( const RadioVisualization radioVisualization) const
protectedpure virtual
void inet::visualizer::RadioVisualizerBase::removeRadioVisualization ( const RadioVisualization radioVisualization)
protectedvirtual

Reimplemented in inet::visualizer::RadioCanvasVisualizer.

Referenced by inet::visualizer::RadioCanvasVisualizer::removeRadioVisualization().

112 {
113  radioVisualizations.erase(radioVisualizations.find(radioVisualization->radioModuleId));
114 }
std::map< int, const RadioVisualization * > radioVisualizations
Definition: RadioVisualizerBase.h:62
void inet::visualizer::RadioVisualizerBase::subscribe ( )
protectedvirtual

Referenced by initialize().

73 {
74  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
75  subscriptionModule->subscribe(IRadio::radioModeChangedSignal, this);
76  subscriptionModule->subscribe(IRadio::receptionStateChangedSignal, this);
77  subscriptionModule->subscribe(IRadio::transmissionStateChangedSignal, this);
78 }
static simsignal_t receptionStateChangedSignal
This signal is emitted every time the radio reception state changes.
Definition: IRadio.h:66
static simsignal_t transmissionStateChangedSignal
This signal is emitted every time the radio transmission state changes.
Definition: IRadio.h:72
static simsignal_t radioModeChangedSignal
This signal is emitted every time the radio mode changes.
Definition: IRadio.h:54
void inet::visualizer::RadioVisualizerBase::unsubscribe ( )
protectedvirtual

Referenced by ~RadioVisualizerBase().

81 {
82  // NOTE: lookup the module again because it may have been deleted first
83  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
84  if (subscriptionModule != nullptr) {
85  subscriptionModule->unsubscribe(IRadio::radioModeChangedSignal, this);
86  subscriptionModule->unsubscribe(IRadio::receptionStateChangedSignal, this);
87  subscriptionModule->unsubscribe(IRadio::transmissionStateChangedSignal, this);
88  }
89 }
static simsignal_t receptionStateChangedSignal
This signal is emitted every time the radio reception state changes.
Definition: IRadio.h:66
static simsignal_t transmissionStateChangedSignal
This signal is emitted every time the radio transmission state changes.
Definition: IRadio.h:72
static simsignal_t radioModeChangedSignal
This signal is emitted every time the radio mode changes.
Definition: IRadio.h:54

Member Data Documentation

Displacement inet::visualizer::RadioVisualizerBase::displacementHint
protected
double inet::visualizer::RadioVisualizerBase::displacementPriority
protected
bool inet::visualizer::RadioVisualizerBase::displayRadioMode = false
protected

Referenced by initialize().

bool inet::visualizer::RadioVisualizerBase::displayRadios = false
protected

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

bool inet::visualizer::RadioVisualizerBase::displayReceptionState = false
protected

Referenced by initialize().

bool inet::visualizer::RadioVisualizerBase::displayTransmissionState = false
protected

Referenced by initialize().

double inet::visualizer::RadioVisualizerBase::height
protected
ModuleFilter inet::visualizer::RadioVisualizerBase::radioFilter
protected
std::vector<std::string> inet::visualizer::RadioVisualizerBase::radioModeImages
protected
std::map<int, const RadioVisualization *> inet::visualizer::RadioVisualizerBase::radioVisualizations
protected
std::vector<std::string> inet::visualizer::RadioVisualizerBase::receptionStateImages
protected
std::vector<std::string> inet::visualizer::RadioVisualizerBase::transmissionStateImages
protected
double inet::visualizer::RadioVisualizerBase::width
protected

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