Skip to content

Commit 9a18b17

Browse files
committed
Refreshing globally
1 parent 4dade2f commit 9a18b17

2 files changed

Lines changed: 30 additions & 24 deletions

File tree

CDMSingle.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ bool defaultRate;
3131
time_t countTime;
3232
time_t countTimeNonCdm;
3333
time_t countFetchServerTime;
34+
time_t countRefreshActions4Time;
3435
time_t countTfcDisconnectionTime;
3536
time_t countEcfmpTime;
3637
time_t countNetworkTobt;
@@ -63,6 +64,7 @@ bool sftpConnection;
6364
bool refresh1;
6465
bool refresh2;
6566
bool refresh3;
67+
bool refresh4;
6668

6769
int deIceTimeL;
6870
int deIceTimeM;
@@ -262,6 +264,7 @@ CDM::CDM(void) :CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_
262264
countTime = std::time(nullptr);
263265
countTimeNonCdm = std::time(nullptr);
264266
countFetchServerTime = std::time(nullptr);
267+
countRefreshActions4Time = std::time(nullptr);
265268
countEcfmpTime = std::time(nullptr);
266269
countNetworkTobt = std::time(nullptr);
267270
countTfcDisconnectionTime = std::time(nullptr);
@@ -413,6 +416,7 @@ CDM::CDM(void) :CPlugIn(EuroScopePlugIn::COMPATIBILITY_CODE, MY_PLUGIN_NAME, MY_
413416
refresh1 = false;
414417
refresh2 = false;
415418
refresh3 = false;
419+
refresh4 = false;
416420

417421
//Initialize with empty callsign
418422
myAtcCallsign = "";
@@ -1648,6 +1652,22 @@ void CDM::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int Ite
16481652
sendMessage("[DEBUG MESSAGE] - REFRESHING FLOW DATA");
16491653
}
16501654
}
1655+
if ((timeNow - countFetchServerTime) > 30 && !refresh3) {
1656+
countFetchServerTime = timeNow;
1657+
std::thread t(&CDM::refreshActions3, this);
1658+
t.detach();
1659+
if (debugMode) {
1660+
sendMessage("[DEBUG MESSAGE] - REFRESHING CDM API DATA 1");
1661+
}
1662+
}
1663+
if ((timeNow - countRefreshActions4Time) > 10 && !refresh4) {
1664+
countRefreshActions4Time = timeNow;
1665+
std::thread t(&CDM::refreshActions4, this);
1666+
t.detach();
1667+
if (debugMode) {
1668+
sendMessage("[DEBUG MESSAGE] - REFRESHING CDM API DATA 2");
1669+
}
1670+
}
16511671

16521672
bool isCDMairport = false;
16531673
for (string a : CDMairports)
@@ -3449,15 +3469,6 @@ void CDM::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int Ite
34493469
}
34503470
}
34513471

3452-
if ((timeNow - countFetchServerTime) > 30 && !refresh3) {
3453-
countFetchServerTime = timeNow;
3454-
std::thread t(&CDM::refreshActions3, this);
3455-
t.detach();
3456-
if (debugMode) {
3457-
sendMessage("[DEBUG MESSAGE] - REFRESHING CDM API DATA");
3458-
}
3459-
}
3460-
34613472
//Check readyToUpdateList;
34623473
if (readyToUpdateList && !refresh1) {
34633474
addLogLine("[AUTO] - Updating slotList with latest update...");
@@ -3497,19 +3508,6 @@ void CDM::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int Ite
34973508
}
34983509
}
34993510
else {
3500-
// Refresh FlowData every 30 seconds
3501-
time_t timeNow = std::time(nullptr);
3502-
if ((timeNow - countFetchServerTime) > 30) {
3503-
countFetchServerTime = timeNow;
3504-
std::thread t1(&CDM::getCdmServerRestricted, this, slotList);
3505-
t1.detach();
3506-
std::thread t2(&CDM::getCdmServerStatus, this);
3507-
t2.detach();
3508-
if (debugMode) {
3509-
sendMessage("[DEBUG MESSAGE] - REFRESHING FLOW DATA");
3510-
}
3511-
}
3512-
35133511
//Remove disconnected planes after 5 min disconnected
35143512
if (countTfcDisconnection != -1) {
35153513
if ((timeNow - countTfcDisconnectionTime) > 300) {
@@ -7797,7 +7795,6 @@ void CDM::refreshActions1() {
77977795
refresh1 = true;
77987796
readyToUpdateList = false;
77997797
saveData();
7800-
getCdmServerStatus();
78017798
//Execute background process in the background
78027799
slotListToUpdate = backgroundProcess_recaulculate();
78037800
//Check rates
@@ -7815,11 +7812,18 @@ void CDM::refreshActions2() {
78157812

78167813
void CDM::refreshActions3() {
78177814
refresh3 = true;
7818-
addLogLine("[AUTO] - REFRESH API");
7815+
addLogLine("[AUTO] - REFRESH API 1");
78197816
getCdmServerRestricted(slotList);
78207817
refresh3 = false;
78217818
}
78227819

7820+
void CDM::refreshActions4() {
7821+
refresh4 = true;
7822+
addLogLine("[AUTO] - REFRESH API 2");
7823+
getCdmServerStatus();
7824+
refresh4 = false;
7825+
}
7826+
78237827
//API requests
78247828

78257829
bool CDM::setMasterAirport(string airport, string position) {

CDMSingle.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ class CDM :
288288

289289
void refreshActions3();
290290

291+
void refreshActions4();
292+
291293
bool setMasterAirport(string airport, string position);
292294

293295
bool removeMasterAirport(string airport, string position);

0 commit comments

Comments
 (0)