-
Notifications
You must be signed in to change notification settings - Fork 9
/
CDMSingle.hpp
238 lines (169 loc) · 5.4 KB
/
CDMSingle.hpp
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#pragma once
#include "EuroScopePlugIn.h"
#include <sstream>
#include <iostream>
#include <string>
#include "Constant.hpp"
#include <fstream>
#include <vector>
#include <map>
#include <regex>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "json/json.h"
#include "CAD.h"
#include "Rate.h"
#include "Plane.h"
#include "Flow.h"
#define CURL_STATICLIB
#include "curl/curl.h"
#include <wininet.h>
#pragma comment(lib, "Wininet")
#define MY_PLUGIN_NAME "CDM Plugin"
#define MY_PLUGIN_VERSION "2.2.4"
#define MY_PLUGIN_DEVELOPER "Roger Puig"
#define MY_PLUGIN_COPYRIGHT "GPL v3"
#define MY_PLUGIN_VIEW_AVISO "Euroscope CDM"
#define PLUGIN_WELCOME_MESSAGE "Thanks for using the CDM Plugin for Euroscope!"
using namespace std;
using namespace boost;
using namespace rapidjson;
using namespace EuroScopePlugIn;
class CDM :
public EuroScopePlugIn::CPlugIn
{
public:
CDM();
virtual ~CDM();
//Define OnGetTagItem function
virtual void OnGetTagItem(CFlightPlan FlightPlan,
CRadarTarget RadarTarget,
int ItemCode,
int TagData,
char sItemString[16],
int* pColorCode,
COLORREF* pRGB,
double* pFontSize);
bool getRateFromUrl(string url);
bool getRate();
Rate rateForRunway(string airport, string depRwy);
void refreshTimes(CFlightPlan FlightPlan, string callsign, string EOBT, string TSATfinal, string TTOTFinal, string origin, int taxiTime, string remarks, string depRwy, Rate dataRate, bool hasCTOT, int ctotPos, int pos, bool aircraftFind);
void PushToOtherControllers(CFlightPlan fp);
void deleteFlightStrips(string callsign);
string EobtPlusTime(string EOBT, int time);
string getTaxiTime(double lat, double lon, string origin, string depRwy);
string GetActualTime();
string GetDateMonthNow();
CPosition readPosition(string lat, string lon)
{
CPosition p;
if (!p.LoadFromStrings(lon.c_str(), lat.c_str()))
{
p.m_Latitude = stod(lat);
p.m_Longitude = stod(lon);
}
return p;
}
int inPoly(int nvert, double* vertx, double* verty, double testx, double testy);
string formatTime(string timeString);
void checkCtot();
void RemoveDataFromTfc(string callsign);
void disconnectTfcs();
string calculateTime(string timeString, double minsToAdd);
bool checkCtotInRange(Plane plane);
string calculateLessTime(string timeString, double minsToAdd);
string GetTimeNow();
void saveData();
void multithread(void(CDM::* f)());
bool checkIsNumber(string str);
string getCidByCallsign(string callsign);
void getFlowData();
void toggleReaMsg(CFlightPlan fp, bool deleteIfExist);
void addTimeToList(int timeToAdd, string minTSAT);
void addTimeToListForSpecificAirportAndRunway(int timeToAdd, string minTSAT, string airport, string runway);
vector<Plane> recalculateSlotList(vector<Plane> mySlotList);
vector<Plane> cleanUpSlotListVector(vector<Plane> mySlotList);
int GetVersion();
void createJsonVDGS(vector<Plane> slotList, string fileName, string airport);
bool isNumber(string s);
void upload(string fileName, string airport, string type);
vector<string> explode(std::string const& s, char delim);
bool getTaxiZonesFromUrl(string url);
bool getCtotsFromUrl(string url);
int GetdifferenceTime(string hour1, string min1, string hour2, string min2);
template <typename Out>
void split(const string& s, char delim, Out result) {
istringstream iss(s);
string item;
while (getline(iss, item, delim)) {
*result++ = item;
}
}
vector<string> split(const string& s, char delim) {
vector<string> elems;
split(s, delim, back_inserter(elems));
return elems;
}
string destArrayContains(const Value& a, string s) {
for (SizeType i = 0; i < a.Size(); i++) {
string test = a[i].GetString();
SizeType x = static_cast<rapidjson::SizeType>(s.rfind(test, 0));
if (s.rfind(a[i].GetString(), 0) != -1)
return a[i].GetString();
}
return "";
}
bool arrayContains(const Value& a, string s) {
for (SizeType i = 0; i < a.Size(); i++) {
if (a[i].GetString() == s)
return true;
}
return false;
}
bool arrayContains(const Value& a, char s) {
for (SizeType i = 0; i < a.Size(); i++) {
if (a[i].GetString()[0] == s)
return true;
}
return false;
}
string arrayToString(const Value& a, char delimiter) {
string s;
for (SizeType i = 0; i < a.Size(); i++) {
s += a[i].GetString()[0];
if (i != a.Size() - 1)
s += delimiter;
}
return s;
}
bool routeContains(string s, const Value& a) {
for (SizeType i = 0; i < a.Size(); i++) {
bool dd = contains(s, a[i].GetString());
if (contains(s, a[i].GetString()))
return true;
}
return false;
}
virtual void OnFlightPlanDisconnect(CFlightPlan FlightPlan);
virtual void debugMessage(string type, string message);
virtual void sendMessage(string type, string message);
virtual void sendMessage(string message);
void RemoveMasterAirports();
void OnRefresh(HDC hDC, int Phase);
void checkFlowStatus(Plane plane);
void OnFunctionCall(int FunctionId, const char* ItemString, POINT Pt, RECT Area);
string getFromXml(string xpath);
void addCtotToMainList(string lineValue);
void addVatcanCtotToEvCTOT(string line);
void addVatcanCtotToMainList(string callsign, string slot);
bool OnCompileCommand(const char* sCommandLine);
vector<CAD> returnCADvalues(string url);
void getCADvalues();
virtual void OnTimer(int Count);
int FuncBuffer;
protected:
Document config;
};