Avionics
Dropship Simulator
N1Indicator.cpp
Go to the documentation of this file.
1 #include "Instrument.h"
2 
3 N1Indicator::N1Indicator(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 N1Indicator::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 
16  n1GetFloatPtr = bus->GetComponentCurrentStatePtr(guid2);
17 
18  digital.color = 0xFF00FF00;
19  digital.elementName = "EngineN1Digital";
20  digital.flags |= DT_RIGHT;
21  digital.width = 64;
22  digital.height = 24;
23  digital.x = 45;
24  digital.y = 136;
25  digital.Initialize(logger, bus, pDevice, x, y, prmFonts->at(1).pFont, prmFlip);
26 
27  status.elementName = "EngineN1Status";
28  status.flags |= DT_CENTER;
29  status.height = 24;
30  status.width = 56;
31  status.x = 50;
32  status.y = 77;
33  status.Initialize(logger, bus, pDevice, x, y, prmFonts->at(1).pFont, prmFlip);
34 
35 // <Text x = "0" y = "0" color = "ff00ff00" width = "64" height = "24" align = "right" font = "1">%.1f< / Text>
36 // <Text x = "0" y = "0" color = "ff00ff00" width = "64" height = "24" align = "right" font = "1">%.1f< / Text>
37 
38  pixel.width = 58;
39  pixel.height = 26;
40  pixel.pathAndFilename = "Textures/Pixel.png";
41  pixel.Initialize(logger, bus, prmDevice, prmScreenHeight, x, y, prmFlip);
42  pixel.x = 48;
43  pixel.y = 77;
44  pixel.z = 0.8f;
45  pixel.Update();
46 
47  needle.width = 128;
48  needle.height = 10;
49  needle.pathAndFilename = "Textures/Instruments/needle.png";
50  needle.Initialize(logger, bus, prmDevice, prmScreenHeight, x, y, prmFlip);
51  needle.x = 11;
52  needle.y = 84;
53  needle.z = 0.9f; // the artificial horizon is at 1.0, text is at 0.5, overlay is at 0.6
54 }
55 
56 void N1Indicator::Render(float fElapsed)
57 {
58  n1 += (*n1GetFloatPtr - n1)*fElapsed;
59  float tempn1 = n1*100.0f;
60  if (tempn1 < 7.0f) tempn1 = 0;
61  //n1 += 0.01f;
62  needle.rotate = -D3DXToRadian(tempn1 / 115.0f*280.0f - 45.0f);
63  needle.Update();
64  needle.Draw();
65 
66 
67 
68  WCHAR msg[99];
69  swprintf_s(msg, 99, L"%4.1f", tempn1);
70  digital.Draw(msg);
71 
73  {
74  pixel.color = 0xffffd610;
75  pixel.Update();
76  pixel.Draw();
77  status.color = 0xff000000;
78  status.Draw(L"FAIL");
79  }
80  else if (*fadecFaultPtr & Systems::Fault::Status3) // OFF
81  {
82  pixel.color = 0xff000000;
83  pixel.Update();
84  pixel.Draw();
85  status.color = 0xff00ffff;
86  status.Draw(L"OFF");
87  }
88 };
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
std::string guid1
Definition: Instrument.h:218
int x
Definition: Text.h:58
int width
Definition: Text.h:60
Systems::Fault * n1FaultPtr
Definition: Instrument.h:215
Definition: Logger.h:5
Systems::Fault * GetComponentFaultStatePtr(std::string guidStr)
Definition: Bus.cpp:141
Text digital
Definition: Instrument.h:210
int y
Definition: Sprite.h:16
N1Indicator(int prmX, int prmY, float prmXScale, float prmYScale, std::string prmGuid1, std::string prmGuid2, int prmOrdinal)
Definition: N1Indicator.cpp:3
Systems::Fault * fadecFaultPtr
Definition: Instrument.h:214
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
std::string guid2
Definition: Instrument.h:219
Definition: Bus.h:12
Sprite pixel
Definition: Instrument.h:209
void Draw(WCHAR *str)
Definition: Text.h:80
float * n1GetFloatPtr
Definition: Instrument.h:216
Bus * bus
Definition: Instrument.h:21
void Draw()
Definition: Sprite.h:64
D3DXCOLOR color
Definition: Sprite.h:20
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
int width
Definition: Sprite.h:16
std::string elementName
Definition: Text.h:63
std::string pathAndFilename
Definition: Sprite.h:18
void Initialize(Bus *prmBus, Logger *prmLogger, DEVICE_OBJECT *prmDevice, int prmScreenWidth, int prmScreenHeight, std::vector< Font > *prmFonts, bool prmFlip) override
Definition: N1Indicator.cpp:10
Logger * logger
Definition: Instrument.h:22
int height
Definition: Text.h:60
Sprite needle
Definition: Instrument.h:207
void Initialize(Logger *prmLogger, Bus *prmBus, DEVICE_OBJECT *prmpDevice, int elementX, int elementY, ID3DX10Font *prmFont, bool prmFlip)
Definition: Text.h:66
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
void Render(float fElapsed) override
Definition: N1Indicator.cpp:56