2

我正在尝试在 Veins 中实现 RSU 到 RSU 的通信。为此,我在 RSU 模块(RSU.ned 文件)中添加了一个 inout 门:

module RSU
{
    parameters:
        string applType; //type of the application layer
        string nicType = default("Nic80211p"); // type of network interface card
    gates:
        input veinsradioIn; // gate for sendDirect
        inout gate[]; // add in out gates to ensure communication between RSUs        
    submodules:
        appl: <applType> like org.car2x.veins.base.modules.IBaseApplLayer {
            parameters:
                @display("p=60,50");
        }

        nic: <nicType> like org.car2x.veins.modules.nic.INic80211p {
            parameters:
                @display("p=60,166");
        }

        mobility: BaseMobility {
            parameters:
                @display("p=130,172;i=block/cogwheel");
        }

    connections allowunconnected:
        nic.upperLayerOut --> appl.lowerLayerIn;
        nic.upperLayerIn <-- appl.lowerLayerOut;
        nic.upperControlOut --> appl.lowerControlIn;
        nic.upperControlIn <-- appl.lowerControlOut;

        veinsradioIn --> nic.radioIn;
}

此外,在 RSUExampleScenario.ned 文件中,我添加了第二个 RSU 并连接两个 RSU:

network RSUExampleScenario extends Scenario
{
    types:
        channel myChannel extends ned.DelayChannel {
            delay = 100ms;
        };

    submodules:
        rsu[2]: RSU {                @display("i=veins/sign/yellowdiamond;is=vs;p=150,140;b=10,10,oval;r=1000");
        }            
    connections allowunconnected:
        rsu[0].gate++ <--> myChannel <--> rsu[1].gate++;
}

在 TraciDemoRSU11p.cc 文件中,我尝试发送这样的消息:

int nb_gate = gateSize("gate");
int out_ = intuniform(0,nb_gate-1);    
cMessage *msg = dynamic_cast<cMessage*>(hmsg);
cMessage *copy = (cMessage *)msg->dup();
send(copy, "gate$o", out_);

执行此代码时,出现以下错误:没有这样的门或门向量:'gate' -- in module (TraCIDemoRSU11p) RSUExampleScenario.rsu[1].appl (id=16), at t=26.019453568907s, event # 452

我该怎么处理?

4

0 回答 0