在 Omnet (INET) 运行 时间节点创建或出现
Node creation or apperance at run time in Omnet (INET)
我需要在 运行 时创建一个节点,其参数与其他节点相似。为此,我在 ned 文件中创建一个动态节点:-
host_send4: meshnode {
parameters:
@dynamic;
@display("p=1000,535;r=200,green;i=device/smallrouter");
}
为了在 C++ 文件中实现这个节点,我添加了这段代码:-
cModuleType *meshnode1 = cModuleType::get("inet.networklayer.manetrouting.PASER.meshnode");
cModule *mod = meshnode1->createScheduleInit("host_send4", this);
cDisplayString& dispstr = mod->getDisplayString();
dispstr.parse("p=1000,535;r=200,green;i=device/smallrouter");
mod->buildInside();
mod->scheduleStart(simTime()+5*beaconInterval);
但我无法正确构建它。我想我需要这方面的任何例子。谁能帮我指出 INETMANET 中的 mixim 或任何其他 oment 框架的示例,其中已经实现了此功能。
谢谢你的帮助。
我也考虑过静态创建一个节点,该节点稍后会出现在模拟中。 INET 或其他 OMNET 框架中节点出现和消失的时间是否可能,是否有任何示例。
OMNeT++ 用户手册有一个 section 专门用于此。据此,使用 createScheduleInit()
.
时不需要 buildInside()
和 scheduleStart()
可以在 Veins 框架中看到如何执行此操作的示例 - 更准确地说,在 TraCIScenarioManager 中。对你来说重要的行可能是:
cModule* parentmod = getParentModule();
if (!parentmod) error("Parent Module not found");
cModuleType* nodeType = cModuleType::get(type.c_str());
if (!nodeType) error("Module Type \"%s\" not found", type.c_str());
cModule* mod = nodeType->create(name.c_str(), parentmod, nodeVectorIndex, nodeVectorIndex);
mod->finalizeParameters();
mod->getDisplayString().parse(displayString.c_str());
mod->buildInside();
mod->scheduleStart(simTime() + updateInterval);
我需要在 运行 时创建一个节点,其参数与其他节点相似。为此,我在 ned 文件中创建一个动态节点:-
host_send4: meshnode {
parameters:
@dynamic;
@display("p=1000,535;r=200,green;i=device/smallrouter");
}
为了在 C++ 文件中实现这个节点,我添加了这段代码:-
cModuleType *meshnode1 = cModuleType::get("inet.networklayer.manetrouting.PASER.meshnode");
cModule *mod = meshnode1->createScheduleInit("host_send4", this);
cDisplayString& dispstr = mod->getDisplayString();
dispstr.parse("p=1000,535;r=200,green;i=device/smallrouter");
mod->buildInside();
mod->scheduleStart(simTime()+5*beaconInterval);
但我无法正确构建它。我想我需要这方面的任何例子。谁能帮我指出 INETMANET 中的 mixim 或任何其他 oment 框架的示例,其中已经实现了此功能。 谢谢你的帮助。
我也考虑过静态创建一个节点,该节点稍后会出现在模拟中。 INET 或其他 OMNET 框架中节点出现和消失的时间是否可能,是否有任何示例。
OMNeT++ 用户手册有一个 section 专门用于此。据此,使用 createScheduleInit()
.
buildInside()
和 scheduleStart()
可以在 Veins 框架中看到如何执行此操作的示例 - 更准确地说,在 TraCIScenarioManager 中。对你来说重要的行可能是:
cModule* parentmod = getParentModule();
if (!parentmod) error("Parent Module not found");
cModuleType* nodeType = cModuleType::get(type.c_str());
if (!nodeType) error("Module Type \"%s\" not found", type.c_str());
cModule* mod = nodeType->create(name.c_str(), parentmod, nodeVectorIndex, nodeVectorIndex);
mod->finalizeParameters();
mod->getDisplayString().parse(displayString.c_str());
mod->buildInside();
mod->scheduleStart(simTime() + updateInterval);