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)
21  else
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)
34  }
35  else
36  currentLoad = 0;
38 
42  if (currentState != setState)
43  {
45  {
46  currentState = setState; // so we can read the AH remaining, but what about voltage, amperage, temperature? are those all attached sensors?
48  }
49  else
50  {
52  }
53  }
54  }
55 }
float propogatedLoad
propogated demand
Definition: BaseComponent.h:26
float pickupPressure
Minimum pressure/voltage to activate.
Definition: Component.h:34
void FrameMove(double fTime) override
this is a generic unimplemented component framemove, eventually make a pure virtual function...
Definition: Battery.cpp:5
These have to be in this order.
Definition: BaseComponent.h:12
float capacityPressureEtc
propogated supply
Definition: BaseComponent.h:24
void PropogateLoad(System system)
Definition: Component.cpp:52
double lastTimeProcessed
these don&#39;t get stored anywhere
Definition: Component.h:55
float EvaluateDependency(System system)
Definition: Component.cpp:35