summaryrefslogtreecommitdiff
path: root/battery.cpp
blob: e0b7c26debb90d12b2664c8dcb9f0a074a8be426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "battery.h"

Battery::Battery() :
    activeBattery(batteries[LiionPhosphate]),
    systemVoltage(0),
    peakPower(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::calculate()
{
    emit calculation();
}

int Battery::seriesCells(void)
{
    return ceil(systemVoltage/activeBattery.nominalVoltage);
}
int Battery::parallelCells(void)
{
    //return ceil(peakPower);
}

float Battery::minimumPackVoltage(void)
{
    return seriesCells()*activeBattery.minimumVoltage;
}

float Battery::maximumPackVoltage(void)
{
    return seriesCells()*activeBattery.maximumVoltage;
}

double Battery::peakCurrent()
{
    return peakPower/minimumPackVoltage();
}