Start on Logbook
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_LOGBOOK_H
|
||||
#define GERMANAIRLINESVA_GACONNECTOR_LOGBOOK_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "logbookEntry.h"
|
||||
|
||||
namespace germanairlinesva_logbook
|
||||
{
|
||||
/*
|
||||
* Logbook Header (6)
|
||||
* CHAR[5] | UINT8
|
||||
* --------+--------
|
||||
* VGAL | VERSION
|
||||
*
|
||||
* Logbook Entries (n)
|
||||
* LOGBOOKENTRY[]
|
||||
*/
|
||||
class Logbook
|
||||
{
|
||||
private:
|
||||
std::ifstream fileStream;
|
||||
std::vector<std::uint8_t> file{'V', 'G', 'A', 'L', '\0', 1};
|
||||
|
||||
void fromFile();
|
||||
void readVersion1();
|
||||
|
||||
public:
|
||||
Logbook(std::ifstream &logbook);
|
||||
void addEntry(LogbookEntry entry);
|
||||
void toFile(std::ofstream &logbook);
|
||||
};
|
||||
} // namespace germanairlinesva_logbook
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_LOGBOOKENTRY_H
|
||||
#define GERMANAIRLINESVA_GACONNECTOR_LOHBOOKENTRY_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace germanairlinesva_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)
|
||||
* FLOAT32 | 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 arrivaleGate;
|
||||
std::string arrivalRunway;
|
||||
std::string offBlockTime;
|
||||
std::string outTime;
|
||||
std::string inTime;
|
||||
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;
|
||||
std::vector<std::uint8_t> file;
|
||||
|
||||
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 arrivaleGate,
|
||||
std::string arrivalRunway,
|
||||
std::string offBlockTime,
|
||||
std::string outTime,
|
||||
std::string inTime,
|
||||
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,
|
||||
std::vector<std::uint8_t> file);
|
||||
|
||||
inline std::uint8_t *getBinaryData() { return file.data(); }
|
||||
inline std::size_t getBinaryLength() { return file.size(); }
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
std::ostringstream str;
|
||||
// TO STR
|
||||
return str.str();
|
||||
}
|
||||
|
||||
friend inline std::ostream &operator<<(std::ostream &os,
|
||||
const LogbookEntry &gate)
|
||||
{
|
||||
return os << gate.to_string();
|
||||
}
|
||||
};
|
||||
} // namespace germanairlinesva_logbook
|
||||
|
||||
#endif
|
||||
@@ -7,29 +7,25 @@
|
||||
|
||||
#include "pathSegment.h"
|
||||
|
||||
#define CURRENT_VERSION 1
|
||||
|
||||
namespace germanairlinesva_recording
|
||||
{
|
||||
/*
|
||||
* Header
|
||||
*
|
||||
* Path Recording (6 + n * 24)
|
||||
* HEADER | SEGMENTS
|
||||
|
||||
* Header (6)
|
||||
* CHAR[5] | UINT8
|
||||
* --------+--------
|
||||
* VGAR | VERSION
|
||||
*/
|
||||
/*
|
||||
* Path Recording
|
||||
*
|
||||
|
||||
* Path Segments (n)
|
||||
* PATHSEGMENT[]
|
||||
* -------------
|
||||
* SEGMENTS
|
||||
*/
|
||||
class PathRecording
|
||||
{
|
||||
private:
|
||||
std::uint64_t count = 0;
|
||||
std::vector<std::uint8_t> file{'V', 'G', 'A', 'R', 0, CURRENT_VERSION};
|
||||
std::vector<std::uint8_t> file{'V', 'G', 'A', 'R', '\0', 1};
|
||||
|
||||
public:
|
||||
void addSegment(PathSegment segment);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace germanairlinesva_recording
|
||||
{
|
||||
/*
|
||||
* Path Segment (24)
|
||||
* UINT32 | UINT16 | UINT16 | POINT
|
||||
* -------+----------+-------------+------------
|
||||
* TIME | ALTITUDE | GROUNDSPEED | COORDINATES
|
||||
|
||||
Reference in New Issue
Block a user