00001 /* -*- mode:c++ -*- ******************************************************** 00002 * file: SingleChannelRadio.h 00003 * 00004 * author: Andreas Koepke 00005 * 00006 * copyright: (C) 2005 Telecommunication Networks Group (TKN) at 00007 * Technische Universitaet Berlin, Germany. 00008 * 00009 * This program is free software; you can redistribute it 00010 * and/or modify it under the terms of the GNU General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later 00013 * version. 00014 * For further information see file COPYING 00015 * in the top level directory 00016 *************************************************************************** 00017 * part of: framework implementation developed by tkn 00018 ***************************************************************************/ 00019 00020 #ifndef SINGLECHANNELRADIO_H 00021 #define SINGLECHANNELRADIO_H 00022 00023 #include <omnetpp.h> 00024 #include <BasicModule.h> 00025 #include <ModuleAccess.h> 00026 #include <ActiveChannel.h> 00027 #include "RadioState.h" 00028 #include "Bitrate.h" 00029 00036 class SingleChannelRadio : public BasicModule 00037 { 00038 Module_Class_Members(SingleChannelRadio,BasicModule,0); 00039 00040 protected: 00042 RadioState state; 00044 int stateCat; 00045 00047 ActiveChannel aChannel; 00049 int aChannelCat; 00050 00052 Bitrate bitrate; 00054 int bitrateCat; 00055 00060 simtime_t swSleep; 00061 simtime_t swSend; 00062 simtime_t swRecv; 00063 00064 cMessage *timer; 00068 bool handlingTimer; 00069 00071 int nicModuleId; 00072 00073 protected: 00077 bool switchTo(RadioState::States, simtime_t delta); 00078 00079 public: 00081 virtual void initialize(int); 00082 virtual void finish(); 00083 00087 virtual void handleMessage( cMessage* ); 00088 00093 bool switchToSleep(); 00094 bool switchToSend(); 00095 bool switchToRecv(); 00096 00098 bool setActiveChannel(int c); 00099 00101 bool setBitrate(double b); 00102 }; 00103 00104 class SingleChannelRadioAccess : public ModuleAccess<SingleChannelRadio> 00105 { 00106 public: 00107 SingleChannelRadioAccess() : ModuleAccess<SingleChannelRadio>("radio") {} 00108 }; 00109 00110 #endif