Formating
This commit is contained in:
parent
3a9db68e74
commit
c214d473e2
@ -57,21 +57,50 @@ struct data {
|
||||
double gForce; // G FORCE IN G
|
||||
};
|
||||
|
||||
struct Port {
|
||||
struct port {
|
||||
double headingTrue; // PLANE HEADING DEGREES TRUE
|
||||
double latitude; // PLANE LATITUDE
|
||||
double longitude; // PLANE LONGITUDE
|
||||
};
|
||||
|
||||
struct airport {
|
||||
double lat;
|
||||
double lon;
|
||||
char name[32];
|
||||
};
|
||||
struct runway {
|
||||
double lat;
|
||||
double lon;
|
||||
float heading;
|
||||
float length;
|
||||
float width;
|
||||
int pNum;
|
||||
int pDeg;
|
||||
int sNum;
|
||||
int sDeg;
|
||||
};
|
||||
struct parking {
|
||||
int type;
|
||||
int name;
|
||||
int suffix;
|
||||
unsigned int number;
|
||||
float heading;
|
||||
float radius;
|
||||
float x;
|
||||
float z;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
enum DEFINITIONS {
|
||||
D_DATA,
|
||||
D_FACILITY,
|
||||
D_PORT,
|
||||
};
|
||||
|
||||
enum REQUESTS {
|
||||
R_DATA,
|
||||
R_FACILITY,
|
||||
R_ACFT,
|
||||
R_DIALOG,
|
||||
R_PORT,
|
||||
|
||||
@ -146,7 +146,7 @@ WINBOOL addNotifyIcon(HWND hWnd)
|
||||
GetSystemMetrics(SM_CYSMICON),
|
||||
LR_SHARED);
|
||||
if (icon == NULL) {
|
||||
toLog("error icon " + std::to_string(GetLastError()));
|
||||
toLog("Error icon " + std::to_string(GetLastError()));
|
||||
}
|
||||
niData.cbSize = sizeof(NOTIFYICONDATA);
|
||||
niData.uVersion = NOTIFYICON_VERSION_4;
|
||||
@ -187,6 +187,9 @@ WINBOOL createMenu(HWND hWnd)
|
||||
version.append(SimConnect::resolveVersion(simConnect->getVersion()));
|
||||
AppendMenu(hMenu, MF_STRING | MF_GRAYED, NULL, version.c_str());
|
||||
}
|
||||
if (!recorder->getSupportedState()) {
|
||||
AppendMenu(hMenu, MF_STRING | MF_GRAYED, NULL, "Sim unsupported");
|
||||
}
|
||||
AppendMenu(hMenu, MF_SEPARATOR, NULL, NULL);
|
||||
AppendMenu(hMenu, MF_STRING, IDM_EXIT, "Exit");
|
||||
|
||||
|
||||
@ -19,48 +19,52 @@ SimConnect::SimConnect(
|
||||
this->toLog("SimConnect_Close: Connection opened");
|
||||
|
||||
// Setup SimConnect
|
||||
SimConnect_SubscribeToSystemEvent(simConnect, EVENTS::E_PAUSE, "Pause");
|
||||
SimConnect_SubscribeToSystemEvent(simConnect, EVENTS::E_STATUS, "Sim");
|
||||
SimConnect_SubscribeToSystemEvent(this->simConnect,
|
||||
EVENTS::E_PAUSE,
|
||||
"Pause");
|
||||
SimConnect_SubscribeToSystemEvent(this->simConnect,
|
||||
EVENTS::E_STATUS,
|
||||
"Sim");
|
||||
|
||||
SimConnect_MapClientEventToSimEvent(simConnect,
|
||||
SimConnect_MapClientEventToSimEvent(this->simConnect,
|
||||
EVENTS::E_TIMESEC,
|
||||
"CLOCK_SECONDS_ZERO");
|
||||
SimConnect_AddClientEventToNotificationGroup(simConnect,
|
||||
SimConnect_AddClientEventToNotificationGroup(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
EVENTS::E_TIMESEC,
|
||||
false);
|
||||
SimConnect_SetNotificationGroupPriority(simConnect,
|
||||
SimConnect_SetNotificationGroupPriority(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
SIMCONNECT_GROUP_PRIORITY_HIGHEST);
|
||||
SimConnect_MapClientEventToSimEvent(simConnect,
|
||||
SimConnect_MapClientEventToSimEvent(this->simConnect,
|
||||
EVENTS::E_TIMEMIN,
|
||||
"ZULU_MINUTES_SET");
|
||||
SimConnect_AddClientEventToNotificationGroup(simConnect,
|
||||
SimConnect_AddClientEventToNotificationGroup(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
EVENTS::E_TIMEMIN,
|
||||
false);
|
||||
SimConnect_SetNotificationGroupPriority(simConnect,
|
||||
SimConnect_SetNotificationGroupPriority(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
SIMCONNECT_GROUP_PRIORITY_HIGHEST);
|
||||
SimConnect_MapClientEventToSimEvent(simConnect,
|
||||
SimConnect_MapClientEventToSimEvent(this->simConnect,
|
||||
EVENTS::E_TIMEHRS,
|
||||
"ZULU_HOURS_SET");
|
||||
SimConnect_AddClientEventToNotificationGroup(simConnect,
|
||||
SimConnect_AddClientEventToNotificationGroup(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
EVENTS::E_TIMEHRS,
|
||||
false);
|
||||
SimConnect_SetNotificationGroupPriority(simConnect,
|
||||
SimConnect_SetNotificationGroupPriority(this->simConnect,
|
||||
GROUPS::G_TIME,
|
||||
SIMCONNECT_GROUP_PRIORITY_HIGHEST);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"BRAKE PARKING INDICATOR",
|
||||
"BOOL",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"SIM ON GROUND",
|
||||
"BOOL",
|
||||
@ -68,14 +72,14 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"EMPTY WEIGHT",
|
||||
"KILOGRAMS",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"TOTAL WEIGHT",
|
||||
"KILOGRAMS",
|
||||
@ -83,7 +87,7 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"FUEL TOTAL QUANTITY WEIGHT",
|
||||
"KILOGRAMS",
|
||||
@ -91,14 +95,14 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE HEADING DEGREES TRUE",
|
||||
"DEGREES",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE HEADING DEGREES MAGNETIC",
|
||||
"DEGREES",
|
||||
@ -106,21 +110,21 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"GROUND VELOCITY",
|
||||
"KNOTS",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"AIRSPEED INDICATED",
|
||||
"KNOTS",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"AIRSPEED BARBER POLE",
|
||||
"KNOTS",
|
||||
@ -128,28 +132,28 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"VELOCITY WORLD Y",
|
||||
"FEET/MINUTE",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"VERTICAL SPEED",
|
||||
"FEET/MINUTE",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE ALTITUDE",
|
||||
"FEET",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE ALT ABOVE GROUND",
|
||||
"FEET",
|
||||
@ -157,14 +161,14 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE LATITUDE",
|
||||
"DEGREES",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"PLANE LONGITUDE",
|
||||
"DEGREES",
|
||||
@ -172,7 +176,7 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ABSOLUTE TIME",
|
||||
"SECONDS",
|
||||
@ -180,28 +184,28 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ENG FUEL FLOW PPH:1",
|
||||
"KILOGRAMS PER SECOND",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ENG FUEL FLOW PPH:2",
|
||||
"KILOGRAMS PER SECOND",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ENG FUEL FLOW PPH:3",
|
||||
"KILOGRAMS PER SECOND",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ENG FUEL FLOW PPH:4",
|
||||
"KILOGRAMS PER SECOND",
|
||||
@ -209,21 +213,21 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"BRAKE INDICATOR",
|
||||
"POSITION",
|
||||
SIMCONNECT_DATATYPE_INT32,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"BRAKE PARKING POSITION",
|
||||
"POSITION",
|
||||
SIMCONNECT_DATATYPE_INT32,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"BRAKE LEFT POSITION",
|
||||
"POSITION",
|
||||
@ -231,7 +235,7 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"ZULU TIME",
|
||||
"SECONDS",
|
||||
@ -239,7 +243,7 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_DATA,
|
||||
"G FORCE",
|
||||
"GForce",
|
||||
@ -247,21 +251,21 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_PORT,
|
||||
"PLANE HEADING DEGREES TRUE",
|
||||
"DEGREES",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_PORT,
|
||||
"PLANE LATITUDE",
|
||||
"DEGREES",
|
||||
SIMCONNECT_DATATYPE_FLOAT64,
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
SimConnect_AddToDataDefinition(simConnect,
|
||||
SimConnect_AddToDataDefinition(this->simConnect,
|
||||
DEFINITIONS::D_PORT,
|
||||
"PLANE LONGITUDE",
|
||||
"DEGREES",
|
||||
@ -269,7 +273,67 @@ SimConnect::SimConnect(
|
||||
0,
|
||||
SIMCONNECT_UNUSED);
|
||||
|
||||
SimConnect_RequestDataOnSimObject(simConnect,
|
||||
#ifdef MSFS
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"OPEN AIRPORT");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"LATITUDE");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"LONGITUDE");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "NAME");
|
||||
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"OPEN RUNWAY");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"LATITUDE");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"LONGITUDE");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "HEADING");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "LENGTH");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "WIDTH");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"PRIMARY_NUMBER");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"PRIMARY_DESIGNATOR");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"SECONDARY_NUMBER");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"SECONDARY_DESIGNATOR");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"CLOSE RUNWAY");
|
||||
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"OPEN TAXI_PARKING");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "TYPE");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "NAME");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "SUFFIX");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "NUMBER");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "HEADING");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "RADIUS");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "BIAS_X");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect, D_FACILITY, "BIAS_Z");
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"CLOSE TAXI_PARKING");
|
||||
|
||||
SimConnect_AddToFacilityDefinition(this->simConnect,
|
||||
D_FACILITY,
|
||||
"CLOSE AIRPORT");
|
||||
#endif
|
||||
|
||||
SimConnect_RequestDataOnSimObject(this->simConnect,
|
||||
REQUESTS::R_DATA,
|
||||
DEFINITIONS::D_DATA,
|
||||
SIMCONNECT_OBJECT_ID_USER,
|
||||
@ -340,6 +404,11 @@ void SimConnect::handleMessage(std::function<void(int)> callbackOpen,
|
||||
callbackData();
|
||||
break;
|
||||
}
|
||||
#ifdef MSFS
|
||||
case SIMCONNECT_RECV_ID_FACILITY_DATA: {
|
||||
this->toLog("NavData API MSFS Message received");
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ namespace gaconnector
|
||||
std::unique_ptr<websocket::Websocket> connector;
|
||||
|
||||
websocket::data toSend;
|
||||
bool simSupported = false;
|
||||
|
||||
std::queue<std::function<void()>> &messageQueue()
|
||||
{
|
||||
@ -67,6 +68,7 @@ namespace gaconnector
|
||||
void handleMessages();
|
||||
std::shared_ptr<file::config::Config> getConfiguration() const;
|
||||
void loadDatabase(int simVersion);
|
||||
bool getSupportedState() const;
|
||||
};
|
||||
} // namespace recorder
|
||||
} // namespace gaconnector
|
||||
|
||||
@ -6,6 +6,8 @@ namespace gaconnector
|
||||
{
|
||||
namespace recorder
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
Recorder::Recorder(int simVersion,
|
||||
std::function<void(const std::string)> toLog)
|
||||
: toLog(std::move(toLog))
|
||||
@ -16,15 +18,7 @@ namespace gaconnector
|
||||
|
||||
// Database
|
||||
#ifdef XP
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (utilities::generateMD5(XPLANE_CUSTOM_SCENERY, hash, this->toLog) ==
|
||||
0) {
|
||||
this->database =
|
||||
std::make_unique<file::simdata::SimDatabase>(simVersion,
|
||||
hash,
|
||||
this->configuration,
|
||||
this->toLog);
|
||||
}
|
||||
this->loadDatabase(simVersion);
|
||||
#endif
|
||||
|
||||
// WebSocket
|
||||
@ -44,28 +38,29 @@ namespace gaconnector
|
||||
this->recordingThread = std::thread(&Recorder::recordingWorker, this);
|
||||
this->toLog("Workers started");
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
Recorder::~Recorder()
|
||||
{
|
||||
wantsExit = true;
|
||||
serverThread.join();
|
||||
recordingThread.join();
|
||||
this->wantsExit.store(true);
|
||||
this->serverThread.join();
|
||||
this->recordingThread.join();
|
||||
}
|
||||
|
||||
void Recorder::setData(websocket::data &data)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::lock_guard<std::mutex> lock(this->mutex);
|
||||
|
||||
std::memcpy(&this->toSend, &data, sizeof(websocket::data));
|
||||
}
|
||||
|
||||
void Recorder::handleMessages()
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::lock_guard<std::mutex> lock(this->mutex);
|
||||
|
||||
if (!messageQueue().empty()) {
|
||||
auto op = std::move(messageQueue().front());
|
||||
messageQueue().pop();
|
||||
if (!this->messageQueue().empty()) {
|
||||
auto op = std::move(this->messageQueue().front());
|
||||
this->messageQueue().pop();
|
||||
op();
|
||||
}
|
||||
}
|
||||
@ -77,11 +72,24 @@ namespace gaconnector
|
||||
|
||||
void Recorder::loadDatabase(int simVersion)
|
||||
{
|
||||
#ifdef XP
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (utilities::generateMD5(XPLANE_CUSTOM_SCENERY, hash, this->toLog) ==
|
||||
0) {
|
||||
this->database =
|
||||
std::make_unique<file::simdata::SimDatabase>(simVersion,
|
||||
hash,
|
||||
this->configuration,
|
||||
this->toLog);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(IBM) && not defined(XP)
|
||||
if (simVersion == MSFS_VERSION) {
|
||||
this->simSupported = strcmp(BIT, "64") == 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(IBM) && not defined(XP)
|
||||
this->toLog("Loading database for " +
|
||||
SimConnect::resolveVersion(simVersion));
|
||||
|
||||
@ -98,14 +106,14 @@ namespace gaconnector
|
||||
|
||||
std::string path(nstring);
|
||||
path.append(SimConnect::resolveScenery(simVersion));
|
||||
this->toLog(path);
|
||||
this->toLog("Scenery path: " + path);
|
||||
|
||||
delete[] nstring;
|
||||
CoTaskMemFree(folder);
|
||||
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (utilities::generateMD5(path.c_str(), hash, toLog) == 0) {
|
||||
database =
|
||||
this->database =
|
||||
std::make_unique<file::simdata::SimDatabase>(simVersion,
|
||||
hash,
|
||||
this->configuration,
|
||||
@ -115,8 +123,13 @@ namespace gaconnector
|
||||
this->test();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only here can we be sure to have a supported sim
|
||||
this->simSupported = true;
|
||||
}
|
||||
|
||||
bool Recorder::getSupportedState() const { return this->simSupported; }
|
||||
|
||||
void Recorder::serverWorker()
|
||||
{
|
||||
utilities::setThreadName("GAServerWorker");
|
||||
@ -124,17 +137,17 @@ namespace gaconnector
|
||||
while (!wantsExit) {
|
||||
struct websocket::data copy;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::lock_guard<std::mutex> lock(this->mutex);
|
||||
|
||||
std::memcpy(©, &toSend, sizeof(websocket::data));
|
||||
std::memcpy(©, &this->toSend, sizeof(websocket::data));
|
||||
}
|
||||
|
||||
connector->sendData(copy);
|
||||
this->connector->sendData(copy);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||
}
|
||||
|
||||
toLog("Server thread stopped");
|
||||
this->toLog("Server thread stopped");
|
||||
}
|
||||
|
||||
void Recorder::recordingWorker()
|
||||
@ -148,9 +161,9 @@ namespace gaconnector
|
||||
while (!wantsExit) {
|
||||
struct websocket::data copy;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
const std::lock_guard<std::mutex> lock(this->mutex);
|
||||
|
||||
std::memcpy(©, &toSend, sizeof(websocket::data));
|
||||
std::memcpy(©, &this->toSend, sizeof(websocket::data));
|
||||
}
|
||||
|
||||
file::recording::RecordingEntry currentPath(
|
||||
@ -171,7 +184,7 @@ namespace gaconnector
|
||||
}
|
||||
|
||||
path.toFile("flight.rec");
|
||||
toLog("Recording thread stopped");
|
||||
this->toLog("Recording thread stopped");
|
||||
}
|
||||
|
||||
void Recorder::test() const
|
||||
|
||||
@ -27,6 +27,7 @@ namespace gaconnector
|
||||
class Websocket
|
||||
{
|
||||
private:
|
||||
bool isLoggedIn = false;
|
||||
char lastPath[513] = "";
|
||||
char lastHash[2 * MD5LEN + 1] = "";
|
||||
ix::WebSocket *webSocket = nullptr;
|
||||
|
||||
@ -41,44 +41,49 @@ namespace gaconnector
|
||||
if (msg->type == ix::WebSocketMessageType::Open) {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
debug_msg << std::endl << "New connection" << std::endl;
|
||||
debug_msg << "Uri: " << msg->openInfo.uri << std::endl;
|
||||
debug_msg << "Headers:" << std::endl;
|
||||
debug_msg << "New connection" << std::endl;
|
||||
debug_msg << "\tUri: " << msg->openInfo.uri << std::endl;
|
||||
debug_msg << "\tHeaders:" << std::endl;
|
||||
for (const auto &it : msg->openInfo.headers) {
|
||||
debug_msg << it.first << ": " << it.second << std::endl;
|
||||
debug_msg << "\t\t" << it.first << ": " << it.second << std::endl;
|
||||
}
|
||||
|
||||
this->toLog(debug_msg.str());
|
||||
|
||||
this->webSocket->send("MASTER:" + user);
|
||||
this->toLog("Connecting as " + user);
|
||||
this->isLoggedIn = true;
|
||||
} else if (msg->type == ix::WebSocketMessageType::Close) {
|
||||
if (msg->closeInfo.reason.compare("DUPLICATE") == 0) {
|
||||
this->webSocket->disableAutomaticReconnection();
|
||||
|
||||
this->toLog("Disconnected due to beeing a duplicate simualtor");
|
||||
this->isLoggedIn = false;
|
||||
} else {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
debug_msg << std::endl << "Connection closed" << std::endl;
|
||||
debug_msg << "Code: " << msg->closeInfo.code << std::endl;
|
||||
debug_msg << "Reason: " << msg->closeInfo.reason << std::endl;
|
||||
debug_msg << "Remote: " << msg->closeInfo.remote << std::endl;
|
||||
debug_msg << "Connection closed" << std::endl;
|
||||
debug_msg << "\tCode: " << msg->closeInfo.code << std::endl;
|
||||
debug_msg << "\tReason: " << msg->closeInfo.reason << std::endl;
|
||||
debug_msg << "\tRemote: " << msg->closeInfo.remote << std::endl;
|
||||
|
||||
this->toLog(debug_msg.str());
|
||||
this->isLoggedIn = false;
|
||||
}
|
||||
} else if (msg->type == ix::WebSocketMessageType::Error) {
|
||||
std::stringstream debug_msg;
|
||||
|
||||
debug_msg << std::endl << "Connection error" << std::endl;
|
||||
debug_msg << "Decompression: " << msg->errorInfo.decompressionError
|
||||
debug_msg << "Connection error" << std::endl;
|
||||
debug_msg << "\tDecompression: " << msg->errorInfo.decompressionError
|
||||
<< std::endl;
|
||||
debug_msg << "HTTP status: " << msg->errorInfo.http_status << std::endl;
|
||||
debug_msg << "Reason: " << msg->errorInfo.reason << std::endl;
|
||||
debug_msg << "Retries: " << msg->errorInfo.retries << std::endl;
|
||||
debug_msg << "Wait time: " << msg->errorInfo.wait_time << std::endl;
|
||||
debug_msg << "\tHTTP status: " << msg->errorInfo.http_status
|
||||
<< std::endl;
|
||||
debug_msg << "\tReason: " << msg->errorInfo.reason << std::endl;
|
||||
debug_msg << "\tRetries: " << msg->errorInfo.retries << std::endl;
|
||||
debug_msg << "\tWait time: " << msg->errorInfo.wait_time << std::endl;
|
||||
|
||||
this->toLog(debug_msg.str());
|
||||
this->isLoggedIn = false;
|
||||
} else if (msg->type == ix::WebSocketMessageType::Message) {
|
||||
if (!msg->str.empty()) {
|
||||
this->toLog(msg->str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user