forked from CPL/Simulator
cpp
This commit is contained in:
44
DroneClientCpp/Client.h
Normal file
44
DroneClientCpp/Client.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
Client(const char* ip, int port);
|
||||
~Client();
|
||||
|
||||
void Start(); // Запуск потоков
|
||||
void Stop(); // Остановка потоков
|
||||
struct DataIn
|
||||
{
|
||||
float AccX, AccY, AccZ;
|
||||
float GyrX, GyrY, GyrZ;
|
||||
float PosX, PosY, LaserRange;
|
||||
} dataIn;
|
||||
|
||||
struct DataOut
|
||||
{
|
||||
float MotorUL, MotorUR, MotorDL, MotorDR;
|
||||
} dataOut;
|
||||
bool ConnectToServer(const char* ip, int port);
|
||||
void CloseConnection();
|
||||
|
||||
private:
|
||||
std::atomic<bool> running;
|
||||
std::mutex dataMutex;
|
||||
|
||||
SOCKET Connection;
|
||||
std::thread recvThread;
|
||||
std::thread sendThread;
|
||||
|
||||
void ReceiveHandler();
|
||||
void SendHandler();
|
||||
};
|
Reference in New Issue
Block a user