-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatusWindow.cpp
More file actions
157 lines (119 loc) · 4.91 KB
/
StatusWindow.cpp
File metadata and controls
157 lines (119 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <stdio.h>
#include <string>
#include <ctime>
#define XPLM200
#include "XPLMPlugin.h"
#include "XPLMDataAccess.h"
#include "XPLMDisplay.h"
#include "XPLMGraphics.h"
#include "XPLMMenus.h"
#include "XPWidgets.h"
#include "XPStandardWidgets.h"
#include "XPLMUtilities.h"
#include "XPLMProcessing.h"
#include "XPLMCamera.h"
#include "XPUIGraphics.h"
#include "XPWidgetUtils.h"
//#include "configDescriptions.h"
#include "serialclass.h"
#include "Config.h"
#include "CWSerial.h"
#include "DataHandler.h"
#include "StatusWindow.h"
extern DataHandler *CWDataHandler;
XPLMWindowID statusWindow = NULL;
//extern configDescriptions descriptions;
extern long int packetsSent;
extern long int packetsReceived;
extern long cycleCount;
extern float elapsedTime;
extern int refreshRate;
void statusWindowCreate()
{
statusWindow = XPLMCreateWindow(
50, 600, 800, 200, /* Area of the window. */
1, /* Start visible. */
statusDrawWindowCallback, /* Callbacks */
statusHandleKeyCallback,
statusHandleMouseClickCallback,
NULL); /* Refcon - not used. */
}
/**************************************************************************************/
/* MyDrawWindowCallback -- Called by xplane while window is active */
/**************************************************************************************/
void statusDrawWindowCallback(
XPLMWindowID inWindowID,
void* inRefcon)
{
int left, top, right, bottom;
float color[] = { 1.0, 1.0, 1.0 }; /* RGB White */
char tstring[800];
/* First we get the location of the window passed in to us. */
XPLMGetWindowGeometry(inWindowID, &left, &top, &right, &bottom);
/* We now use an XPLMGraphics routine to draw a translucent dark
* rectangle that is our window's shape. */
XPLMDrawTranslucentDarkBox(left, top, right, bottom);
/* Finally we draw the text into the window, also using XPLMGraphics
* routines. The NULL indicates no word wrapping. */
XPLMDrawString(color, left + 5, top - 20, "Curiosity Workshop CWSerialNMEA Plugin. Updates and Examples: www.patreon.com/curiosityworkshop", NULL, xplmFont_Basic);
//XPLMDrawString(color, left + 5, top - 20, "Curiosity Workshop AgPilotX Connection Plugin. Updates and Examples: www.patreon.com/curiosityworkshop", NULL, xplmFont_Basic);
sprintf(tstring, "Distribution Build: %u. Click this window when complete", CWSERIAL_VERSION);
XPLMDrawString(color, left + 5, top - 35, tstring, NULL, xplmFont_Basic);
sprintf(tstring, "Requested Com Port: com%i, Baud Rate: %i. tx: %i, rx: %i",
CWDataHandler->getComPort(), CWDataHandler->getBaudRate(), CWDataHandler->getPacketsSent(), CWDataHandler->getPacketsReceived());
XPLMDrawString(color, left + 5, top - 60, tstring, NULL, xplmFont_Basic);
sprintf(tstring, "Requested Refresh Rate in ms: %i", refreshRate);
XPLMDrawString(color, left + 5, top - 75, tstring, NULL, xplmFont_Basic);
sprintf(tstring, "Elapsed time since start: %i, cycles: %i, average time between cycles: %3.2f", (int)elapsedTime, cycleCount, elapsedTime / cycleCount);
XPLMDrawString(color, left + 5, top - 90, tstring, NULL, xplmFont_Basic);
sprintf(tstring, "Last Transmission: %s", CWDataHandler->transmitString);
XPLMDrawString(color, left + 5, top - 120, tstring, NULL, xplmFont_Basic);
/* for (int i = 0; i < validPorts; i++)
{
if (myXPLDevices[i])
{
if (strlen(myXPLDevices[i]->lastDebugMessageReceived))
sprintf(tstring, "Last message device %s: %s", myXPLDevices[i]->deviceName, myXPLDevices[i]->lastDebugMessageReceived);
else
{
if (myXPLDevices[i]->deviceType == XPLTYPE_XPLDIRECT)
sprintf(tstring, "Device %i type XPLDirect: %s", i, myXPLDevices[i]->deviceName);
else
sprintf(tstring, "Device %i type XPLWizard: %s (%s)", i, myXPLDevices[i]->deviceName, descriptions.getBoardName(myXPLDevices[i]->boardType));
}
XPLMDrawString(color, left + 5, top - (80 + i * 10), tstring, NULL, xplmFont_Basic);
}
}
*/
}
int statusWindowActive(void)
{
if (!statusWindow) return 0;
else return 1;
}
/**************************************************************************************/
/* MyHandleMouseClickCallback -- Called by xplane while status window is active */
/**************************************************************************************/
int statusHandleMouseClickCallback(
XPLMWindowID inWindowID,
int x,
int y,
XPLMMouseStatus inMouse,
void* inRefcon)
{
XPLMDestroyWindow(statusWindow);
statusWindow = NULL;
return 1;
}
/**************************************************************************************/
/* MyHandleKeyCallback -- Called by xplane while status window is active */
/**************************************************************************************/
void statusHandleKeyCallback(
XPLMWindowID inWindowID,
char inKey,
XPLMKeyFlags inFlags,
char inVirtualKey,
void* inRefcon,
int losingFocus)
{
}