PhyLayerBattery.h

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 #ifndef PHYLAYERBATTERY_H_
00017 #define PHYLAYERBATTERY_H_
00018 
00019 #include "PhyLayer.h"
00020 #include "Decider80211Battery.h"
00021 #include "HostState.h"
00022 #include "MacToPhyControlInfo.h"
00023 
00053 class PhyLayerBattery : public PhyLayer{
00054 protected:
00056   int numActivities;
00057 
00060   double sleepCurrent, rxCurrent, decodingCurrentDelta, txCurrent;
00065   double setupRxCurrent, setupTxCurrent, rxTxCurrent, txRxCurrent;
00072   enum Activities {
00073     SLEEP_ACCT=0,
00074     RX_ACCT,
00075     TX_ACCT,
00076     SWITCHING_ACCT,
00077     DECIDER_ACCT,
00078   };
00079 
00080 protected:
00092   virtual Decider* getDeciderFromName(std::string name, ParameterMap& params);
00093 
00097   virtual Decider* initializeDecider80211Battery(ParameterMap& params);
00098 
00102   virtual Decider* initializeDecider80211MultiChannel(ParameterMap& params);
00103 
00115   virtual double calcTXCurrentForPacket(MacPkt* pkt, MacToPhyControlInfo* cInfo)
00116   { return -1.0; }
00117 
00119   virtual void setRadioCurrent(int rs);
00120 
00123   virtual void setSwitchingCurrent(int from, int to);
00124 
00133   virtual void handleUpperMessage(cMessage* msg);
00134 
00141   virtual void handleAirFrame(cMessage* msg);
00142 
00149   virtual void handleHostState(const HostState& state);
00150 
00154   virtual void finishRadioSwitching();
00155 
00156 public:
00157   virtual void initialize(int stage);
00158 
00168   virtual void drawCurrent(double amount, int activity);
00169 
00173   virtual simtime_t setRadioState(int rs);
00174 };
00175 
00176 #endif /* PHYLAYERBATTERY_H_ */