diff --git a/CMakeLists.txt b/CMakeLists.txt index 935f4fe..6e27d5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,6 @@ option(DEBUG "Debug symbols" OFF) add_subdirectory( ixwebsocket ) -add_subdirectory( - file -) if(NOT (WIN32 AND (BIT STREQUAL "32"))) add_subdirectory( xplugin diff --git a/TODO.md b/TODO.md index 9021437..f019edb 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,3 @@ -- Potentially revert to Header only File lib (NO LINKING) - Update OSXCross Docker image to SDK 11 - Implement ARM64 arch for Plugin - Implement Logbook PHP diff --git a/file/CMakeLists.txt b/file/CMakeLists.txt deleted file mode 100644 index fba2a1c..0000000 --- a/file/CMakeLists.txt +++ /dev/null @@ -1,84 +0,0 @@ -file(GLOB file CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/file/*.cpp) - -add_library(file SHARED - ${file} -) - -target_include_directories(file PRIVATE - ${CMAKE_SOURCE_DIR}/file/include - ${CMAKE_SOURCE_DIR}/simdata/include - ${CMAKE_SOURCE_DIR}/utilities/include -) - -set_target_properties(file PROPERTIES - PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/file/include -) -target_compile_options(file PRIVATE - -Wall - -Wextra - -pedantic -) -if(DEBUG) - target_compile_options(file PRIVATE - -g - ) - target_link_options(file PRIVATE - -g - ) -else() - target_compile_options(file PRIVATE - -O2 - ) -endif() - -if(APPLE) - message("Building file for MacOSX Universal into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}") - - set_target_properties(file PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}" - BUILD_WITH_INSTALL_NAME_DIR TRUE - ) - - target_compile_options(file PRIVATE - "SHELL:-arch x86_64" - ) - target_link_options(file PRIVATE - "SHELL:-arch x86_64" - ) - target_link_libraries(file PRIVATE - "-framework Security" - ) -elseif(UNIX) - message("Building file for Linux ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}") - - set_target_properties(file PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}" - ) - - target_compile_options(file PRIVATE - -nodefaultlibs - ) -elseif(WIN32) - if (BIT STREQUAL "32") - message("Building file for Windows ${BIT} into ${PROJECT_BINARY_DIR}/ESP/${PLUGIN_NAME}") - - set_target_properties(file PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/ESP/${PLUGIN_NAME}" - ) - else() - message("Building file for Windows ${BIT} into ${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}") - - set_target_properties(file PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/X-Plane/${PLUGIN_NAME}/${BIT}" - ) - endif() - - if(DEBUG) - target_compile_options(file PRIVATE - -gcodeview - ) - target_link_options(file PRIVATE - -Wl,-pdb= - ) - endif() -endif() diff --git a/file/include/config/config.hpp b/file/include/config/config.hpp index 84eca7e..1aca19c 100644 --- a/file/include/config/config.hpp +++ b/file/include/config/config.hpp @@ -1,5 +1,5 @@ -#ifndef GERMANAIRLINESVA_FILE_CONFIG_H -#define GERMANAIRLINESVA_FILE_CONFIG_H +#ifndef GERMANAIRLINESVA_FILE_CONFIG_CONFIG_H +#define GERMANAIRLINESVA_FILE_CONFIG_CONFIG_H #include diff --git a/file/include/logbook/logbook.h b/file/include/logbook/logbook.h deleted file mode 100644 index c8b6177..0000000 --- a/file/include/logbook/logbook.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef GERMANAIRLINESVA_FILE_LOGBOOK_H -#define GERMANAIRLINESVA_FILE_LOGBOOK_H - -#include -#include -#include -#include -#include - -#include "constants.h" -#include "helpers.hpp" -#include "logbookEntry.h" -#include "util.hpp" - -namespace germanairlinesva -{ -namespace file -{ - namespace logbook - { - /* - * Logbook Header (6) - * CHAR[5] | UINT8 - * --------+-------- - * VGAL | VERSION - * - * Logbook Entries (n) - * LOGBOOKENTRY[] - */ - class Logbook - { - private: - std::vector entries; - - void fromFile(); - void readVersion1(std::ifstream &in); - - public: - Logbook(); - - template inline void addEntry(Args &&...args) - { - this->entries.emplace_back(std::forward(args)...); - } - void toFile() const; - }; - } // namespace logbook -} // namespace file -} // namespace germanairlinesva -#endif \ No newline at end of file diff --git a/file/include/logbook/logbook.hpp b/file/include/logbook/logbook.hpp new file mode 100644 index 0000000..cb4d856 --- /dev/null +++ b/file/include/logbook/logbook.hpp @@ -0,0 +1,143 @@ +#ifndef GERMANAIRLINESVA_FILE_LOGBOOK_LOGBOOK_H +#define GERMANAIRLINESVA_FILE_LOGBOOK_LOGBOOK_H + +#include +#include +#include +#include +#include + +#include "constants.h" +#include "helpers.hpp" +#include "logbookEntry.hpp" +#include "util.hpp" + +namespace germanairlinesva +{ +namespace file +{ + namespace logbook + { + /* + * Logbook Header (6) + * CHAR[5] | UINT8 + * --------+-------- + * VGAL | VERSION + * + * Logbook Entries (n) + * LOGBOOKENTRY[] + */ + class Logbook + { + private: + std::vector entries; + + inline void readVersion1(std::ifstream &in) + { + std::string date = readString(in, 10); + std::string flightNumber = readString(in, 4); + std::string aircraftType = readString(in, 4); + std::string aircraftRegistration = readString(in, 6); + std::string departureAirport = readString(in); + std::string departureGate = readString(in); + std::string departureRunway = readString(in); + std::string arrivalAirport = readString(in); + std::string arrivalGate = readString(in); + std::string arrivalRunway = readString(in); + std::string offBlockTime = readString(in, 5); + std::string outTime = readString(in, 5); + std::string inTime = readString(in, 5); + std::string onBlockTime = readString(in, 5); + float totalFlightTime = read(in); + float taxiOutFuel = read(in); + float inFlightFuel = read(in); + float taxiInFuel = read(in); + float totalFuel = read(in); + float taxiOutDistance = read(in); + float inFlightDistance = read(in); + float taxiInDistance = read(in); + float totalDistance = read(in); + float maxLandingRate = read(in); + std::uint8_t touchdowns = read(in); + float maxLandingGees = read(in); + std::string recordingFilename = readString(in); + float points = read(in); + std::uint8_t flags = read(in); + + this->addEntry(date, + flightNumber, + aircraftType, + aircraftRegistration, + departureAirport, + departureGate, + departureRunway, + arrivalAirport, + arrivalGate, + arrivalRunway, + offBlockTime, + outTime, + inTime, + onBlockTime, + totalFlightTime, + taxiOutFuel, + inFlightFuel, + taxiInFuel, + totalFuel, + taxiOutDistance, + inFlightDistance, + taxiInDistance, + totalDistance, + maxLandingRate, + touchdowns, + maxLandingGees, + recordingFilename, + points, + flags); + } + + inline void fromFile() + { + std::ifstream in(BASE_DIRECTORY LOGBOOK, std::ifstream::binary); + + // File Header + std::string ident = readString(in, 5); + if (ident.compare("VGAL") != 0) { + throw std::invalid_argument("Wrong file"); + } + std::uint8_t version = read(in); + + if (version == 1) { + while (in.peek() != EOF) { + this->readVersion1(in); + } + } + } + + public: + inline Logbook() + { + if (util::fileExists(BASE_DIRECTORY LOGBOOK)) { + this->fromFile(); + } + } + + template inline void addEntry(Args &&...args) + { + this->entries.emplace_back(std::forward(args)...); + } + + inline void toFile() const + { + std::ofstream out(BASE_DIRECTORY LOGBOOK, std::fstream::binary); + char header[] = {'V', 'G', 'A', 'L', '\0', 1}; + out.write(header, 6); + for (const LogbookEntry &entry : this->entries) { + entry.toFile(out); + } + out.close(); + } + }; + } // namespace logbook +} // namespace file +} // namespace germanairlinesva +#endif \ No newline at end of file diff --git a/file/include/logbook/logbookEntry.h b/file/include/logbook/logbookEntry.h deleted file mode 100644 index 36e23ea..0000000 --- a/file/include/logbook/logbookEntry.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef GERMANAIRLINESVA_FILE_LOGBOOKENTRY_H -#define GERMANAIRLINESVA_FILE_LOGBOOKENTRY_H - -#include -#include -#include -#include - -#include "helpers.hpp" - -namespace germanairlinesva -{ -namespace file -{ - namespace logbook - { - /* - * Preamble (24) - * CHAR[10] | CHAR[4] | CHAR[4] | CHAR[6] - * ---------+---------------+----------+------------- - * DATE | FLIGHT NUMBER | AIRCRAFT | REGISTRATION - - * Departure Airport Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Departure Gate Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Departure Runway Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Arrival Airport Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Arrival Gate Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Arrival Runway Name (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Times (24) - * CHAR[5] | CHAR[5] | CHAR[5] | CHAR[4] | FLOAT - * ----------+---------------+--------------+---------------+------ - * OFF BLOCK | TAKEOFF (OUT) | LANDING (ON) | ON BLOCK (IN) | TOTAL - - * Fuels (16) - * FLOAT | FLOAT | FLOAT | FLOAT - * ---------+-----------+---------+------ - * TAXI OUT | IN FLIGHT | TAXI IN | TOTAL - - * Distances (16) - * FLOAT | FLOAT | FLOAT |FLOAT - * ---------+-----------+---------+----- - * TAXI OUT | IN FLIGHT | TAXI IN |TOTAL - - * Landing (9) - * FLOAT | CHAR | FLOAT - * ---------+---------- +------------ - * MAX RATE | TOUCHDOWNS | MAX G-FORCE - - * Recording Filename (2...256) - * UINT8 | CHAR[] - * -------+------- - * STRLEN | STRING - - * Postamble (5) - * FLOAT | BITFIELD - * -------+--------- - * POINTS | FLAGS - - * Flags Bitfield - * 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 - * ----+-----+-----+-----+-----+-----+-----+------ - * NIL | NIL | NIL | NIL | NIL | NIL | NIL | FILED - */ - class LogbookEntry - { - private: - std::string date; - std::string flightNumber; - std::string aircraftType; - std::string aircraftRegistration; - std::string departureAirport; - std::string departureGate; - std::string departureRunway; - std::string arrivalAirport; - std::string arrivalGate; - std::string arrivalRunway; - std::string offBlockTime; - std::string outTime; - std::string onTime; - std::string onBlockTime; - float totalFlightTime; - float taxiOutFuel; - float inFlightFuel; - float taxiInFuel; - float totalFuel; - float taxiOutDistance; - float inFlightDistance; - float taxiInDistance; - float totalDistance; - float maxLandingRate; - std::uint8_t touchdowns; - float maxLandingGees; - std::string recordingFilename; - float points; - std::uint8_t flags; - - public: - LogbookEntry(std::string date, - std::string flightNumber, - std::string aircraftType, - std::string aircraftRegistration, - std::string departureAirport, - std::string departureGate, - std::string departureRunway, - std::string arrivalAirport, - std::string arrivalGate, - std::string arrivalRunway, - std::string offBlockTime, - std::string outTime, - std::string onTime, - std::string onBlockTime, - float totalFlightTime, - float taxiOutFuel, - float inFlightFuel, - float taxiInFuel, - float totalFuel, - float taxiOutDistance, - float inFlightDistance, - float taxiInDistance, - float totalDistance, - float maxLandingRate, - std::uint8_t touchdowns, - float maxLandingGees, - std::string recordingFilename, - float points, - std::uint8_t flags); - - void toFile(std::ofstream &out) const; - }; - } // namespace logbook -} // namespace file -} // namespace germanairlinesva - -#endif \ No newline at end of file diff --git a/file/include/logbook/logbookEntry.hpp b/file/include/logbook/logbookEntry.hpp new file mode 100644 index 0000000..a241015 --- /dev/null +++ b/file/include/logbook/logbookEntry.hpp @@ -0,0 +1,207 @@ +#ifndef GERMANAIRLINESVA_FILE_LOGBOOK_LOGBOOKENTRY_H +#define GERMANAIRLINESVA_FILE_LOGBOOK_LOGBOOKENTRY_H + +#include +#include +#include +#include + +#include "helpers.hpp" + +namespace germanairlinesva +{ +namespace file +{ + namespace logbook + { + /* + * Preamble (24) + * CHAR[10] | CHAR[4] | CHAR[4] | CHAR[6] + * ---------+---------------+----------+------------- + * DATE | FLIGHT NUMBER | AIRCRAFT | REGISTRATION + + * Departure Airport Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Departure Gate Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Departure Runway Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Arrival Airport Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Arrival Gate Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Arrival Runway Name (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Times (24) + * CHAR[5] | CHAR[5] | CHAR[5] | CHAR[4] | FLOAT + * ----------+---------------+--------------+---------------+------ + * OFF BLOCK | TAKEOFF (OUT) | LANDING (ON) | ON BLOCK (IN) | TOTAL + + * Fuels (16) + * FLOAT | FLOAT | FLOAT | FLOAT + * ---------+-----------+---------+------ + * TAXI OUT | IN FLIGHT | TAXI IN | TOTAL + + * Distances (16) + * FLOAT | FLOAT | FLOAT |FLOAT + * ---------+-----------+---------+----- + * TAXI OUT | IN FLIGHT | TAXI IN |TOTAL + + * Landing (9) + * FLOAT | CHAR | FLOAT + * ---------+---------- +------------ + * MAX RATE | TOUCHDOWNS | MAX G-FORCE + + * Recording Filename (2...256) + * UINT8 | CHAR[] + * -------+------- + * STRLEN | STRING + + * Postamble (5) + * FLOAT | BITFIELD + * -------+--------- + * POINTS | FLAGS + + * Flags Bitfield + * 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 + * ----+-----+-----+-----+-----+-----+-----+------ + * NIL | NIL | NIL | NIL | NIL | NIL | NIL | FILED + */ + class LogbookEntry + { + private: + std::string date; + std::string flightNumber; + std::string aircraftType; + std::string aircraftRegistration; + std::string departureAirport; + std::string departureGate; + std::string departureRunway; + std::string arrivalAirport; + std::string arrivalGate; + std::string arrivalRunway; + std::string offBlockTime; + std::string outTime; + std::string onTime; + std::string onBlockTime; + float totalFlightTime; + float taxiOutFuel; + float inFlightFuel; + float taxiInFuel; + float totalFuel; + float taxiOutDistance; + float inFlightDistance; + float taxiInDistance; + float totalDistance; + float maxLandingRate; + std::uint8_t touchdowns; + float maxLandingGees; + std::string recordingFilename; + float points; + std::uint8_t flags; + + public: + inline LogbookEntry(std::string date, + std::string flightNumber, + std::string aircraftType, + std::string aircraftRegistration, + std::string departureAirport, + std::string departureGate, + std::string departureRunway, + std::string arrivalAirport, + std::string arrivalGate, + std::string arrivalRunway, + std::string offBlockTime, + std::string outTime, + std::string onTime, + std::string onBlockTime, + float totalFlightTime, + float taxiOutFuel, + float inFlightFuel, + float taxiInFuel, + float totalFuel, + float taxiOutDistance, + float inFlightDistance, + float taxiInDistance, + float totalDistance, + float maxLandingRate, + std::uint8_t touchdowns, + float maxLandingGees, + std::string recordingFilename, + float points, + std::uint8_t flags) + : date(date), flightNumber(flightNumber), + aircraftType(aircraftType), + aircraftRegistration(aircraftRegistration), + departureAirport(departureAirport), departureGate(departureGate), + departureRunway(departureRunway), arrivalAirport(arrivalAirport), + arrivalGate(arrivalGate), arrivalRunway(arrivalRunway), + offBlockTime(offBlockTime), outTime(outTime), onTime(onTime), + onBlockTime(onBlockTime), totalFlightTime(totalFlightTime), + taxiOutFuel(taxiOutFuel), inFlightFuel(inFlightFuel), + taxiInFuel(taxiInFuel), totalFuel(totalFuel), + taxiOutDistance(taxiOutDistance), + inFlightDistance(inFlightDistance), + taxiInDistance(taxiInDistance), totalDistance(totalDistance), + maxLandingRate(maxLandingRate), touchdowns(touchdowns), + maxLandingGees(maxLandingGees), + recordingFilename(recordingFilename), points(points), flags(flags) + { + } + + inline void toFile(std::ofstream &out) const + { + writeString(out, this->date, 10); + writeString(out, this->flightNumber, 4); + writeString(out, this->aircraftType, 4); + writeString(out, this->aircraftRegistration, 6); + writeString(out, this->departureAirport); + writeString(out, this->departureGate); + writeString(out, this->departureRunway); + writeString(out, this->arrivalAirport); + writeString(out, this->arrivalGate); + writeString(out, this->arrivalRunway); + writeString(out, this->offBlockTime, 5); + writeString(out, this->outTime, 5); + writeString(out, this->onTime, 5); + writeString(out, this->onBlockTime, 5); + writetotalFlightTime)>(out, this->totalFlightTime); + writetaxiOutFuel)>(out, this->taxiOutFuel); + writeinFlightFuel)>(out, this->inFlightFuel); + writetaxiInFuel)>(out, this->taxiInFuel); + writetotalFuel)>(out, this->totalFuel); + writetaxiOutDistance)>(out, this->taxiOutDistance); + writeinFlightDistance)>(out, this->inFlightDistance); + writetaxiInDistance)>(out, this->taxiInDistance); + writetotalDistance)>(out, this->totalDistance); + writemaxLandingRate)>(out, this->maxLandingRate); + writetouchdowns)>(out, this->touchdowns); + writemaxLandingGees)>(out, this->maxLandingGees); + writeString(out, this->recordingFilename); + writepoints)>(out, this->points); + writeflags)>(out, this->flags); + } + }; + } // namespace logbook +} // namespace file +} // namespace germanairlinesva + +#endif \ No newline at end of file diff --git a/file/include/recording/recording.h b/file/include/recording/recording.hpp similarity index 56% rename from file/include/recording/recording.h rename to file/include/recording/recording.hpp index 38465d9..37b0a60 100644 --- a/file/include/recording/recording.h +++ b/file/include/recording/recording.hpp @@ -1,12 +1,12 @@ -#ifndef GERMANAIRLINESVA_FILE_RECORDING_H -#define GERMANAIRLINESVA_FILE_RECORDING_H +#ifndef GERMANAIRLINESVA_FILE_RECORDING_RECORDING_H +#define GERMANAIRLINESVA_FILE_RECORDING_RECORDING_H #include #include #include #include "constants.h" -#include "recordingEntry.h" +#include "recordingEntry.hpp" namespace germanairlinesva { @@ -36,7 +36,18 @@ namespace file { this->entries.emplace_back(std::forward(args)...); } - void toFile(std::string fileName) const; + + inline void toFile(std::string fileName) const + { + std::ofstream out(BASE_DIRECTORY RECORDING_DIRECTORY + fileName, + std::fstream::binary); + char header[] = {'V', 'G', 'A', 'R', '\0', 1}; + out.write(header, 6); + for (const RecordingEntry &entry : this->entries) { + entry.toFile(out); + } + out.close(); + } }; } // namespace recording } // namespace file diff --git a/file/include/recording/recordingEntry.h b/file/include/recording/recordingEntry.hpp similarity index 59% rename from file/include/recording/recordingEntry.h rename to file/include/recording/recordingEntry.hpp index 8befabb..874f54d 100644 --- a/file/include/recording/recordingEntry.h +++ b/file/include/recording/recordingEntry.hpp @@ -24,20 +24,28 @@ namespace file { private: std::uint32_t time; - std::uint16_t altitude = 0; - std::uint16_t groundSpeed = 0; - struct geodata::point coordinates { - NAN, NAN - }; + std::uint16_t altitude; + std::uint16_t groundSpeed; + struct geodata::point coordinates; public: - RecordingEntry() = default; - RecordingEntry(std::uint32_t time, - std::uint16_t altitude, - std::uint16_t groundSpeed, - struct geodata::point coordinates); + inline RecordingEntry() = default; + inline RecordingEntry(std::uint32_t time, + std::uint16_t altitude, + std::uint16_t groundSpeed, + struct geodata::point coordinates) + : time(time), altitude(altitude), groundSpeed(groundSpeed), + coordinates(coordinates) + { + } - void toFile(std::ofstream &out) const; + inline void toFile(std::ofstream &out) const + { + writetime)>(out, this->time); + writealtitude)>(out, this->altitude); + writegroundSpeed)>(out, this->groundSpeed); + writecoordinates)>(out, this->coordinates); + } friend inline bool operator==(const RecordingEntry &lhs, const RecordingEntry &rhs) diff --git a/file/include/simdata/gate.hpp b/file/include/simdata/gate.hpp index fcd169b..0c8eb34 100644 --- a/file/include/simdata/gate.hpp +++ b/file/include/simdata/gate.hpp @@ -1,5 +1,5 @@ -#ifndef GERMANAIRLINESVA_FILE_GATE_H -#define GERMANAIRLINESVA_FILE_GATE_H +#ifndef GERMANAIRLINESVA_FILE_SIMDATA_GATE_H +#define GERMANAIRLINESVA_FILE_SIMDATA_GATE_H #include #include diff --git a/file/include/simdata/runway.hpp b/file/include/simdata/runway.hpp index 921069b..7733f5b 100644 --- a/file/include/simdata/runway.hpp +++ b/file/include/simdata/runway.hpp @@ -1,5 +1,5 @@ -#ifndef GERMANAIRLINESVA_FILE_RUNWAY_H -#define GERMANAIRLINESVA_FILE_RUNWAY_H +#ifndef GERMANAIRLINESVA_FILE_SIMDATA_RUNWAY_H +#define GERMANAIRLINESVA_FILE_SIMDATA_RUNWAY_H #include #include diff --git a/file/include/simdata/simDatabase.hpp b/file/include/simdata/simDatabase.hpp index 73e264a..75a28bc 100644 --- a/file/include/simdata/simDatabase.hpp +++ b/file/include/simdata/simDatabase.hpp @@ -1,5 +1,5 @@ -#ifndef GERMANAIRLINESVA_FILE_SIMDATABASE_H -#define GERMANAIRLINESVA_FILE_SIMDATABASE_H +#ifndef GERMANAIRLINESVA_FILE_SIMDATA_SIMDATABASE_H +#define GERMANAIRLINESVA_FILE_SIMDATA_SIMDATABASE_H #include #include diff --git a/file/include/simdata/simdataXP.hpp b/file/include/simdata/simdataXP.hpp index 0428343..84d0d00 100644 --- a/file/include/simdata/simdataXP.hpp +++ b/file/include/simdata/simdataXP.hpp @@ -1,5 +1,5 @@ -#ifndef GERMANAIRLINESVA_FILE_SIMDATAXP_H -#define GERMANAIRLINESVA_FILE_SIMDATAXP_H +#ifndef GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAXP_H +#define GERMANAIRLINESVA_FILE_SIMDATA_SIMDATAXP_H #include #include diff --git a/file/logbook.cpp b/file/logbook.cpp deleted file mode 100644 index d65bd76..0000000 --- a/file/logbook.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "logbook/logbook.h" - -namespace germanairlinesva -{ -namespace file -{ - namespace logbook - { - Logbook::Logbook() - { - if (util::fileExists(BASE_DIRECTORY LOGBOOK)) { - this->fromFile(); - } - } - - void Logbook::fromFile() - { - std::ifstream in(BASE_DIRECTORY LOGBOOK, std::ifstream::binary); - - // File Header - std::string ident = readString(in, 5); - if (ident.compare("VGAL") != 0) { - throw std::invalid_argument("Wrong file"); - } - std::uint8_t version = read(in); - - if (version == 1) { - while (in.peek() != EOF) { - this->readVersion1(in); - } - } - } - - void Logbook::readVersion1(std::ifstream &in) - { - std::string date = readString(in, 10); - std::string flightNumber = readString(in, 4); - std::string aircraftType = readString(in, 4); - std::string aircraftRegistration = readString(in, 6); - std::string departureAirport = readString(in); - std::string departureGate = readString(in); - std::string departureRunway = readString(in); - std::string arrivalAirport = readString(in); - std::string arrivalGate = readString(in); - std::string arrivalRunway = readString(in); - std::string offBlockTime = readString(in, 5); - std::string outTime = readString(in, 5); - std::string inTime = readString(in, 5); - std::string onBlockTime = readString(in, 5); - float totalFlightTime = read(in); - float taxiOutFuel = read(in); - float inFlightFuel = read(in); - float taxiInFuel = read(in); - float totalFuel = read(in); - float taxiOutDistance = read(in); - float inFlightDistance = read(in); - float taxiInDistance = read(in); - float totalDistance = read(in); - float maxLandingRate = read(in); - std::uint8_t touchdowns = read(in); - float maxLandingGees = read(in); - std::string recordingFilename = readString(in); - float points = read(in); - std::uint8_t flags = read(in); - - this->addEntry(date, - flightNumber, - aircraftType, - aircraftRegistration, - departureAirport, - departureGate, - departureRunway, - arrivalAirport, - arrivalGate, - arrivalRunway, - offBlockTime, - outTime, - inTime, - onBlockTime, - totalFlightTime, - taxiOutFuel, - inFlightFuel, - taxiInFuel, - totalFuel, - taxiOutDistance, - inFlightDistance, - taxiInDistance, - totalDistance, - maxLandingRate, - touchdowns, - maxLandingGees, - recordingFilename, - points, - flags); - } - - void Logbook::toFile() const - { - std::ofstream out(BASE_DIRECTORY LOGBOOK, std::fstream::binary); - char header[] = {'V', 'G', 'A', 'L', '\0', 1}; - out.write(header, 6); - for (const LogbookEntry &entry : this->entries) { - entry.toFile(out); - } - out.close(); - } - } // namespace logbook -} // namespace file -} // namespace germanairlinesva \ No newline at end of file diff --git a/file/logbookEntry.cpp b/file/logbookEntry.cpp deleted file mode 100644 index f6bbee8..0000000 --- a/file/logbookEntry.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "logbook/logbookEntry.h" - -namespace germanairlinesva -{ -namespace file -{ - namespace logbook - { - LogbookEntry::LogbookEntry(std::string date, - std::string flightNumber, - std::string aircraftType, - std::string aircraftRegistration, - std::string departureAirport, - std::string departureGate, - std::string departureRunway, - std::string arrivalAirport, - std::string arrivalGate, - std::string arrivalRunway, - std::string offBlockTime, - std::string outTime, - std::string onTime, - std::string onBlockTime, - float totalFlightTime, - float taxiOutFuel, - float inFlightFuel, - float taxiInFuel, - float totalFuel, - float taxiOutDistance, - float inFlightDistance, - float taxiInDistance, - float totalDistance, - float maxLandingRate, - std::uint8_t touchdowns, - float maxLandingGees, - std::string recordingFilename, - float points, - std::uint8_t flags) - { - this->date = date; - this->flightNumber = flightNumber; - this->aircraftType = aircraftType; - this->aircraftRegistration = aircraftRegistration; - this->departureAirport = departureAirport; - this->departureGate = departureGate; - this->departureRunway = departureRunway; - this->arrivalAirport = arrivalAirport; - this->arrivalGate = arrivalGate; - this->arrivalRunway = arrivalRunway; - this->offBlockTime = offBlockTime; - this->outTime = outTime; - this->onTime = onTime; - this->onBlockTime = onBlockTime; - this->totalFlightTime = totalFlightTime; - this->taxiOutFuel = taxiOutFuel; - this->inFlightFuel = inFlightFuel; - this->taxiInFuel = taxiInFuel; - this->totalFuel = totalFuel; - this->taxiOutDistance = taxiOutDistance; - this->inFlightDistance = inFlightDistance; - this->taxiInDistance = taxiInDistance; - this->totalDistance = totalDistance; - this->maxLandingRate = maxLandingRate; - this->touchdowns = touchdowns; - this->maxLandingGees = maxLandingGees; - this->recordingFilename = recordingFilename; - this->points = points; - this->flags = flags; - } - - void LogbookEntry::toFile(std::ofstream &out) const - { - writeString(out, this->date, 10); - writeString(out, this->flightNumber, 4); - writeString(out, this->aircraftType, 4); - writeString(out, this->aircraftRegistration, 6); - writeString(out, this->departureAirport); - writeString(out, this->departureGate); - writeString(out, this->departureRunway); - writeString(out, this->arrivalAirport); - writeString(out, this->arrivalGate); - writeString(out, this->arrivalRunway); - writeString(out, this->offBlockTime, 5); - writeString(out, this->outTime, 5); - writeString(out, this->onTime, 5); - writeString(out, this->onBlockTime, 5); - writetotalFlightTime)>(out, this->totalFlightTime); - writetaxiOutFuel)>(out, this->taxiOutFuel); - writeinFlightFuel)>(out, this->inFlightFuel); - writetaxiInFuel)>(out, this->taxiInFuel); - writetotalFuel)>(out, this->totalFuel); - writetaxiOutDistance)>(out, this->taxiOutDistance); - writeinFlightDistance)>(out, this->inFlightDistance); - writetaxiInDistance)>(out, this->taxiInDistance); - writetotalDistance)>(out, this->totalDistance); - writemaxLandingRate)>(out, this->maxLandingRate); - writetouchdowns)>(out, this->touchdowns); - writemaxLandingGees)>(out, this->maxLandingGees); - writeString(out, this->recordingFilename); - writepoints)>(out, this->points); - writeflags)>(out, this->flags); - } - } // namespace logbook -} // namespace file -} // namespace germanairlinesva \ No newline at end of file diff --git a/file/recording.cpp b/file/recording.cpp deleted file mode 100644 index 87bcdb4..0000000 --- a/file/recording.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "recording/recording.h" - -namespace germanairlinesva -{ -namespace file -{ - namespace recording - { - void Recording::toFile(std::string fileName) const - { - std::ofstream out(BASE_DIRECTORY RECORDING_DIRECTORY + fileName, - std::fstream::binary); - char header[] = {'V', 'G', 'A', 'R', '\0', 1}; - out.write(header, 6); - for (const RecordingEntry &entry : this->entries) { - entry.toFile(out); - } - out.close(); - } - } // namespace recording -} // namespace file -} // namespace germanairlinesva \ No newline at end of file diff --git a/file/recordingEntry.cpp b/file/recordingEntry.cpp deleted file mode 100644 index 9c5aefd..0000000 --- a/file/recordingEntry.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "recording/recordingEntry.h" - - -namespace germanairlinesva -{ -namespace file -{ - namespace recording - { - RecordingEntry::RecordingEntry(std::uint32_t time, - std::uint16_t altitude, - std::uint16_t groundSpeed, - struct geodata::point coordinates) - { - this->time = time; - this->altitude = altitude; - this->groundSpeed = groundSpeed; - this->coordinates = coordinates; - }; - - void RecordingEntry::toFile(std::ofstream &out) const - { - writetime)>(out, this->time); - writealtitude)>(out, this->altitude); - writegroundSpeed)>(out, this->groundSpeed); - writecoordinates)>(out, this->coordinates); - } - } // namespace recording -} // namespace file -} // namespace germanairlinesva \ No newline at end of file diff --git a/xplugin/CMakeLists.txt b/xplugin/CMakeLists.txt index a090c05..63d73be 100644 --- a/xplugin/CMakeLists.txt +++ b/xplugin/CMakeLists.txt @@ -1,9 +1,7 @@ file(GLOB socket CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/websocket/*.cpp) -file(GLOB file CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/file/*.cpp) add_library(germanairlinesva_xplugin SHARED ${socket} - ${file} main.cpp ) diff --git a/xplugin/include/main.h b/xplugin/include/main.h index 727c205..aa4063d 100644 --- a/xplugin/include/main.h +++ b/xplugin/include/main.h @@ -3,8 +3,8 @@ #include "config/config.hpp" #include "constants.h" -#include "logbook/logbook.h" -#include "recording/recording.h" +#include "logbook/logbook.hpp" +#include "recording/recording.hpp" #include "simdata/simDatabase.hpp" #include "util.hpp" #include "websocket.h"