00001
00002
00003
00004
00005
00006
00007
00008 #include "BatteryAccess.h"
00009
00010 BatteryAccess::BatteryAccess():
00011 BaseModule(),
00012 battery(NULL)
00013 {}
00014
00015 void BatteryAccess::registerWithBattery(const std::string& name, int numAccounts) {
00016 battery = FindModule<BaseBattery*>::findSubModule(findHost());
00017
00018 if(!battery) {
00019 opp_warning("No battery module defined!");
00020 } else {
00021 deviceID = battery->registerDevice(name, numAccounts);
00022 }
00023 }
00024
00025 void BatteryAccess::draw(DrawAmount& amount, int account) {
00026 if(!battery)
00027 return;
00028
00029 battery->draw(deviceID, amount, account);
00030 }
00031
00032 void BatteryAccess::drawCurrent(double amount, int account) {
00033 if(!battery)
00034 return;
00035
00036 DrawAmount val(DrawAmount::CURRENT, amount);
00037 battery->draw(deviceID, val, account);
00038 }
00039
00040 void BatteryAccess::drawEnergy(double amount, int account) {
00041 if(!battery)
00042 return;
00043
00044 DrawAmount val(DrawAmount::ENERGY, amount);
00045 battery->draw(deviceID, val, account);
00046 }