Hello everybody !
Please !! Help me to modify code of omnet++ following below:
int Physic::addNewGate(cModule *mod, char* gname, char type)
{
cGate* g;
int index = 0,
gateNum = 0;
bool found = false;
int i = 0;
d("gates number before connection:"<<mod->gates());
//look for a free entry
while((i< mod->size()) && (!found))
{
g = (cGate*) mod->gate(i);
d("gate: "<<i);
if(g == NULL)
{
d("found a null gate vector place. Use it !");
g = new cGate(gname,type); // Error 1
check_and_cast<cArray*>(mod)->addAt(i,g);
g->setOwnerModule( mod, i); //Error2 index = i;
found = true;
}
else{
if(!g->isConnected())
{
d("found a not connected gate. recycling :"<<g->name());
deleteGate( g->getName());
g = new cGate(gname, type); //Error 3
check_and_cast<cArray*>(mod)->addAt(i,g);
g->setOwnerModule(mod,i); //Error 4
found = true;
index = i;
}
else
i++;
}
}
//all the entries are used, add a new gate
if(!found)
{
d("free place not found, adding a new one ");
mod->addGate(gname,type); //Error 5
gateNum = mod->size();
if(mod->hasGate(gname))
{
d("has gate ok !");
index = mod->findGate(gname);
}
else
{
d("--- ERROR new gate not found!");
}
}
//mod->setGateSize(gname,mod->gates());
g = (cGate*) mod->gate(index);
//g->setIndex(index,gateNum);
//g->setIndex(index,mod->gates());
g->setOwnerModule(mod,index); //Error 6
//cGate* newGate = new cGate(gname, type);
return index;
}
I don’t understant why errors 1, 3, 5 was occurred. Errors 2,4,6 was wrote in release Omnet++ 2.2, I try to application them into Omnet++ 4.1 . “setOwnerModule()” function belong to cModulePar in Omnet++ 2.2, but Omnet++ 4.1 have not this library. I don’t know how to transform them to not ocurr error. Please help me !!!!
The owner of a module can be changed with take,
But omenet 4.x is designed with the idea that the gates are defined in the ned file, you can change the size of a vector gate array dynamically but the base gate is defined in the ned file
--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Do you really need the AdhocSim Project? The functionality is present in inet or inetmanet, Manet routing protocols, mobility and a lot of more.
The gate should be defined in the ned definition file.
...
g = new cGate(gname,type); // Error 1
check_and_cast<cArray*>(mod)->addAt(i,g);
g->setOwnerModule( mod, i); //Error2 index = i;
I have read de manual ant these machanims has been replaced by cModule::addGate()
mod->addGate(“myGate”, cGate::INPUT,true);
mod->setGateSize(“myGate”,1);
You should read the documentation
...<p clas
You can use the debug and discover the error, but there is an erroneous identification in the gate
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de tung_dhqn
Enviado el: miércoles, 23 de julio de 2014 5:47
Para: omn...@googlegroups.com
CC: aari...@hotmail.com
Asunto: Re: [Omnetpp-l] Help !!!! Modify errors in File.cc
Hi !
I modified my physic.cc as you say me. but it's remain error. I think that my file don't remain creat a gate. What's your opinion,Alfonso Ariza Quintana ?