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

#include <MediumVisualizerBase.h>

Inheritance diagram for inet::visualizer::MediumVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::MediumCanvasVisualizer inet::visualizer::MediumOsgVisualizer

Public Member Functions

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

Protected Types

enum  SignalShape { SIGNAL_SHAPE_RING, SIGNAL_SHAPE_SPHERE, SIGNAL_SHAPE_BOTH }
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual bool isSignalPropagationInProgress (const ITransmission *transmission) const
 
virtual bool isSignalTransmissionInProgress (const ITransmission *transmission) const
 
virtual bool matchesTransmission (const ITransmission *transmission) const
 
virtual void radioAdded (const IRadio *radio)=0
 
virtual void radioRemoved (const IRadio *radio)=0
 
virtual void transmissionAdded (const ITransmission *transmission)=0
 
virtual void transmissionRemoved (const ITransmission *transmission)=0
 
virtual void transmissionStarted (const ITransmission *transmission)=0
 
virtual void transmissionEnded (const ITransmission *transmission)=0
 
virtual void receptionStarted (const IReception *reception)=0
 
virtual void receptionEnded (const IReception *reception)=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

Parameters
IRadioMediumradioMedium = nullptr
 
NetworkNodeFilter networkNodeFilter
 
InterfaceFilter interfaceFilter
 
PacketFilter packetFilter
 
bool displaySignals = false
 
ColorSet signalColorSet
 
double signalPropagationAnimationSpeed = NaN
 
double signalPropagationAnimationTime = NaN
 
double signalPropagationAdditionalTime = NaN
 
double signalTransmissionAnimationSpeed = NaN
 
double signalTransmissionAnimationTime = NaN
 
double signalAnimationSpeedChangeTime = NaN
 
bool displayTransmissions = false
 
bool displayReceptions = false
 
Displacement transmissionDisplacementHint
 
Displacement receptionDisplacementHint
 
double transmissionDisplacementPriority
 
double receptionDisplacementPriority
 
bool displayInterferenceRanges = false
 
cFigure::Color interferenceRangeLineColor
 
cFigure::LineStyle interferenceRangeLineStyle
 
double interferenceRangeLineWidth = NaN
 
bool displayCommunicationRanges = false
 
cFigure::Color communicationRangeLineColor
 
cFigure::LineStyle communicationRangeLineStyle
 
double communicationRangeLineWidth = NaN
 
State
double defaultSignalPropagationAnimationSpeed = NaN
 
double defaultSignalTransmissionAnimationSpeed = NaN
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Member Enumeration Documentation

Enumerator
SIGNAL_SHAPE_RING 
SIGNAL_SHAPE_SPHERE 
SIGNAL_SHAPE_BOTH 

Constructor & Destructor Documentation

inet::visualizer::MediumVisualizerBase::~MediumVisualizerBase ( )
virtual
27 {
28  // NOTE: lookup the medium module again because it may have been deleted first
29  auto radioMediumModule = getModuleFromPar<cModule>(par("mediumModule"), this, false);
30  if (radioMediumModule != nullptr) {
31  radioMediumModule->unsubscribe(IRadioMedium::radioAddedSignal, this);
32  radioMediumModule->unsubscribe(IRadioMedium::radioRemovedSignal, this);
33  radioMediumModule->unsubscribe(IRadioMedium::transmissionAddedSignal, this);
34  radioMediumModule->unsubscribe(IRadioMedium::transmissionRemovedSignal, this);
35  radioMediumModule->unsubscribe(IRadioMedium::transmissionStartedSignal, this);
36  radioMediumModule->unsubscribe(IRadioMedium::transmissionEndedSignal, this);
37  radioMediumModule->unsubscribe(IRadioMedium::receptionStartedSignal, this);
38  radioMediumModule->unsubscribe(IRadioMedium::receptionEndedSignal, this);
39  }
40 }
static simsignal_t transmissionRemovedSignal
Definition: IRadioMedium.h:58
static simsignal_t radioRemovedSignal
Definition: IRadioMedium.h:55
static simsignal_t radioAddedSignal
Definition: IRadioMedium.h:54
static simsignal_t transmissionStartedSignal
Definition: IRadioMedium.h:60
static simsignal_t receptionEndedSignal
Definition: IRadioMedium.h:64
static simsignal_t receptionStartedSignal
Definition: IRadioMedium.h:63
static simsignal_t transmissionAddedSignal
Definition: IRadioMedium.h:57
static simsignal_t transmissionEndedSignal
Definition: IRadioMedium.h:61

Member Function Documentation

void inet::visualizer::MediumVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
96 {
97  if (name != nullptr) {
98  if (!strcmp(name, "networkNodeFilter"))
99  networkNodeFilter.setPattern(par("nodeFilter"));
100  else if (!strcmp(name, "interfaceFilter"))
101  interfaceFilter.setPattern(par("interfaceFilter"));
102  else if (!strcmp(name, "packetFilter"))
103  packetFilter.setPattern(par("packetFilter"));
104  else if (!strcmp(name, "signalPropagationAnimationSpeed"))
105  signalPropagationAnimationSpeed = par("signalPropagationAnimationSpeed");
106  else if (!strcmp(name, "signalTransmissionAnimationSpeed"))
107  signalTransmissionAnimationSpeed = par("signalTransmissionAnimationSpeed");
108  // TODO:
109  }
110 }
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
double signalTransmissionAnimationSpeed
Definition: MediumVisualizerBase.h:57
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
InterfaceFilter interfaceFilter
Definition: MediumVisualizerBase.h:50
void setPattern(const char *pattern)
Definition: PacketFilter.cc:24
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
double signalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:54
PacketFilter packetFilter
Definition: MediumVisualizerBase.h:51
void inet::visualizer::MediumVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::MediumOsgVisualizer, and inet::visualizer::MediumCanvasVisualizer.

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

43 {
45  if (!hasGUI()) return;
46  if (stage == INITSTAGE_LOCAL) {
47  networkNodeFilter.setPattern(par("nodeFilter"));
48  interfaceFilter.setPattern(par("interfaceFilter"));
49  packetFilter.setPattern(par("packetFilter"));
50  displaySignals = par("displaySignals");
51  signalColorSet.parseColors(par("signalColor"));
52  signalPropagationAnimationSpeed = par("signalPropagationAnimationSpeed");
53  signalPropagationAnimationTime = par("signalPropagationAnimationTime");
54  signalPropagationAdditionalTime = par("signalPropagationAdditionalTime");
55  signalTransmissionAnimationSpeed = par("signalTransmissionAnimationSpeed");
56  signalTransmissionAnimationTime = par("signalTransmissionAnimationTime");
57  signalAnimationSpeedChangeTime = par("signalAnimationSpeedChangeTime");
58  displayTransmissions = par("displayTransmissions");
59  displayReceptions = par("displayReceptions");
60  transmissionDisplacementHint = parseDisplacement(par("transmissionDisplacementHint"));
61  receptionDisplacementHint = parseDisplacement(par("receptionDisplacementHint"));
62  transmissionDisplacementPriority = par("transmissionDisplacementPriority");
63  receptionDisplacementPriority = par("receptionDisplacementPriority");
64  displayInterferenceRanges = par("displayInterferenceRanges");
65  interferenceRangeLineColor = cFigure::Color(par("interferenceRangeLineColor"));
66  interferenceRangeLineStyle = cFigure::parseLineStyle(par("interferenceRangeLineStyle"));
67  interferenceRangeLineWidth = par("interferenceRangeLineWidth");
68  displayCommunicationRanges = par("displayCommunicationRanges");
69  communicationRangeLineColor = cFigure::Color(par("communicationRangeLineColor"));
70  communicationRangeLineStyle = cFigure::parseLineStyle(par("communicationRangeLineStyle"));
71  communicationRangeLineWidth = par("communicationRangeLineWidth");
72  signalPropagationAnimationSpeed = par("signalPropagationAnimationSpeed");
73  signalTransmissionAnimationSpeed = par("signalTransmissionAnimationSpeed");
74  radioMedium = getModuleFromPar<IRadioMedium>(par("mediumModule"), this, false);
75  if (radioMedium != nullptr) {
76  cModule *radioMediumModule = check_and_cast<cModule *>(radioMedium);
77  radioMediumModule->subscribe(IRadioMedium::radioAddedSignal, this);
78  radioMediumModule->subscribe(IRadioMedium::radioRemovedSignal, this);
79  radioMediumModule->subscribe(IRadioMedium::transmissionAddedSignal, this);
80  radioMediumModule->subscribe(IRadioMedium::transmissionRemovedSignal, this);
81  radioMediumModule->subscribe(IRadioMedium::transmissionStartedSignal, this);
82  radioMediumModule->subscribe(IRadioMedium::transmissionEndedSignal, this);
83  radioMediumModule->subscribe(IRadioMedium::receptionStartedSignal, this);
84  radioMediumModule->subscribe(IRadioMedium::receptionEndedSignal, this);
85  }
86  }
87  else if (stage == INITSTAGE_LAST) {
88  if (std::isnan(signalPropagationAnimationSpeed) && radioMedium != nullptr) {
91  }
92  }
93 }
static simsignal_t transmissionRemovedSignal
Definition: IRadioMedium.h:58
virtual Coord getMinConstraintArea() const =0
Returns the minimum possible position among the radios, the coordinate values are in the range (-infi...
bool displayTransmissions
Definition: MediumVisualizerBase.h:60
bool displayReceptions
Definition: MediumVisualizerBase.h:61
double interferenceRangeLineWidth
Definition: MediumVisualizerBase.h:69
void parseColors(const char *colorNames)
Definition: ColorSet.cc:24
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
bool displayInterferenceRanges
Definition: MediumVisualizerBase.h:66
double transmissionDisplacementPriority
Definition: MediumVisualizerBase.h:64
double signalTransmissionAnimationSpeed
Definition: MediumVisualizerBase.h:57
virtual const IPropagation * getPropagation() const =0
Returns the radio signal propagation model of this radio medium.
static simsignal_t radioRemovedSignal
Definition: IRadioMedium.h:55
bool displaySignals
Definition: MediumVisualizerBase.h:52
Operations that no other initializations can depend on, e.g.
Definition: InitStages.h:111
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
Displacement receptionDisplacementHint
Definition: MediumVisualizerBase.h:63
cFigure::Color interferenceRangeLineColor
Definition: MediumVisualizerBase.h:67
ColorSet signalColorSet
Definition: MediumVisualizerBase.h:53
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
static simsignal_t radioAddedSignal
Definition: IRadioMedium.h:54
InterfaceFilter interfaceFilter
Definition: MediumVisualizerBase.h:50
double communicationRangeLineWidth
Definition: MediumVisualizerBase.h:73
cFigure::LineStyle communicationRangeLineStyle
Definition: MediumVisualizerBase.h:72
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
double signalPropagationAdditionalTime
Definition: MediumVisualizerBase.h:56
Local initializations.
Definition: InitStages.h:35
static simsignal_t transmissionStartedSignal
Definition: IRadioMedium.h:60
void setPattern(const char *pattern)
Definition: PacketFilter.cc:24
double distance(const Coord &a) const
Returns the distance to Coord &#39;a&#39;.
Definition: Coord.h:201
Displacement transmissionDisplacementHint
Definition: MediumVisualizerBase.h:62
Color
Definition: DiffservUtil.h:30
static simsignal_t receptionEndedSignal
Definition: IRadioMedium.h:64
static simsignal_t receptionStartedSignal
Definition: IRadioMedium.h:63
double signalPropagationAnimationTime
Definition: MediumVisualizerBase.h:55
virtual mps getPropagationSpeed() const =0
Returns the theoretical propagation speed of radio signals in the range (0, +infinity).
double signalTransmissionAnimationTime
Definition: MediumVisualizerBase.h:58
static simsignal_t transmissionAddedSignal
Definition: IRadioMedium.h:57
bool displayCommunicationRanges
Definition: MediumVisualizerBase.h:70
static simsignal_t transmissionEndedSignal
Definition: IRadioMedium.h:61
double receptionDisplacementPriority
Definition: MediumVisualizerBase.h:65
IRadioMedium * radioMedium
Definition: MediumVisualizerBase.h:48
double defaultSignalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:78
compose< m, pow< s,-1 > > mps
Definition: Units.h:968
double signalAnimationSpeedChangeTime
Definition: MediumVisualizerBase.h:59
virtual Coord getMaxConstraintArea() const =0
Returns the maximum possible position among the radios, the coordinate values are in the range (-infi...
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
double signalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:54
virtual const IMediumLimitCache * getMediumLimitCache() const =0
cFigure::Color communicationRangeLineColor
Definition: MediumVisualizerBase.h:71
cFigure::LineStyle interferenceRangeLineStyle
Definition: MediumVisualizerBase.h:68
PacketFilter packetFilter
Definition: MediumVisualizerBase.h:51
bool inet::visualizer::MediumVisualizerBase::isSignalPropagationInProgress ( const ITransmission transmission) const
protectedvirtual

Referenced by inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

136 {
137  simtime_t now = simTime();
138  ICommunicationCache *communicationCache = const_cast<ICommunicationCache *>(radioMedium->getCommunicationCache());
139  const IMediumLimitCache *mediumLimitCache = radioMedium->getMediumLimitCache();
140  const simtime_t transmissionStartTime = transmission->getStartTime();
141  const simtime_t transmissionEndTime = transmission->getEndTime();
142  const simtime_t interferenceEndTime = communicationCache->getCachedInterferenceEndTime(transmission);
143  simtime_t maxPropagationTime = interferenceEndTime - transmissionEndTime - mediumLimitCache->getMaxTransmissionDuration() + signalPropagationAdditionalTime;
144  return (transmissionStartTime <= now && now < transmissionStartTime + maxPropagationTime) ||
145  (transmissionEndTime <= now && now < transmissionEndTime + maxPropagationTime);
146 }
virtual const simtime_t & getMaxTransmissionDuration() const =0
Returns the maximum possible transmission durations among the radios, the value is in the range [0...
double signalPropagationAdditionalTime
Definition: MediumVisualizerBase.h:56
virtual const ICommunicationCache * getCommunicationCache() const =0
IRadioMedium * radioMedium
Definition: MediumVisualizerBase.h:48
virtual const IMediumLimitCache * getMediumLimitCache() const =0
bool inet::visualizer::MediumVisualizerBase::isSignalTransmissionInProgress ( const ITransmission transmission) const
protectedvirtual

Referenced by inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed().

149 {
150  simtime_t now = simTime();
151  return transmission->getStartTime() <= now && now < transmission->getEndTime();
152 }
bool inet::visualizer::MediumVisualizerBase::matchesTransmission ( const ITransmission transmission) const
protectedvirtual

Referenced by inet::visualizer::MediumCanvasVisualizer::receptionEnded(), inet::visualizer::MediumCanvasVisualizer::receptionStarted(), inet::visualizer::MediumCanvasVisualizer::refreshDisplay(), inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed(), inet::visualizer::MediumCanvasVisualizer::transmissionAdded(), inet::visualizer::MediumCanvasVisualizer::transmissionEnded(), inet::visualizer::MediumCanvasVisualizer::transmissionRemoved(), and inet::visualizer::MediumCanvasVisualizer::transmissionStarted().

155 {
156  auto radio = check_and_cast<const cModule *>(transmission->getTransmitter());
157  auto networkNode = getContainingNode(radio);
158  if (!networkNodeFilter.matches(networkNode))
159  return false;
160  L3AddressResolver addressResolver;
161  if (auto interfaceTable = addressResolver.findInterfaceTableOf(networkNode)) {
162  auto interfaceEntry = interfaceTable->getInterfaceByInterfaceModule(radio->getParentModule());
163  if (!interfaceFilter.matches(interfaceEntry))
164  return false;
165  }
166  auto packet = transmission->getPhyFrame() != nullptr ? transmission->getPhyFrame() : transmission->getMacFrame();
167  return packetFilter.matches(packet);
168 }
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
InterfaceFilter interfaceFilter
Definition: MediumVisualizerBase.h:50
bool matches(const cPacket *packet) const
Definition: PacketFilter.cc:29
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
bool matches(const InterfaceEntry *interfaceEntry) const
Definition: InterfaceFilter.cc:29
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
PacketFilter packetFilter
Definition: MediumVisualizerBase.h:51
virtual void inet::visualizer::MediumVisualizerBase::radioAdded ( const IRadio radio)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::radioRemoved ( const IRadio radio)
protectedpure virtual
void inet::visualizer::MediumVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
113 {
114  Enter_Method_Silent();
115  if (signal == IRadioMedium::radioAddedSignal)
116  radioAdded(check_and_cast<IRadio *>(object));
117  else if (signal == IRadioMedium::radioRemovedSignal)
118  radioRemoved(check_and_cast<IRadio *>(object));
119  else if (signal == IRadioMedium::transmissionAddedSignal)
120  transmissionAdded(check_and_cast<ITransmission *>(object));
121  else if (signal == IRadioMedium::transmissionRemovedSignal)
122  transmissionRemoved(check_and_cast<ITransmission *>(object));
123  else if (signal == IRadioMedium::transmissionStartedSignal)
124  transmissionStarted(check_and_cast<ITransmission *>(object));
125  else if (signal == IRadioMedium::transmissionEndedSignal)
126  transmissionEnded(check_and_cast<ITransmission *>(object));
127  else if (signal == IRadioMedium::receptionStartedSignal)
128  receptionStarted(check_and_cast<IReception *>(object));
129  else if (signal == IRadioMedium::receptionEndedSignal)
130  receptionEnded(check_and_cast<IReception *>(object));
131  else
132  throw cRuntimeError("Unknown signal");
133 }
static simsignal_t transmissionRemovedSignal
Definition: IRadioMedium.h:58
virtual void transmissionEnded(const ITransmission *transmission)=0
virtual void transmissionStarted(const ITransmission *transmission)=0
virtual void radioAdded(const IRadio *radio)=0
virtual void receptionEnded(const IReception *reception)=0
static simsignal_t radioRemovedSignal
Definition: IRadioMedium.h:55
virtual void transmissionAdded(const ITransmission *transmission)=0
static simsignal_t radioAddedSignal
Definition: IRadioMedium.h:54
static simsignal_t transmissionStartedSignal
Definition: IRadioMedium.h:60
virtual void transmissionRemoved(const ITransmission *transmission)=0
static simsignal_t receptionEndedSignal
Definition: IRadioMedium.h:64
static simsignal_t receptionStartedSignal
Definition: IRadioMedium.h:63
virtual void radioRemoved(const IRadio *radio)=0
static simsignal_t transmissionAddedSignal
Definition: IRadioMedium.h:57
virtual void receptionStarted(const IReception *reception)=0
static simsignal_t transmissionEndedSignal
Definition: IRadioMedium.h:61
virtual void inet::visualizer::MediumVisualizerBase::receptionEnded ( const IReception reception)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::receptionStarted ( const IReception reception)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::transmissionAdded ( const ITransmission transmission)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::transmissionEnded ( const ITransmission transmission)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::transmissionRemoved ( const ITransmission transmission)
protectedpure virtual
virtual void inet::visualizer::MediumVisualizerBase::transmissionStarted ( const ITransmission transmission)
protectedpure virtual

Member Data Documentation

cFigure::Color inet::visualizer::MediumVisualizerBase::communicationRangeLineColor
protected
cFigure::LineStyle inet::visualizer::MediumVisualizerBase::communicationRangeLineStyle
protected
double inet::visualizer::MediumVisualizerBase::communicationRangeLineWidth = NaN
protected
double inet::visualizer::MediumVisualizerBase::defaultSignalPropagationAnimationSpeed = NaN
protected
double inet::visualizer::MediumVisualizerBase::defaultSignalTransmissionAnimationSpeed = NaN
protected
bool inet::visualizer::MediumVisualizerBase::displayCommunicationRanges = false
protected
bool inet::visualizer::MediumVisualizerBase::displayInterferenceRanges = false
protected
InterfaceFilter inet::visualizer::MediumVisualizerBase::interfaceFilter
protected
cFigure::Color inet::visualizer::MediumVisualizerBase::interferenceRangeLineColor
protected
cFigure::LineStyle inet::visualizer::MediumVisualizerBase::interferenceRangeLineStyle
protected
double inet::visualizer::MediumVisualizerBase::interferenceRangeLineWidth = NaN
protected
PacketFilter inet::visualizer::MediumVisualizerBase::packetFilter
protected
Displacement inet::visualizer::MediumVisualizerBase::receptionDisplacementHint
protected
double inet::visualizer::MediumVisualizerBase::receptionDisplacementPriority
protected
double inet::visualizer::MediumVisualizerBase::signalAnimationSpeedChangeTime = NaN
protected
ColorSet inet::visualizer::MediumVisualizerBase::signalColorSet
protected
double inet::visualizer::MediumVisualizerBase::signalPropagationAdditionalTime = NaN
protected
double inet::visualizer::MediumVisualizerBase::signalPropagationAnimationSpeed = NaN
protected
double inet::visualizer::MediumVisualizerBase::signalPropagationAnimationTime = NaN
protected

Referenced by initialize().

double inet::visualizer::MediumVisualizerBase::signalTransmissionAnimationSpeed = NaN
protected
double inet::visualizer::MediumVisualizerBase::signalTransmissionAnimationTime = NaN
protected
Displacement inet::visualizer::MediumVisualizerBase::transmissionDisplacementHint
protected
double inet::visualizer::MediumVisualizerBase::transmissionDisplacementPriority
protected

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