00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef BATTERYSTATE_H
00015 #define BATTERYSTATE_H
00016
00017 #include <omnetpp.h>
00018 #include "BaseUtility.h"
00019 #include <sstream>
00020
00031 class BatteryState : public BBItem
00032 {
00033 BBITEM_METAINFO(BBItem);
00034
00035 protected:
00037 double nominal;
00039 double absolute;
00040
00041 public:
00042
00047 BatteryState(double n=-1) :
00048 BBItem(), nominal(n)
00049 {};
00050
00052 double getRel() const {
00053 return absolute/nominal;
00054 }
00055
00057 double getAbs() const {
00058 return absolute;
00059 }
00060
00062 void set(double s) {
00063 absolute = s;
00064 }
00065
00067 std::string info() const {
00068 std::ostringstream ost;
00069 ost << " battery at "<< (absolute/nominal) * 100 <<"%";
00070 return ost.str();
00071 }
00072 };
00073
00074 #endif