#include <FailureManager.h>
Inheritance diagram for FailureManager:

Protected Member Functions | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | processCommand (const cXMLElement &node) |
Private Member Functions | |
| void | replaceNode (cModule *mod, const char *newNodeType) |
| void | reconnectNode (cModule *old, cModule *n) |
| void | reconnect (cModule *old, cModule *n, const char *ins, const char *outs) |
| cModule * | getTargetNode (const char *target) |
|
|
00034 {
00035 cModule *mod = simulation.moduleByPath(target);
00036 ASSERT(mod);
00037 return mod;
00038 }
|
|
|
00029 {
00030 ASSERT(false);
00031 }
|
|
|
00024 {
00025 // so far no initialization
00026 }
|
|
|
Called by ScenarioManager whenever a script command needs to be carried out by the module. The command is represented by the XML element or element tree. The command name can be obtained as:
const char *command = node->getTagName() Parameters are XML attributes, e.g. a "neighbour" parameter can be retrieved as:
const char *attr = node->getAttribute("neighbour")
More complex input can be passed in child elements.
Implements IScriptable. 00041 {
00042 cModule *target = getTargetNode(node.getAttribute("target"));
00043
00044 if (!strcmp(node.getTagName(), "shutdown"))
00045 {
00046 target->displayString().setTagArg("i2",0,"status/cross");
00047 if(!strcmp(target->moduleType()->name(), "RSVP_LSR"))
00048 replaceNode(target, "RSVP_FAILED");
00049 else if(!strcmp(target->moduleType()->name(), "LDP_LSR"))
00050 replaceNode(target, "LDP_FAILED");
00051 else if(!strcmp(target->moduleType()->name(), "QuaggaRouter"))
00052 replaceNode(target, "FailedRouter");
00053 else
00054 ASSERT(false);
00055 }
00056 else if(!strcmp(node.getTagName(), "startup"))
00057 {
00058 target->displayString().removeTag("i2");
00059 if(!strcmp(target->moduleType()->name(), "RSVP_FAILED"))
00060 replaceNode(target, "RSVP_LSR");
00061 else if(!strcmp(target->moduleType()->name(), "LDP_FAILED"))
00062 replaceNode(target, "LDP_LSR");
00063 else if(!strcmp(target->moduleType()->name(), "FailedRouter"))
00064 replaceNode(target, "QuaggaRouter");
00065 else
00066 ASSERT(false);
00067 }
00068 else
00069 ASSERT(false);
00070
00071 }
|
|
||||||||||||||||||||
|
00103 {
00104 unsigned int insize = old->gateSize(ins);
00105 unsigned int outsize = old->gateSize(outs);
00106
00107 n->setGateSize(ins, insize);
00108 n->setGateSize(outs, outsize);
00109
00110 for(unsigned int i = 0; i < outsize; i++)
00111 {
00112 cGate *out = old->gate(outs, i);
00113 if(out->isConnected())
00114 {
00115 cGate *to = out->toGate();
00116 cChannel *ch = check_and_cast<cChannel*>(out->channel()->dup());
00117 out->disconnect();
00118 n->gate(outs, i)->connectTo(to, ch);
00119 }
00120 }
00121
00122 for (unsigned int i = 0; i < insize; i++)
00123 {
00124 cGate *in = old->gate(ins, i);
00125 if (in->isConnected())
00126 {
00127 cGate *from = in->fromGate();
00128 cChannel *ch = check_and_cast<cChannel*>(from->channel()->dup());
00129 from->disconnect();
00130 from->connectTo(n->gate(ins, i), ch);
00131 }
00132 }
00133 }
|
|
||||||||||||
|
00089 {
00090 for(int i = 0; i < old->params(); i++)
00091 n->par(i) = old->par(i);
00092
00093 n->setDisplayString(old->displayString().getString());
00094
00095 // FIXME should examine which gates the "old" module has, and reconnect all of them
00096 // automatically (ie eliminate hardcoded gate names from here)
00097 reconnect(old, n, "in", "out");
00098 //reconnect(old, n, "ethIn", "ethOut");
00099
00100 }
|
|
||||||||||||
|
00074 {
00075 cModuleType *nodeType = findModuleType(newNodeType);
00076 ASSERT(nodeType);
00077 cModule *nodeMod = nodeType->create(mod->name(), simulation.systemModule());
00078 ASSERT(nodeMod);
00079
00080 reconnectNode(mod, nodeMod);
00081 delete mod;
00082
00083 nodeMod->buildInside();
00084 nodeMod->scheduleStart(simTime());
00085 nodeMod->callInitialize();
00086 }
|
1.4.1