Rise
The Vieneo Province
Loading...
Searching...
No Matches
Component.h
Go to the documentation of this file.
1#pragma once
2
3#include "Condition.h"
5
7{
8 Bus* bus = nullptr;
9 Logger* logger = nullptr;
11
12public:
13 std::string profileName = "Component";
14 //std::string guid; // not supporting real sensors
15
16 std::string busval;
17
18 float* ptrValue = nullptr;
19 char* chrValue = nullptr;
20
21 //Systems::Fault* ptrFault = nullptr; // not supporting fault flags
22
23 float bias = 0.0f;
24 float modulate = 1.0f;
25 bool abs = false;
26 std::vector<Condition> conditions;
27
28 Component(Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice);
29 void Update();
30 void Render();
31};
32
33inline Component::Component(Bus* prmBus, Logger* prmLogger, DeviceObject* prmDevice)
34{
35 logger = prmLogger;
36 logger->AddToCallStack("Component::ctor");
37 bus = prmBus;
38 pDevice = prmDevice;
39}
40
41inline void Component::Update()
42{
44 logger->AddToCallStack("Component::Update");
45
46 for (UINT j = 0; j < conditions.size(); j++)
47 {
48 // Draw all the sprites
49 for (UINT k = 0; k < conditions.at(j).sprites.size(); k++)
50 {
51 conditions.at(j).sprites.at(k).Update();
52 }
53 }
54}
55
56inline void Component::Render()
57{
59 logger->AddToCallStack("Component::Render");
60
61 for (UINT j = 0; j < conditions.size(); j++)
62 {
63 if (!ptrValue || conditions.at(j).MeetsCondition(*ptrValue))
64 {
65 // Draw all the sprites
66 for (UINT k = 0; k < conditions.at(j).sprites.size(); k++)
67 {
68 conditions.at(j).sprites.at(k).Draw();
69 }
70
71 // Draw all the text
72 for (UINT k = 0; k < conditions.at(j).text.size(); k++)
73 {
74 if (conditions.at(j).text.at(k).hasVar)
75 {
76 WCHAR str[64];
77 if (ptrValue)
78 {
79 if (!abs)
80 swprintf_s(str, 64, conditions.at(j).text.at(k).formattedText, *ptrValue * modulate + bias);
81 else
82 swprintf_s(str, 64, conditions.at(j).text.at(k).formattedText, fabsf(*ptrValue * modulate + bias));
83 conditions.at(j).text.at(k).Draw(str);
84 }
85 else if (chrValue)
86 {
87 swprintf_s(str, 64, conditions.at(j).text.at(k).formattedText, chrValue);
88 conditions.at(j).text.at(k).Draw(str);
89 }
90 else
91 {
92 conditions.at(j).text.at(k).Draw(conditions.at(j).text.at(k).formattedText);
93 }
94 }
95 else
96 {
97 conditions.at(j).text.at(k).Draw(conditions.at(j).text.at(k).formattedText);
98 }
99 }
100 break;
101 }
102 }
103}
Definition Bus.h:20
DeviceObject * pDevice
Definition Component.h:10
void Render()
Definition Component.h:56
std::string busval
Definition Component.h:16
std::string profileName
Definition Component.h:13
char * chrValue
Definition Component.h:19
void Update()
Definition Component.h:41
float bias
Definition Component.h:23
float * ptrValue
Definition Component.h:18
Logger * logger
Definition Component.h:9
float modulate
Definition Component.h:24
bool abs
Definition Component.h:25
Component(Bus *prmBus, Logger *prmLogger, DeviceObject *prmDevice)
Definition Component.h:33
Bus * bus
Definition Component.h:8
std::vector< Condition > conditions
Definition Component.h:26
void AddToCallStack(const char *msg)
Definition Logger.cpp:355