Initial Logbook read and write
This commit is contained in:
@@ -45,10 +45,10 @@ else()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
message("Building for MacOSX Universal into ${PROJECT_BINARY_DIR}/${PLUGIN_NAME}/${BIT}")
|
||||
message("Building for MacOSX Universal into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}")
|
||||
|
||||
set_target_properties(germanairlinesva_xplugin PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Plugin/${PLUGIN_NAME}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}
|
||||
INSTALL_RPATH "@loader_path"
|
||||
OUTPUT_NAME mac
|
||||
)
|
||||
@@ -66,10 +66,10 @@ if(APPLE)
|
||||
${CMAKE_SOURCE_DIR}/XPSDK/Libraries/Mac/XPLM.framework/XPLM
|
||||
)
|
||||
elseif(UNIX)
|
||||
message("Building for Linux ${BIT} into ${PROJECT_BINARY_DIR}/Plugin/${PLUGIN_NAME}/${BIT}")
|
||||
message("Building for Linux ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}")
|
||||
|
||||
set_target_properties(germanairlinesva_xplugin PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Plugin/${PLUGIN_NAME}/${BIT}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}
|
||||
INSTALL_RPATH "\$ORIGIN"
|
||||
OUTPUT_NAME lin
|
||||
)
|
||||
@@ -84,10 +84,10 @@ elseif(UNIX)
|
||||
pthread
|
||||
)
|
||||
elseif(WIN32)
|
||||
message("Building for Windows ${BIT} into ${PROJECT_BINARY_DIR}/Plugin/${PLUGIN_NAME}/${BIT}")
|
||||
message("Building for Windows ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}")
|
||||
|
||||
set_target_properties(germanairlinesva_xplugin PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Plugin/${PLUGIN_NAME}/${BIT}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}
|
||||
OUTPUT_NAME win
|
||||
)
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
#define GERMANAIRLINESVA_GACONNECTOR_XPLUGIN_MAIN_H
|
||||
|
||||
#include "config.hpp"
|
||||
#include "constants.h"
|
||||
#include "logbook.h"
|
||||
#include "pathRecording.h"
|
||||
#include "simdata.h"
|
||||
#include "simulatorDatabase.hpp"
|
||||
#include "util.hpp"
|
||||
#include "websocket.h"
|
||||
|
||||
#include "XPLM/XPLMDataAccess.h"
|
||||
|
||||
+48
-17
@@ -114,8 +114,8 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
roll = XPLMFindDataRef("sim/flightmodel/position/phi"); // FLOAT
|
||||
quaternion = XPLMFindDataRef("sim/flightmodel/position/q"); // FLOAT[4]
|
||||
|
||||
configuration = germanairlinesva_config::readConfig(
|
||||
"Resources/plugins/GAConnector/config.cfg");
|
||||
configuration =
|
||||
germanairlinesva_config::readConfig(XPLANE_PLUGIN_DIRECTORY CONFIG);
|
||||
toLog("Config loaded");
|
||||
|
||||
try {
|
||||
@@ -130,29 +130,27 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
toLog("WebSocket started");
|
||||
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (germanairlinesva_util::generateMD5("Custom Scenery/scenery_packs.ini",
|
||||
hash,
|
||||
toLog) == 0) {
|
||||
if (germanairlinesva_util::generateMD5(XPLANE_CUSTOM_SCENERY, hash, toLog) ==
|
||||
0) {
|
||||
|
||||
if (strcmp(configuration["scenery"].c_str(), hash) != 0 ||
|
||||
!germanairlinesva_util::fileExists(
|
||||
"Resources/plugins/GAConnector/sim.bin")) {
|
||||
scan("Resources/default scenery/default apt dat/Earth nav "
|
||||
"data/apt.dat",
|
||||
"Custom Scenery/scenery_packs.ini",
|
||||
"Resources/plugins/GAConnector/log.txt",
|
||||
XPLANE_PLUGIN_DIRECTORY SIMDATABASE)) {
|
||||
scan(xplaneVersion < 12000 ? XPLANE11_BASE_SCENERY
|
||||
: XPLANE12_BASE_SCENERY,
|
||||
XPLANE_CUSTOM_SCENERY,
|
||||
XPLANE_PLUGIN_DIRECTORY "log.txt",
|
||||
airports);
|
||||
germanairlinesva_simdata::toFile(airports,
|
||||
"Resources/plugins/GAConnector/sim.bin");
|
||||
XPLANE_PLUGIN_DIRECTORY SIMDATABASE);
|
||||
|
||||
configuration["scenery"] = hash;
|
||||
germanairlinesva_config::writeConfig(
|
||||
configuration,
|
||||
"Resources/plugins/GAConnector/config.cfg");
|
||||
germanairlinesva_config::writeConfig(configuration,
|
||||
XPLANE_PLUGIN_DIRECTORY CONFIG);
|
||||
toLog("Sim Database updated");
|
||||
} else {
|
||||
airports = germanairlinesva_simdata::fromFile(
|
||||
"Resources/plugins/GAConnector/sim.bin");
|
||||
XPLANE_PLUGIN_DIRECTORY SIMDATABASE);
|
||||
toLog("Sim Database loaded");
|
||||
}
|
||||
|
||||
@@ -171,6 +169,39 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
recordingThread = std::thread(&recordingWorker);
|
||||
toLog("Workers started");
|
||||
|
||||
toLog("Logbook Test");
|
||||
germanairlinesva_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;
|
||||
}
|
||||
|
||||
@@ -184,7 +215,7 @@ PLUGIN_API void XPluginStop(void)
|
||||
serverThread.join();
|
||||
recordingThread.join();
|
||||
|
||||
std::ofstream out("Resources/plugins/GAConnector/flight.rec",
|
||||
std::ofstream out(XPLANE_PLUGIN_DIRECTORY RECORDING_DIRECTORY "flight.rec",
|
||||
std::fstream::binary);
|
||||
out.write(reinterpret_cast<const char *>(p.getBinaryData()),
|
||||
(std::streamsize)p.getBinaryLength());
|
||||
@@ -209,7 +240,7 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
memset(&toSend, 0, sizeof(germanairlinesva_websocket::data));
|
||||
std::memset(&toSend, 0, sizeof(germanairlinesva_websocket::data));
|
||||
|
||||
toSend.pause = XPLMGetDatai(pauseIndicator);
|
||||
toSend.pBrake = XPLMGetDataf(parkingBrake);
|
||||
|
||||
Reference in New Issue
Block a user