Omnet ++ Error in Module (Node) No gate Index specified when access vector gate ‘out';
来源:互联网 发布:java方法覆盖输出结果 编辑:程序博客网 时间:2024/06/06 18:54
Error in Module (Node) No gate Index specified when access vector gate ‘out';
如图:
原因是我把gate 的index和id搞混淆了。
我这里的情况是,一个基站和nodeamount个节点,在ned语言中,指定了基站有多个输入门和多个输出门,input in[]; output out[];
每个Node指定了一个输出门和多个输入门,如下: input in[]; output out;(在初始化函数里面设置好门向量的大小就好,记住要比nodeamount数字大几个,不然有时候会报错)。
但是并没有给他们之间建立连接,而是在代码中随时指定连接。
基站的类中,在out门与in门建立连接后,使用send函数,需要指定输出门的索引,不能只是简单的用send(msg,"out")就行,而是send(msg,"out",outgate->getIndex())
我这里,在获取向量门中某个具体的门的时候,是通过ID获取的,在发送消息的时候,是通过索引获取的。
而造成这个错误原因,在于发送消息时候没有使用指定out门的索引。
参考api;
const cGate* cModule::gate(int id ) const [inline];
贴下我的正确代码:
for(int i = CHANNELAMOUNT;i < NODEAMOUNT;i++){ cGate* outgate = gate("out",i); //这里获取的是id个门 Node* node = Node::nodev[i]; if(node->channelNum == -1 ) continue; cGate* ingate = node->gate("in",0); if((outgate) ->isConnected()) outgate->disconnect(); outgate->connectTo(ingate); //基站的第i个out门与节点的in门相连接 cMessage* msg = new cMessage("data"); msg->setKind(Test_Msg); send(msg->dup(),"out",outgate->getIndex());//消息发送是按照索引发送的 cout<<"基站成功给节点发送消息,节点编号"<<i<<endl; }
如有侵权,请留言,我把这几个图片删除。
另外在修改尝试修改这段代码的时候,陆陆续续出了一些其他问题。
这个是在Node类里面尝试使用sink给各个节点发送消息。
记录下来,希望对大家有所帮助。
阅读全文
0 0
- Omnet ++ Error in Module (Node) No gate Index specified when access vector gate ‘out';
- Gate
- Life In Bill Gate's Eyes
- A20 Gate
- Bill Gate
- A20 Gate
- SYN-GATE
- Gate Count
- Golden Gate
- A20 Gate
- A20 gate
- gate算法
- Gate架构
- ERROR in Cannot find module 'node-sass'
- ERROR in Cannot find module 'node-sass'
- 不少Gate或Node运算子 的反向传播代码
- vcs option +udpsched in gate level simulation without delay
- ERROR: No query specified
- ICPC新疆赛区-Banana
- 数据结构队的使用
- 1024. 科学计数法 (20)
- 线程池原理(七):线程池的使用
- web前端笔试准备1
- Omnet ++ Error in Module (Node) No gate Index specified when access vector gate ‘out';
- 转载—Java中try catch finally语句中含有return语句的执行情况(总结版)
- 【硅谷问道】对于 iOS 开发,人工智能意味着什么?
- 对给定正整数数列A进行重新排序,使得数列A满足所有的A[i]*A[i+1]都是4的倍数。
- 十连测 D2T2 market(二分+背包)
- HDU 2955 Robberies
- Leetcode493——Reverse Pairs
- 从牛顿法到L-BFGS的算法演变
- 打印出所有的"水仙花数"