Remove ixWebSocket
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_SOCKET_H
|
||||
#define GERMANAIRLINESVA_GACONNECTOR_SOCKET_H
|
||||
|
||||
#define BUFSIZE 1024
|
||||
#define MD5LEN 16
|
||||
|
||||
#include <json.hpp>
|
||||
|
||||
#include "types.h"
|
||||
#include "util.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
class Socket
|
||||
{
|
||||
private:
|
||||
char lastPath[513] = "";
|
||||
char lastHash[2 * MD5LEN + 1] = "";
|
||||
std::mutex wsLock;
|
||||
std::string url;
|
||||
std::function<void(std::string)> toLog;
|
||||
|
||||
public:
|
||||
explicit Socket(std::string url,
|
||||
std::function<void(const std::string)> toLog);
|
||||
~Socket();
|
||||
void sendData(data d);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef GERMANAIRLINESVA_GACONNECTOR_SOCKET_TYPES_H
|
||||
#define GERMANAIRLINESVA_GACONNECTOR_SOCKET_TYPES_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/* Structures and enums */
|
||||
typedef struct data {
|
||||
std::int32_t pause = 0;
|
||||
float pBrake = 0;
|
||||
std::int32_t onGrnd = 0;
|
||||
float totFuelKg = 0;
|
||||
float truHdg = 0;
|
||||
double alt = 0;
|
||||
float gs = 0;
|
||||
float ias = 0;
|
||||
float vs = 0;
|
||||
double lat = 0;
|
||||
double lon = 0;
|
||||
float ff[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
float maxSpd = 0;
|
||||
char path[513] = "";
|
||||
float uptime = 0;
|
||||
float magHeading = 0;
|
||||
float payloadKg = 0;
|
||||
float totalWeightKg = 0;
|
||||
} data;
|
||||
|
||||
typedef enum commands {
|
||||
PROCESS,
|
||||
SAVE,
|
||||
LOAD,
|
||||
TEXT,
|
||||
TIME,
|
||||
UNPAUSE,
|
||||
PAUSE,
|
||||
PORT,
|
||||
END
|
||||
} commands;
|
||||
|
||||
typedef struct command_base {
|
||||
commands type;
|
||||
} command_base;
|
||||
|
||||
#pragma pack(push) /* push current alignment to stack */
|
||||
#pragma pack(1) /* set alignment to 1 byte boundary */
|
||||
|
||||
typedef struct command_port {
|
||||
double latitude;
|
||||
double longitude;
|
||||
float trueHeading;
|
||||
} command_port;
|
||||
|
||||
#pragma pack(pop) /* restore original alignment from stack */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "include/socket.h"
|
||||
|
||||
Socket::Socket(std::string url, std::function<void(const std::string)> toLog)
|
||||
: url(url), toLog(std::move(toLog))
|
||||
{
|
||||
#ifdef IBM
|
||||
// WSA INIT
|
||||
int a = 0;
|
||||
#endif
|
||||
// PLATFORM AGNOSTIC
|
||||
}
|
||||
|
||||
Socket::~Socket()
|
||||
{
|
||||
// PLATFORM AGNOSTIC
|
||||
#ifdef IBM
|
||||
// WSA DEINIT
|
||||
int a = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Socket::sendData(data d)
|
||||
{
|
||||
if (strcmp(d.path, lastPath) != 0) {
|
||||
strcpy(lastPath, d.path);
|
||||
if (util::generateMD5(d.path, lastHash, toLog)) {
|
||||
strcpy(lastHash, "NOT SET");
|
||||
}
|
||||
}
|
||||
|
||||
nlohmann::json json = {
|
||||
{"altitude", d.alt},
|
||||
{"vs", d.vs},
|
||||
{"ias", d.ias},
|
||||
{"magHdg", d.magHeading},
|
||||
{"truHdg", d.truHdg},
|
||||
{"totFuel", d.totFuelKg},
|
||||
{"fuelFlow", d.ff},
|
||||
{"hash", lastHash},
|
||||
};
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(wsLock);
|
||||
// SEND
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user