Skip to content

Commit

Permalink
StatisticVisualizerBase: Changed signalName parameter to be mandatory.
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Feb 19, 2024
1 parent 298b492 commit bd454f9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/inet/visualizer/base/StatisticVisualizerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void StatisticVisualizerBase::initialize(int stage)
displayStatistics = par("displayStatistics");
sourceFilter.setPattern(par("sourceFilter"));
signalName = par("signalName");
if (opp_isempty(signalName))
throw cRuntimeError("The signalName parameter must be not empty");
statisticName = par("statisticName");
statisticUnit = par("statisticUnit");
statisticExpression = par("statisticExpression");
Expand Down Expand Up @@ -92,18 +94,15 @@ void StatisticVisualizerBase::handleParameterChange(const char *name)

void StatisticVisualizerBase::subscribe()
{
if (*signalName != '\0')
visualizationSubjectModule->subscribe(registerSignal(signalName), this);
visualizationSubjectModule->subscribe(registerSignal(signalName), this);
}

void StatisticVisualizerBase::unsubscribe()
{
// NOTE: lookup the module again because it may have been deleted first
auto visualizationSubjectModule = findModuleFromPar<cModule>(par("visualizationSubjectModule"), this);
if (visualizationSubjectModule != nullptr) {
if (*signalName != '\0')
visualizationSubjectModule->unsubscribe(registerSignal(signalName), this);
}
if (visualizationSubjectModule != nullptr)
visualizationSubjectModule->unsubscribe(registerSignal(signalName), this);
}

void StatisticVisualizerBase::addResultRecorder(cComponent *source, simsignal_t signal)
Expand Down

0 comments on commit bd454f9

Please sign in to comment.