Omnet++,如何获取模块所有预定事件的列表? [英] Omnet++, How can I get list of all scheduled events of a module?

查看:62
本文介绍了Omnet++,如何获取模块所有预定事件的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令针对 omnet++ 中的节点安排事件列表:

I am scheduling list of events against a node in omnet++ using:

scheduleAt(simTime().dbl() + slotTime, msg)

一个模块的未来活动列表中可能会有多个这样的时间表.

and there could be multiple such schedule in future event list for a single module.

现在在给定的时刻,我想取消节点的所有未来计划事件,这就是为什么我需要所有未来事件的列表.

Now at a given time instant I want to cancel all future scheduled events of a node and that's why I need list of all future events.

据我所知 cancelEvent(msg) 只取消一个事件.如何找到列表并删除所有事件.请帮忙.

To the best of my knowledge cancelEvent(msg) only cancel one event. How can I find the list and remove all events. Please help.

推荐答案

要访问 所有 未来事件的列表,可以使用 getMessageQueue().并且要仅删除自己的事件(即 selfmessages),必须使用 isSelfMessage() 检查该列表中的每个事件.示例代码,从未来事件集中删除所有自我消息:

To access a list of all future events one can use getMessageQueue(). And to remove only own events (i.e. selfmessages) every event in that list has to be checked using isSelfMessage(). The sample code, which removes all selfmessages from future event set:

cMessageHeap& heap = cSimulation::getActiveSimulation()->getMessageQueue();
cMessageHeap::Iterator it(heap);
do {
    cMessage * event = it();
    if (event && event->isSelfMessage()) {
        cancelAndDelete(event);
        it.init(heap);
    } else {
        it++;
    }

} while (!it.end());

这篇关于Omnet++,如何获取模块所有预定事件的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆