open / close pince with tcp

This commit is contained in:
ackimixs
2024-04-02 16:59:31 +02:00
parent efff922668
commit 3771f3d2d7
3 changed files with 25 additions and 16 deletions

View File

@@ -48,12 +48,22 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
this->homologation = new Homologation(centralWidget);
connect(this->homologation, &Homologation::deplierClicked, this, [&]() {
// TODO servo moteur
this->tcpClient->sendMessage("ihm;strat;deplier;1");
this->tcpClient->sendMessage("ihm;servo_pot;baisser bras;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;ouvrir pince;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;ouvrir pince;2");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;ouvrir pince;3");
});
connect(this->homologation, &Homologation::replierClicked, [&]() {
// TODO servo moteur
this->tcpClient->sendMessage("ihm;strat;replier;1");
this->tcpClient->sendMessage("ihm;servo_pot;lever bras;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;fermer pince;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;fermer pince;2");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
this->tcpClient->sendMessage("ihm;servo_pot;fermer pince;3");
});
this->teamChooser = new TeamChooser(centralWidget);
@@ -80,7 +90,7 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
this->testMode = new TestMode(centralWidget);
connect(this->testMode, &TestMode::goPressed, [&](int x, int y, int theta) {
this->tcpClient->sendMessage("ihm;strat;go;" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(theta));
this->tcpClient->sendMessage("ihm;arduino;go;" + std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(theta));
});
this->inGame = new InGame(teamChooser);

View File

@@ -1,5 +1,9 @@
//
// Created by acki on 3/30/24.
//
#include "MyTCPClient.h"
MyTCPClient::MyTCPClient(const char *address, int port, QObject *parent) : TCPClient(address, port), QObject(parent) {
this->start();
}
void MyTCPClient::handleMessage(const std::string &message) {
emit messageReceived(message);
}

View File

@@ -7,14 +7,9 @@
class MyTCPClient : public QObject, public TCPClient {
Q_OBJECT
public:
explicit MyTCPClient(const char* address = "127.0.0.1", int port = 8080, QObject* parent = nullptr) : TCPClient(address, port), QObject(parent) {
this->start();
}
void handleMessage(const std::string &message) override {
emit messageReceived(message);
};
explicit MyTCPClient(const char* address = "127.0.0.1", int port = 8080, QObject* parent = nullptr);
void handleMessage(const std::string &message) override;
signals:
void messageReceived(const std::string &message);
};