INET Framework for OMNeT++/OMNEST
inet::NodeStatus Class Reference

Keeps track of the status of network node (up, down, etc.) for other modules, and also displays it as a small overlay icon on this module and on the module of the network node. More...

#include <NodeStatus.h>

Inheritance diagram for inet::NodeStatus:
inet::ILifecycle

Public Types

enum  State { UP, DOWN, GOING_UP, GOING_DOWN }
 

Public Member Functions

virtual State getState () const
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Static Public Attributes

static simsignal_t nodeStatusChangedSignal = registerSignal("nodeStatusChanged")
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual void setState (State state)
 
virtual void refreshDisplay () const override
 

Static Protected Member Functions

static State getStateByName (const char *name)
 

Private Attributes

State state
 
std::string origIcon
 

Detailed Description

Keeps track of the status of network node (up, down, etc.) for other modules, and also displays it as a small overlay icon on this module and on the module of the network node.

Other modules can obtain the network node's status by calling the getState() method.

See NED file for more information.

Member Enumeration Documentation

Enumerator
UP 
DOWN 
GOING_UP 
GOING_DOWN 
40 { UP, DOWN, GOING_UP, GOING_DOWN };
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40

Member Function Documentation

virtual State inet::NodeStatus::getState ( ) const
inlinevirtual

Referenced by inet::Define_Module(), inet::power::SimpleEpEnergyManagement::executeNodeOperation(), inet::power::SimpleCcBattery::executeNodeOperation(), inet::power::SimpleEpEnergyStorage::executeNodeOperation(), handleOperationStage(), inet::OperationalBase::initialize(), inet::TelnetApp::initialize(), inet::MACRelayUnit::initialize(), inet::TCPSinkApp::initialize(), inet::TCPSrvHostApp::initialize(), inet::IPvXTrafSink::initialize(), inet::rtp::RTP::initialize(), inet::bgp::BGPRouting::initialize(), inet::ieee80211::Ieee80211MgmtBase::initialize(), inet::TCPGenericSrvApp::initialize(), inet::IPv4NodeConfigurator::initialize(), inet::rtp::RTCP::initialize(), inet::VoIPStreamReceiver::initialize(), inet::Ieee8021dRelay::initialize(), inet::STPBase::initialize(), inet::EtherLLC::initialize(), inet::tcp::TCP_lwIP::initialize(), inet::SimpleVoIPSender::initialize(), inet::VoIPStreamSender::initialize(), inet::DHCPServer::initialize(), inet::tcp::TCP_NSC::initialize(), inet::TED::initialize(), inet::IPvXTrafGen::initialize(), inet::PacketDrillApp::initialize(), inet::DHCPClient::initialize(), inet::ICMPv6::initialize(), inet::httptools::HttpServerBase::initialize(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), inet::SCTPPeer::initialize(), inet::SimpleVoIPReceiver::initialize(), inet::httptools::HttpBrowserBase::initialize(), inet::AODVRouting::initialize(), inet::IPv6Tunneling::initialize(), inet::IPv4RoutingTable::initialize(), inet::tcp::TCP::initialize(), inet::IPv6NeighbourDiscovery::initialize(), inet::UDP::initialize(), inet::RIPRouting::initialize(), inet::IPv6::initialize(), inet::RSVP::initialize(), inet::TCPEchoApp::isNodeUp(), inet::MACBase::isNodeUp(), inet::TCPBasicClientApp::isNodeUp(), inet::EtherAppSrv::isNodeUp(), inet::TCPSessionApp::isNodeUp(), inet::EtherTrafGen::isNodeUp(), inet::IPvXTrafGen::isNodeUp(), inet::EtherAppCli::isNodeUp(), inet::ospf::OSPFRouting::isNodeUp(), inet::PingApp::isNodeUp(), inet::GlobalARP::isNodeUp(), inet::ARP::isNodeUp(), inet::GPSR::isNodeUp(), inet::LDP::isNodeUp(), inet::dymo::DYMO::isNodeUp(), inet::IPv4::isNodeUp(), inet::L2NodeConfigurator::receiveSignal(), and inet::power::SimpleEpEnergyManagement::scheduleLifecycleOperationTimer().

48 { return state; }
State state
Definition: NodeStatus.h:44
NodeStatus::State inet::NodeStatus::getStateByName ( const char *  name)
staticprotected

Referenced by initialize().

43 {
44  std::string temp = name;
45  std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper);
46  cEnum *e = cEnum::get("inet::NodeStatus");
47  int state = e->lookup(temp.c_str(), -1);
48  if (state == -1)
49  throw cRuntimeError("Invalid state name '%s'", name);
50  return (State)state;
51 }
State state
Definition: NodeStatus.h:44
State
Definition: NodeStatus.h:40
const value< double, units::C > e(1.602176487e-19)
virtual void inet::NodeStatus::handleMessage ( cMessage *  msg)
inlineoverrideprotectedvirtual
53 { throw cRuntimeError("This module doesn't handle messages"); }
bool inet::NodeStatus::handleOperationStage ( LifecycleOperation operation,
int  stage,
IDoneCallback doneCallback 
)
overrideprotectedvirtual

Perform one stage of a lifecycle operation.

Processing may be done entirely within this method, or may be a longer process that involves nonzero simulation time or several events, and is triggered by this method call.

Return value: true = "done"; false = "not yet done, will invoke doneCallback when done"

Implements inet::ILifecycle.

54 {
55  Enter_Method_Silent();
56  cModule *node = getContainingNode(this);
57  if (dynamic_cast<NodeStartOperation *>(operation)) {
58  if (opStage == 0) {
59  EV << node->getFullPath() << " starting up" << endl;
60  if (getState() != DOWN)
61  throw cRuntimeError("Current node status is not 'down' at NodeStartOperation");
63  }
64  // NOTE: this is not an 'else if' so that it works if there's only 1 stage
65  if (opStage == operation->getNumStages() - 1) {
66  ASSERT(getState() == GOING_UP);
67  setState(UP);
68  EV << node->getFullPath() << " started" << endl;
69  node->bubble("Node started");
70  }
71  }
72  else if (dynamic_cast<NodeShutdownOperation *>(operation)) {
73  if (opStage == 0) {
74  EV << node->getFullPath() << " shutting down" << endl;
75  if (getState() != UP)
76  throw cRuntimeError("Current node status is not 'up' at NodeShutdownOperation");
78  }
79  // NOTE: this is not an 'else if' so that it works if there's only 1 stage
80  if (opStage == operation->getNumStages() - 1) {
81  ASSERT(getState() == GOING_DOWN);
82  setState(DOWN);
83  EV << node->getFullPath() << " shut down" << endl;
84  node->bubble("Node shut down");
85  }
86  }
87  else if (dynamic_cast<NodeCrashOperation *>(operation)) {
88  if (opStage == 0) {
89  EV << node->getFullPath() << " crashing" << endl;
90  if (getState() != UP)
91  throw cRuntimeError("Current node status is not 'up' at NodeCrashOperation");
93  }
94  // NOTE: this is not an 'else if' so that it works if there's only 1 stage
95  if (opStage == operation->getNumStages() - 1) {
96  ASSERT(getState() == GOING_DOWN);
97  setState(DOWN);
98  EV << node->getFullPath() << " crashed" << endl;
99  node->bubble("Node crashed");
100  }
101  }
102  return true;
103 }
virtual void setState(State state)
Definition: NodeStatus.cc:105
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
virtual State getState() const
Definition: NodeStatus.h:48
Definition: NodeStatus.h:40
void inet::NodeStatus::initialize ( int  stage)
overrideprotectedvirtual
33 {
34  cSimpleModule::initialize(stage);
35 
36  if (stage == INITSTAGE_LOCAL) {
37  state = getStateByName(par("initialStatus"));
38  origIcon = getDisplayString().getTagArg("i", 0);
39  }
40 }
std::string origIcon
Definition: NodeStatus.h:45
Local initializations.
Definition: InitStages.h:35
State state
Definition: NodeStatus.h:44
static State getStateByName(const char *name)
Definition: NodeStatus.cc:42
virtual int inet::NodeStatus::numInitStages ( ) const
inlineoverrideprotectedvirtual
51 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::NodeStatus::refreshDisplay ( ) const
overrideprotectedvirtual
112 {
113  const char *icon;
114  switch (state) {
115  case UP:
116  icon = "";
117  break;
118 
119  case DOWN:
120  icon = "status/cross";
121  break;
122 
123  case GOING_UP:
124  icon = "status/execute";
125  break;
126 
127  case GOING_DOWN:
128  icon = "status/execute";
129  break;
130 
131  default:
132  throw cRuntimeError("Unknown status");
133  }
134  cModule *node = getContainingNode(this);
135  const char *myicon = state == UP ? origIcon.c_str() : icon;
136  getDisplayString().setTagArg("i", 0, myicon);
137  if (*icon)
138  node->getDisplayString().setTagArg("i2", 0, icon);
139  else
140  node->getDisplayString().removeTag("i2");
141 }
std::string origIcon
Definition: NodeStatus.h:45
State state
Definition: NodeStatus.h:44
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
Definition: NodeStatus.h:40
void inet::NodeStatus::setState ( State  state)
protectedvirtual

Referenced by handleOperationStage().

106 {
107  state = s;
108  emit(nodeStatusChangedSignal, this);
109 }
State state
Definition: NodeStatus.h:44
static simsignal_t nodeStatusChangedSignal
Definition: NodeStatus.h:41
value< double, units::s > s
Definition: Units.h:1049

Member Data Documentation

simsignal_t inet::NodeStatus::nodeStatusChangedSignal = registerSignal("nodeStatusChanged")
static

Referenced by setState().

std::string inet::NodeStatus::origIcon
private

Referenced by initialize(), and refreshDisplay().

State inet::NodeStatus::state
private

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