Begin path recording trials
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "config.hpp"
|
||||
#include "makeRwysXP.h"
|
||||
#include "recordingPath.hpp"
|
||||
#include "simulatorDatabase.hpp"
|
||||
#include "websocket.h"
|
||||
|
||||
@@ -23,6 +24,7 @@
|
||||
|
||||
float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon);
|
||||
void serverWorker();
|
||||
void recordingWorker();
|
||||
void toLog(const std::string &message);
|
||||
|
||||
#endif
|
||||
|
||||
+29
-4
@@ -7,11 +7,12 @@ std::queue<std::function<void()>> &messageQueue()
|
||||
return _messageQueue;
|
||||
}
|
||||
std::thread serverThread;
|
||||
std::thread recordingThread;
|
||||
std::atomic<bool> wantsExit;
|
||||
|
||||
std::map<std::string, std::string> configuration;
|
||||
|
||||
websocket *connector;
|
||||
Websocket *connector;
|
||||
|
||||
/* Datarefs */
|
||||
XPLMDataRef pauseIndicator;
|
||||
@@ -108,7 +109,7 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
|
||||
// Initialize connector
|
||||
try {
|
||||
connector = new websocket(toLog);
|
||||
connector = new Websocket(toLog);
|
||||
} catch (const std::invalid_argument &e) {
|
||||
toLog(e.what());
|
||||
return 0;
|
||||
@@ -147,7 +148,8 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
|
||||
// Thread for sending data to web socket
|
||||
serverThread = std::thread(&serverWorker);
|
||||
toLog("Worker started");
|
||||
recordingThread = std::thread(&recordingWorker);
|
||||
toLog("Workers started");
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -218,7 +220,7 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
||||
|
||||
void serverWorker()
|
||||
{
|
||||
util::setThreadName("GAWorker");
|
||||
util::setThreadName("GAServerWorker");
|
||||
|
||||
while (!wantsExit) {
|
||||
data copy;
|
||||
@@ -234,6 +236,29 @@ void serverWorker()
|
||||
}
|
||||
}
|
||||
|
||||
void recordingWorker()
|
||||
{
|
||||
util::setThreadName("GARecordingWorker");
|
||||
|
||||
Path p;
|
||||
|
||||
while (!wantsExit) {
|
||||
data copy;
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
memcpy(©, &toSend, sizeof(data));
|
||||
}
|
||||
|
||||
p.addSegment({static_cast<std::uint16_t>(copy.alt),
|
||||
static_cast<std::uint16_t>(copy.gs),
|
||||
copy.lat,
|
||||
copy.lon});
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
}
|
||||
}
|
||||
|
||||
void toLog(const std::string &message)
|
||||
{
|
||||
std::stringstream msg;
|
||||
|
||||
Reference in New Issue
Block a user