【发布时间】:2020-12-16 13:23:51
【问题描述】:
我是 OMNeT++ 的新手,我正在为一个项目使用 Inet 框架。 我想在应用程序模块中访问 Mac 模块以获取变量。我在 omnet++ 手册中看到了这一点。
cModule *targetModule = getParentModule()->getSubmodule("foo");
Foo *target = check_and_cast<Foo *>(targetModule);
target->doSomething();
还有这个
cModule *app = module->getModuleByPath(".app[3]"); // note leading dot
cModule *gen = module->getModuleByPath(".app[3].gen");
所以我把它们结合起来,我的表现是这样的:
cModule *macModule = cModule::getModuleByPath("TestNetwork.wlan[0].mac");
updatedMac *target = check_and_cast<updatedMac *>(macModule);
var = target->getVar();
路径来自ini文件。
我收到此错误:
check_and_cast(): 无法将 nullptr 转换为类型 'inet::updatedMac *' -- 在模块 (inet::ApplicationApp) TestNetwork.host[1].app[0] (id=85) 中,位于t=0.305s,事件#250
我是不是弄错了路径?那么我该如何编写从应用层模块到链接层模块的路径。
我真的可以使用帮助。
【问题讨论】:
-
其实你得到了 nullptr ...
标签: c++ frameworks omnet++ inet