More recording

This commit is contained in:
2022-01-03 21:37:00 +01:00
parent 3ec41a1a19
commit d7b765fba5
5 changed files with 57 additions and 16 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ public:
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
}
std::uint8_t *getBinaryData() { return this->file.data(); }
std::size_t getBinaryLength() { return this->file.size(); }
std::uint8_t *getBinaryData() { return file.data(); }
std::size_t getBinaryLength() { return file.size(); }
};
#endif
+22 -5
View File
@@ -12,20 +12,23 @@
class PathSegment
{
private:
std::uint16_t altitude;
std::uint16_t groundSpeed;
double latitude;
double longitude;
std::uint16_t altitude = 0;
std::uint16_t groundSpeed = 0;
double latitude = 0;
double longitude = 0;
std::vector<std::uint8_t> file;
public:
PathSegment() = default;
PathSegment(std::uint16_t altitude,
std::uint16_t groundSpeed,
double latitude,
double longitude)
{
this->altitude = altitude;
this->groundSpeed = groundSpeed;
this->latitude = latitude;
this->longitude = longitude;
file = std::vector<std::uint8_t>(20, 0);
std::uint8_t *bufPtr = file.data();
@@ -37,4 +40,18 @@ public:
bufPtr += sizeof(this->latitude);
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);
}
};
+13 -2
View File
@@ -1,4 +1,5 @@
#include <cstdint>
#include <cstring>
#include <vector>
#include "pathSegment.hpp"
@@ -6,8 +7,18 @@
class Path
{
private:
std::vector<PathSegment> segments;
std::uint64_t count = 0;
std::vector<std::uint8_t> file;
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(); }
};
+2 -2
View File
@@ -107,8 +107,8 @@ public:
memcpy(bufPtr, &this->trueHeading, sizeof(this->trueHeading));
}
std::uint8_t *getBinaryData() { return this->file.data(); }
std::size_t getBinaryLength() { return this->file.size(); }
std::uint8_t *getBinaryData() { return file.data(); }
std::size_t getBinaryLength() { return file.size(); }
};
#endif