Compare commits

...

2 Commits

15 changed files with 208 additions and 301 deletions

View File

@ -63,6 +63,7 @@
"thread": "cpp", "thread": "cpp",
"cinttypes": "cpp", "cinttypes": "cpp",
"typeinfo": "cpp", "typeinfo": "cpp",
"valarray": "cpp" "valarray": "cpp",
"__threading_support": "cpp"
}, },
} }

View File

@ -17,11 +17,15 @@ case $1 in
;; ;;
"win32") "win32")
cmake -DDEBUG=$DEBUG -DBIT=32 -DCMAKE_TOOLCHAIN_FILE=../toolchain-win-32.cmake .. cmake -DDEBUG=$DEBUG -DBIT=32 -DCMAKE_TOOLCHAIN_FILE=../toolchain-win-32.cmake ..
\cp -rf ../openSSL/win32/*.dll ESP/GAConnector/
\cp -rf /opt/llvm-mingw/i686-w64-mingw32/bin/libc++.dll ESP/GAConnector/
\cp -rf /opt/llvm-mingw/i686-w64-mingw32/bin/libunwind.dll ESP/GAConnector/
;; ;;
"win64") "win64")
cmake -DDEBUG=$DEBUG -DBIT=64 -DCMAKE_TOOLCHAIN_FILE=../toolchain-win-64.cmake .. cmake -DDEBUG=$DEBUG -DBIT=64 -DCMAKE_TOOLCHAIN_FILE=../toolchain-win-64.cmake ..
\cp -rf ../openSSL/win64/*.dll X-Plane/GAConnector/64/ \cp -rf ../openSSL/win64/*.dll X-Plane/GAConnector/64/
\cp -rf ../openSSL/win64/*.dll ESP/GAConnector/ \cp -rf /opt/llvm-mingw/x86_64-w64-mingw32/bin/libc++.dll X-Plane/GAConnector/64
\cp -rf /opt/llvm-mingw/x86_64-w64-mingw32/bin/libunwind.dll X-Plane/GAConnector/64
;; ;;
esac esac

View File

@ -81,8 +81,4 @@ elseif(WIN32)
-Wl,-pdb= -Wl,-pdb=
) )
endif() endif()
target_link_options(file PRIVATE
-static-libgcc
-static-libstdc++
)
endif() endif()

View File

@ -2,7 +2,6 @@
#define GERMANAIRLINESVA_FILE_LOGBOOK_H #define GERMANAIRLINESVA_FILE_LOGBOOK_H
#include <cstdint> #include <cstdint>
#include <cstring>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <utility> #include <utility>
@ -33,7 +32,7 @@ namespace file
private: private:
std::vector<LogbookEntry> entries; std::vector<LogbookEntry> entries;
void fromFile(const std::string &file); void fromFile();
void readVersion1(std::ifstream &in); void readVersion1(std::ifstream &in);
public: public:

View File

@ -2,15 +2,36 @@
#define GERMANAIRLINESVA_FILE_SIMDATABASE_H #define GERMANAIRLINESVA_FILE_SIMDATABASE_H
#include <cstdint> #include <cstdint>
#include <cstring>
#include <fstream> #include <fstream>
#include <functional>
#include <iostream>
#include <map> #include <map>
#include <stdexcept>
#include <string>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "geodata.hpp" #include "config/config.h"
#include "helpers.hpp" #include "constants.h"
#include "simdata/gate.h" #include "simdata/gate.h"
#include "simdata/runway.h" #include "simdata/runway.h"
#include "simdata/simdataXP.h"
/*
* Header
*
* CHAR[5] | UINT8
* --------+--------
* VGAS | VERSION
*/
/*
* Airport
*
* UINT8 | CHAR[] | UINT16 | GATE[] | UINT8 | RUNWAY[]
* --------+--------+----------+--------+---------+---------
* STRLEN | ICAO | NUMGATES | GATES | NUMRWYS | RUNWAYS
*/
namespace germanairlinesva namespace germanairlinesva
{ {
@ -21,41 +42,36 @@ namespace file
class SimDatabase class SimDatabase
{ {
private: private:
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>> std::map<
std::string,
std::pair<std::vector<const germanairlinesva::file::simdata::Gate>,
std::vector<const germanairlinesva::file::simdata::Runway>>>
airports; airports;
void fromFile();
void readVersion1(std::ifstream &in);
public: public:
void toFile(std::ofstream &out) const; SimDatabase(int xPlaneVersion,
const char *hash,
std::unique_ptr<config::Config> &configuration,
std::function<void(const std::string)> toLog);
const Gate *checkGate( void toFile() const;
const std::string icao,
const struct germanairlinesva::geodata::point coordinates) const;
inline std::size_t numAirports() const { return this->airports.size(); } inline std::size_t getCount() const { return this->airports.size(); }
inline const std::pair<std::vector<Gate>, std::vector<Runway>> & inline const std::pair<const std::vector<const Gate>, const std::vector<const Runway>>
getAirport(std::string icao) const operator[](std::string key)
{ {
return this->airports.at(icao); try {
} return this->airports.at(key);
inline void addAirport(std::string icao, } catch (std::out_of_range &ex) {
std::vector<Gate> &gates, return std::pair<const std::vector<const Gate>, const std::vector<const Runway>>();
std::vector<Runway> &runways) }
{
this->airports[icao] = std::make_pair(gates, runways);
}
template <class... Args>
inline void addGate(std::string icao, Args &&...args)
{
this->airports[icao].first.emplace_back(std::forward<Args>(args)...);
}
template <class... Args>
inline void addRunway(std::string icao, Args &&...args)
{
this->airports[icao].second.emplace_back(std::forward<Args>(args)...);
} }
}; };
} // namespace simdata } // namespace simdata
} // namespace file } // namespace file
} // namespace germanairlinesva } // namespace germanairlinesva
#endif #endif

View File

@ -27,9 +27,9 @@ namespace file
std::ofstream &logfile); std::ofstream &logfile);
void makeGate15(std::vector<Gate> &gates, void makeGate15(std::vector<Gate> &gates,
const std::vector<std::string> &fields); const std::vector<std::string> &fields);
void makeRunway(std::vector<Runway> &runways, void makeRunway(std::vector<const Runway> &runways,
const std::vector<std::string> &fields); const std::vector<std::string> &fields);
void makeGate1300(std::vector<Gate> &gates, void makeGate1300(std::vector<const Gate> &gates,
const std::vector<std::string> &fields); const std::vector<std::string> &fields);
} // namespace simdata } // namespace simdata
} // namespace file } // namespace file

View File

@ -1,114 +0,0 @@
#ifndef GERMANAIRLINESVA_FILE_SIMULATORDATABASE_H
#define GERMANAIRLINESVA_FILE_SIMULATORDATABASE_H
#include <cstdint>
#include <fstream>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "simdata/gate.h"
#include "simdata/runway.h"
#include "simdata/simDatabase.h"
/*
* Header
*
* CHAR[5] | UINT8
* --------+--------
* VGAS | VERSION
*/
/*
* Airport
*
* UINT8 | CHAR[] | UINT16 | GATE[] | UINT8 | RUNWAY[]
* --------+--------+----------+--------+---------+---------
* STRLEN | ICAO | NUMGATES | GATES | NUMRWYS | RUNWAYS
*/
namespace germanairlinesva
{
namespace file
{
namespace simdata
{
static inline void toFile(const SimDatabase &database,
const std::string &file)
{
std::ofstream out(file, std::fstream::binary);
// File Header, Last member is version
std::uint8_t header[] = {'V', 'G', 'A', 'S', '\0', 1};
out.write(reinterpret_cast<const char *>(header), 6);
database.toFile(out);
out.close();
}
static inline const SimDatabase readVersion1(std::ifstream &in)
{
SimDatabase database;
std::uint16_t numAirports = read<std::uint16_t>(in);
for (int i = 0; i < numAirports; i++) {
// ICAO
std::string icao = readString(in);
// Gates
std::uint16_t numGates = read<std::uint16_t>(in);
for (int j = 0; j < numGates; j++) {
std::string designator = readString(in);
struct germanairlinesva::geodata::point center =
read<struct germanairlinesva::geodata::point>(in);
std::uint8_t radius = read<std::uint8_t>(in);
database.addGate(icao, designator, center, radius);
}
// Runways
std::uint8_t numRunways = read<std::uint8_t>(in);
for (int j = 0; j < numRunways; j++) {
std::string designator = readString(in);
// Bounds
struct germanairlinesva::geodata::box bounds =
read<struct germanairlinesva::geodata::box>(in);
std::uint8_t width = read<std::uint8_t>(in);
std::uint16_t length = read<std::uint16_t>(in);
std::uint16_t trueHeading = read<std::uint16_t>(in);
database
.addRunway(icao, designator, bounds, width, length, trueHeading);
}
}
in.close();
return database;
}
static inline const SimDatabase fromFile(const std::string &file)
{
std::ifstream in(file, std::ifstream::binary);
// File Header
char ident[5];
in.read(ident, 5);
if (strcmp(ident, "VGAS") != 0) {
throw std::invalid_argument("Wrong file");
}
std::uint8_t version = read<std::uint8_t>(in);
if (version == 1) {
return readVersion1(in);
}
in.close();
return SimDatabase();
}
} // namespace simdata
} // namespace file
} // namespace germanairlinesva
#endif

View File

@ -9,22 +9,20 @@ namespace file
Logbook::Logbook() Logbook::Logbook()
{ {
if (germanairlinesva::util::fileExists(XPLANE_PLUGIN_DIRECTORY LOGBOOK)) { if (germanairlinesva::util::fileExists(XPLANE_PLUGIN_DIRECTORY LOGBOOK)) {
this->fromFile(XPLANE_PLUGIN_DIRECTORY LOGBOOK); this->fromFile();
} }
} }
void Logbook::fromFile(const std::string &file) void Logbook::fromFile()
{ {
std::ifstream in(file, std::ifstream::binary); std::ifstream in(XPLANE_PLUGIN_DIRECTORY LOGBOOK, std::ifstream::binary);
// File Header // File Header
char ident[5]; std::string ident = readString(in, 5);
in.read(ident, 5); if (ident.compare("VGAL") != 0) {
if (strcmp(ident, "VGAL") != 0) {
throw std::invalid_argument("Wrong file"); throw std::invalid_argument("Wrong file");
} }
std::uint8_t version; std::uint8_t version = read<std::uint8_t>(in);
in.read(reinterpret_cast<char *>(&version), 1);
if (version == 1) { if (version == 1) {
while (in.peek() != EOF) { while (in.peek() != EOF) {

View File

@ -6,33 +6,115 @@ namespace file
{ {
namespace simdata namespace simdata
{ {
void SimDatabase::toFile(std::ofstream &out) const SimDatabase::SimDatabase(int xPlaneVersion,
const char *hash,
std::unique_ptr<config::Config> &configuration,
std::function<void(const std::string)> toLog)
{ {
write<std::uint16_t>(out, this->airports.size()); if (strcmp(configuration->getScenery().c_str(), hash) != 0 ||
for (const auto &airport : this->airports) { !util::fileExists(XPLANE_PLUGIN_DIRECTORY SIMDATABASE)) {
writeString(out, airport.first); scan(xPlaneVersion < 12000 ? XPLANE11_BASE_SCENERY
write<std::uint16_t>(out, airport.second.first.size()); : XPLANE12_BASE_SCENERY,
for (const Gate &gate : airport.second.first) { XPLANE_CUSTOM_SCENERY,
gate.toFile(out); XPLANE_PLUGIN_DIRECTORY "log.txt",
} airports);
write<std::uint8_t>(out, airport.second.second.size());
for (const Runway &runway : airport.second.second) { configuration->updateScenery(hash);
runway.toFile(out); this->toFile();
}
toLog("Sim Database updated");
} else {
this->fromFile();
} }
} }
const Gate *SimDatabase::checkGate( void SimDatabase::fromFile()
const std::string icao,
const struct germanairlinesva::geodata::point coordinates) const
{ {
auto airport = this->getAirport(icao); std::ifstream in(XPLANE_PLUGIN_DIRECTORY SIMDATABASE,
for (const Gate &gate : airport.first) { std::ifstream::binary);
if (gate.contains(coordinates)) {
return &gate; // File Header
std::string ident = readString(in, 5);
if (ident.compare("VGAS") != 0) {
throw std::invalid_argument("Wrong file");
}
std::uint8_t version = read<std::uint8_t>(in);
if (version == 1) {
this->readVersion1(in);
}
}
void SimDatabase::readVersion1(std::ifstream &in)
{
std::uint16_t numAirports = read<std::uint16_t>(in);
for (int i = 0; i < numAirports; i++) {
// ICAO
std::string icao = readString(in);
// Gates
std::uint16_t numGates = read<std::uint16_t>(in);
for (int j = 0; j < numGates; j++) {
std::string designator = readString(in);
struct germanairlinesva::geodata::point center =
read<struct germanairlinesva::geodata::point>(in);
std::uint8_t radius = read<std::uint8_t>(in);
this->airports[icao].first.emplace_back(designator, center, radius);
}
// Runways
std::uint8_t numRunways = read<std::uint8_t>(in);
for (int j = 0; j < numRunways; j++) {
std::string designator = readString(in);
// Bounds
struct germanairlinesva::geodata::box bounds =
read<struct germanairlinesva::geodata::box>(in);
std::uint8_t width = read<std::uint8_t>(in);
std::uint16_t length = read<std::uint16_t>(in);
std::uint16_t trueHeading = read<std::uint16_t>(in);
this->airports[icao].second.emplace_back(designator,
bounds,
width,
length,
trueHeading);
} }
} }
return nullptr;
in.close();
}
void SimDatabase::toFile() const
{
std::ofstream out(XPLANE_PLUGIN_DIRECTORY SIMDATABASE,
std::fstream::binary);
// File Header, Last member is version
std::uint8_t header[] = {'V', 'G', 'A', 'S', '\0', 1};
out.write(reinterpret_cast<const char *>(header), 6);
// Num Airports
write<std::uint16_t>(out, airports.size());
// Airport
for (const std::pair<const std::string,
std::pair<std::vector<const Gate>, std::vector<const Runway>>>
&airport : airports) {
std::string icao = airport.first;
const std::vector<const Gate> gates = airport.second.first;
const std::vector<const Runway> runways = airport.second.second;
// ICAO
writeString(out, icao);
// Gates
write<std::uint16_t>(out, gates.size());
for (const Gate &gate : gates) {
gate.toFile(out);
}
// Runways
write<std::uint8_t>(out, runways.size());
for (const Runway &runway : runways) {
runway.toFile(out);
}
}
out.close();
} }
} // namespace simdata } // namespace simdata
} // namespace file } // namespace file

View File

@ -74,8 +74,8 @@ namespace file
{ {
std::string line; std::string line;
std::string *currentIcao = nullptr; std::string *currentIcao = nullptr;
std::vector<Gate> tmpGates; std::vector<const Gate> tmpGates;
std::vector<Runway> tmpRunways; std::vector<const Runway> tmpRunways;
int apCount = 0; int apCount = 0;
int validCount = 0; int validCount = 0;
@ -101,8 +101,8 @@ namespace file
logfile << "\t<STATUS> " << *currentIcao logfile << "\t<STATUS> " << *currentIcao
<< " had no gates or runways" << std::endl; << " had no gates or runways" << std::endl;
} }
tmpGates = std::vector<Gate>(); tmpGates = std::vector<const Gate>();
tmpRunways = std::vector<Runway>(); tmpRunways = std::vector<const Runway>();
currentIcao = new std::string(fields[4]); currentIcao = new std::string(fields[4]);
apCount += 1; apCount += 1;
logfile << "\t<" << kind << "> " << line << std::endl; logfile << "\t<" << kind << "> " << line << std::endl;
@ -121,8 +121,8 @@ namespace file
logfile << "\t<STATUS> " << *currentIcao logfile << "\t<STATUS> " << *currentIcao
<< " had no gates or runways" << std::endl; << " had no gates or runways" << std::endl;
} }
tmpGates = std::vector<Gate>(); tmpGates = std::vector<const Gate>();
tmpRunways = std::vector<Runway>(); tmpRunways = std::vector<const Runway>();
currentIcao = nullptr; currentIcao = nullptr;
logfile << "\t<" << kind << " SKIPPED> " << line << std::endl; logfile << "\t<" << kind << " SKIPPED> " << line << std::endl;
} else if (currentIcao != nullptr && fields[0] == "100") { } else if (currentIcao != nullptr && fields[0] == "100") {
@ -143,7 +143,7 @@ namespace file
<< validCount << " are valid" << std::endl; << validCount << " are valid" << std::endl;
} }
void makeGate15(std::vector<Gate> &gates, void makeGate15(std::vector<const Gate> &gates,
const std::vector<std::string> &fields) const std::vector<std::string> &fields)
{ {
std::string gateName; std::string gateName;
@ -158,7 +158,7 @@ namespace file
gates.emplace_back(gateName, pt, 40); gates.emplace_back(gateName, pt, 40);
} }
void makeRunway(std::vector<Runway> &runways, void makeRunway(std::vector<const Runway> &runways,
const std::vector<std::string> &fields) const std::vector<std::string> &fields)
{ {
runways.emplace_back(fields[8], runways.emplace_back(fields[8],
@ -175,7 +175,7 @@ namespace file
std::stod(fields[1])); std::stod(fields[1]));
} }
void makeGate1300(std::vector<Gate> &gates, void makeGate1300(std::vector<const Gate> &gates,
const std::vector<std::string> &fields) const std::vector<std::string> &fields)
{ {
std::string gateName; std::string gateName;

View File

@ -78,7 +78,6 @@ elseif(UNIX)
) )
target_link_libraries(ixwebsocket PRIVATE target_link_libraries(ixwebsocket PRIVATE
${OPENSSL_LIBRARIES} ${OPENSSL_LIBRARIES}
pthread
) )
elseif(WIN32) elseif(WIN32)
if (BIT STREQUAL "32") if (BIT STREQUAL "32")
@ -107,10 +106,6 @@ elseif(WIN32)
-Wl,-pdb= -Wl,-pdb=
) )
endif() endif()
target_link_options(ixwebsocket PRIVATE
-static-libgcc
-static-libstdc++
)
target_include_directories(ixwebsocket PRIVATE target_include_directories(ixwebsocket PRIVATE
${CMAKE_SOURCE_DIR}/openSSL/win${BIT}/include ${CMAKE_SOURCE_DIR}/openSSL/win${BIT}/include
) )
@ -124,4 +119,8 @@ elseif(WIN32)
) )
endif() endif()
target_link_libraries(ixwebsocket PRIVATE
pthread
)
add_library(ixwebsocket::ixwebsocket ALIAS ixwebsocket) add_library(ixwebsocket::ixwebsocket ALIAS ixwebsocket)

View File

@ -170,7 +170,7 @@ namespace util
static inline int static inline int
generateMD5(const char *filepath, generateMD5(const char *filepath,
char *lastHash, char *lastHash,
const std::function<void(const std::string)> &toLog) const std::function<void(const std::string)> toLog)
{ {
int file_descript; int file_descript;
unsigned long file_size; unsigned long file_size;
@ -205,7 +205,7 @@ namespace util
static inline int static inline int
generateMD5(const char *filepath, generateMD5(const char *filepath,
char *buffer, char *buffer,
const std::function<void(const std::string)> &toLog) const std::function<void(const std::string)> toLog)
{ {
int file_descriptor; int file_descriptor;
unsigned long file_size; unsigned long file_size;

View File

@ -80,9 +80,6 @@ elseif(UNIX)
target_compile_options(germanairlinesva_xplugin PRIVATE target_compile_options(germanairlinesva_xplugin PRIVATE
-nodefaultlibs -nodefaultlibs
) )
target_link_libraries(germanairlinesva_xplugin PRIVATE
pthread
)
elseif(WIN32) elseif(WIN32)
message("Building for Windows ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}") message("Building for Windows ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}")
@ -102,12 +99,6 @@ elseif(WIN32)
-Wl,-pdb= -Wl,-pdb=
) )
endif() endif()
target_link_options(germanairlinesva_xplugin PRIVATE
-static-libgcc
-static-libstdc++
)
target_link_libraries(germanairlinesva_xplugin PRIVATE
)
target_link_libraries(germanairlinesva_xplugin PRIVATE target_link_libraries(germanairlinesva_xplugin PRIVATE
${CMAKE_SOURCE_DIR}/XPSDK/Libraries/Win/XPLM_64.lib ${CMAKE_SOURCE_DIR}/XPSDK/Libraries/Win/XPLM_64.lib
) )
@ -118,4 +109,5 @@ endif()
target_link_libraries(germanairlinesva_xplugin PRIVATE target_link_libraries(germanairlinesva_xplugin PRIVATE
ixwebsocket ixwebsocket
pthread
) )

View File

@ -5,8 +5,8 @@
#include "constants.h" #include "constants.h"
#include "logbook/logbook.h" #include "logbook/logbook.h"
#include "recording/recording.h" #include "recording/recording.h"
#include "simdata/simDatabase.h"
#include "simdata/simdataXP.h" #include "simdata/simdataXP.h"
#include "simdata/simulatorDatabase.hpp"
#include "util.hpp" #include "util.hpp"
#include "websocket.h" #include "websocket.h"

View File

@ -10,9 +10,9 @@ std::thread serverThread;
std::thread recordingThread; std::thread recordingThread;
std::atomic<bool> wantsExit; std::atomic<bool> wantsExit;
germanairlinesva::file::config::Config configuration; std::unique_ptr<germanairlinesva::file::config::Config> configuration;
germanairlinesva::file::simdata::SimDatabase database; std::unique_ptr<germanairlinesva::file::simdata::SimDatabase> database;
germanairlinesva_websocket::Websocket *connector; std::unique_ptr<germanairlinesva_websocket::Websocket> connector;
int xplaneVersion; int xplaneVersion;
/* Datarefs */ /* Datarefs */
@ -111,49 +111,30 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
roll = XPLMFindDataRef("sim/flightmodel/position/phi"); // FLOAT roll = XPLMFindDataRef("sim/flightmodel/position/phi"); // FLOAT
quaternion = XPLMFindDataRef("sim/flightmodel/position/q"); // FLOAT[4] quaternion = XPLMFindDataRef("sim/flightmodel/position/q"); // FLOAT[4]
configuration = germanairlinesva::file::config::Config(); configuration = std::make_unique<germanairlinesva::file::config::Config>();
toLog("Config loaded"); toLog("Config loaded");
/*
try { try {
connector = new germanairlinesva_websocket::Websocket( connector = std::make_unique<germanairlinesva_websocket::Websocket>(
"wss://ws.hofmannnet.myhome-server.de:8000", "wss://ws.hofmannnet.myhome-server.de:8000",
configuration.getUser(), configuration->getUser(),
toLog); toLog);
} catch (const std::invalid_argument &e) { } catch (const std::invalid_argument &e) {
toLog(e.what()); toLog(e.what());
return 0; return 0;
} }
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::util::generateMD5(XPLANE_CUSTOM_SCENERY, hash, toLog) ==
0) { 0) {
database = std::make_unique<germanairlinesva::file::simdata::SimDatabase>(
xplaneVersion,
hash,
configuration,
toLog);
if (strcmp(configuration.getScenery().c_str(), hash) != 0 ||
!germanairlinesva::util::fileExists(
XPLANE_PLUGIN_DIRECTORY SIMDATABASE)) {
scan(xplaneVersion < 12000 ? XPLANE11_BASE_SCENERY
: XPLANE12_BASE_SCENERY,
XPLANE_CUSTOM_SCENERY,
XPLANE_PLUGIN_DIRECTORY "log.txt",
database);
germanairlinesva::file::simdata::toFile(
database,
XPLANE_PLUGIN_DIRECTORY SIMDATABASE);
configuration.updateScenery(hash);
toLog("Sim Database updated");
} else {
database = germanairlinesva::file::simdata::fromFile(
XPLANE_PLUGIN_DIRECTORY SIMDATABASE);
toLog("Sim Database loaded");
}
toLog("Binary readback test");
germanairlinesva::file::simdata::toFile(database,
XPLANE_PLUGIN_DIRECTORY "sim2.bin");
toLog("Readback test of sim database using EDDF"); toLog("Readback test of sim database using EDDF");
auto ap = database.getAirport("EDDF"); auto ap = (*database)["EDDF"];
for (const auto &it : ap.first) { for (const auto &it : ap.first) {
toLog(" " + it.to_string()); toLog(" " + it.to_string());
} }
@ -161,64 +142,17 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
toLog(" " + it.to_string()); toLog(" " + it.to_string());
} }
toLog("Readback test of sim database using XXXX"); toLog("Readback test of sim database using XXXX");
try { auto ap2 = (*database)["XXXX"];
ap = database.getAirport("XXXX"); ap2.first.size() == 0 ? toLog(" SUCCESS") : toLog(" ERROR");
toLog(" Return was non null ! ERROR");
} catch (std::out_of_range) {
toLog(" Return was null");
}
} }
// 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"); delete connector.release();
germanairlinesva::file::logbook::Logbook logbook; delete database.release();
logbook.addEntry("08.09.2022", delete configuration.release();
"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;
p.toFile("flight.rec"); p.toFile("flight.rec");