|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // This program is free software: you can redistribute it and/or modify 00003 // it under the terms of the GNU Lesser General Public License as published by 00004 // the Free Software Foundation, either version 3 of the License, or 00005 // (at your option) any later version. 00006 // 00007 // This program is distributed in the hope that it will be useful, 00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 // GNU Lesser General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU Lesser General Public License 00013 // along with this program. If not, see http://www.gnu.org/licenses/. 00014 // 00015 00016 #include "linkBreaker.h" 00017 00018 Define_Module(LinkBreaker); 00019 00020 void LinkBreaker::initialize() { 00021 breakEnabled = false; 00022 WATCH_RW(breakEnabled); 00023 00024 } 00025 00026 void LinkBreaker::handleMessage(cMessage *msg) { 00027 00028 if (breakEnabled) { 00029 getDisplayString().parse("i=block/control,red;is=vs"); 00030 delete msg; 00031 return; 00032 } else { 00033 getDisplayString().parse("i=block/control;is=vs"); 00034 } 00035 00036 if (strcmp(msg->getArrivalGate()->getBaseName(), "A") == 0) { 00037 send(msg, "B$o"); 00038 } else { 00039 send(msg, "A$o"); 00040 } 00041 }