Dynamic 如何在OMNet+中连接动态模块和静态模块+;

Dynamic 如何在OMNet+中连接动态模块和静态模块+;,dynamic,module,omnet++,Dynamic,Module,Omnet++,我有一个关于计算云的项目,我正在使用Omnet++。我试图创建随机数目的动态模块来表示虚拟机。我现在能够做到这一点,但我无法将新的动态模块连接到表示虚拟机核心的静态模块。OMNet++的用户手册解释了如何将动态模块连接到另一个动态模块,而不是将动态模块连接到静态模块 有人能帮忙吗?我已经创建了一个动态模块,并使用以下代码将其连接到静态模块: void Txc::initialize() { if(strcmp( getName(), "txc" ) ==0){ index

我有一个关于计算云的项目,我正在使用Omnet++。我试图创建随机数目的动态模块来表示虚拟机。我现在能够做到这一点,但我无法将新的动态模块连接到表示虚拟机核心的静态模块。OMNet++的用户手册解释了如何将动态模块连接到另一个动态模块,而不是将动态模块连接到静态模块


有人能帮忙吗?

我已经创建了一个动态模块,并使用以下代码将其连接到静态模块:

void Txc::initialize()
{
    if(strcmp( getName(), "txc" ) ==0){
        index =0;
        cModuleType *moduleType = cModuleType::get("createmoduledynamically.Txc");
        cModule *module = moduleType->create("node", getParentModule(), 10 , index);//createScheduleInit()

        module->setGateSize("in", 2);
        module->setGateSize("out", 2);

        gate("out",0)->connectTo(module->gate("in",0));
        module->gate("out",0)->connectTo(gate("in",0));

        cMessage *msg = new cMessage("Data");
        send(msg,"out", 0);
    }
}

void Txc::handleMessage(cMessage *msg)
{
    cModule *mod = getParentModule()->getSubmodule("txc");
    Txc * txcMod = check_and_cast<Txc *>(mod);
    txcMod->index++;
    if(txcMod->index<10){
        cModuleType *moduleType = cModuleType::get("createmoduledynamically.Txc");
        cModule *module = moduleType->create("node", getParentModule(), 10 , txcMod->index);//createScheduleInit()

        module->setGateSize("in", 2);
        module->setGateSize("out", 2);

        gate("out",1)->connectTo(module->gate("in",0));
        module->gate("out",0)->connectTo(gate("in",1));

        module->callInitialize();

        send(msg, "out", 1);
    }
}
void Txc::initialize()
{
if(strcmp(getName(),“txc”)==0){
指数=0;
cModuleType*moduleType=cModuleType::get(“createModuleDynamicly.Txc”);
cModule*module=moduleType->create(“节点”,getParentModule(),10,索引);//createScheduleInit()
模块->设置网关大小(“in”,2);
模块->设置网关大小(“输出”,2);
门(“输出”,0)->连接到(模块->门(“输入”,0));
模块->门(“输出”,0)->连接到(门(“输入”,0));
cMessage*msg=新的cMessage(“数据”);
发送(msg,“out”,0);
}
}
void Txc::handleMessage(cMessage*msg)
{
cModule*mod=getParentModule()->getSubmodule(“txc”);
Txc*txcMod=检查和铸造(mod);
txcMod->index++;
if(txcMod->indexcreate(“node”,getParentModule(),10,txcMod->index);//createScheduleInit()
模块->设置网关大小(“in”,2);
模块->设置网关大小(“输出”,2);
门(“输出”,1)->连接到(模块->门(“输入”,0));
模块->门(“输出”,0)->连接到(门(“输入”,1));
模块->callInitialize();
发送(msg,“out”,1);
}
}
在静态网络文件中仅创建一个模块时:

子模块: txc:txc


希望这会有用。

今天我遇到了你同样的问题。你解决了吗?