模拟运行,但在控制台中我有这个说明 .
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'的时间 .