Avionics
Dropship Simulator
ITTIndicator.cpp
Go to the documentation of this file.
1 #include "Instrument.h"
2 
3 ITTIndicator::ITTIndicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal): Instrument(prmX, prmY, prmXScale, prmYScale)
4 {
5  guid1 = prmGuid1;
6  guid2 = prmGuid2;
7  engineOrdinal = prmOrdinal;
8 }
9 
10 void ITTIndicator::Initialize(Bus* prmBus, Logger* prmLogger, DEVICE_OBJECT* prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector<Font>* prmFonts, bool prmFlip)
11 {
12  Instrument::Initialize(prmBus, prmLogger, prmDevice, prmScreenWidth, prmScreenHeight, prmFonts, prmFlip);
13 
14  ignitorAGetFloatPtr = bus->GetComponentCurrentStatePtr(guid1);
15  //ittFaultPtr = (DWORD*)bus->GetComponentFaultStatePtr(guid2);
16  ittGetFloatPtr = bus->GetComponentCurrentStatePtr(guid2);
17 
18  digital.color = 0xFF00FF00;
19  digital.elementName = "EngineITTDigital";
20  digital.flags |= DT_RIGHT;
21  digital.width = 64;
22  digital.height = 24;
23  digital.x = 33;
24  digital.y = 125;
25  digital.Initialize(logger, bus, pDevice, x, y, prmFonts->at(1).pFont, prmFlip);
26 
27  ignition.elementName = "IgnitionStatus";
28  ignition.flags &= ~DT_SINGLELINE;
29  if (engineOrdinal == 1)
30  ignition.flags |= DT_RIGHT;
31  ignition.height = 24;
32  ignition.width = 56;
33  if (engineOrdinal == 0)
34  ignition.x = 0;
35  else
36  ignition.x = 95;
37  ignition.y = 120;
38  ignition.Initialize(logger, bus, pDevice, x, y, prmFonts->at(0).pFont, prmFlip);
39 
40 // <Text x = "0" y = "0" color = "ff00ff00" width = "64" height = "24" align = "right" font = "1">%.1f< / Text>
41 // <Text x = "0" y = "0" color = "ff00ff00" width = "64" height = "24" align = "right" font = "1">%.1f< / Text>
42 
43  //pixel.width = 58;
44  //pixel.height = 26;
45  //pixel.pathAndFilename = "Textures/Pixel.png";
46  //pixel.Initialize(logger, bus, prmDevice, prmScreenHeight, x, y, prmFlip);
47  //pixel.x = 48;
48  //pixel.y = 77;
49  //pixel.z = 0.8f;
50  //pixel.Update();
51 
52  needle.width = 99;
53  needle.height = 8;
54  needle.pathAndFilename = "Textures/Instruments/needle.png";
55  needle.Initialize(logger, bus, prmDevice, prmScreenHeight, x, y, prmFlip);
56  needle.x = 25;
57  needle.y = 84;
58  needle.z = 0.9f; // the artificial horizon is at 1.0, text is at 0.5, overlay is at 0.6
59 }
60 
61 void ITTIndicator::Render(float fElapsed)
62 {
63  if (*ittGetFloatPtr != -999.0f)
64  itt += (*ittGetFloatPtr - itt)*fElapsed;
65  //itt += 0.01f;
66  needle.rotate = -D3DXToRadian(itt / 1103.0f*270.0f - 45.0f);
67  needle.Update();
68  needle.Draw();
69 
70 
71 
72  WCHAR msg[99];
73  swprintf_s(msg, 99, L"%.0f", itt);
74  digital.Draw(msg);
75 
76  if (*ignitorAGetFloatPtr == 1.0f)
77  {
78  ignition.color = 0xff00ff00;
79  ignition.Draw(L"IGN\nA");
80  }
82  //else if (*fadecFaultPtr & Systems::Fault::Status2) // FAIL
83  //{
84  // ignition.color = 0xff00ffff;
85  // ignition.Draw(L"IGN\nOFF");
86  //}
87 };
virtual void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip)
Definition: Instrument.h:45
D3DXCOLOR color
Definition: Text.h:59
int x
Definition: Text.h:58
int width
Definition: Text.h:60
Definition: Logger.h:5
int engineOrdinal
Definition: Instrument.h:240
int y
Definition: Sprite.h:16
void Update()
Definition: Sprite.h:50
float rotate
Definition: Sprite.h:21
int x
Definition: Sprite.h:16
float z
Definition: Sprite.h:17
int height
Definition: Sprite.h:16
Definition: Bus.h:12
void Draw(WCHAR *str)
Definition: Text.h:80
Bus * bus
Definition: Instrument.h:21
void Draw()
Definition: Sprite.h:64
Abstract base class for instrumentation By definition, instruments don&#39;t do any of the work (they don...
Definition: Instrument.h:15
DEVICE_OBJECT * pDevice
Definition: Instrument.h:24
std::string guid1
Definition: Instrument.h:241
int width
Definition: Sprite.h:16
float * ittGetFloatPtr
Definition: Instrument.h:239
void Render(float fElapsed) override
std::string elementName
Definition: Text.h:63
std::string pathAndFilename
Definition: Sprite.h:18
ITTIndicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal)
Definition: ITTIndicator.cpp:3
std::string guid2
Definition: Instrument.h:242
Logger * logger
Definition: Instrument.h:22
int height
Definition: Text.h:60
Sprite needle
Definition: Instrument.h:231
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int elementX, int elementY, ID3DX10Font *prmFont, bool prmFlip)
Definition: Text.h:66
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
float * ignitorAGetFloatPtr
Definition: Instrument.h:237
int flags
Definition: Text.h:61
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int prmScreenHeight, int prmElementX, int prmElementY, bool prmFlip)
Definition: Sprite.h:26
int y
Definition: Text.h:58