Merge branch 'develop' of https://git.hofmannnet.myhome-server.de/GermanAirlines/GermanAirlinesVA-GAConnector into develop
This commit is contained in:
commit
6027095c38
@ -21,6 +21,12 @@ namespace file
|
|||||||
write<decltype(this->center)>(out, this->center);
|
write<decltype(this->center)>(out, this->center);
|
||||||
write<decltype(this->radius)>(out, this->radius);
|
write<decltype(this->radius)>(out, this->radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Gate::contains(germanairlinesva::geodata::point coordinates) const
|
||||||
|
{
|
||||||
|
return germanairlinesva::geodata::distanceEarthP(this->center,
|
||||||
|
coordinates);
|
||||||
|
}
|
||||||
} // namespace simdata
|
} // namespace simdata
|
||||||
} // namespace file
|
} // namespace file
|
||||||
} // namespace germanairlinesva
|
} // namespace germanairlinesva
|
||||||
@ -24,9 +24,9 @@ namespace file
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::uint32_t time;
|
std::uint32_t time;
|
||||||
std::uint16_t altitude;
|
std::uint16_t altitude = 0;
|
||||||
std::uint16_t groundSpeed;
|
std::uint16_t groundSpeed = 0;
|
||||||
struct germanairlinesva::geodata::point coordinates;
|
struct germanairlinesva::geodata::point coordinates{NAN, NAN};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RecordingEntry() = default;
|
RecordingEntry() = default;
|
||||||
|
|||||||
@ -43,6 +43,7 @@ namespace file
|
|||||||
std::uint8_t radius);
|
std::uint8_t radius);
|
||||||
|
|
||||||
void toFile(std::ofstream &out) const;
|
void toFile(std::ofstream &out) const;
|
||||||
|
bool contains(germanairlinesva::geodata::point coordinates) const;
|
||||||
|
|
||||||
inline const std::string to_string() const
|
inline const std::string to_string() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "simdata/gate.h"
|
#include "simdata/gate.h"
|
||||||
#include "simdata/runway.h"
|
#include "simdata/runway.h"
|
||||||
|
#include "simdata/simDatabase.h"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
namespace germanairlinesva
|
namespace germanairlinesva
|
||||||
@ -15,20 +16,16 @@ namespace file
|
|||||||
{
|
{
|
||||||
namespace simdata
|
namespace simdata
|
||||||
{
|
{
|
||||||
int scan(
|
int scan(const std::string defaultFile,
|
||||||
const std::string defaultFile,
|
const std::string sceneryPack,
|
||||||
const std::string sceneryPack,
|
const std::string logFile,
|
||||||
const std::string logFile,
|
SimDatabase &airports);
|
||||||
std::map<std::string, std::pair<std::vector<const Gate>, std::vector<const Runway>>>
|
|
||||||
&airports);
|
|
||||||
|
|
||||||
void makeAirport(
|
void makeAirport(const std::string &kind,
|
||||||
const std::string &kind,
|
std::ifstream &infile,
|
||||||
std::ifstream &infile,
|
SimDatabase &airports,
|
||||||
std::map<std::string, std::pair<std::vector<const Gate>, std::vector<const Runway>>>
|
std::ofstream &logfile);
|
||||||
&airports,
|
void makeGate15(std::vector<Gate> &gates,
|
||||||
std::ofstream &logfile);
|
|
||||||
void makeGate15(std::vector<const Gate> &gates,
|
|
||||||
const std::vector<std::string> &fields);
|
const std::vector<std::string> &fields);
|
||||||
void makeRunway(std::vector<const Runway> &runways,
|
void makeRunway(std::vector<const Runway> &runways,
|
||||||
const std::vector<std::string> &fields);
|
const std::vector<std::string> &fields);
|
||||||
|
|||||||
@ -6,12 +6,10 @@ namespace file
|
|||||||
{
|
{
|
||||||
namespace simdata
|
namespace simdata
|
||||||
{
|
{
|
||||||
int scan(
|
int scan(const std::string defaultFile,
|
||||||
const std::string defaultFile,
|
const std::string sceneryPack,
|
||||||
const std::string sceneryPack,
|
const std::string logFile,
|
||||||
const std::string logFile,
|
SimDatabase &database)
|
||||||
std::map<std::string, std::pair<std::vector<const Gate>, std::vector<const Runway>>>
|
|
||||||
&airports)
|
|
||||||
{
|
{
|
||||||
std::ifstream base(defaultFile);
|
std::ifstream base(defaultFile);
|
||||||
if (!base.good()) {
|
if (!base.good()) {
|
||||||
@ -31,7 +29,7 @@ namespace file
|
|||||||
|
|
||||||
// Default
|
// Default
|
||||||
logfile << "<FILE> " << defaultFile << std::endl;
|
logfile << "<FILE> " << defaultFile << std::endl;
|
||||||
makeAirport("DEFAULT", base, airports, logfile);
|
makeAirport("DEFAULT", base, database, logfile);
|
||||||
base.close();
|
base.close();
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
@ -51,7 +49,7 @@ namespace file
|
|||||||
std::ifstream pack(path);
|
std::ifstream pack(path);
|
||||||
if (pack.good()) {
|
if (pack.good()) {
|
||||||
logfile << "<FILE> " << path << std::endl;
|
logfile << "<FILE> " << path << std::endl;
|
||||||
makeAirport("CUSTOM", pack, airports, logfile);
|
makeAirport("CUSTOM", pack, database, logfile);
|
||||||
pack.close();
|
pack.close();
|
||||||
} else {
|
} else {
|
||||||
pack.close();
|
pack.close();
|
||||||
@ -61,19 +59,18 @@ namespace file
|
|||||||
}
|
}
|
||||||
|
|
||||||
logfile << std::endl
|
logfile << std::endl
|
||||||
<< "<STATUS> Total airports: " << airports.size() << std::endl;
|
<< "<STATUS> Total airports: " << database.numAirports()
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
custom.close();
|
custom.close();
|
||||||
logfile.close();
|
logfile.close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeAirport(
|
void makeAirport(const std::string &kind,
|
||||||
const std::string &kind,
|
std::ifstream &infile,
|
||||||
std::ifstream &infile,
|
SimDatabase &database,
|
||||||
std::map<std::string, std::pair<std::vector<const Gate>, std::vector<const Runway>>>
|
std::ofstream &logfile)
|
||||||
&airports,
|
|
||||||
std::ofstream &logfile)
|
|
||||||
{
|
{
|
||||||
std::string line;
|
std::string line;
|
||||||
std::string *currentIcao = nullptr;
|
std::string *currentIcao = nullptr;
|
||||||
@ -96,7 +93,7 @@ namespace file
|
|||||||
// Write to file if ICAO is valid, and we have gates and runways
|
// Write to file if ICAO is valid, and we have gates and runways
|
||||||
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
||||||
!tmpGates.empty()) {
|
!tmpGates.empty()) {
|
||||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||||
validCount += 1;
|
validCount += 1;
|
||||||
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -116,7 +113,7 @@ namespace file
|
|||||||
// Write to file if ICAO is valid, and we have gates and runways
|
// Write to file if ICAO is valid, and we have gates and runways
|
||||||
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
if (currentIcao != nullptr && !tmpRunways.empty() &&
|
||||||
!tmpGates.empty()) {
|
!tmpGates.empty()) {
|
||||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||||
validCount += 1;
|
validCount += 1;
|
||||||
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
logfile << "\t<STATUS> " << *currentIcao << " committed"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -138,7 +135,7 @@ namespace file
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) {
|
if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) {
|
||||||
airports[*currentIcao] = {tmpGates, tmpRunways};
|
database.addAirport(*currentIcao, tmpGates, tmpRunways);
|
||||||
validCount += 1;
|
validCount += 1;
|
||||||
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
|
logfile << "\t<STATUS> " << *currentIcao << " committed" << std::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,19 @@ namespace geodata
|
|||||||
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
|
||||||
|
static inline double distanceEarthP(point from, point to)
|
||||||
|
{
|
||||||
|
double lat1r, lon1r, lat2r, lon2r, u, v;
|
||||||
|
lat1r = toRadians(from.latitude);
|
||||||
|
lon1r = toRadians(from.longitude);
|
||||||
|
lat2r = toRadians(to.latitude);
|
||||||
|
lon2r = toRadians(to.longitude);
|
||||||
|
u = sin((lat2r - lat1r) / 2);
|
||||||
|
v = sin((lon2r - lon1r) / 2);
|
||||||
|
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
|
||||||
static inline struct point calculatePointDD(struct point coordinates,
|
static inline struct point calculatePointDD(struct point coordinates,
|
||||||
double bearing,
|
double bearing,
|
||||||
|
|||||||
@ -49,7 +49,7 @@ void Websocket::onClientMessageCallback(const ix::WebSocketMessagePtr &msg)
|
|||||||
this->webSocket->send("MASTER:" + user);
|
this->webSocket->send("MASTER:" + user);
|
||||||
this->toLog("Connecting as " + user);
|
this->toLog("Connecting as " + user);
|
||||||
} else if (msg->type == ix::WebSocketMessageType::Close) {
|
} else if (msg->type == ix::WebSocketMessageType::Close) {
|
||||||
if (msg->closeInfo.reason.compare("DUPLICATE")) {
|
if (msg->closeInfo.reason.compare("DUPLICATE") == 0) {
|
||||||
this->webSocket->disableAutomaticReconnection();
|
this->webSocket->disableAutomaticReconnection();
|
||||||
|
|
||||||
this->toLog("Disconnected due to beeing a duplicate simualtor");
|
this->toLog("Disconnected due to beeing a duplicate simualtor");
|
||||||
|
|||||||
@ -146,61 +146,17 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
|||||||
ap2.first.size() == 0 ? toLog(" SUCCESS") : toLog(" ERROR");
|
ap2.first.size() == 0 ? toLog(" SUCCESS") : toLog(" ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thread for sending data to websocket
|
delete connector.release();
|
||||||
serverThread = std::thread(&serverWorker);
|
delete database.release();
|
||||||
recordingThread = std::thread(&recordingWorker);
|
delete configuration.release();
|
||||||
toLog("Workers started");
|
|
||||||
|
|
||||||
toLog("Logbook Test");
|
|
||||||
germanairlinesva::file::logbook::Logbook logbook;
|
|
||||||
logbook.addEntry("08.09.2022",
|
|
||||||
"1000",
|
|
||||||
"L049",
|
|
||||||
"D-ALFA",
|
|
||||||
"John F. Kennedy International Aiport / EDDF",
|
|
||||||
"A1",
|
|
||||||
"14L",
|
|
||||||
"Gander International Airport / CYQX",
|
|
||||||
"10",
|
|
||||||
"03",
|
|
||||||
"10:00",
|
|
||||||
"10:20",
|
|
||||||
"13:20",
|
|
||||||
"13:30",
|
|
||||||
210.5,
|
|
||||||
20.1,
|
|
||||||
5012.4156,
|
|
||||||
8.87,
|
|
||||||
5041.3856,
|
|
||||||
7.1,
|
|
||||||
971.14,
|
|
||||||
2.41,
|
|
||||||
980.65,
|
|
||||||
-165.23,
|
|
||||||
1,
|
|
||||||
1.2012,
|
|
||||||
"2022-09-08_VGA1000",
|
|
||||||
5.5,
|
|
||||||
1);
|
|
||||||
logbook.toFile();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLUGIN_API void XPluginStop(void)
|
|
||||||
{
|
|
||||||
/* Flight Loop */
|
|
||||||
XPLMUnregisterFlightLoopCallback(flightLoop, nullptr);
|
|
||||||
/* End threads */
|
|
||||||
wantsExit = true;
|
|
||||||
serverThread.join();
|
|
||||||
recordingThread.join();
|
|
||||||
|
|
||||||
delete connector.release();
|
delete connector.release();
|
||||||
delete database.release();
|
delete database.release();
|
||||||
delete configuration.release();
|
delete configuration.release();
|
||||||
|
|
||||||
p.toFile("flight.rec");
|
p.toFile("flight.rec");
|
||||||
|
|
||||||
|
toLog("Plugin stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN_API void XPluginDisable(void) {}
|
PLUGIN_API void XPluginDisable(void) {}
|
||||||
@ -273,6 +229,8 @@ void serverWorker()
|
|||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
std::this_thread::sleep_for(std::chrono::milliseconds(250));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toLog("Server thread stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordingWorker()
|
void recordingWorker()
|
||||||
@ -305,6 +263,8 @@ void recordingWorker()
|
|||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toLog("Recording thread stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void toLog(const std::string &message)
|
void toLog(const std::string &message)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user