SimpleBattery.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * Energy Framework for Omnet++, version 0.9
00003  *
00004  * Author:  Laura Marie Feeney
00005  *
00006  * Copyright 2009 Swedish Institute of Computer Science.
00007  *
00008  * This software is provided `as is' and without any express or implied
00009  * warranties, including, but not limited to, the implied warranties of
00010  * merchantability and fitness for a particular purpose.
00011  *
00012  ***************************************************************************/
00013 #ifndef BATTERY_H
00014 #define BATTERY_H
00015 
00016 #include <omnetpp.h>
00017 #include "BaseBattery.h"
00018 
00019 #include "BatteryState.h"
00020 #include "HostState.h"
00021 
00022 #include "DeviceEntry.h"
00023 
00039 class SimpleBattery: public BaseBattery {
00040 public:
00041   virtual ~SimpleBattery();
00042   virtual void initialize(int);
00043   virtual void handleMessage(cMessage*);
00044   virtual void handleHostState(const HostState& state);
00045   virtual void finish();
00046 
00056   double getVoltage();
00060   double estimateResidualRelative();
00062   double estimateResidualAbs();
00068   virtual int registerDevice(const std::string& name, int numAccounts);
00069 
00074   virtual void draw(int drainID, DrawAmount& amount, int activity);
00075 
00076 protected:
00077 
00079   int numDevices;
00080 
00084   double capmAh;
00086   double nominalCapmAh;
00088   double voltage;
00092   simtime_t resolution;
00093   cMessage *timeout;
00094 
00097   int batteryCat;
00098   cMessage *publish;
00099   double publishDelta;
00100   simtime_t publishTime;
00101 
00103   BatteryState *batteryState;
00109   int scopeHost;
00110   int hostStateCat;
00111   HostState hostState;
00116   double capacity;
00117   double nominalCapacity;
00118   double residualCapacity;
00119   double lastPublishCapacity;
00120   simtime_t lifetime;
00124   cOutVector residualVec;
00125 
00127   DeviceEntry *devices;
00129   int registeredDevices;
00130 
00132   enum msgType {
00133     AUTO_UPDATE,
00134     PUBLISH,
00135   };
00136 
00137   simtime_t lastUpdateTime;
00138   virtual void deductAndCheck();
00139 };
00140 
00141 #endif