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

#include <Ieee80211VisualizerBase.h>

Inheritance diagram for inet::visualizer::Ieee80211VisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::Ieee80211CanvasVisualizer inet::visualizer::Ieee80211OsgVisualizer

Classes

class  Ieee80211Visualization
 

Public Member Functions

virtual ~Ieee80211VisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual Ieee80211VisualizationcreateIeee80211Visualization (cModule *networkNode, InterfaceEntry *interfaceEntry, std::string ssid)=0
 
virtual const Ieee80211VisualizationgetIeee80211Visualization (cModule *networkNode, InterfaceEntry *interfaceEntry)
 
virtual void addIeee80211Visualization (const Ieee80211Visualization *ieee80211Visualization)
 
virtual void removeIeee80211Visualization (const Ieee80211Visualization *ieee80211Visualization)
 
virtual void removeAllIeee80211Visualizations ()
 
- 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< std::pair< int, int >, const Ieee80211Visualization * > ieee80211Visualizations
 
Parameters
bool displayAssociations = false
 
NetworkNodeFilter nodeFilter
 
InterfaceFilter interfaceFilter
 
const char * icon = nullptr
 
ColorSet iconColorSet
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Constructor & Destructor Documentation

inet::visualizer::Ieee80211VisualizerBase::~Ieee80211VisualizerBase ( )
virtual
38 {
40  unsubscribe();
41 }
bool displayAssociations
Definition: Ieee80211VisualizerBase.h:48
virtual void unsubscribe()
Definition: Ieee80211VisualizerBase.cc:82

Member Function Documentation

void inet::visualizer::Ieee80211VisualizerBase::addIeee80211Visualization ( const Ieee80211Visualization ieee80211Visualization)
protectedvirtual

Reimplemented in inet::visualizer::Ieee80211CanvasVisualizer.

Referenced by inet::visualizer::Ieee80211CanvasVisualizer::addIeee80211Visualization(), and receiveSignal().

102 {
103  auto key = std::pair<int, int>(ieee80211Visualization->networkNodeId, ieee80211Visualization->interfaceId);
104  ieee80211Visualizations[key] = ieee80211Visualization;
105 }
std::map< std::pair< int, int >, const Ieee80211Visualization * > ieee80211Visualizations
Definition: Ieee80211VisualizerBase.h:59
virtual Ieee80211Visualization* inet::visualizer::Ieee80211VisualizerBase::createIeee80211Visualization ( cModule *  networkNode,
InterfaceEntry interfaceEntry,
std::string  ssid 
)
protectedpure virtual
const Ieee80211VisualizerBase::Ieee80211Visualization * inet::visualizer::Ieee80211VisualizerBase::getIeee80211Visualization ( cModule *  networkNode,
InterfaceEntry interfaceEntry 
)
protectedvirtual

Referenced by receiveSignal().

95 {
96  auto key = std::pair<int, int>(networkNode->getId(), interfaceEntry->getInterfaceId());
97  auto it = ieee80211Visualizations.find(key);
98  return it == ieee80211Visualizations.end() ? nullptr : it->second;
99 }
std::map< std::pair< int, int >, const Ieee80211Visualization * > ieee80211Visualizations
Definition: Ieee80211VisualizerBase.h:59
void inet::visualizer::Ieee80211VisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
63 {
64  if (name != nullptr) {
65  if (!strcmp(name, "nodeFilter"))
66  nodeFilter.setPattern(par("nodeFilter"));
67  else if (!strcmp(name, "interfaceFilter"))
68  interfaceFilter.setPattern(par("interfaceFilter"));
70  }
71 }
virtual void removeAllIeee80211Visualizations()
Definition: Ieee80211VisualizerBase.cc:113
NetworkNodeFilter nodeFilter
Definition: Ieee80211VisualizerBase.h:49
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
InterfaceFilter interfaceFilter
Definition: Ieee80211VisualizerBase.h:50
void inet::visualizer::Ieee80211VisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::Ieee80211OsgVisualizer, and inet::visualizer::Ieee80211CanvasVisualizer.

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

44 {
46  if (!hasGUI()) return;
47  if (stage == INITSTAGE_LOCAL) {
48  displayAssociations = par("displayAssociations");
49  nodeFilter.setPattern(par("nodeFilter"));
50  interfaceFilter.setPattern(par("interfaceFilter"));
51  icon = par("icon");
52  iconColorSet.parseColors(par("iconColor"));
53  labelFont = cFigure::parseFont(par("labelFont"));
54  labelColor = cFigure::Color(par("labelColor"));
55  displacementHint = parseDisplacement(par("displacementHint"));
56  displacementPriority = par("displacementPriority");
58  subscribe();
59  }
60 }
NetworkNodeFilter nodeFilter
Definition: Ieee80211VisualizerBase.h:49
void parseColors(const char *colorNames)
Definition: ColorSet.cc:24
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
bool displayAssociations
Definition: Ieee80211VisualizerBase.h:48
ColorSet iconColorSet
Definition: Ieee80211VisualizerBase.h:52
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
InterfaceFilter interfaceFilter
Definition: Ieee80211VisualizerBase.h:50
Local initializations.
Definition: InitStages.h:35
Color
Definition: DiffservUtil.h:30
Displacement displacementHint
Definition: Ieee80211VisualizerBase.h:55
virtual void subscribe()
Definition: Ieee80211VisualizerBase.cc:73
double displacementPriority
Definition: Ieee80211VisualizerBase.h:56
cFigure::Font labelFont
Definition: Ieee80211VisualizerBase.h:53
const char * icon
Definition: Ieee80211VisualizerBase.h:51
cFigure::Color labelColor
Definition: Ieee80211VisualizerBase.h:54
void inet::visualizer::Ieee80211VisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
125 {
126 #ifdef WITH_IEEE80211
127  Enter_Method_Silent();
128  if (signal == NF_L2_ASSOCIATED) {
129  auto networkNode = getContainingNode(check_and_cast<cModule *>(source));
130  if (nodeFilter.matches(networkNode)) {
131  auto interfaceEntry = check_and_cast<InterfaceEntry *>(object);
132  auto apInfo = check_and_cast<inet::ieee80211::Ieee80211MgmtSTA::APInfo *>(details);
133  auto ieee80211Visualization = createIeee80211Visualization(networkNode, interfaceEntry, apInfo->ssid);
134  addIeee80211Visualization(ieee80211Visualization);
135  }
136  }
137  else if (signal == NF_L2_DISASSOCIATED) {
138  auto networkNode = getContainingNode(check_and_cast<cModule *>(source));
139  if (nodeFilter.matches(networkNode)) {
140  auto interfaceEntry = check_and_cast<InterfaceEntry *>(object);
141  auto ieee80211Visualization = getIeee80211Visualization(networkNode, interfaceEntry);
142  removeIeee80211Visualization(ieee80211Visualization);
143  }
144  }
145  else if (signal == NF_L2_AP_ASSOCIATED) {
146  auto networkNode = getContainingNode(check_and_cast<cModule *>(source));
147  if (nodeFilter.matches(networkNode)) {
148  // TODO: KLUDGE: this is the wrong way to lookup the interface and the ssid
149  L3AddressResolver addressResolver;
150  auto mgmt = check_and_cast<inet::ieee80211::Ieee80211MgmtAP *>(source);
151  auto interfaceEntry = addressResolver.findInterfaceTableOf(networkNode)->getInterfaceByInterfaceModule(mgmt->getParentModule());
152  auto ieee80211Visualization = getIeee80211Visualization(networkNode, interfaceEntry);
153  if (ieee80211Visualization == nullptr) {
154  auto ieee80211Visualization = createIeee80211Visualization(networkNode, interfaceEntry, mgmt->par("ssid"));
155  addIeee80211Visualization(ieee80211Visualization);
156  }
157  }
158  }
159  else if (signal == NF_L2_AP_DISASSOCIATED) {
160  auto networkNode = getContainingNode(check_and_cast<cModule *>(source));
161  if (nodeFilter.matches(networkNode)) {
162  // TODO: KLUDGE: this is the wrong way to lookup the interface
163  L3AddressResolver addressResolver;
164  auto mgmt = check_and_cast<inet::ieee80211::Ieee80211MgmtAP *>(source);
165  auto interfaceEntry = addressResolver.findInterfaceTableOf(networkNode)->getInterfaceByInterfaceModule(mgmt->getParentModule());
166  auto ieee80211Visualization = getIeee80211Visualization(networkNode, interfaceEntry);
167  removeIeee80211Visualization(ieee80211Visualization);
168  }
169  }
170  else
171  throw cRuntimeError("Unknown signal");
172 #endif // WITH_IEEE80211
173 }
NetworkNodeFilter nodeFilter
Definition: Ieee80211VisualizerBase.h:49
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
Used in 802.11 infrastructure mode: handles management frames for an access point (AP)...
Definition: Ieee80211MgmtAP.h:37
simsignal_t NF_L2_DISASSOCIATED
Definition: NotifierConsts.cc:39
virtual const Ieee80211Visualization * getIeee80211Visualization(cModule *networkNode, InterfaceEntry *interfaceEntry)
Definition: Ieee80211VisualizerBase.cc:94
virtual Ieee80211Visualization * createIeee80211Visualization(cModule *networkNode, InterfaceEntry *interfaceEntry, std::string ssid)=0
simsignal_t NF_L2_AP_DISASSOCIATED
Definition: NotifierConsts.cc:41
Definition: Ieee80211MgmtSTA.h:61
virtual void removeIeee80211Visualization(const Ieee80211Visualization *ieee80211Visualization)
Definition: Ieee80211VisualizerBase.cc:107
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
simsignal_t NF_L2_ASSOCIATED
Definition: NotifierConsts.cc:36
virtual void addIeee80211Visualization(const Ieee80211Visualization *ieee80211Visualization)
Definition: Ieee80211VisualizerBase.cc:101
simsignal_t NF_L2_AP_ASSOCIATED
Definition: NotifierConsts.cc:40
void inet::visualizer::Ieee80211VisualizerBase::removeAllIeee80211Visualizations ( )
protectedvirtual

Referenced by handleParameterChange().

114 {
115  std::vector<const Ieee80211Visualization *> removedIeee80211Visualizations;
116  for (auto it : ieee80211Visualizations)
117  removedIeee80211Visualizations.push_back(it.second);
118  for (auto it : removedIeee80211Visualizations) {
120  delete it;
121  }
122 }
std::map< std::pair< int, int >, const Ieee80211Visualization * > ieee80211Visualizations
Definition: Ieee80211VisualizerBase.h:59
virtual void removeIeee80211Visualization(const Ieee80211Visualization *ieee80211Visualization)
Definition: Ieee80211VisualizerBase.cc:107
void inet::visualizer::Ieee80211VisualizerBase::removeIeee80211Visualization ( const Ieee80211Visualization ieee80211Visualization)
protectedvirtual

Reimplemented in inet::visualizer::Ieee80211CanvasVisualizer.

Referenced by receiveSignal(), removeAllIeee80211Visualizations(), and inet::visualizer::Ieee80211CanvasVisualizer::removeIeee80211Visualization().

108 {
109  auto key = std::pair<int, int>(ieee80211Visualization->networkNodeId, ieee80211Visualization->interfaceId);
111 }
std::map< std::pair< int, int >, const Ieee80211Visualization * > ieee80211Visualizations
Definition: Ieee80211VisualizerBase.h:59
void inet::visualizer::Ieee80211VisualizerBase::subscribe ( )
protectedvirtual

Referenced by initialize().

74 {
75  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
76  subscriptionModule->subscribe(NF_L2_ASSOCIATED, this);
77  subscriptionModule->subscribe(NF_L2_DISASSOCIATED, this);
78  subscriptionModule->subscribe(NF_L2_AP_ASSOCIATED, this);
79  subscriptionModule->subscribe(NF_L2_AP_DISASSOCIATED, this);
80 }
simsignal_t NF_L2_DISASSOCIATED
Definition: NotifierConsts.cc:39
simsignal_t NF_L2_AP_DISASSOCIATED
Definition: NotifierConsts.cc:41
simsignal_t NF_L2_ASSOCIATED
Definition: NotifierConsts.cc:36
simsignal_t NF_L2_AP_ASSOCIATED
Definition: NotifierConsts.cc:40
void inet::visualizer::Ieee80211VisualizerBase::unsubscribe ( )
protectedvirtual

Referenced by ~Ieee80211VisualizerBase().

83 {
84  // NOTE: lookup the module again because it may have been deleted first
85  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
86  if (subscriptionModule != nullptr) {
87  subscriptionModule->unsubscribe(NF_L2_ASSOCIATED, this);
88  subscriptionModule->unsubscribe(NF_L2_DISASSOCIATED, this);
89  subscriptionModule->unsubscribe(NF_L2_AP_ASSOCIATED, this);
90  subscriptionModule->unsubscribe(NF_L2_AP_DISASSOCIATED, this);
91  }
92 }
simsignal_t NF_L2_DISASSOCIATED
Definition: NotifierConsts.cc:39
simsignal_t NF_L2_AP_DISASSOCIATED
Definition: NotifierConsts.cc:41
simsignal_t NF_L2_ASSOCIATED
Definition: NotifierConsts.cc:36
simsignal_t NF_L2_AP_ASSOCIATED
Definition: NotifierConsts.cc:40

Member Data Documentation

Displacement inet::visualizer::Ieee80211VisualizerBase::displacementHint
protected
double inet::visualizer::Ieee80211VisualizerBase::displacementPriority
protected
bool inet::visualizer::Ieee80211VisualizerBase::displayAssociations = false
protected
const char* inet::visualizer::Ieee80211VisualizerBase::icon = nullptr
protected
ColorSet inet::visualizer::Ieee80211VisualizerBase::iconColorSet
protected
std::map<std::pair<int, int>, const Ieee80211Visualization *> inet::visualizer::Ieee80211VisualizerBase::ieee80211Visualizations
protected
InterfaceFilter inet::visualizer::Ieee80211VisualizerBase::interfaceFilter
protected
cFigure::Color inet::visualizer::Ieee80211VisualizerBase::labelColor
protected
cFigure::Font inet::visualizer::Ieee80211VisualizerBase::labelFont
protected
NetworkNodeFilter inet::visualizer::Ieee80211VisualizerBase::nodeFilter
protected

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