omnet java_omnet:自我消息作为被处置对象

模拟运行,但在控制台中我有这个说明 .

undisposed对象:(omnetpp :: cMessage)Mysimulation.Switch4.eth [2] .queue.scheduler.IntervalTimemsg - 检查模块析构函数未处理对象:(omnetpp :: cMessage)Mysimulation.Switch5.eth [1] .queue.scheduler .IntervalTimemsg - 检查模块析构函数

实际上,这是我通过模拟反复使用两个定时消息创建的模块 . 我在线阅读并发现此错误与创建应删除时未删除的对象有关 .

void PriorityScheduler::initialize() {

gateCycleTimemsg = new cMessage("gateCycleTimemsg");

scheduleAt(baseTime , gateCycleTimemsg);

// baseTime = 2s

}

void PriorityScheduler::handleMessage(cMessage *msg) {

if (msg == gateCycleTimemsg) {

if (currentList == (lastIntervalTime)) {

delete msg;

gateCycleTimemsg = new cMessage("gateCycleTimemsg");

scheduleAt( simTime() + gateCycleTime , gateCycleTimemsg);

...

IntervalTimemsg = new cMessage("IntervalTimemsg");

scheduleAt( simTime() + Interval , IntervalTimemsg);

}

else if (currentList == (firstIntervalTime)) {

gateCycleTimemsg = msg; // same message reused

scheduleAt(simTime() + gateCycleTime , gateCycleTimemsg);

//gateCycleTime = 10 seconds

...

IntervalTimemsg = new cMessage("IntervalTimemsg");

scheduleAt( simTime() + Interval , IntervalTimemsg);

// Interval = 1s

}

}

else if (msg == IntervalTimemsg) {

if (currentList == (lastIntervalTime));

else{

IntervalTimemsg = msg;

scheduleAt( simTime() + Interval , IntervalTimemsg);

}

}

插件路径:/home/amr/omnetpp-5.0/samples/etc/plugins;./plugins在抛出'omnetpp :: cRuntimeError'的实例后调用what():对象pk-56-145当前在(omnetpp) :: cEventHeap)simulation.scheduled-events,无法删除 . 如果在omnetpp :: cEventHeap中发生此错误,则需要将其更改为调用drop()才能删除该对象 . 如果在omnetpp :: cEventHeap的析构函数中发生此错误并且pk-56-145是类成员,则omnetpp :: cEventHeap需要在析构函数中调用drop()

我创建了一个构造函数和析构函数 . 在线阅读解决方案之后,我还创建了函数finish() . 仍然没有解决它 .

我也删除了收到的每条消息,并在发送时创建了一个新消息,但它没有改变任何东西 .

edit: 我用delete msg编辑了编码;我添加了一个时间示例并添加了以下部分,

BaseTime'BT',gateCycleTime'CT',Interval'IT'

----> BT

.........

我使用相同的信息用于BT和CT,而另一条信息用于IT,因为我不知道最后一次IT'ITx'的时间 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值