#include "battery.h" Battery::Battery() : activeBattery(batteries[LiionPhosphate]), systemVoltage(0), peakPower(0), minimumAllowableSOC(0), packDischargeRate(0), packChargeRate(0), packWeight(0), packEnergy(0) { } void Battery::changeBatteryChemistry(int name) { activeBattery= batteries[name]; } void Battery::setSystemVoltage(double voltage) { systemVoltage = voltage; } void Battery::setPeakSystemPower(double power) { peakPower = power; } void Battery::setMinimumSOC(double SOC) { minimumAllowableSOC = SOC; } void Battery::calculate() { emit calculation(); } int Battery::seriesCells(void) { return ceil(systemVoltage/activeBattery.nominalVoltage); } int Battery::parallelCells(void) { //return ceil(peakPower); } float Battery::minimumPackVoltage(void) { float min = seriesCells()*activeBattery.minimumVoltage; return (min) + (maximumPackVoltage()-min)*(minimumAllowableSOC*0.01); } float Battery::maximumPackVoltage(void) { return seriesCells()*activeBattery.maximumVoltage; } double Battery::peakCurrent() { return peakPower/minimumPackVoltage(); }