Merge branch 'develop' of https://git.hofmannnet.myhome-server.de/GermanAirlines/GermanAirlinesVA-GAConnector into develop
This commit is contained in:
commit
27edf28f42
@ -49,8 +49,8 @@ public:
|
|||||||
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t *getBinaryData() { return this->file.data(); }
|
std::uint8_t *getBinaryData() { return file.data(); }
|
||||||
std::size_t getBinaryLength() { return this->file.size(); }
|
std::size_t getBinaryLength() { return file.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -12,20 +12,23 @@
|
|||||||
class PathSegment
|
class PathSegment
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::uint16_t altitude;
|
std::uint16_t altitude = 0;
|
||||||
std::uint16_t groundSpeed;
|
std::uint16_t groundSpeed = 0;
|
||||||
double latitude;
|
double latitude = 0;
|
||||||
double longitude;
|
double longitude = 0;
|
||||||
std::vector<std::uint8_t> file;
|
std::vector<std::uint8_t> file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PathSegment() = default;
|
||||||
PathSegment(std::uint16_t altitude,
|
PathSegment(std::uint16_t altitude,
|
||||||
std::uint16_t groundSpeed,
|
std::uint16_t groundSpeed,
|
||||||
double latitude,
|
double latitude,
|
||||||
double longitude)
|
double longitude)
|
||||||
{
|
{
|
||||||
this->altitude = altitude;
|
this->altitude = altitude;
|
||||||
|
this->groundSpeed = groundSpeed;
|
||||||
|
this->latitude = latitude;
|
||||||
|
this->longitude = longitude;
|
||||||
|
|
||||||
file = std::vector<std::uint8_t>(20, 0);
|
file = std::vector<std::uint8_t>(20, 0);
|
||||||
std::uint8_t *bufPtr = file.data();
|
std::uint8_t *bufPtr = file.data();
|
||||||
@ -37,4 +40,18 @@ public:
|
|||||||
bufPtr += sizeof(this->latitude);
|
bufPtr += sizeof(this->latitude);
|
||||||
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::uint8_t *getBinaryData() { return file.data(); }
|
||||||
|
std::size_t getBinaryLength() { return file.size(); }
|
||||||
|
|
||||||
|
friend bool operator==(const PathSegment &lhs, const PathSegment &rhs)
|
||||||
|
{
|
||||||
|
return lhs.altitude == rhs.altitude &&
|
||||||
|
lhs.groundSpeed == rhs.groundSpeed &&
|
||||||
|
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude;
|
||||||
|
}
|
||||||
|
friend bool operator!=(const PathSegment &lhs, const PathSegment &rhs)
|
||||||
|
{
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "pathSegment.hpp"
|
#include "pathSegment.hpp"
|
||||||
@ -6,8 +7,18 @@
|
|||||||
class Path
|
class Path
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::vector<PathSegment> segments;
|
std::uint64_t count = 0;
|
||||||
|
std::vector<std::uint8_t> file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addSegment(PathSegment segment) { segments.push_back(segment); }
|
void addSegment(PathSegment segment)
|
||||||
|
{
|
||||||
|
file.resize(file.size() + segment.getBinaryLength());
|
||||||
|
std::uint8_t *bufPtr = file.data() + count * segment.getBinaryLength();
|
||||||
|
memcpy(bufPtr, segment.getBinaryData(), segment.getBinaryLength());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::uint8_t *getBinaryData() { return file.data(); }
|
||||||
|
std::size_t getBinaryLength() { return file.size(); }
|
||||||
};
|
};
|
||||||
@ -107,8 +107,8 @@ public:
|
|||||||
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t *getBinaryData() { return this->file.data(); }
|
std::uint8_t *getBinaryData() { return file.data(); }
|
||||||
std::size_t getBinaryLength() { return this->file.size(); }
|
std::size_t getBinaryLength() { return file.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -43,6 +43,7 @@ XPLMDataRef roll;
|
|||||||
XPLMDataRef quaternion;
|
XPLMDataRef quaternion;
|
||||||
|
|
||||||
data toSend;
|
data toSend;
|
||||||
|
Path p;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callbacks
|
* Callbacks
|
||||||
@ -162,6 +163,12 @@ PLUGIN_API void XPluginStop(void)
|
|||||||
wantsExit = true;
|
wantsExit = true;
|
||||||
delete connector;
|
delete connector;
|
||||||
serverThread.join();
|
serverThread.join();
|
||||||
|
recordingThread.join();
|
||||||
|
|
||||||
|
std::ofstream out("Resources/plugins/GAConnector/flight.rec");
|
||||||
|
out.write(reinterpret_cast<const char *>(p.getBinaryData()),
|
||||||
|
(std::streamsize)p.getBinaryLength());
|
||||||
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN_API void XPluginDisable(void) {}
|
PLUGIN_API void XPluginDisable(void) {}
|
||||||
@ -240,7 +247,7 @@ void recordingWorker()
|
|||||||
{
|
{
|
||||||
util::setThreadName("GARecordingWorker");
|
util::setThreadName("GARecordingWorker");
|
||||||
|
|
||||||
Path p;
|
PathSegment lastPath;
|
||||||
|
|
||||||
while (!wantsExit) {
|
while (!wantsExit) {
|
||||||
data copy;
|
data copy;
|
||||||
@ -250,10 +257,16 @@ void recordingWorker()
|
|||||||
memcpy(©, &toSend, sizeof(data));
|
memcpy(©, &toSend, sizeof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
p.addSegment({static_cast<std::uint16_t>(copy.alt),
|
PathSegment currentPath(static_cast<std::uint16_t>(copy.alt),
|
||||||
static_cast<std::uint16_t>(copy.gs),
|
static_cast<std::uint16_t>(copy.gs),
|
||||||
copy.lat,
|
copy.lat,
|
||||||
copy.lon});
|
copy.lon);
|
||||||
|
|
||||||
|
if (strcmp(copy.path, "") != 0 && copy.pause &&
|
||||||
|
lastPath != currentPath) {
|
||||||
|
p.addSegment(currentPath);
|
||||||
|
lastPath = currentPath;
|
||||||
|
}
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user