omnet++ - 如何使用 setDoubleValue() 在 Omnet++ 中更改参数运行时
问题描述
我正在模拟具有 2 个无线主机和 1 个接入点的网络。在运行期间,节点通过访问模块并使用 setDoubleValue(0) 将接入点的发射功率设置为零(将其关闭)。但是新的价值观永远不会生效。AP 的消息继续到达节点。我在这里做错了什么?我想在模拟运行时关闭接入点。请帮忙。
cSimulation *currentSimulation = getSimulation();
cModule *tx = nullptr;
tx=currentSimulation->getModuleByPath("agranet.ap.wlan[0].radio.transmitter");
tx->par("power").setDoubleValue(0);
//cPar& po = tx->par("power");
//po.setDoubleValue(0);
我想在模拟运行时关闭接入点。
解决方案
初始化后不能更改 power 参数,因为它是非易失性参数,因此在初始化时读取其值并在之后缓存。您只能操作 C++ 代码已经为此准备好的易失性 NED 参数。
另一方面,您要实现的是在某个时间禁用节点,这就是 ScenaioManager 的用途:
https://inet.omnetpp.org/docs/users-guide/ch-scenario-scripting.html
推荐阅读
- javascript - 如何切换 div 的显示?
- python - python正在另一个窗口中启动
- excel - 从另一个单元格向单元格添加注释,如果源单元格为空白或零,则跳过该单元格并转到下一个
- python - Maya 中的 __file__ 未定义(#NameError)
- linux - 如何找出系统软锁的真正原因?
- google-sheets - 在 Google 表格中重复范围
- android - 片段中的 editText.getText().append 不起作用
- python - 尝试在 python 上为 FLIR 轻子相机构建脚本
- isabelle - 使用单射函数的反值
- linux - 实现自定义 u-boot 命令