API Documentation v0.0.1
Loading...
Searching...
No Matches
DcsRunningChecker.h
Go to the documentation of this file.
1#ifndef DCS_RUNNING_CHECKER_H
2#define DCS_RUNNING_CHECKER_H
3
11#include <DcsBios.h>
12
13
14// DCS connection monitoring variables
15static int currDcsHeartbeat = 0;
16static int prevDcsHeartbeat = 0;
17static unsigned long dcsLastUpdateTime = 0;
18static const unsigned long DCS_TIMEOUT_MS = 10000;
19
20
30 if (currDcsHeartbeat != prevDcsHeartbeat) {
31 dcsLastUpdateTime = millis();
32 prevDcsHeartbeat = currDcsHeartbeat;
33 return true;
34 }
35
36 // Check if we've exceeded the timeout period
37 if (millis() - dcsLastUpdateTime >= DCS_TIMEOUT_MS) {
38 // No communication from DCS for over 1 second
39 return false;
40 }
41
42 // Within timeout window - assume DCS is still running
43 return true;
44}
45
46// DCS-BIOS callback for update counter changes
47void onDcsUpdateCounterChange(unsigned int newValue) {
48 currDcsHeartbeat = newValue;
49 }
50DcsBios::IntegerBuffer dcsUpdateCounterBuffer(0xfffe, 0x00ff, 0, onDcsUpdateCounterChange);
51
52#endif // DCS_RUNNING_CHECKER_H
bool checkDcsRunning()
Check if DCS World is currently running and sending data.