Avionics
Dropship Simulator
Component.cpp
Go to the documentation of this file.
1 #include "Component.h"
2 
3 namespace Systems
4 {
6  {
7  logger = prmLogger;
8  }
9 
11  void Component::FrameMove(double fTime)
12  {
13  // process messages (state change requests)
14  // determine failures here?
15  // push sensor data to bus?
16 
17  float newCapacityPressureEtc = EvaluateDependency(system);
18  if (newCapacityPressureEtc != capacityPressureEtc)
19  {
20  capacityPressureEtc = newCapacityPressureEtc;
21  currentState = newCapacityPressureEtc;
22 
23  char msg[99];
24  if (name.empty())
25  sprintf_s(msg, 99, "Generic->FrameMove->{%s} updated capacityPressureEtc to %f", description.c_str(), capacityPressureEtc);
26  else
27  sprintf_s(msg, 99, "Generic->FrameMove->%s updated capacityPressureEtc to %f", name.c_str(), capacityPressureEtc);
28  logger->Log(msg);
29  }
30 
31  currentLoad = 0;
33  }
34 
36  {
37  for (UINT i = 0; i < dependencies.size(); i++)
38  {
39  Dependency* dependency = &dependencies.at(i);
40  if (dependency->system == system)
41  {
42  // check if current loop is default loop?
43  //
44  // see if current loop failed and autotransfer is on
45  if (dependency->connectors.at(dependency->currentLoop)->capacityPressureEtc > 0.0f)
46  return dependency->connectors.at(dependency->currentLoop)->capacityPressureEtc;
47  }
48  }
49  return 0.0f;
50  }
51 
53  {
54  for (UINT i = 0; i < dependencies.size(); i++)
55  {
56  if (dependencies.at(i).system == system) // same system only
57  {
58  Dependency* dependency = &dependencies.at(i);
59  Connector* connector = dependency->connectors.at(dependency->currentLoop);
60  /*float newLoad = propogatedLoad + currentLoad;
61  if (newLoad != connector->propogatedLoad)
62  {
63  char msg[199];
64  sprintf_s(msg, 199, "Propogating load from %s %s to dependency %s: %f (was %f)", name.c_str(), guidStr.c_str(), connector->guidStr.c_str(), newLoad, connector->propogatedLoad);
65  logger->Log(msg);
66  }*/
68  break;
69  }
70  }
71  }
72 }
float propogatedLoad
propogated demand
Definition: BaseComponent.h:26
std::vector< Connector * > connectors
Definition: Dependency.h:12
Definition: Logger.h:5
virtual void FrameMove(double fTime)
this is a generic unimplemented component framemove, eventually make a pure virtual function...
Definition: Component.cpp:11
These have to be in this order.
Definition: BaseComponent.h:12
std::string name
Definition: Component.h:21
std::string description
Definition: Component.h:43
float capacityPressureEtc
propogated supply
Definition: BaseComponent.h:24
void PropogateLoad(System system)
Definition: Component.cpp:52
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
Definition: Logger.cpp:16
std::vector< Dependency > dependencies
Definition: Component.h:22
float EvaluateDependency(System system)
Definition: Component.cpp:35
Logger * logger
Definition: Component.h:15