Reputation: 37
I have two submodules in compound module. I try to connect them using gate, but it creates this error:
Error in module(cmodule) wnetwork.host0 during network setup. Gate 'wnetwork.host[0].gate$i[0]' is not connected to a submodule(or internally to another gate of the same module)
My compound module code is
wirelessnode.ned:
package core;
import org.mixim.modules.power.battery.BatteryStats;
import org.mixim.modules.power.battery.SimpleBattery;
module wirelessnode
{
parameters:
volatile double Energy @unit(mW) = default(10.0mW);
double Tx_energy @unit(mW) = default(0.8mW);
double Tx_interval @unit(s) = default(0.5s);
@display("bgb=210,450,white;i=device/palm;i2=status/battery;b=40,40,rect");
submodules:
batteryStats: BatteryStats {
@display("p=110,221;i=block/table,#FF8040");
}
battery: SimpleBattery {
@display("p=101,90;i=block/plug,#FF8000");
}
}
wirelessnodehost.ned:
package core;
module wirelessnodehost extends wirelessnode
{
gates:
inout gate[];
}
wnetwork.ned:
package core;
import core.wirelessnodehost;
network wnetwork
{
parameters:
int numDevices=default(3);
submodules:
host[numDevices]: wirelessnodehost;
connections:
for i = 0..numDevices-2 {
host[i].gate++ <--> host[i+1].gate++;
}
}
How to solve this error?
Upvotes: 0
Views: 1525
Reputation: 6681
If you check the error message, it says: wnetwork.host[0].gate$i[0]
is not connected to a submodule (or internally to another gate of the same module). (see emphasis), so the problem is NOT that connecting the two module is wrong somehow, but instead the internals of the wirelessnodehost
are incorrect.
Specifically, you are defining the wirelessnodehost
as a compound module (a module built up from other modules by connecting them together, while you do not specify any submodules in it). I assume that you have some C++ code for the wirelessnodehost
. In this case you must define it as simple wirelessnodehost
. Only simple modules have a corresponding code and they are allowed to process the incoming messages using their code. On the other hand compound modules should always pass the incoming message to a submodule for processing, that's why the runtime complaining. You have not connected the gate internally so the runtime does not know where to pass the incoming message.
As a side note, the fact that you extend wirelessnode
module (which itself should have a corresponding C++ code and should be defined as 'simple') is rather suspicious. If the code that handles the behavior of the node is implemented in the wirelessnode
class, then it does not know anything about the gate that is defined in the wirelessnodehost
. I would suggest to take a deeper look at the part of the OMNeT++ manual which describes the differences between simple and compound modules.
Upvotes: 1