- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 VANETs 项目,我使用 veins-2.0-rc2。
在 LinearMobility.cc 类中,我有这段代码,
void LinearMobility::initialize(int stage)
{
BaseMobility::initialize(stage);
debugEV << "initializing LinearMobility stage " << stage << endl;
if (stage == 0)
{
move.setSpeed(par("speed").doubleValue());
acceleration = par("acceleration");
angle = par("angle");
angle = fmod(angle,360);
}
else if(stage == 1)
{
stepTarget = move.getStartPos();
if(!world->use2D())
{
opp_warning("This mobility module does not yet support 3 dimensional movement."\
"Movements will probably be incorrect.");
}
if(!world->useTorus())
{
opp_warning("You are not using a torus (parameter \"useTorus\" in"\
"BaseWorldUtility module) playground but this mobility"\
"module uses WRAP as border policy.");
}
}
}
我尝试通过修改 LinearMobility.cc 类将事故事件添加到我的场景中
void LinearMobility::initialize(int stage)
{
BaseMobility::initialize(stage);
debugEV << "initializing LinearMobility stage " << stage << endl;
if (stage == 0){
move.setSpeed(par("speed").doubleValue());
acceleration = par("acceleration");
angle = par("angle");
angle = fmod(angle,360);
accidentCount = par("accidentCount");
WATCH(angle);
startAccidentMsg = 0;
stopAccidentMsg = 0;
if (accidentCount > 0) {
simtime_t accidentStart = par("accidentStart");
startAccidentMsg = new cMessage("scheduledAccident");
stopAccidentMsg = new cMessage("scheduledAccidentResolved");
scheduleAt(simTime() + accidentStart, startAccidentMsg);
}
}
else if(stage == 1){
stepTarget = move.getStartPos();
if(!world->use2D()) {
opp_warning("This mobility module does not yet support 3 dimensional movement."\
"Movements will probably be incorrect.");
}
if(!world->useTorus()) {
opp_warning("You are not using a torus (parameter \"useTorus\" in"\
"BaseWorldUtility module) playground but this mobility"\
"module uses WRAP as border policy.");
}
}
}
void LinearMobility::handleSelfMsg(cMessage *msg)
{
if (msg == startAccidentMsg) {
simtime_t accidentDuration = par("accidentDuration");
scheduleAt(simTime() + accidentDuration, stopAccidentMsg);
accidentCount--;
}
else if (msg == stopAccidentMsg) {
if (accidentCount > 0) {
simtime_t accidentInterval = par("accidentInterval");
scheduleAt(simTime() + accidentInterval, startAccidentMsg);
}
}
}
但是我在 OMNeT++ 中遇到了这个问题:
undisposed object: (cMessage) Scenario.node[0].mobility.scheduledAccidentResolved -- check module destructor
undisposed object: (cMessage) Scenario.node[0].mobility.scheduledAccident -- check module destructor
undisposed object: (cMessage) Scenario.node[1].mobility.move -- check module destructorundisposed object: (cMessage) Scenario.node[2].mobility.move -- check module destructorundisposed object: (cMessage) Scenario.node[3].mobility.move -- check module destructorundisposed object: (cMessage) Scenario.node[4].mobility.move -- check module destructor
谁能帮我解决一下?
最佳答案
这些消息通知您您已经创建了一个对象但没有删除它。它涉及消息:startAccidentMsg
、stopAccidentMsg
以及可能与移动相关的消息。
解决方法:在finish()
方法中添加如下代码:
cancelAndDelete(startAccidentMsg);
cancelAndDelete(stopAccidentMsg);
如果没有finish()
方法,直接添加即可。
关于c++ - 使用 Veins 检查 Omnet++ 中的模块析构函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37543640/
我是一名优秀的程序员,十分优秀!