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

#include <EnergyStorageVisualizerBase.h>

Inheritance diagram for inet::visualizer::EnergyStorageVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::EnergyStorageCanvasVisualizer inet::visualizer::EnergyStorageOsgVisualizer

Classes

class  EnergyStorageVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual double getNominalCapacity (const IEnergyStorage *energyStorage) const
 
virtual double getResidualCapacity (const IEnergyStorage *energyStorage) const
 
virtual EnergyStorageVisualizationcreateEnergyStorageVisualization (const IEnergyStorage *energyStorage) const =0
 
virtual void addEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization)
 
virtual void addEnergyStorageVisualizations ()
 
virtual void removeEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization)
 
virtual void refreshEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization) const =0
 
virtual void removeAllEnergyStorageVisualizations ()
 
- 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::vector< const EnergyStorageVisualization * > energyStorageVisualizations
 
Parameters
bool displayEnergyStorages = false
 
ModuleFilter energyStorageFilter
 
cFigure::Color color
 
double width
 
double height
 
double spacing
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Member Function Documentation

void inet::visualizer::EnergyStorageVisualizerBase::addEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization)
protectedvirtual

Reimplemented in inet::visualizer::EnergyStorageCanvasVisualizer.

Referenced by inet::visualizer::EnergyStorageCanvasVisualizer::addEnergyStorageVisualization(), and addEnergyStorageVisualizations().

87 {
88  energyStorageVisualizations.push_back(energyStorageVisualization);
89 }
std::vector< const EnergyStorageVisualization * > energyStorageVisualizations
Definition: EnergyStorageVisualizerBase.h:58
void inet::visualizer::EnergyStorageVisualizerBase::addEnergyStorageVisualizations ( )
protectedvirtual

Referenced by handleParameterChange(), and initialize().

97 {
98  auto simulation = getSimulation();
99  for (int id = 0; id < simulation->getLastComponentId(); id++) {
100  auto component = simulation->getComponent(id);
101  auto module = dynamic_cast<cModule *>(component);
102  auto energyStorage = dynamic_cast<IEnergyStorage *>(module);
103  if (energyStorage != nullptr && energyStorageFilter.matches(module))
105  }
106 }
virtual EnergyStorageVisualization * createEnergyStorageVisualization(const IEnergyStorage *energyStorage) const =0
bool matches(const cModule *module) const
Definition: ModuleFilter.cc:29
virtual void addEnergyStorageVisualization(const EnergyStorageVisualization *energyStorageVisualization)
Definition: EnergyStorageVisualizerBase.cc:86
ModuleFilter energyStorageFilter
Definition: EnergyStorageVisualizerBase.h:49
virtual EnergyStorageVisualization* inet::visualizer::EnergyStorageVisualizerBase::createEnergyStorageVisualization ( const IEnergyStorage energyStorage) const
protectedpure virtual
double inet::visualizer::EnergyStorageVisualizerBase::getNominalCapacity ( const IEnergyStorage energyStorage) const
protectedvirtual

Referenced by inet::visualizer::EnergyStorageCanvasVisualizer::createEnergyStorageVisualization().

67 {
68  if (auto epEnergyStorage = dynamic_cast<const IEpEnergyStorage *>(energyStorage))
69  return epEnergyStorage->getNominalEnergyCapacity().get();
70  else if (auto ccEnergyStorage = dynamic_cast<const ICcEnergyStorage *>(energyStorage))
71  return ccEnergyStorage->getNominalChargeCapacity().get();
72  else
73  throw cRuntimeError("Unknown energy storage");
74 }
double inet::visualizer::EnergyStorageVisualizerBase::getResidualCapacity ( const IEnergyStorage energyStorage) const
protectedvirtual

Referenced by inet::visualizer::EnergyStorageCanvasVisualizer::refreshEnergyStorageVisualization().

77 {
78  if (auto epEnergyStorage = dynamic_cast<const IEpEnergyStorage *>(energyStorage))
79  return epEnergyStorage->getResidualEnergyCapacity().get();
80  else if (auto ccEnergyStorage = dynamic_cast<const ICcEnergyStorage *>(energyStorage))
81  return ccEnergyStorage->getResidualChargeCapacity().get();
82  else
83  throw cRuntimeError("Unknown energy storage");
84 }
void inet::visualizer::EnergyStorageVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
53 {
54  if (name != nullptr) {
57  }
58 }
virtual void removeAllEnergyStorageVisualizations()
Definition: EnergyStorageVisualizerBase.cc:108
virtual void addEnergyStorageVisualizations()
Definition: EnergyStorageVisualizerBase.cc:96
void inet::visualizer::EnergyStorageVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::EnergyStorageOsgVisualizer, and inet::visualizer::EnergyStorageCanvasVisualizer.

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

33 {
35  if (!hasGUI()) return;
36  if (stage == INITSTAGE_LOCAL) {
37  displayEnergyStorages = par("displayEnergyStorages");
38  energyStorageFilter.setPattern(par("energyStorageFilter"));
39  color = cFigure::parseColor(par("color"));
40  width = par("width");
41  height = par("height");
42  spacing = par("spacing");
43  displacementHint = parseDisplacement(par("displacementHint"));
44  displacementPriority = par("displacementPriority");
45  }
46  else if (stage == INITSTAGE_LAST) {
49  }
50 }
void setPattern(const char *pattern)
Definition: ModuleFilter.cc:24
double height
Definition: EnergyStorageVisualizerBase.h:52
double width
Definition: EnergyStorageVisualizerBase.h:51
bool displayEnergyStorages
Definition: EnergyStorageVisualizerBase.h:48
Operations that no other initializations can depend on, e.g.
Definition: InitStages.h:111
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement displacementHint
Definition: EnergyStorageVisualizerBase.h:54
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
double displacementPriority
Definition: EnergyStorageVisualizerBase.h:55
Local initializations.
Definition: InitStages.h:35
cFigure::Color color
Definition: EnergyStorageVisualizerBase.h:50
ModuleFilter energyStorageFilter
Definition: EnergyStorageVisualizerBase.h:49
virtual void addEnergyStorageVisualizations()
Definition: EnergyStorageVisualizerBase.cc:96
double spacing
Definition: EnergyStorageVisualizerBase.h:53
void inet::visualizer::EnergyStorageVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual
61 {
62  for (auto energyStorageVisualization : energyStorageVisualizations)
63  refreshEnergyStorageVisualization(energyStorageVisualization);
64 }
virtual void refreshEnergyStorageVisualization(const EnergyStorageVisualization *energyStorageVisualization) const =0
std::vector< const EnergyStorageVisualization * > energyStorageVisualizations
Definition: EnergyStorageVisualizerBase.h:58
virtual void inet::visualizer::EnergyStorageVisualizerBase::refreshEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization) const
protectedpure virtual
void inet::visualizer::EnergyStorageVisualizerBase::removeAllEnergyStorageVisualizations ( )
protectedvirtual

Referenced by handleParameterChange().

109 {
110  for (auto energyStorageVisualization : energyStorageVisualizations) {
111  removeEnergyStorageVisualization(energyStorageVisualization);
112  delete energyStorageVisualization;
113  }
114 }
virtual void removeEnergyStorageVisualization(const EnergyStorageVisualization *energyStorageVisualization)
Definition: EnergyStorageVisualizerBase.cc:91
std::vector< const EnergyStorageVisualization * > energyStorageVisualizations
Definition: EnergyStorageVisualizerBase.h:58
void inet::visualizer::EnergyStorageVisualizerBase::removeEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization)
protectedvirtual

Reimplemented in inet::visualizer::EnergyStorageCanvasVisualizer.

Referenced by removeAllEnergyStorageVisualizations(), and inet::visualizer::EnergyStorageCanvasVisualizer::removeEnergyStorageVisualization().

92 {
94 }
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
std::vector< const EnergyStorageVisualization * > energyStorageVisualizations
Definition: EnergyStorageVisualizerBase.h:58

Member Data Documentation

cFigure::Color inet::visualizer::EnergyStorageVisualizerBase::color
protected
Displacement inet::visualizer::EnergyStorageVisualizerBase::displacementHint
protected
double inet::visualizer::EnergyStorageVisualizerBase::displacementPriority
protected
bool inet::visualizer::EnergyStorageVisualizerBase::displayEnergyStorages = false
protected

Referenced by initialize().

ModuleFilter inet::visualizer::EnergyStorageVisualizerBase::energyStorageFilter
protected
std::vector<const EnergyStorageVisualization *> inet::visualizer::EnergyStorageVisualizerBase::energyStorageVisualizations
protected
double inet::visualizer::EnergyStorageVisualizerBase::height
protected
double inet::visualizer::EnergyStorageVisualizerBase::spacing
protected
double inet::visualizer::EnergyStorageVisualizerBase::width
protected

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