Namespaces and formatting
This commit is contained in:
parent
42acea35bb
commit
eafe0b18f6
@ -100,7 +100,7 @@ class SimConnect
|
|||||||
bool pausedMenu;
|
bool pausedMenu;
|
||||||
bool paused;
|
bool paused;
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
struct germanairlinesva::websocket::data simData;
|
struct germanairlinesva::gaconnector::websocket::data simData;
|
||||||
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
||||||
std::function<void(const std::string)> toLog;
|
std::function<void(const std::string)> toLog;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ class SimConnect
|
|||||||
~SimConnect();
|
~SimConnect();
|
||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
const std::string getVersion() const;
|
const std::string getVersion() const;
|
||||||
void getData(struct germanairlinesva::websocket::data *data);
|
void getData(struct germanairlinesva::gaconnector::websocket::data *data);
|
||||||
void getStates() const;
|
void getStates() const;
|
||||||
void handleMessage();
|
void handleMessage();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,11 +16,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "_simconnect.h"
|
||||||
#include "config/config.hpp"
|
#include "config/config.hpp"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "logbook/logbook.hpp"
|
#include "logbook/logbook.hpp"
|
||||||
#include "recording/recording.hpp"
|
#include "recording/recording.hpp"
|
||||||
#include "_simconnect.h"
|
|
||||||
#include "simdata/simDatabase.hpp"
|
#include "simdata/simDatabase.hpp"
|
||||||
|
|
||||||
WINBOOL addNotifyIcon(HWND hWnd);
|
WINBOOL addNotifyIcon(HWND hWnd);
|
||||||
|
|||||||
22
esp/main.cpp
22
esp/main.cpp
@ -12,10 +12,10 @@ std::atomic<bool> wantsExit;
|
|||||||
|
|
||||||
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
||||||
std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
|
std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
|
||||||
std::unique_ptr<germanairlinesva::websocket::Websocket> connector;
|
std::unique_ptr<germanairlinesva::gaconnector::websocket::Websocket> connector;
|
||||||
std::unique_ptr<SimConnect> simConnect;
|
std::unique_ptr<SimConnect> simConnect;
|
||||||
|
|
||||||
struct germanairlinesva::websocket::data toSend;
|
struct germanairlinesva::gaconnector::websocket::data toSend;
|
||||||
germanairlinesva::file::recording::Recording p;
|
germanairlinesva::file::recording::Recording p;
|
||||||
|
|
||||||
// The Window Procedure
|
// The Window Procedure
|
||||||
@ -127,7 +127,8 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||||||
configuration = std::make_unique<germanairlinesva::file::config::Config>();
|
configuration = std::make_unique<germanairlinesva::file::config::Config>();
|
||||||
toLog("Config loaded");
|
toLog("Config loaded");
|
||||||
|
|
||||||
connector = std::make_unique<germanairlinesva::websocket::Websocket>(
|
connector =
|
||||||
|
std::make_unique<germanairlinesva::gaconnector::websocket::Websocket>(
|
||||||
"wss://ws.hofmannnet.myhome-server.de:8000",
|
"wss://ws.hofmannnet.myhome-server.de:8000",
|
||||||
configuration->getUser(),
|
configuration->getUser(),
|
||||||
toLog);
|
toLog);
|
||||||
@ -153,7 +154,8 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||||||
CoTaskMemFree(folder);
|
CoTaskMemFree(folder);
|
||||||
|
|
||||||
char hash[2 * MD5LEN + 1] = "";
|
char hash[2 * MD5LEN + 1] = "";
|
||||||
if (germanairlinesva::util::generateMD5(path.c_str(), hash, toLog) == 0) {
|
if (germanairlinesva::utilities::generateMD5(path.c_str(), hash, toLog) ==
|
||||||
|
0) {
|
||||||
database = std::make_unique<germanairlinesva::file::simdata::SimDatabase>(
|
database = std::make_unique<germanairlinesva::file::simdata::SimDatabase>(
|
||||||
FSX_VERSION,
|
FSX_VERSION,
|
||||||
hash,
|
hash,
|
||||||
@ -324,13 +326,13 @@ void end(HWND hWnd)
|
|||||||
|
|
||||||
void serverWorker()
|
void serverWorker()
|
||||||
{
|
{
|
||||||
germanairlinesva::util::setThreadName("GAServerWorker");
|
germanairlinesva::utilities::setThreadName("GAServerWorker");
|
||||||
|
|
||||||
while (!wantsExit) {
|
while (!wantsExit) {
|
||||||
simConnect->getStates();
|
simConnect->getStates();
|
||||||
|
|
||||||
struct germanairlinesva::websocket::data *copy =
|
struct germanairlinesva::gaconnector::websocket::data *copy =
|
||||||
new germanairlinesva::websocket::data();
|
new germanairlinesva::gaconnector::websocket::data();
|
||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(mutex);
|
const std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
@ -347,7 +349,7 @@ void serverWorker()
|
|||||||
|
|
||||||
void recordingWorker()
|
void recordingWorker()
|
||||||
{
|
{
|
||||||
germanairlinesva::util::setThreadName("GARecordingWorker");
|
germanairlinesva::utilities::setThreadName("GARecordingWorker");
|
||||||
|
|
||||||
germanairlinesva::file::recording::RecordingEntry lastPath;
|
germanairlinesva::file::recording::RecordingEntry lastPath;
|
||||||
std::uint32_t segment = 0;
|
std::uint32_t segment = 0;
|
||||||
@ -356,8 +358,8 @@ void recordingWorker()
|
|||||||
auto rwys = ap.second;
|
auto rwys = ap.second;
|
||||||
|
|
||||||
while (!wantsExit) {
|
while (!wantsExit) {
|
||||||
struct germanairlinesva::websocket::data *copy =
|
struct germanairlinesva::gaconnector::websocket::data *copy =
|
||||||
new germanairlinesva::websocket::data();
|
new germanairlinesva::gaconnector::websocket::data();
|
||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(mutex);
|
const std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
|
|||||||
@ -323,7 +323,8 @@ const std::string SimConnect::getVersion() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimConnect::getData(struct germanairlinesva::websocket::data *data)
|
void SimConnect::getData(
|
||||||
|
struct germanairlinesva::gaconnector::websocket::data *data)
|
||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(this->mutex);
|
const std::lock_guard<std::mutex> lock(this->mutex);
|
||||||
memcpy(data, &this->simData, sizeof(this->simData));
|
memcpy(data, &this->simData, sizeof(this->simData));
|
||||||
|
|||||||
@ -51,10 +51,10 @@ namespace file
|
|||||||
std::ifstream in(BASE_DIRECTORY CONFIG);
|
std::ifstream in(BASE_DIRECTORY CONFIG);
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(in, line)) {
|
while (std::getline(in, line)) {
|
||||||
std::vector<std::string> fields = util::split(line, '=');
|
std::vector<std::string> fields = utilities::split(line, '=');
|
||||||
if (fields.size() >= 2) {
|
if (fields.size() >= 2) {
|
||||||
util::trim(fields[0]);
|
utilities::trim(fields[0]);
|
||||||
util::trim(fields[1]);
|
utilities::trim(fields[1]);
|
||||||
if (fields[0] == "scenery") {
|
if (fields[0] == "scenery") {
|
||||||
this->scenery = fields[1];
|
this->scenery = fields[1];
|
||||||
} else if (fields[0] == "user") {
|
} else if (fields[0] == "user") {
|
||||||
|
|||||||
@ -117,7 +117,7 @@ namespace file
|
|||||||
public:
|
public:
|
||||||
inline Logbook()
|
inline Logbook()
|
||||||
{
|
{
|
||||||
if (util::fileExists(BASE_DIRECTORY LOGBOOK)) {
|
if (utilities::fileExists(BASE_DIRECTORY LOGBOOK)) {
|
||||||
this->fromFile();
|
this->fromFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_FILE_RECORDINGENTRY_H
|
#ifndef GERMANAIRLINESVA_FILE_RECORDING_RECORDINGENTRY_H
|
||||||
#define GERMANAIRLINESVA_FILE_RECORDINGENTRY_H
|
#define GERMANAIRLINESVA_FILE_RECORDING_RECORDINGENTRY_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -26,14 +26,14 @@ namespace file
|
|||||||
std::uint32_t time;
|
std::uint32_t time;
|
||||||
std::uint16_t altitude = 0;
|
std::uint16_t altitude = 0;
|
||||||
std::uint16_t groundSpeed = 0;
|
std::uint16_t groundSpeed = 0;
|
||||||
struct geodata::point coordinates = {NAN, NAN};
|
struct utilities::geodata::point coordinates = {NAN, NAN};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline RecordingEntry() = default;
|
inline RecordingEntry() = default;
|
||||||
inline RecordingEntry(std::uint32_t time,
|
inline RecordingEntry(std::uint32_t time,
|
||||||
std::uint16_t altitude,
|
std::uint16_t altitude,
|
||||||
std::uint16_t groundSpeed,
|
std::uint16_t groundSpeed,
|
||||||
struct geodata::point coordinates)
|
struct utilities::geodata::point coordinates)
|
||||||
: time(time), altitude(altitude), groundSpeed(groundSpeed),
|
: time(time), altitude(altitude), groundSpeed(groundSpeed),
|
||||||
coordinates(coordinates)
|
coordinates(coordinates)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace file
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string designator;
|
std::string designator;
|
||||||
struct geodata::point center;
|
struct utilities::geodata::point center;
|
||||||
std::uint8_t radius;
|
std::uint8_t radius;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -45,7 +45,7 @@ namespace file
|
|||||||
radius(radius){};
|
radius(radius){};
|
||||||
// From Database
|
// From Database
|
||||||
inline Gate(std::string designator,
|
inline Gate(std::string designator,
|
||||||
struct geodata::point center,
|
struct utilities::geodata::point center,
|
||||||
std::uint8_t radius)
|
std::uint8_t radius)
|
||||||
: designator(designator), center(center), radius(radius){};
|
: designator(designator), center(center), radius(radius){};
|
||||||
|
|
||||||
@ -56,9 +56,9 @@ namespace file
|
|||||||
write<decltype(this->radius)>(out, this->radius);
|
write<decltype(this->radius)>(out, this->radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool contains(geodata::point coordinates) const
|
inline bool contains(utilities::geodata::point coordinates) const
|
||||||
{
|
{
|
||||||
return geodata::distanceEarthP(this->center, coordinates);
|
return utilities::geodata::distanceEarthP(this->center, coordinates);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string to_string() const
|
inline const std::string to_string() const
|
||||||
|
|||||||
@ -34,7 +34,7 @@ namespace file
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string designator;
|
std::string designator;
|
||||||
struct geodata::box bounds;
|
struct utilities::geodata::box bounds;
|
||||||
std::uint8_t width;
|
std::uint8_t width;
|
||||||
std::uint16_t length;
|
std::uint16_t length;
|
||||||
double trueHeading;
|
double trueHeading;
|
||||||
@ -49,49 +49,51 @@ namespace file
|
|||||||
double width)
|
double width)
|
||||||
: designator(designator), width(width)
|
: designator(designator), width(width)
|
||||||
{
|
{
|
||||||
this->length = geodata::distanceEarthD(latitudeStart,
|
this->length = utilities::geodata::distanceEarthD(latitudeStart,
|
||||||
longitudeStart,
|
longitudeStart,
|
||||||
latitudeEnd,
|
latitudeEnd,
|
||||||
longitudeEnd);
|
longitudeEnd);
|
||||||
this->trueHeading = geodata::bearingDD(latitudeStart,
|
this->trueHeading = utilities::geodata::bearingDD(latitudeStart,
|
||||||
longitudeStart,
|
longitudeStart,
|
||||||
latitudeEnd,
|
latitudeEnd,
|
||||||
longitudeEnd);
|
longitudeEnd);
|
||||||
this->bounds =
|
this->bounds = utilities::geodata::calculateBoxDD(
|
||||||
geodata::calculateBoxDD({latitudeStart, longitudeStart},
|
{latitudeStart, longitudeStart},
|
||||||
{latitudeEnd, longitudeEnd},
|
{latitudeEnd, longitudeEnd},
|
||||||
this->trueHeading,
|
this->trueHeading,
|
||||||
this->width);
|
this->width);
|
||||||
};
|
};
|
||||||
// From MakeRwys
|
// From MakeRwys
|
||||||
inline Runway(std::string designator,
|
inline Runway(std::string designator,
|
||||||
struct geodata::point start,
|
struct utilities::geodata::point start,
|
||||||
double width,
|
double width,
|
||||||
double length,
|
double length,
|
||||||
double trueHeading)
|
double trueHeading)
|
||||||
: designator(designator), width(width), length(length),
|
: designator(designator), width(width), length(length),
|
||||||
trueHeading(trueHeading)
|
trueHeading(trueHeading)
|
||||||
{
|
{
|
||||||
geodata::point end =
|
utilities::geodata::point end =
|
||||||
geodata::calculatePointDD(start, trueHeading, length);
|
utilities::geodata::calculatePointDD(start, trueHeading, length);
|
||||||
|
|
||||||
this->bounds =
|
this->bounds = utilities::geodata::calculateBoxDD(start,
|
||||||
geodata::calculateBoxDD(start, end, trueHeading, width);
|
end,
|
||||||
|
trueHeading,
|
||||||
|
width);
|
||||||
};
|
};
|
||||||
// From database
|
// From database
|
||||||
inline Runway(std::string designator,
|
inline Runway(std::string designator,
|
||||||
struct geodata::box bounds,
|
struct utilities::geodata::box bounds,
|
||||||
std::uint8_t width,
|
std::uint8_t width,
|
||||||
std::uint16_t length,
|
std::uint16_t length,
|
||||||
double trueHeading)
|
double trueHeading)
|
||||||
: designator(designator), bounds(bounds), width(width),
|
: designator(designator), bounds(bounds), width(width),
|
||||||
length(length), trueHeading(trueHeading){};
|
length(length), trueHeading(trueHeading){};
|
||||||
|
|
||||||
inline bool containsPoint(const geodata::point point) const
|
inline bool containsPoint(const utilities::geodata::point point) const
|
||||||
{
|
{
|
||||||
size_t j = 3;
|
size_t j = 3;
|
||||||
bool c = false;
|
bool c = false;
|
||||||
std::vector<geodata::point> poly{this->bounds.topLeft,
|
std::vector<utilities::geodata::point> poly{this->bounds.topLeft,
|
||||||
this->bounds.topRight,
|
this->bounds.topRight,
|
||||||
this->bounds.bottomRight,
|
this->bounds.bottomRight,
|
||||||
this->bounds.bottomLeft};
|
this->bounds.bottomLeft};
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifdef XP
|
#ifdef XP
|
||||||
#include "simdata/simdataXP.hpp"
|
#include "simdata/simdataXP.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifndef MSFS
|
#if not defined(XP) && not defined(MSFS)
|
||||||
#include "simdata/simdataESP.hpp"
|
#include "simdata/simdataESP.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -61,7 +61,8 @@ namespace file
|
|||||||
std::uint16_t numGates = read<std::uint16_t>(in);
|
std::uint16_t numGates = read<std::uint16_t>(in);
|
||||||
for (int j = 0; j < numGates; j++) {
|
for (int j = 0; j < numGates; j++) {
|
||||||
std::string designator = readString(in);
|
std::string designator = readString(in);
|
||||||
struct geodata::point center = read<struct geodata::point>(in);
|
struct utilities::geodata::point center =
|
||||||
|
read<struct utilities::geodata::point>(in);
|
||||||
std::uint8_t radius = read<std::uint8_t>(in);
|
std::uint8_t radius = read<std::uint8_t>(in);
|
||||||
|
|
||||||
this->airports[icao].first.emplace_back(designator,
|
this->airports[icao].first.emplace_back(designator,
|
||||||
@ -73,7 +74,8 @@ namespace file
|
|||||||
for (int j = 0; j < numRunways; j++) {
|
for (int j = 0; j < numRunways; j++) {
|
||||||
std::string designator = readString(in);
|
std::string designator = readString(in);
|
||||||
// Center
|
// Center
|
||||||
struct geodata::box bounds = read<struct geodata::box>(in);
|
struct utilities::geodata::box bounds =
|
||||||
|
read<struct utilities::geodata::box>(in);
|
||||||
std::uint8_t width = read<std::uint8_t>(in);
|
std::uint8_t width = read<std::uint8_t>(in);
|
||||||
std::uint16_t length = read<std::uint16_t>(in);
|
std::uint16_t length = read<std::uint16_t>(in);
|
||||||
double trueHeading = read<double>(in);
|
double trueHeading = read<double>(in);
|
||||||
@ -113,7 +115,7 @@ namespace file
|
|||||||
std::function<void(const std::string)> toLog)
|
std::function<void(const std::string)> toLog)
|
||||||
{
|
{
|
||||||
if (strcmp(configuration->getScenery().c_str(), hash) != 0 ||
|
if (strcmp(configuration->getScenery().c_str(), hash) != 0 ||
|
||||||
!util::fileExists(BASE_DIRECTORY SIMDATABASE)) {
|
!utilities::fileExists(BASE_DIRECTORY SIMDATABASE)) {
|
||||||
#ifdef XP
|
#ifdef XP
|
||||||
scan(simVersion < 12000 ? XPLANE11_BASE_SCENERY
|
scan(simVersion < 12000 ? XPLANE11_BASE_SCENERY
|
||||||
: XPLANE12_BASE_SCENERY,
|
: XPLANE12_BASE_SCENERY,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAXP_H
|
#ifndef GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAESP_H
|
||||||
#define GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAXP_H
|
#define GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAESP_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -55,7 +55,7 @@ namespace file
|
|||||||
log << "<FILE> " << runwaysFile << std::endl;
|
log << "<FILE> " << runwaysFile << std::endl;
|
||||||
|
|
||||||
while (std::getline(runways, line)) {
|
while (std::getline(runways, line)) {
|
||||||
std::vector<std::string> fields = util::split(line, ',');
|
std::vector<std::string> fields = utilities::split(line, ',');
|
||||||
// New ICAO
|
// New ICAO
|
||||||
if (currentIcao != nullptr && *currentIcao != fields[0]) {
|
if (currentIcao != nullptr && *currentIcao != fields[0]) {
|
||||||
tmpAirportRunways[*currentIcao] = tmpRunways;
|
tmpAirportRunways[*currentIcao] = tmpRunways;
|
||||||
@ -85,12 +85,13 @@ namespace file
|
|||||||
designator = "0" + designator;
|
designator = "0" + designator;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct geodata::point start = {std::stod(fields[2]),
|
struct utilities::geodata::point start = {std::stod(fields[2]),
|
||||||
std::stod(fields[3])};
|
std::stod(fields[3])};
|
||||||
tmpRunways.emplace_back(designator,
|
tmpRunways.emplace_back(
|
||||||
|
designator,
|
||||||
start,
|
start,
|
||||||
geodata::toMetre(std::stod(fields[8])),
|
utilities::geodata::toMetre(std::stod(fields[8])),
|
||||||
geodata::toMetre(std::stod(fields[6])),
|
utilities::geodata::toMetre(std::stod(fields[6])),
|
||||||
std::stod(fields[5]) + std::stod(fields[9]));
|
std::stod(fields[5]) + std::stod(fields[9]));
|
||||||
|
|
||||||
log << "\t<RUNWAY> " << line << std::endl;
|
log << "\t<RUNWAY> " << line << std::endl;
|
||||||
@ -98,7 +99,7 @@ namespace file
|
|||||||
|
|
||||||
currentIcao = nullptr;
|
currentIcao = nullptr;
|
||||||
while (std::getline(gates, line)) {
|
while (std::getline(gates, line)) {
|
||||||
std::vector<std::string> fields = util::split(line, ',');
|
std::vector<std::string> fields = utilities::split(line, ',');
|
||||||
// New ICAO
|
// New ICAO
|
||||||
if (currentIcao != nullptr && *currentIcao != fields[0]) {
|
if (currentIcao != nullptr && *currentIcao != fields[0]) {
|
||||||
tmpAirportGates[*currentIcao] = tmpGates;
|
tmpAirportGates[*currentIcao] = tmpGates;
|
||||||
|
|||||||
@ -79,8 +79,9 @@ namespace file
|
|||||||
int validCount = 0;
|
int validCount = 0;
|
||||||
|
|
||||||
while (std::getline(infile, line)) {
|
while (std::getline(infile, line)) {
|
||||||
std::vector<std::string> fields = util::split(line, ' ');
|
std::vector<std::string> fields = utilities::split(line, ' ');
|
||||||
fields = util::select_T<std::string>(fields, [](const std::string &s) {
|
fields =
|
||||||
|
utilities::select_T<std::string>(fields, [](const std::string &s) {
|
||||||
return s.length() > 0;
|
return s.length() > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,7 +174,7 @@ namespace file
|
|||||||
std::vector<std::string> packs;
|
std::vector<std::string> packs;
|
||||||
while (std::getline(custom, line)) {
|
while (std::getline(custom, line)) {
|
||||||
if ((pos = line.find("SCENERY_PACK")) != std::string::npos) {
|
if ((pos = line.find("SCENERY_PACK")) != std::string::npos) {
|
||||||
std::string path = util::rtrim_copy(line.substr(pos + 13)) +
|
std::string path = utilities::rtrim_copy(line.substr(pos + 13)) +
|
||||||
"Earth nav data/apt.dat";
|
"Earth nav data/apt.dat";
|
||||||
packs.emplace_back(path);
|
packs.emplace_back(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
GLOBIGNORE='**/XPLM/**:XPLM/**:**/XPLM:**/ixwebsocket/**:ixwebsocket/**:**/ixwebsocket:**/nlohmann/**:nlohmann/**:**/nlohmann:**/XPSDK/**:XPSDK/**:**/XPSDK:**/build*/**:build*/**:**/build*:**/openSSL/**:openSSL/**:**/openSSL'
|
GLOBIGNORE='**/XPLM/**:XPLM/**:**/XPLM:**/ixwebsocket/**:ixwebsocket/**:**/ixwebsocket:**/nlohmann/**:nlohmann/**:**/nlohmann:**/XPSDK/**:XPSDK/**:**/XPSDK:**/build*/**:build*/**:**/build*:**/openSSL/**:openSSL/**:**/openSSL:**/SimConnect/**:SimConnect/**:**/SimConnect'
|
||||||
|
|
||||||
clang-format -verbose -i **/*.cpp
|
clang-format -verbose -i **/*.cpp
|
||||||
clang-format -verbose -i **/*.h
|
clang-format -verbose -i **/*.h
|
||||||
|
|||||||
17
recorder/include/recorder.h
Normal file
17
recorder/include/recorder.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef GERMANAIRLINESVA_GACONNECTOR_RECORDER_RECORDER_H
|
||||||
|
#define GERMANAIRLINESVA_GACONNECTOR_RECORDER_RECORDER_H
|
||||||
|
|
||||||
|
namespace germanairlinesva
|
||||||
|
{
|
||||||
|
namespace gaconnector
|
||||||
|
{
|
||||||
|
namespace recorder
|
||||||
|
{
|
||||||
|
class Recorder
|
||||||
|
{
|
||||||
|
};
|
||||||
|
} // namespace recorder
|
||||||
|
} // namespace gaconnector
|
||||||
|
} // namespace germanairlinesva
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_CONSTANTS_H
|
#ifndef GERMANAIRLINESVA_UTILITIES_CONSTANTS_H
|
||||||
#define GERMANAIRLINESVA_GACONNECTOR_CONSTANTS_H
|
#define GERMANAIRLINESVA_UTILITIES_CONSTANTS_H
|
||||||
|
|
||||||
#ifdef XP
|
#ifdef XP
|
||||||
#define BASE_DIRECTORY "Resources/plugins/GAConnector/"
|
#define BASE_DIRECTORY "Resources/plugins/GAConnector/"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_GEODATA_H
|
#ifndef GERMANAIRLINESVA_UTILITIES_GEODATA_H
|
||||||
#define GERMANAIRLINESVA_GACONNECTOR_GEODATA_H
|
#define GERMANAIRLINESVA_UTILITIES_GEODATA_H
|
||||||
|
|
||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
@ -9,6 +9,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
|
{
|
||||||
|
namespace utilities
|
||||||
{
|
{
|
||||||
namespace geodata
|
namespace geodata
|
||||||
{
|
{
|
||||||
@ -91,7 +93,8 @@ namespace geodata
|
|||||||
lon2r = toRadians(toLongitude);
|
lon2r = toRadians(toLongitude);
|
||||||
u = sin((lat2r - lat1r) / 2);
|
u = sin((lat2r - lat1r) / 2);
|
||||||
v = sin((lon2r - lon1r) / 2);
|
v = sin((lon2r - lon1r) / 2);
|
||||||
return 2.0 * EARTH_M * asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
|
return 2.0 * EARTH_M *
|
||||||
|
asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input in degrees, Output in metres
|
// Input in degrees, Output in metres
|
||||||
@ -104,7 +107,8 @@ namespace geodata
|
|||||||
lon2r = toRadians(to.longitude);
|
lon2r = toRadians(to.longitude);
|
||||||
u = sin((lat2r - lat1r) / 2);
|
u = sin((lat2r - lat1r) / 2);
|
||||||
v = sin((lon2r - lon1r) / 2);
|
v = sin((lon2r - lon1r) / 2);
|
||||||
return 2.0 * EARTH_M * asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
|
return 2.0 * EARTH_M *
|
||||||
|
asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input and Output in degrees
|
// Input and Output in degrees
|
||||||
@ -169,7 +173,8 @@ namespace geodata
|
|||||||
std::atan2(std::sin(r_bearing) * std::sin(distance / EARTH_M) *
|
std::atan2(std::sin(r_bearing) * std::sin(distance / EARTH_M) *
|
||||||
std::cos(coordinates.latitude),
|
std::cos(coordinates.latitude),
|
||||||
std::cos(distance / EARTH_M) -
|
std::cos(distance / EARTH_M) -
|
||||||
std::sin(coordinates.latitude) * std::sin(newLatitude));
|
std::sin(coordinates.latitude) *
|
||||||
|
std::sin(newLatitude));
|
||||||
|
|
||||||
return {toDegrees(newLatitude), toDegrees(newLongitude)};
|
return {toDegrees(newLatitude), toDegrees(newLongitude)};
|
||||||
}
|
}
|
||||||
@ -190,7 +195,8 @@ namespace geodata
|
|||||||
std::atan2(std::sin(r_bearing) * std::sin(distance / EARTH_M) *
|
std::atan2(std::sin(r_bearing) * std::sin(distance / EARTH_M) *
|
||||||
std::cos(coordinates.latitude),
|
std::cos(coordinates.latitude),
|
||||||
std::cos(distance / EARTH_M) -
|
std::cos(distance / EARTH_M) -
|
||||||
std::sin(coordinates.latitude) * std::sin(newLatitude));
|
std::sin(coordinates.latitude) *
|
||||||
|
std::sin(newLatitude));
|
||||||
|
|
||||||
return {newLatitude, newLongitude};
|
return {newLatitude, newLongitude};
|
||||||
}
|
}
|
||||||
@ -201,7 +207,8 @@ namespace geodata
|
|||||||
double length,
|
double length,
|
||||||
double width)
|
double width)
|
||||||
{
|
{
|
||||||
struct point primaryCenter = calculatePointDR(center, bearing, -length / 2);
|
struct point primaryCenter =
|
||||||
|
calculatePointDR(center, bearing, -length / 2);
|
||||||
struct point secondaryCenter =
|
struct point secondaryCenter =
|
||||||
calculatePointDR(center, bearing, length / 2);
|
calculatePointDR(center, bearing, length / 2);
|
||||||
double offsetHeadingNorth =
|
double offsetHeadingNorth =
|
||||||
@ -237,8 +244,8 @@ namespace geodata
|
|||||||
|
|
||||||
return {primaryTop, secondaryTop, secondaryBottom, primaryBottom};
|
return {primaryTop, secondaryTop, secondaryBottom, primaryBottom};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace geodata
|
} // namespace geodata
|
||||||
|
} // namespace utilities
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_UTIL_H
|
#ifndef GERMANAIRLINESVA_UTILITIES_UTIL_H
|
||||||
#define GERMANAIRLINESVA_GACONNECTOR_UTIL_H
|
#define GERMANAIRLINESVA_UTILITIES_UTIL_H
|
||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
#define MD5LEN 16
|
#define MD5LEN 16
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
{
|
{
|
||||||
namespace util
|
namespace utilities
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static inline std::vector<T>
|
static inline std::vector<T>
|
||||||
@ -294,7 +294,7 @@ namespace util
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} // namespace util
|
} // namespace utilities
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_SOCKET_TYPES_H
|
#ifndef GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_TYPES_H
|
||||||
#define GERMANAIRLINESVA_GACONNECTOR_SOCKET_TYPES_H
|
#define GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_TYPES_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
|
{
|
||||||
|
namespace gaconnector
|
||||||
{
|
{
|
||||||
namespace websocket
|
namespace websocket
|
||||||
{
|
{
|
||||||
@ -32,7 +34,17 @@ namespace websocket
|
|||||||
float totalWeightKg = 0;
|
float totalWeightKg = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum commands { PROCESS, SAVE, LOAD, TEXT, TIME, UNPAUSE, PAUSE, PORT, END };
|
enum commands {
|
||||||
|
PROCESS,
|
||||||
|
SAVE,
|
||||||
|
LOAD,
|
||||||
|
TEXT,
|
||||||
|
TIME,
|
||||||
|
UNPAUSE,
|
||||||
|
PAUSE,
|
||||||
|
PORT,
|
||||||
|
END
|
||||||
|
};
|
||||||
|
|
||||||
struct command_base {
|
struct command_base {
|
||||||
enum commands type;
|
enum commands type;
|
||||||
@ -46,6 +58,7 @@ namespace websocket
|
|||||||
|
|
||||||
#pragma pack(pop) /* restore original alignment from stack */
|
#pragma pack(pop) /* restore original alignment from stack */
|
||||||
} // namespace websocket
|
} // namespace websocket
|
||||||
|
} // namespace gaconnector
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_H
|
#ifndef GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_WEBSOCKET_H
|
||||||
#define GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_H
|
#define GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_WEBSOCKET_H
|
||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
#define MD5LEN 16
|
#define MD5LEN 16
|
||||||
@ -19,6 +19,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
|
{
|
||||||
|
namespace gaconnector
|
||||||
{
|
{
|
||||||
namespace websocket
|
namespace websocket
|
||||||
{
|
{
|
||||||
@ -41,6 +43,7 @@ namespace websocket
|
|||||||
void sendData(data &d);
|
void sendData(data &d);
|
||||||
};
|
};
|
||||||
} // namespace websocket
|
} // namespace websocket
|
||||||
|
} // namespace gaconnector
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1,6 +1,8 @@
|
|||||||
#include "include/websocket.h"
|
#include "include/websocket.h"
|
||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
|
{
|
||||||
|
namespace gaconnector
|
||||||
{
|
{
|
||||||
namespace websocket
|
namespace websocket
|
||||||
{
|
{
|
||||||
@ -88,7 +90,7 @@ namespace websocket
|
|||||||
{
|
{
|
||||||
if (strcmp(d.path, this->lastPath) != 0) {
|
if (strcmp(d.path, this->lastPath) != 0) {
|
||||||
strcpy(this->lastPath, d.path);
|
strcpy(this->lastPath, d.path);
|
||||||
if (util::generateMD5(d.path, this->lastHash, this->toLog)) {
|
if (utilities::generateMD5(d.path, this->lastHash, this->toLog)) {
|
||||||
strcpy(this->lastHash, "NOT SET");
|
strcpy(this->lastHash, "NOT SET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,4 +113,5 @@ namespace websocket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace websocket
|
} // namespace websocket
|
||||||
|
} // namespace gaconnector
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
@ -12,7 +12,7 @@ std::atomic<bool> wantsExit;
|
|||||||
|
|
||||||
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
std::shared_ptr<germanairlinesva::file::config::Config> configuration;
|
||||||
std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
|
std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
|
||||||
std::unique_ptr<germanairlinesva::websocket::Websocket> connector;
|
std::unique_ptr<germanairlinesva::gaconnector::websocket::Websocket> connector;
|
||||||
int xplaneVersion;
|
int xplaneVersion;
|
||||||
|
|
||||||
/* Datarefs */
|
/* Datarefs */
|
||||||
@ -43,7 +43,7 @@ XPLMDataRef pitch;
|
|||||||
XPLMDataRef roll;
|
XPLMDataRef roll;
|
||||||
XPLMDataRef quaternion;
|
XPLMDataRef quaternion;
|
||||||
|
|
||||||
struct germanairlinesva::websocket::data toSend;
|
struct germanairlinesva::gaconnector::websocket::data toSend;
|
||||||
germanairlinesva::file::recording::Recording p;
|
germanairlinesva::file::recording::Recording p;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,15 +114,17 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
|||||||
configuration = std::make_unique<germanairlinesva::file::config::Config>();
|
configuration = std::make_unique<germanairlinesva::file::config::Config>();
|
||||||
toLog("Config loaded");
|
toLog("Config loaded");
|
||||||
|
|
||||||
connector = std::make_unique<germanairlinesva::websocket::Websocket>(
|
connector =
|
||||||
|
std::make_unique<germanairlinesva::gaconnector::websocket::Websocket>(
|
||||||
"wss://ws.hofmannnet.myhome-server.de:8000",
|
"wss://ws.hofmannnet.myhome-server.de:8000",
|
||||||
configuration->getUser(),
|
configuration->getUser(),
|
||||||
toLog);
|
toLog);
|
||||||
toLog("WebSocket started");
|
toLog("WebSocket started");
|
||||||
|
|
||||||
char hash[2 * MD5LEN + 1] = "";
|
char hash[2 * MD5LEN + 1] = "";
|
||||||
if (germanairlinesva::util::generateMD5(XPLANE_CUSTOM_SCENERY, hash, toLog) ==
|
if (germanairlinesva::utilities::generateMD5(XPLANE_CUSTOM_SCENERY,
|
||||||
0) {
|
hash,
|
||||||
|
toLog) == 0) {
|
||||||
database = std::make_unique<germanairlinesva::file::simdata::SimDatabase>(
|
database = std::make_unique<germanairlinesva::file::simdata::SimDatabase>(
|
||||||
xplaneVersion,
|
xplaneVersion,
|
||||||
hash,
|
hash,
|
||||||
@ -216,7 +218,9 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
|||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(mutex);
|
const std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
std::memset(&toSend, 0, sizeof(germanairlinesva::websocket::data));
|
std::memset(&toSend,
|
||||||
|
0,
|
||||||
|
sizeof(germanairlinesva::gaconnector::websocket::data));
|
||||||
|
|
||||||
toSend.pause = XPLMGetDatai(pauseIndicator);
|
toSend.pause = XPLMGetDatai(pauseIndicator);
|
||||||
toSend.pBrake = XPLMGetDataf(parkingBrake);
|
toSend.pBrake = XPLMGetDataf(parkingBrake);
|
||||||
@ -254,14 +258,16 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
|||||||
|
|
||||||
void serverWorker()
|
void serverWorker()
|
||||||
{
|
{
|
||||||
germanairlinesva::util::setThreadName("GAServerWorker");
|
germanairlinesva::utilities::setThreadName("GAServerWorker");
|
||||||
|
|
||||||
while (!wantsExit) {
|
while (!wantsExit) {
|
||||||
struct germanairlinesva::websocket::data copy;
|
struct germanairlinesva::gaconnector::websocket::data copy;
|
||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(mutex);
|
const std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
std::memcpy(©, &toSend, sizeof(germanairlinesva::websocket::data));
|
std::memcpy(©,
|
||||||
|
&toSend,
|
||||||
|
sizeof(germanairlinesva::gaconnector::websocket::data));
|
||||||
}
|
}
|
||||||
|
|
||||||
connector->sendData(copy);
|
connector->sendData(copy);
|
||||||
@ -274,7 +280,7 @@ void serverWorker()
|
|||||||
|
|
||||||
void recordingWorker()
|
void recordingWorker()
|
||||||
{
|
{
|
||||||
germanairlinesva::util::setThreadName("GARecordingWorker");
|
germanairlinesva::utilities::setThreadName("GARecordingWorker");
|
||||||
|
|
||||||
germanairlinesva::file::recording::RecordingEntry lastPath;
|
germanairlinesva::file::recording::RecordingEntry lastPath;
|
||||||
std::uint32_t segment = 0;
|
std::uint32_t segment = 0;
|
||||||
@ -283,11 +289,13 @@ void recordingWorker()
|
|||||||
auto rwys = ap.second;
|
auto rwys = ap.second;
|
||||||
|
|
||||||
while (!wantsExit) {
|
while (!wantsExit) {
|
||||||
struct germanairlinesva::websocket::data copy;
|
struct germanairlinesva::gaconnector::websocket::data copy;
|
||||||
{
|
{
|
||||||
const std::lock_guard<std::mutex> lock(mutex);
|
const std::lock_guard<std::mutex> lock(mutex);
|
||||||
|
|
||||||
std::memcpy(©, &toSend, sizeof(germanairlinesva::websocket::data));
|
std::memcpy(©,
|
||||||
|
&toSend,
|
||||||
|
sizeof(germanairlinesva::gaconnector::websocket::data));
|
||||||
}
|
}
|
||||||
|
|
||||||
germanairlinesva::file::recording::RecordingEntry currentPath(
|
germanairlinesva::file::recording::RecordingEntry currentPath(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user