|
INET Framework for OMNeT++/OMNEST
|
00001 /*************************************************************************** 00002 * file: WirelessMacBase.cc 00003 * 00004 * derived by Andras Varga using decremental programming from BasicMacLayer.cc, 00005 * which had the following copyright: 00006 * 00007 * author: Daniel Willkomm 00008 * 00009 * copyright: (C) 2004 Telecommunication Networks Group (TKN) at 00010 * Technische Universitaet Berlin, Germany. 00011 * 00012 * This program is free software; you can redistribute it 00013 * and/or modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 2 of the License, or (at your option) any later 00016 * version. 00017 * For further information see file COPYING 00018 * in the top level directory 00019 *************************************************************************** 00020 * part of: framework implementation developed by tkn 00021 **************************************************************************/ 00022 00023 00024 #include "WirelessMacBase.h" 00025 #include "NotificationBoard.h" 00026 00027 00028 void WirelessMacBase::initialize(int stage) 00029 { 00030 if (stage==0) 00031 { 00032 uppergateIn = findGate("uppergateIn"); 00033 uppergateOut = findGate("uppergateOut"); 00034 lowergateIn = findGate("lowergateIn"); 00035 lowergateOut = findGate("lowergateOut"); 00036 00037 // get a pointer to the NotificationBoard module 00038 nb = NotificationBoardAccess().get(); 00039 } 00040 } 00041 00042 00043 void WirelessMacBase::handleMessage(cMessage *msg) 00044 { 00045 if (msg->isSelfMessage()) 00046 handleSelfMsg(msg); 00047 else if (!msg->isPacket()) 00048 handleCommand(msg); 00049 else if (msg->getArrivalGateId()==uppergateIn) 00050 handleUpperMsg(PK(msg)); 00051 else 00052 handleLowerMsg(PK(msg)); 00053 } 00054 00055 bool WirelessMacBase::isUpperMsg(cMessage *msg) 00056 { 00057 return msg->getArrivalGateId()==uppergateIn; 00058 } 00059 00060 bool WirelessMacBase::isLowerMsg(cMessage *msg) 00061 { 00062 return msg->getArrivalGateId()==lowergateIn; 00063 } 00064 00065 void WirelessMacBase::sendDown(cMessage *msg) 00066 { 00067 EV << "sending down " << msg << "\n"; 00068 send(msg, lowergateOut); 00069 } 00070 00071 void WirelessMacBase::sendUp(cMessage *msg) 00072 { 00073 EV << "sending up " << msg << "\n"; 00074 send(msg, uppergateOut); 00075 } 00076