多个邮件内容omnet ++串联时出错

时间:2018-12-09 13:38:53

标签: omnet++

我有这段代码,我从两个流程块(Hey.cc和See.cc)的句柄消息中获取消息,并将其组合为新消息(在There.cc中),但似乎无法正常工作帮助

嘿.cc

#include "Hey.h"

Define_Module(Hey);

void Hey::initialize()
{
    // TODO - Generated method body
    cMessage *mmsg = new cMessage("hello");
    send(mmsg,"hello");
}

void Hey::handleMessage(cMessage *msg)
{
    // TODO - Generated method body
}

和See.cc

#include "See.h"

Define_Module(See);

void See::initialize()
{
    // TODO - Generated method body
    cMessage *smsg = new cMessage("hi");
    send(smsg,"tempexit");
}

void See::handleMessage(cMessage *msg)
{
    // TODO - Generated method body
}

和There.cc

#include "There.h"
#include "See.h"
#include "Hey.h"
#include <string>

Define_Module(There);

void There::initialize()
{
    // TODO - Generated method body
}

void There::handleMessage(cMessage *msg)
{
    cMessage *smsg = new cMessage("hi");    // supposed to be from See.cc
    cMessage *mmsg = new cMessage("hello"); // supposed to be from Hey.cc
    cMessage strNew = *smsg;
    cMessage sstrNew = *mmsg;
    cMessage rNew = strNew + sstrNew ;

    EV << rNew ;
}

1 个答案:

答案 0 :(得分:0)

  1. send方法的第二个参数应为the name of gate或指向cGate对象的指针。 Hey.ned是否包含hello输出门,并且See.ned是否包含tempexit门?

  2. cMessage没有operator+,因此一个不能添加两个cMessage的实例。顺便说一句:您期望此操作带来什么?如果是封装消息,则应使用encapsulate()