Help !!!! Modify errors in File.cc

45 views
Skip to first unread message

tung_dhqn

unread,
Jul 21, 2014, 10:05:58 AM7/21/14
to omn...@googlegroups.com

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 !!!! 

Alfonso Ariza Quintana

unread,
Jul 21, 2014, 11:06:08 AM7/21/14
to omn...@googlegroups.com

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.

tung_dhqn

unread,
Jul 22, 2014, 3:23:40 AM7/22/14
to omn...@googlegroups.com, aari...@hotmail.com
Thank for your reply !!! You can talk more detailed. This file.cc stay in the AdhocSim project, and I want to application into Omnet++4.1. Please guide to me to it's not error . Thank you very much.

Vào 22:06:08 UTC+7 Thứ hai, ngày 21 tháng bảy năm 2014, Alfonso Ariza Quintana đã viết:

Alfonso Ariza Quintana

unread,
Jul 22, 2014, 3:46:04 AM7/22/14
to omn...@googlegroups.com

Do you really need the AdhocSim Project? The functionality is present in inet or inetmanet, Manet routing protocols, mobility and a lot of more.

tung_dhqn

unread,
Jul 22, 2014, 4:45:55 AM7/22/14
to omn...@googlegroups.com, aari...@hotmail.com
I am sorry. Because I am a student 4th year and I am working a Project to get a certificate at University(My country). So, I am worry and don't know anyway to running AdhocSim. I know also about inet or inetmanet, but I don't use , so I think modifying Adhocsim will make new something and better my project. In addition, verything is very good except this Physic.cc, 6 error. Hope you understood. :)) . 

Vào 14:46:04 UTC+7 Thứ ba, ngày 22 tháng bảy năm 2014, Alfonso Ariza Quintana đã viết:

Alfonso Ariza Quintana

unread,
Jul 22, 2014, 5:50:12 AM7/22/14
to omn...@googlegroups.com

The gate should be defined in the ned definition file.

tung_dhqn

unread,
Jul 22, 2014, 10:53:29 AM7/22/14
to omn...@googlegroups.com, aari...@hotmail.com
How do you can define a gate when staying at file.cc ??. that idea is detect and creat to a link when nodes move together. So, gates must to be dynamally creat in file.cc . ???? 

Vào 16:50:12 UTC+7 Thứ ba, ngày 22 tháng bảy năm 2014, Alfonso Ariza Quintana đã viết:
...

Alfonso Ariza Quintana

unread,
Jul 22, 2014, 11:16:25 AM7/22/14
to omn...@googlegroups.com

                                                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

tung_dhqn

unread,
Jul 22, 2014, 11:46:43 PM7/22/14
to omn...@googlegroups.com, aari...@hotmail.com
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 ? 

" if ( type=='O') mod->addGate("ngate",cGate::OUTPUT,true);
else mod->addGate("ngate",cGate::INPUT,true); 
mod->setGateSize("ngate",1);
//g=mod->gate("ngate");
check_and_cast<cArray*>(mod)->addAt(i,g); "
It's difficult !!!!!!!!!

Vào 22:16:25 UTC+7 Thứ ba, ngày 22 tháng bảy năm 2014, Alfonso Ariza Quintana đã viết:
<p clas
...

Alfonso Ariza Quintana

unread,
Jul 23, 2014, 3:57:07 AM7/23/14
to omn...@googlegroups.com

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 ? 

https://lh6.googleusercontent.com/-cuNgGXmNdIE/U88u4bj5xdI/AAAAAAAAAEQ/ISW9MUhqqg4/s320/Untitled.png

Reply all
Reply to author
Forward
0 new messages