简体   繁体   English

从节点向其邻居发送消息

[英]Sending a message from a node to its neighbour

I am trying to create a grid network and send messages.我正在尝试创建一个网格网络并发送消息。 My Node is as follows:我的节点如下:

simple Node
{
    parameters:
        @display("i=misc/node");
        gates:
        inout up;
        inout left;
        inout down;
        inout right;
}

And i am sending a msg as follows:我正在发送如下消息:

if(this->gate("right$o")->isConnected())
        {
            send(msg,"right$o",k);
        }

It doesn't give any build errors but gives an error in simulation.它不会给出任何构建错误,但会在模拟中给出错误。 What am i doing wrong?我究竟做错了什么? The error is as below:错误如下:

send()/sendDelayed(): Scalar gate 'right$o' referenced with index -- in module (Node) GridNetwork.sensor[0] (id=2), at t=0s, event #1

Your example Node has a inout right gate, which is a scalar inout gate rather than a vector.您的示例Node有一个输入inout right门,它是一个标inout输入输出门,而不是一个向量。 This means that there's only one, and it has two gates: right$i and right$o , as you're trying to use in your example.这意味着只有一个,它有两个门: right$iright$o ,正如您在示例中尝试使用的那样。

You must thus replace inout right with inout right[] , as well as create connections from it to another gate.因此,您必须将inout right替换为inout right[] ,并创建从它到另一个门的连接。 See the OMNeT++ documentation on gates .请参阅有关 gates 的 OMNeT++ 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM