Avionics
Dropship Simulator
Battery.cpp
Go to the documentation of this file.
1
#include "../../Component.h"
2
3
namespace
Systems
4
{
5
void
Battery::FrameMove
(
double
fTime)
6
{
9
10
double
elapsed = (fTime -
lastTimeProcessed
) / 60 / 60;
11
lastTimeProcessed
= fTime;
12
13
// drain battery with incoming propogated load
14
setState
-=
propogatedLoad
*
static_cast<
float
>
(elapsed);
15
propogatedLoad
= 0;
16
if
(
setState
< 0)
17
setState
= 0;
18
19
if
(
setState
> 0)
20
capacityPressureEtc
= 96;
21
else
22
capacityPressureEtc
= 0;
23
24
// recharge battery by putting a load on charger
25
float
recharge =
EvaluateDependency
(
system
);
27
if
(recharge >
pickupPressure
&&
setState
<
maxCapacity
)
28
{
29
// we are drawing a load
30
currentLoad
=
loadDraw
;
// should be 10A
31
setState
+=
loadDraw
*
static_cast<
float
>
(elapsed);
32
if
(
setState
>
maxCapacity
)
33
setState
=
maxCapacity
;
34
}
35
else
36
currentLoad
= 0;
37
PropogateLoad
(
System::Electrical
);
38
42
if
(
currentState
!=
setState
)
43
{
44
if
(
EvaluateDependency
(
System::Data
))
45
{
46
currentState
=
setState
;
// so we can read the AH remaining, but what about voltage, amperage, temperature? are those all attached sensors?
47
fault
=
Fault::None
;
48
}
49
else
50
{
51
fault
=
Fault::NoSignal
;
52
}
53
}
54
}
55
}
Systems::BaseComponent::propogatedLoad
float propogatedLoad
propogated demand
Definition:
BaseComponent.h:26
Systems::Component::pickupPressure
float pickupPressure
Minimum pressure/voltage to activate.
Definition:
Component.h:34
Systems::Component::currentState
float currentState
Definition:
Component.h:52
Systems::Battery::FrameMove
void FrameMove(double fTime) override
this is a generic unimplemented component framemove, eventually make a pure virtual function...
Definition:
Battery.cpp:5
Systems::Component::setState
float setState
Definition:
Component.h:51
Systems::None
Definition:
Enumerations.h:59
Systems
These have to be in this order.
Definition:
BaseComponent.h:12
Systems::BaseComponent::fault
Fault fault
Definition:
BaseComponent.h:33
Systems::Component::currentLoad
float currentLoad
Definition:
Component.h:56
Systems::BaseComponent::capacityPressureEtc
float capacityPressureEtc
propogated supply
Definition:
BaseComponent.h:24
Systems::Component::maxCapacity
float maxCapacity
Definition:
Component.h:42
Systems::Component::PropogateLoad
void PropogateLoad(System system)
Definition:
Component.cpp:52
Systems::BaseComponent::system
System system
Definition:
BaseComponent.h:20
Systems::Data
Definition:
Enumerations.h:15
Systems::Component::loadDraw
float loadDraw
Definition:
Component.h:39
Systems::Component::lastTimeProcessed
double lastTimeProcessed
these don't get stored anywhere
Definition:
Component.h:55
Systems::Component::EvaluateDependency
float EvaluateDependency(System system)
Definition:
Component.cpp:35
Systems::Electrical
Definition:
Enumerations.h:13
Systems::NoSignal
Definition:
Enumerations.h:60
Systems
Electrical
Battery.cpp
Generated on Sat Feb 13 2021 09:30:43 for Avionics by
1.8.14