1 #include "../Virtualization.h" 10 logger->
Log(
"Virtualization::ctor LoadFile...");
13 logger->
Log(
"Virtualization::ctor Initialize...");
88 sprintf_s(msg, 99,
"Could not find connector %i dependency!", i);
102 sprintf_s(msg, 99,
"Could not find component %i attachment!", i);
106 for (UINT j = 0; j < component->
dependencies.size(); j++)
111 for (UINT k = 0; k < dependency->
loops.size(); k++)
114 if (connector ==
nullptr)
117 sprintf_s(msg, 99,
"Could not find component %i dependency %i loop %i connector!", i, j, k);
126 sprintf_s(msg, 99,
"All the loops in component %i dependency %i do not match system %i!", i, j, static_cast<int>(system));
132 system = connector->
system;
140 sprintf_s(msg, 99,
"None of the loops in component %i dependency %i have a system type?", i, j);
144 dependency->
system = system;
151 FILE* asmstream =
nullptr;
154 if (fopen_s(&asmstream,
"Dropship.cmp",
"rt") != 0)
156 logger->
Log(
"Virtualization::LoadFile Could not load component file!", Logger::Level::Error, errno);
160 fscanf_s(asmstream,
"%f ,\n", &
filever2);
163 fscanf_s(asmstream,
"%d ,\n", &connectorCount);
164 for (
int i = 0; i < connectorCount; i++)
169 fscanf_s(asmstream,
"%s ,", guidChar, 99);
173 int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
174 int err = sscanf_s(guidChar,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
175 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
178 connector.
guid.Data1 = p0;
179 connector.
guid.Data2 =
static_cast<unsigned short>(p1);
180 connector.
guid.Data3 =
static_cast<unsigned short>(p2);
181 connector.
guid.Data4[0] =
static_cast<unsigned char>(p3);
182 connector.
guid.Data4[1] =
static_cast<unsigned char>(p4);
183 connector.
guid.Data4[2] =
static_cast<unsigned char>(p5);
184 connector.
guid.Data4[3] =
static_cast<unsigned char>(p6);
185 connector.
guid.Data4[4] =
static_cast<unsigned char>(p7);
186 connector.
guid.Data4[5] =
static_cast<unsigned char>(p8);
187 connector.
guid.Data4[6] =
static_cast<unsigned char>(p9);
188 connector.
guid.Data4[7] =
static_cast<unsigned char>(p10);
192 logger->
Log(
"Virtualization::LoadFile Invalid GUID for connector", Logger::Level::Error, i);
195 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
196 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
200 connector.
dependency.Data2 =
static_cast<unsigned short>(p1);
201 connector.
dependency.Data3 =
static_cast<unsigned short>(p2);
202 connector.
dependency.Data4[0] =
static_cast<unsigned char>(p3);
203 connector.
dependency.Data4[1] =
static_cast<unsigned char>(p4);
204 connector.
dependency.Data4[2] =
static_cast<unsigned char>(p5);
205 connector.
dependency.Data4[3] =
static_cast<unsigned char>(p6);
206 connector.
dependency.Data4[4] =
static_cast<unsigned char>(p7);
207 connector.
dependency.Data4[5] =
static_cast<unsigned char>(p8);
208 connector.
dependency.Data4[6] =
static_cast<unsigned char>(p9);
209 connector.
dependency.Data4[7] =
static_cast<unsigned char>(p10);
213 logger->
Log(
"Virtualization::LoadFile Invalid GUID for connector dependency", Logger::Level::Error, i);
216 fscanf_s(asmstream,
"%f ,%f ,%f ,%f ,%f ,%f ,%d ,%f ,%f ,%f ,%f ,%d ,\n",
239 fscanf_s(asmstream,
"%d ,\n", &componentCount);
240 for (
int i = 0; i < componentCount; i++)
246 fscanf_s(asmstream,
"%d ,%d ,", &componentType, &system);
250 switch (componentType)
293 component->
system = system;
295 fscanf_s(asmstream,
"%f ,%f ,%f ,%f, %f, %d, %d ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,\n",
314 int bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
315 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
316 component->
make = bob;
318 component->
make.clear();
319 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
320 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
321 component->
model = bob;
323 component->
model.clear();
324 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
325 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
333 fscanf_s(asmstream,
"%s ,", guidChar, 99);
337 int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
339 int err = sscanf_s(guidChar,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
340 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
343 component->
guid.Data1 = p0;
344 component->
guid.Data2 =
static_cast<unsigned short>(p1);
345 component->
guid.Data3 =
static_cast<unsigned short>(p2);
346 component->
guid.Data4[0] =
static_cast<unsigned char>(p3);
347 component->
guid.Data4[1] =
static_cast<unsigned char>(p4);
348 component->
guid.Data4[2] =
static_cast<unsigned char>(p5);
349 component->
guid.Data4[3] =
static_cast<unsigned char>(p6);
350 component->
guid.Data4[4] =
static_cast<unsigned char>(p7);
351 component->
guid.Data4[5] =
static_cast<unsigned char>(p8);
352 component->
guid.Data4[6] =
static_cast<unsigned char>(p9);
353 component->
guid.Data4[7] =
static_cast<unsigned char>(p10);
357 logger->
Log(
"Virtualization::LoadFile Invalid GUID for component", Logger::Level::Error, i);
360 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
361 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
365 component->
attachedTo.Data2 =
static_cast<unsigned short>(p1);
366 component->
attachedTo.Data3 =
static_cast<unsigned short>(p2);
367 component->
attachedTo.Data4[0] =
static_cast<unsigned char>(p3);
368 component->
attachedTo.Data4[1] =
static_cast<unsigned char>(p4);
369 component->
attachedTo.Data4[2] =
static_cast<unsigned char>(p5);
370 component->
attachedTo.Data4[3] =
static_cast<unsigned char>(p6);
371 component->
attachedTo.Data4[4] =
static_cast<unsigned char>(p7);
372 component->
attachedTo.Data4[5] =
static_cast<unsigned char>(p8);
373 component->
attachedTo.Data4[6] =
static_cast<unsigned char>(p9);
374 component->
attachedTo.Data4[7] =
static_cast<unsigned char>(p10);
378 logger->
Log(
"Virtualization::LoadFile Invalid GUID for component attachment", Logger::Level::Error, i);
381 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
383 component->
name = bob;
385 component->
name.clear();
388 fscanf_s(asmstream,
"%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%d ,\n",
409 fscanf_s(asmstream,
"%d ,\n", &dependencyCount);
410 for (
int j = 0; j < dependencyCount; j++)
412 int loopCount, boolFailover;
414 fscanf_s(asmstream,
"%d ,%d ,%d ,%d ,\n",
422 for (
int k = 0; k < loopCount; k++)
426 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
427 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
431 loopGuid.Data2 =
static_cast<unsigned short>(p1);
432 loopGuid.Data3 =
static_cast<unsigned short>(p2);
433 loopGuid.Data4[0] =
static_cast<unsigned char>(p3);
434 loopGuid.Data4[1] =
static_cast<unsigned char>(p4);
435 loopGuid.Data4[2] =
static_cast<unsigned char>(p5);
436 loopGuid.Data4[3] =
static_cast<unsigned char>(p6);
437 loopGuid.Data4[4] =
static_cast<unsigned char>(p7);
438 loopGuid.Data4[5] =
static_cast<unsigned char>(p8);
439 loopGuid.Data4[6] =
static_cast<unsigned char>(p9);
440 loopGuid.Data4[7] =
static_cast<unsigned char>(p10);
445 sprintf_s(str, 499,
"Invalid GUID for component %i dependency %i loop: %i", i, j, k);
449 dependency.
loops.push_back(loopGuid);
463 logger->
Log(
"Virtualization::SaveFile File was never loaded, returning!", Logger::Level::Error);
467 FILE* asmstream =
nullptr;
470 if (fopen_s(&asmstream,
"Dropship.cmp",
"rt") != 0)
472 logger->
Log(
"Virtualization::SaveFile Could not load component file!", Logger::Level::Error, errno);
476 fscanf_s(asmstream,
"%f ,\n", &
filever2);
479 fscanf_s(asmstream,
"%d ,\n", &connectorCount);
480 for (
int i = 0; i < connectorCount; i++)
484 int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
486 int err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
487 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
490 connector.
guid.Data1 = p0;
491 connector.
guid.Data2 =
static_cast<unsigned short>(p1);
492 connector.
guid.Data3 =
static_cast<unsigned short>(p2);
493 connector.
guid.Data4[0] =
static_cast<unsigned char>(p3);
494 connector.
guid.Data4[1] =
static_cast<unsigned char>(p4);
495 connector.
guid.Data4[2] =
static_cast<unsigned char>(p5);
496 connector.
guid.Data4[3] =
static_cast<unsigned char>(p6);
497 connector.
guid.Data4[4] =
static_cast<unsigned char>(p7);
498 connector.
guid.Data4[5] =
static_cast<unsigned char>(p8);
499 connector.
guid.Data4[6] =
static_cast<unsigned char>(p9);
500 connector.
guid.Data4[7] =
static_cast<unsigned char>(p10);
504 logger->
Log(
"Virtualization::SaveFile Invalid GUID for connector", Logger::Level::Error, i);
507 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
508 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
512 connector.
dependency.Data2 =
static_cast<unsigned short>(p1);
513 connector.
dependency.Data3 =
static_cast<unsigned short>(p2);
514 connector.
dependency.Data4[0] =
static_cast<unsigned char>(p3);
515 connector.
dependency.Data4[1] =
static_cast<unsigned char>(p4);
516 connector.
dependency.Data4[2] =
static_cast<unsigned char>(p5);
517 connector.
dependency.Data4[3] =
static_cast<unsigned char>(p6);
518 connector.
dependency.Data4[4] =
static_cast<unsigned char>(p7);
519 connector.
dependency.Data4[5] =
static_cast<unsigned char>(p8);
520 connector.
dependency.Data4[6] =
static_cast<unsigned char>(p9);
521 connector.
dependency.Data4[7] =
static_cast<unsigned char>(p10);
525 logger->
Log(
"Invalid GUID for connector dependency", Logger::Level::Error, i);
528 fscanf_s(asmstream,
"%f ,%f ,%f ,%f ,%f ,%f ,%d ,%f ,%f ,%f ,%f ,%d ,\n",
551 fscanf_s(asmstream,
"%d ,\n", &componentCount);
552 for (
int i = 0; i < componentCount; i++)
558 fscanf_s(asmstream,
"%d ,%d ,", &componentType, &system);
562 switch (componentType)
581 component->
system = system;
583 fscanf_s(asmstream,
"%f ,%f ,%f ,%f, %f, %d, %d ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,\n",
602 int bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
603 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
604 component->
make = bob;
606 component->
make.clear();
607 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
608 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
609 component->
model = bob;
611 component->
model.clear();
612 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
613 if (bytes > 0 && _strcmpi(bob,
"unused") != 0)
621 fscanf_s(asmstream,
"%s ,", guidChar, 99);
625 int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10;
627 int err = sscanf_s(guidChar,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
628 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
631 component->
guid.Data1 = p0;
632 component->
guid.Data2 =
static_cast<unsigned short>(p1);
633 component->
guid.Data3 =
static_cast<unsigned short>(p2);
634 component->
guid.Data4[0] =
static_cast<unsigned char>(p3);
635 component->
guid.Data4[1] =
static_cast<unsigned char>(p4);
636 component->
guid.Data4[2] =
static_cast<unsigned char>(p5);
637 component->
guid.Data4[3] =
static_cast<unsigned char>(p6);
638 component->
guid.Data4[4] =
static_cast<unsigned char>(p7);
639 component->
guid.Data4[5] =
static_cast<unsigned char>(p8);
640 component->
guid.Data4[6] =
static_cast<unsigned char>(p9);
641 component->
guid.Data4[7] =
static_cast<unsigned char>(p10);
645 logger->
Log(
"Invalid GUID for component", Logger::Level::Error, i);
648 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
649 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
653 component->
attachedTo.Data2 =
static_cast<unsigned short>(p1);
654 component->
attachedTo.Data3 =
static_cast<unsigned short>(p2);
655 component->
attachedTo.Data4[0] =
static_cast<unsigned char>(p3);
656 component->
attachedTo.Data4[1] =
static_cast<unsigned char>(p4);
657 component->
attachedTo.Data4[2] =
static_cast<unsigned char>(p5);
658 component->
attachedTo.Data4[3] =
static_cast<unsigned char>(p6);
659 component->
attachedTo.Data4[4] =
static_cast<unsigned char>(p7);
660 component->
attachedTo.Data4[5] =
static_cast<unsigned char>(p8);
661 component->
attachedTo.Data4[6] =
static_cast<unsigned char>(p9);
662 component->
attachedTo.Data4[7] =
static_cast<unsigned char>(p10);
666 logger->
Log(
"Invalid GUID for component attachment", Logger::Level::Error, i);
669 bytes = fscanf_s(asmstream,
"%[^\n]\n", bob, 99);
671 component->
name = bob;
673 component->
name.clear();
676 fscanf_s(asmstream,
"%f ,%f ,%f ,%f ,%f ,%f ,%f ,%f ,%lu ,\n",
690 fscanf_s(asmstream,
"%d ,\n", &dependencyCount);
691 for (
int j = 0; j < dependencyCount; j++)
693 int loopCount, boolFailover;
695 fscanf_s(asmstream,
"%d ,%d ,%d ,%d ,\n",
703 for (
int k = 0; k < loopCount; k++)
707 err = fscanf_s(asmstream,
"%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X ,",
708 &p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7, &p8, &p9, &p10);
712 loopGuid.Data2 =
static_cast<unsigned short>(p1);
713 loopGuid.Data3 =
static_cast<unsigned short>(p2);
714 loopGuid.Data4[0] =
static_cast<unsigned char>(p3);
715 loopGuid.Data4[1] =
static_cast<unsigned char>(p4);
716 loopGuid.Data4[2] =
static_cast<unsigned char>(p5);
717 loopGuid.Data4[3] =
static_cast<unsigned char>(p6);
718 loopGuid.Data4[4] =
static_cast<unsigned char>(p7);
719 loopGuid.Data4[5] =
static_cast<unsigned char>(p8);
720 loopGuid.Data4[6] =
static_cast<unsigned char>(p9);
721 loopGuid.Data4[7] =
static_cast<unsigned char>(p10);
726 sprintf_s(str, 499,
"Invalid GUID for component %i dependency %i loop: %i", i, j, k);
730 dependency.
loops.push_back(loopGuid);
float propogatedLoad
propogated demand
float pickupPressure
Minimum pressure/voltage to activate.
Connector * FindConnectorByGuid(GUID guid)
starter is very specific, load differential
float dropoutPressure
Minimum pressure/voltage to keep active.
Igniter is very specific, on or off set, we get the pulses.
std::vector< Connector * > connectors
N1 is very specific, load differential.
These have to be in this order.
float hpPhysicalRemaining
Combustion Chamber is very specific, on or off set, we get the pulses.
Component * attachedToComponent
float temperature
componentInfo
float averageServiceLife
Average service life in hours.
float capacityPressureEtc
propogated supply
float serviceLifeCycleHit
Power-on service life cycle hit.
Switch is a direct-set (no control voltage, command from bus from physical switch) which takes a supp...
float serviceLifeRemaining
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
std::vector< Dependency > dependencies
void FrameMove(double fTime)
BaseComponent * dependsOn
Is a real environment-related simulator sensor.
Component * FindComponentByGuid(GUID guid) const
std::vector< Systems::Component * > components
SYSTEMS SUPPORT.
Uses control voltage control to turn on and off flow.
std::vector< Connector > connectors
N2 is very specific, load differential.
Temperature sensor reads data from setState (or attached component?) and puts it on currentState assu...
std::vector< GUID > loops
real components simply take setState and apply it to currentState, they run their own fault states ...