mirror of
https://github.com/modelec/ihm.git
synced 2026-03-18 21:30:52 +01:00
open / close pince with tcp
This commit is contained in:
@@ -48,12 +48,22 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
|
|||||||
|
|
||||||
this->homologation = new Homologation(centralWidget);
|
this->homologation = new Homologation(centralWidget);
|
||||||
connect(this->homologation, &Homologation::deplierClicked, this, [&]() {
|
connect(this->homologation, &Homologation::deplierClicked, this, [&]() {
|
||||||
// TODO servo moteur
|
this->tcpClient->sendMessage("ihm;servo_pot;baisser bras;1");
|
||||||
this->tcpClient->sendMessage("ihm;strat;deplier;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, [&]() {
|
connect(this->homologation, &Homologation::replierClicked, [&]() {
|
||||||
// TODO servo moteur
|
this->tcpClient->sendMessage("ihm;servo_pot;lever bras;1");
|
||||||
this->tcpClient->sendMessage("ihm;strat;replier;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);
|
this->teamChooser = new TeamChooser(centralWidget);
|
||||||
@@ -80,7 +90,7 @@ MainWindow::MainWindow(const char *address, int port, QWidget *parent) : QMainWi
|
|||||||
|
|
||||||
this->testMode = new TestMode(centralWidget);
|
this->testMode = new TestMode(centralWidget);
|
||||||
connect(this->testMode, &TestMode::goPressed, [&](int x, int y, int theta) {
|
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);
|
this->inGame = new InGame(teamChooser);
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
//
|
|
||||||
// Created by acki on 3/30/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "MyTCPClient.h"
|
#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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,14 +7,9 @@
|
|||||||
class MyTCPClient : public QObject, public TCPClient {
|
class MyTCPClient : public QObject, public TCPClient {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MyTCPClient(const char* address = "127.0.0.1", int port = 8080, QObject* parent = nullptr) : TCPClient(address, port), QObject(parent) {
|
explicit MyTCPClient(const char* address = "127.0.0.1", int port = 8080, QObject* parent = nullptr);
|
||||||
this->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleMessage(const std::string &message) override {
|
|
||||||
emit messageReceived(message);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
void handleMessage(const std::string &message) override;
|
||||||
signals:
|
signals:
|
||||||
void messageReceived(const std::string &message);
|
void messageReceived(const std::string &message);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user