RealworldDevice.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #include "RealworldDevice.h"
00025
00026
00027 void RealworldDevice::initialize(int stage)
00028 {
00029
00030 RealworldConnector::initialize(stage);
00031
00032
00033 if (stage == 0) {
00034 interfaceEntry = registerInterface();
00035 }
00036
00037 }
00038
00039 InterfaceEntry *RealworldDevice::registerInterface()
00040 {
00041 InterfaceEntry *e = new InterfaceEntry();
00042
00043
00044 char *interfaceName = new char[strlen(getFullName())+1];
00045 char *d=interfaceName;
00046 for (const char *s=getFullName(); *s; s++)
00047 if (isalnum(*s))
00048 *d++ = *s;
00049 *d = '\0';
00050
00051 e->setName(interfaceName);
00052 delete [] interfaceName;
00053
00054
00055 int outputPort = gate("netwIn")->getPreviousGate()->getIndex();
00056 e->setNodeOutputGateId(outputPort);
00057
00058
00059 InterfaceToken token(0, simulation.getUniqueNumber(), 64);
00060 e->setInterfaceToken(token);
00061
00062
00063
00064 e->setMtu(mtu);
00065
00066
00067 e->setMulticast(true);
00068 e->setPointToPoint(true);
00069
00070
00071 IInterfaceTable *ift = InterfaceTableAccess().get();
00072 ift->addInterface(e, this);
00073
00074 return e;
00075 }
00076
00077