Parameter initialization when dynamically creating compound modules

157 views
Skip to first unread message

Dave Mck

unread,
Nov 26, 2012, 3:30:03 PM11/26/12
to omn...@googlegroups.com
Hello again everybody...

I am wondering how parameter initialization for submodules is supposed to be done when creating compound modules dynamically. Within the files I have been playing around with, I have figured out a solution that works for my current purposes, which I will explain below, but I am wondering if this is the proper way of setting parameters for the submodule of a compound module you are creating dynamically, or if there is an easier/less hard-coded method of doing it. As far as I know, the user manual only discusses creation of simple modules in this way, so if anybody knows of documentation or examples that cover this if I am incorrect, that would be nice.

Below is the code for module creation that I currently have. It works, but I'm not 100% sure why :D

//Get the module type, as the goal is to create more of the same
cModuleType
*moduleType = this->getParentModule()->getModuleType();

//Create the module and initialize its parameters (the mobility type is the only parameter)
cModule
*module = moduleType->create("rsu", this->getParentModule()->getParentModule(), numModules, curModule);
module->par("mobilityType") = "MySimpleMobility";
module->finalizeParameters();

module->buildInside();

//Get the submodule of the created module and set the parameters (the x/y/z coordinates in this case)
module->getSubmodule("mobility")->par("x") = initX;
module->getSubmodule("mobility")->par("y") = initY;
module->getSubmodule("mobility")->par("z") = initZ;

//Schedule the start of the created module
module->scheduleStart(simTime());

//Added this in because it made things work…? Otherwise I received an error stating the submodule (mobility) was not initialized
module->callInitialize();


TALBI Elhadi

unread,
Aug 1, 2013, 7:03:03 PM8/1/13
to omn...@googlegroups.com
Hi all


I used to read omnet++ manual to generate the RSUs dynamically. I’ve created rsu.ned from Car.ned file with a LinearMobility instead of tracimobility used in car.ned

The probleme I encountred is that I don’t know where to inject the c++ code to generate dynamically this RSUs. I created a new c++ file rsu.cc but no RSU was generated.

Can you please give me some clarification about where to inject the C++ code to generate the RSUs.

TALBI Elhadi


Reply all
Reply to author
Forward
0 new messages