15 #include <QCloseEvent>
19 #include <QGraphicsDropShadowEffect>
22 #include <QSerialPortInfo>
23 #include <QSignalMapper>
24 #include <QTranslator>
27 #include "ui_mainwindow.h"
34 ui->serialStatus->setAlignment(Qt::AlignCenter);
35 ui->statusbar->addPermanentWidget(
ui->serialStatus, 1);
66 ui->lineEditAccelerationValueL->setText(QString(
"0.00"));
67 ui->lineEditSpeedValueL->setText(QString(
"0.00"));
68 ui->lineEditGSpeedValueL->setText(QString(
"0.00"));
70 ui->lineEditAccelerationValueR->setText(QString(
"0.00"));
71 ui->lineEditSpeedValueR->setText(QString(
"0.00"));
72 ui->lineEditGSpeedValueR->setText(QString(
"0.00"));
74 QStringList languages;
75 const QStringList uiLanguages = QLocale::system().uiLanguages();
76 for(
const QString& locale : uiLanguages)
78 const QString baseName =
"roomba-app_" + QLocale(locale).name();
86 ui->retranslateUi(
this);
105 QApplication::quit();
116 ui->menuConnect->clear();
119 QList<QSerialPortInfo> devices;
120 devices = QSerialPortInfo::availablePorts();
122 QSignalMapper* mapper =
new QSignalMapper;
125 for(
int i = 0; i < devices.count(); i++)
127 QString message = tr(
"Znalazłem urządzenie: ");
128 addMessageToLogs(message + devices.at(i).portName() +
" " + devices.at(i).description());
129 QAction* deviceName =
new QAction(QString(devices.at(i).portName() +
"\t" + devices.at(i).description()),
this);
130 QObject::connect(deviceName, SIGNAL(triggered()), mapper, SLOT(map()));
131 mapper->setMapping(deviceName, deviceName->text());
132 ui->menuConnect->addAction(deviceName);
138 QString portName = actionName.split(
"\t").first();
177 ui->statusbar->showMessage(message, 100);
182 QString currentDate = QDateTime::currentDateTime().toString(
"yyyy.MM.dd");
183 QString currentTime = QDateTime::currentDateTime().toString(
"hh:mm:ss");
184 ui->textEditLogs->append(currentDate +
" | " + currentTime +
" | " + message);
189 QGraphicsDropShadowEffect* shadow =
new QGraphicsDropShadowEffect();
190 shadow->setBlurRadius(radius);
191 shadow->setOffset(xOffset, yOffset);
192 group->setGraphicsEffect(shadow);
197 ui->lineEditSpeedValueL->setText(message);
202 ui->lineEditGSpeedValueL->setText(message);
207 ui->lineEditAccelerationValueL->setText(message);
212 ui->lineEditSpeedValueR->setText(message);
217 ui->lineEditGSpeedValueR->setText(message);
222 ui->lineEditAccelerationValueR->setText(message);
227 ui->progressBarBattery->setValue(message);
232 ui->serialStatus->setText(message);
237 ui->labelSkiddingInfo->setStyleSheet(
"QLabel#labelSkiddingInfo {color: #FF0000;}");
238 ui->labelSkiddingInfo->setText(tr(
"Zwolnij przeszkoda jest blisko!"));
243 ui->labelSkiddingInfo->setStyleSheet(
"QLabel#labelSkiddingInfo {color: #00AA00;}");
244 ui->labelSkiddingInfo->setText(tr(
"Jazda normalna!"));
253 ui->retranslateUi(
this);
262 ui->retranslateUi(
this);
The class connecting main application and serial port.
const FrameBuffer & getFrameBuffer() const
Get a unmodifiable frame from the circular buffer.
FrameBuffer & useFrameBuffer()
Get a modifiable frame from the circular buffer.
void setDeviceName(const std::string &name)
Set the serial device name.
void endCommunication()
Set the end of communication flag to end communication.
bool isOpen() const
Check if the serial port is open.
bool isFrame() const
Check if there is any frame in a circular buffer.
bool getFrame(std::string &frame)
Get one frame from the top of the list.
Thread wrapper class for communicating with the serial device on a separate thread.
void setSerialStatus(const QString &message)
Signal emmitted to change connection status with the serial device on the status bar.
void info(const QString &info)
Signal emmitted to add informations to logs.
void error(const QString &error)
Signal emmitted to add errors on the status bar.
void movePos(const QPoint &coordinates)
Change the knop coordinates.
The class connecting all modules through the UI interface.
void showErrorMessage(const QString &message)
Show error message as status bar message.
void closeEvent(QCloseEvent *event) override
Closing event function.
void on_actionDisconnect_triggered()
Slot triggered when the disconnecting signal was emitted.
FrameThread * _frameThread
Handle for communicating on different thread.
void on_actionClose_triggered()
Slot triggered when the closing signal was emitted.
void setObstacleCloseStatus()
Set the close distance status with the obstacle on the motor information widget.
Communication * _communication
Communication handle.
Ui::MainWindow * ui
Pointer to all UI widgets.
void addValueGSpeedL(const QString &message)
Set the value of the left motor given speed.
void addValueSpeedR(const QString &message)
Set the value of the right motor speed.
void resetObstacleCloseStatus()
Set the normal distance status with the obstacle on the motor information widget.
void setSerialStatus(const QString &message)
Set the connection status with the serial port on the status bar.
void addMessageToLogs(const QString &message)
Add a message to the logs widget.
Parser * _parser
Serial data processor.
void addValueSpeedL(const QString &message)
Set the value of the left motor speed.
void on_actionEnglish_US_triggered()
Change UI language to English (US).
MainWindow(QWidget *parent=nullptr)
Construct a new MainWindow object.
void addValueBattery(const int message)
Set the battery voltage value.
QTranslator _translator
Handle to translator object.
void addDropShadow(QGroupBox *group, int xOffset, int yOffset, int radius)
Add drop shadow under given GroupBox widget.
void serialTimeout()
Update information read from the serial port.
void addValueAccelerationR(const QString &message)
Set the value of the right motor acceleration.
void on_actionPolish_triggered()
Change UI language to Polish.
QTimer _serialTimer
Serial data updating timer.
void on_actionSearch_triggered()
Slot triggered when the searching signal was emitted.
~MainWindow()
Destroy the MainWindow object.
void connectSerialDevice(const QString &actionName)
Connect to the serial device.
void addValueAccelerationL(const QString &message)
Set the value of the left motor acceleration.
void addValueGSpeedR(const QString &message)
Set the value of the right motor given speed.
Parsing class for a processing data from the serial port frame.
void changedRightMotorAcceleration(const QString &accelerationValue)
A signal emitted when parsed data of the right motor acceleration is ready.
void setObstacleCloseStatus()
Set the Obstacle Close Status.
void changedLidar(const std::map< float, int > lidarData)
A signal emitted when parsed data of the lidar is ready.
void leftMotorDirection(const int &direction)
A signal emitted to pass wheel rotating direction to the openGL widget.
void changedLeftMotorGSpeed(const QString &speedValue)
A signal emitted when parsed data of the left motor given speed is ready.
void changedBattery(int battery)
A signal emitted when parsed data of the battery voltage is ready.
void processData()
Process data from a one frame.
bool parseFrame(const std::string &frame)
Parse line from the serial port into managed variables.
void changedRightMotorSpeed(const QString &speedValue)
A signal emitted when parsed data of the right motor speed is ready.
void changedLeftMotorSpeed(const QString &speedValue)
A signal emitted when parsed data of the left motor speed is ready.
void changedJoystick(const QPoint &coordinates)
A signal emitted when parsed data of a joystick swing is ready.
void changedRightMotorGSpeed(const QString &speedValue)
A signal emitted when parsed data of the right motor given speed is ready.
void resetObstacleCloseStatus()
Reset the Obstacle Close Status.
void rightMotorDirection(const int &direction)
A signal emitted to pass wheel rotating direction to the openGL widget.
void changedLeftMotorAcceleration(const QString &accelerationValue)
A signal emitted when parsed data of the left motor acceleration is ready.
MainWindow class declaration.