mirror of
https://github.com/modelec/ihm.git
synced 2026-01-18 16:47:32 +01:00
add servo pot and use c++ file
This commit is contained in:
@@ -25,7 +25,7 @@ PreparationMatch::PreparationMatch(QWidget* parent) : QWidget(parent)
|
||||
|
||||
this->arduino = new OneItemPreparation("Arduino", "Ping", this);
|
||||
connect(this->arduino, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("start;arduino;ping;0");
|
||||
emit askTCPServer("ihm;arduino;ping;1");
|
||||
});
|
||||
|
||||
this->aruco = new OneItemPreparation("Aruco", "Ping", this);
|
||||
@@ -43,11 +43,17 @@ PreparationMatch::PreparationMatch(QWidget* parent) : QWidget(parent)
|
||||
emit askTCPServer("ihm;tirette;ping;1");
|
||||
});
|
||||
|
||||
this->servo_pot = new OneItemPreparation("Servo Pot", "Ping", this);
|
||||
connect(this->servo_pot, &OneItemPreparation::buttonClicked, this, [=]() {
|
||||
emit askTCPServer("ihm;servo_pot;ping;1");
|
||||
});
|
||||
|
||||
this->rightLayout->addWidget(ledVerte);
|
||||
this->rightLayout->addWidget(arduino);
|
||||
this->rightLayout->addWidget(aruco);
|
||||
this->rightLayout->addWidget(lidarPing);
|
||||
this->rightLayout->addWidget(tirette);
|
||||
this->rightLayout->addWidget(servo_pot);
|
||||
|
||||
this->gridLayout->addLayout(leftLayout);
|
||||
this->gridLayout->addLayout(rightLayout);
|
||||
@@ -74,9 +80,10 @@ void PreparationMatch::responseFromPing(const QString& message)
|
||||
this->lidarPing->setChecked(true);
|
||||
} else if (list[0] == "aruco") {
|
||||
this->aruco->setChecked(true);
|
||||
}
|
||||
else if (list[0] == "arduino") {
|
||||
} else if (list[0] == "arduino") {
|
||||
this->arduino->setChecked(true);
|
||||
} else if (list[0] == "servo_pot") {
|
||||
this->servo_pot->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
OneItemPreparation* aruco;
|
||||
OneItemPreparation* lidarPing;
|
||||
OneItemPreparation* tirette;
|
||||
OneItemPreparation* servo_pot;
|
||||
TiretteState* tiretteState;
|
||||
|
||||
QPushButton* startButton;
|
||||
|
||||
@@ -1,5 +1,73 @@
|
||||
//
|
||||
// Created by acki on 3/27/24.
|
||||
//
|
||||
|
||||
#include "Lidar.h"
|
||||
|
||||
Lidar::Lidar(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->mainLayout->setAlignment(Qt::AlignTop);
|
||||
this->title = new QLabel("Lidar", this);
|
||||
this->title->setStyleSheet("font-size: 24px; color: black;");
|
||||
|
||||
this->startLidar = new QPushButton("Start", this);
|
||||
this->startLidar->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->position = new QHBoxLayout();
|
||||
this->postionTitle = new QLabel("x: 0, y : 0, r: 0", this);
|
||||
this->postionTitle->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->positionButton = new QPushButton("Get pos", this);
|
||||
this->positionButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->position->addWidget(postionTitle);
|
||||
this->position->addWidget(positionButton);
|
||||
|
||||
this->health = new QHBoxLayout();
|
||||
this->healthTitle = new QLabel("Health : OK", this);
|
||||
this->healthTitle->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->healthButton = new QPushButton("Get health", this);
|
||||
this->healthButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->health->addWidget(healthTitle);
|
||||
this->health->addWidget(healthButton);
|
||||
|
||||
this->mainLayout->addWidget(title, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(startLidar, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addLayout(position);
|
||||
this->mainLayout->addLayout(health);
|
||||
|
||||
connect(this->startLidar, &QPushButton::clicked, this, &Lidar::onStartButtonClicked);
|
||||
connect(this->positionButton, &QPushButton::clicked, this, &Lidar::onPositionButtonClicked);
|
||||
connect(this->healthButton, &QPushButton::clicked, this, &Lidar::onHealthButtonClicked);
|
||||
}
|
||||
|
||||
void Lidar::TCPMessage(const QString &message) {
|
||||
auto list = message.split(";");
|
||||
|
||||
if (list[2] == "set health")
|
||||
{
|
||||
if (list[3] == "1")
|
||||
{
|
||||
this->healthTitle->setText("Health : OK");
|
||||
} else if (list[3] == "0")
|
||||
{
|
||||
this->healthTitle->setText("Health : KO");
|
||||
}
|
||||
} else if (list[2] == "set avoidance")
|
||||
{
|
||||
auto pos = list[3].split(",");
|
||||
this->postionTitle->setText("x: " + pos[0] + ", y: " + pos[1] + ", r: " + pos[2]);
|
||||
}
|
||||
}
|
||||
|
||||
void Lidar::onStartButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;start;1");
|
||||
}
|
||||
|
||||
void Lidar::onHealthButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;get health;1");
|
||||
}
|
||||
|
||||
void Lidar::onPositionButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;get data;1");
|
||||
}
|
||||
|
||||
@@ -8,82 +8,19 @@ class Lidar : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Lidar(QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->mainLayout->setAlignment(Qt::AlignTop);
|
||||
this->title = new QLabel("Lidar", this);
|
||||
this->title->setStyleSheet("font-size: 24px; color: black;");
|
||||
Lidar(QWidget* parent = nullptr);
|
||||
|
||||
this->startLidar = new QPushButton("Start", this);
|
||||
this->startLidar->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->position = new QHBoxLayout();
|
||||
this->postionTitle = new QLabel("x: 0, y : 0, r: 0", this);
|
||||
this->postionTitle->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->positionButton = new QPushButton("Get pos", this);
|
||||
this->positionButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->position->addWidget(postionTitle);
|
||||
this->position->addWidget(positionButton);
|
||||
|
||||
this->health = new QHBoxLayout();
|
||||
this->healthTitle = new QLabel("Health : OK", this);
|
||||
this->healthTitle->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->healthButton = new QPushButton("Get health", this);
|
||||
this->healthButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->health->addWidget(healthTitle);
|
||||
this->health->addWidget(healthButton);
|
||||
|
||||
this->mainLayout->addWidget(title, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addWidget(startLidar, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addLayout(position);
|
||||
this->mainLayout->addLayout(health);
|
||||
|
||||
connect(this->startLidar, &QPushButton::clicked, this, &Lidar::onStartButtonClicked);
|
||||
connect(this->positionButton, &QPushButton::clicked, this, &Lidar::onPositionButtonClicked);
|
||||
connect(this->healthButton, &QPushButton::clicked, this, &Lidar::onHealthButtonClicked);
|
||||
}
|
||||
|
||||
void TCPMessage(const QString& message)
|
||||
{
|
||||
auto list = message.split(";");
|
||||
|
||||
if (list[2] == "set health")
|
||||
{
|
||||
if (list[3] == "1")
|
||||
{
|
||||
this->healthTitle->setText("Health : OK");
|
||||
} else if (list[3] == "0")
|
||||
{
|
||||
this->healthTitle->setText("Health : KO");
|
||||
}
|
||||
} else if (list[2] == "set avoidance")
|
||||
{
|
||||
auto pos = list[3].split(",");
|
||||
this->postionTitle->setText("x: " + pos[0] + ", y: " + pos[1] + ", r: " + pos[2]);
|
||||
}
|
||||
}
|
||||
void TCPMessage(const QString& message);
|
||||
|
||||
signals:
|
||||
void askTCPServer(const std::string& message);
|
||||
|
||||
public slots:
|
||||
void onStartButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;start;0");
|
||||
}
|
||||
void onStartButtonClicked();
|
||||
|
||||
void onHealthButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;get health;0");
|
||||
}
|
||||
void onHealthButtonClicked();
|
||||
|
||||
void onPositionButtonClicked()
|
||||
{
|
||||
emit askTCPServer("ihm;lidar;get data;0");
|
||||
}
|
||||
void onPositionButtonClicked();
|
||||
|
||||
private:
|
||||
QVBoxLayout* mainLayout;
|
||||
|
||||
@@ -1,5 +1,39 @@
|
||||
//
|
||||
// Created by acki on 3/27/24.
|
||||
//
|
||||
|
||||
#include "OneItemPreparation.h"
|
||||
|
||||
OneItemPreparation::OneItemPreparation(const QString &title, const QString &buttonText, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QHBoxLayout(this);
|
||||
|
||||
this->item = new QLabel(title, this);
|
||||
this->item->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->checkBox = new QCheckBox(this);
|
||||
this->button = new QPushButton(buttonText, this);
|
||||
this->button->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
|
||||
this->mainLayout->addWidget(item);
|
||||
this->mainLayout->addWidget(checkBox);
|
||||
this->mainLayout->addWidget(button);
|
||||
|
||||
this->checkBox->setDisabled(true);
|
||||
|
||||
connect(this->button, &QPushButton::pressed, this, &OneItemPreparation::onButtonClicked);
|
||||
}
|
||||
|
||||
void OneItemPreparation::setChecked(const bool checked) const
|
||||
{
|
||||
this->checkBox->setChecked(checked);
|
||||
}
|
||||
|
||||
void OneItemPreparation::toggleChecked() const
|
||||
{
|
||||
this->checkBox->toggle();
|
||||
}
|
||||
|
||||
bool OneItemPreparation::isChecked() const
|
||||
{
|
||||
return this->checkBox->isChecked();
|
||||
}
|
||||
|
||||
void OneItemPreparation::onButtonClicked() {
|
||||
emit buttonClicked();
|
||||
}
|
||||
|
||||
@@ -9,49 +9,19 @@ class OneItemPreparation : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OneItemPreparation(const QString& title, const QString& buttonText, QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QHBoxLayout(this);
|
||||
OneItemPreparation(const QString& title, const QString& buttonText, QWidget* parent = nullptr);
|
||||
|
||||
this->item = new QLabel(title, this);
|
||||
this->item->setStyleSheet("font-size: 24px; color: black;");
|
||||
this->checkBox = new QCheckBox(this);
|
||||
this->button = new QPushButton(buttonText, this);
|
||||
this->button->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
void setChecked(bool checked) const;
|
||||
|
||||
this->mainLayout->addWidget(item);
|
||||
this->mainLayout->addWidget(checkBox);
|
||||
this->mainLayout->addWidget(button);
|
||||
void toggleChecked() const;
|
||||
|
||||
this->checkBox->setDisabled(true);
|
||||
|
||||
connect(this->button, &QPushButton::pressed, this, &OneItemPreparation::onButtonClicked);
|
||||
}
|
||||
|
||||
void setChecked(const bool checked) const
|
||||
{
|
||||
this->checkBox->setChecked(checked);
|
||||
}
|
||||
|
||||
void toggleChecked() const
|
||||
{
|
||||
this->checkBox->toggle();
|
||||
}
|
||||
|
||||
bool isChecked() const
|
||||
{
|
||||
return this->checkBox->isChecked();
|
||||
}
|
||||
[[nodiscard]] bool isChecked() const;
|
||||
|
||||
signals:
|
||||
void buttonClicked();
|
||||
|
||||
public slots:
|
||||
void onButtonClicked()
|
||||
{
|
||||
emit buttonClicked();
|
||||
}
|
||||
|
||||
void onButtonClicked();
|
||||
|
||||
private:
|
||||
QHBoxLayout* mainLayout;
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
//
|
||||
// Created by acki on 3/27/24.
|
||||
//
|
||||
|
||||
#include "TiretteState.h"
|
||||
|
||||
TiretteState::TiretteState(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->title = new QLabel("Tirette", this);
|
||||
this->title->setStyleSheet("font-size: 24px; color: black;");
|
||||
|
||||
this->tiretteStateLayout = new QHBoxLayout();
|
||||
this->stateLabel = new QLabel(" ", this);
|
||||
this->stateButton = new QPushButton("Get state", this);
|
||||
this->stateButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
this->tiretteStateLayout->addWidget(stateLabel);
|
||||
this->tiretteStateLayout->addWidget(stateButton);
|
||||
|
||||
this->mainLayout->addWidget(this->title, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addLayout(this->tiretteStateLayout);
|
||||
|
||||
connect(this->stateButton, &QPushButton::clicked, this, &TiretteState::onStateButtonClicked);
|
||||
}
|
||||
|
||||
void TiretteState::setState(const std::string &state) {
|
||||
if (state == "1")
|
||||
{
|
||||
this->stateLabel->setText("1 : Tirette en place");
|
||||
} else if (state == "0")
|
||||
{
|
||||
this->stateLabel->setText("0 : Tirette absente");
|
||||
}
|
||||
}
|
||||
|
||||
void TiretteState::onStateButtonClicked() {
|
||||
emit askTCPServer("strat;tirette;get state;1");
|
||||
}
|
||||
|
||||
@@ -8,44 +8,15 @@ class TiretteState : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TiretteState(QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
this->mainLayout = new QVBoxLayout(this);
|
||||
this->title = new QLabel("Tirette", this);
|
||||
this->title->setStyleSheet("font-size: 24px; color: black;");
|
||||
TiretteState(QWidget* parent = nullptr);
|
||||
|
||||
this->tiretteStateLayout = new QHBoxLayout();
|
||||
this->stateLabel = new QLabel(" ", this);
|
||||
this->stateButton = new QPushButton("Get state", this);
|
||||
this->stateButton->setStyleSheet("height: 46px; color: black; font-size: 24px;");
|
||||
this->tiretteStateLayout->addWidget(stateLabel);
|
||||
this->tiretteStateLayout->addWidget(stateButton);
|
||||
|
||||
this->mainLayout->addWidget(this->title, 0, Qt::AlignCenter);
|
||||
this->mainLayout->addLayout(this->tiretteStateLayout);
|
||||
|
||||
connect(this->stateButton, &QPushButton::clicked, this, &TiretteState::onStateButtonClicked);
|
||||
}
|
||||
|
||||
void setState(const std::string& state)
|
||||
{
|
||||
if (state == "1")
|
||||
{
|
||||
this->stateLabel->setText("1 : Tirette en place");
|
||||
} else if (state == "0")
|
||||
{
|
||||
this->stateLabel->setText("0 : Tirette absente");
|
||||
}
|
||||
}
|
||||
void setState(const std::string& state);
|
||||
|
||||
signals:
|
||||
void askTCPServer(const std::string& message);
|
||||
|
||||
public slots:
|
||||
void onStateButtonClicked()
|
||||
{
|
||||
emit askTCPServer("strat;tirette;get state;0");
|
||||
}
|
||||
void onStateButtonClicked();
|
||||
|
||||
private:
|
||||
QVBoxLayout* mainLayout;
|
||||
|
||||
Reference in New Issue
Block a user