Reputation: 311
I need to delete sensor node if its energy level is less than 0.Every sensor nodes has inout gate.Every sensor node is also connected to the LCN.LCN has inout gate. I wrote this code to delete the module.
if(totPower<0){
deleteModule();
callFinish();
}
it works but If another request is came to this lcn to sensing data, Lcn assume this deleted sensor module is still connected to it and throws connection error.How can I solve this problem?By the way I am using just Omnet++, not inet,castalia etc.
<!> Error in module (LCN) Network.lcn[7] (id=254) at event #188, t=1200: send()/sendDelayed(): gate `lcnSN$o[11]' not connected.
Upvotes: 0
Views: 440
Reputation: 7002
First of all, you should change declaration of connection in your network NED
into:
connections allowunconnected:
It allows gate to be left unconnected.
Secondly, callFinish()
should be involve before deleteModule()
.
Moreover, you have to check whether a gate is connected before sending through it. Sample code:
// i - is an index of gate lcnSN you want to send
cGate *outGate = gate("lcnSN$o", i);
if (outGate->isConnected()) {
send(msg, "lcnSN$o", i);
}
The suffix $o
means an output part of the gate.
Upvotes: 1