Roomba App  1.0
frameThread.cpp
Go to the documentation of this file.
1 
16 #include <QSerialPort>
17 
18 #include "communication.hh"
19 #include "frameThread.hh"
20 
21 FrameThread::FrameThread(Communication* communication /* = nullptr */, QObject* parent /* = nullptr */)
22  : QThread(parent), _communication(communication)
23 {
24 }
25 
27 {
28  QSerialPort serial;
29  _communication->setDevice(&serial);
30 
32  {
33  emit error(tr("Wątek nie mógł otworzyć portu"));
34  return;
35  }
36 
37  emit info(tr("Otwarto port szeregowy"));
38  emit setSerialStatus(tr("Połączono z portem szeregowym | Nazwa portu: ") +
39  QString(_communication->getDeviceName().c_str()));
40 
42 
44  {
45  emit error(tr("Wątek nie mógł poprawnie zamknąć portu!"));
46  return;
47  }
48 
49  emit info(tr("Zamknięto połączenie."));
50  emit setSerialStatus(tr("Rozłączono z portem szeregowym"));
51 }
The class connecting main application and serial port.
void receiveData()
Receive line one by one from the serial device in loop until end of communication.
bool closeSerialPort()
Close the serial port.
const std::string & getDeviceName() const
Get the serial device name.
void setDevice(QSerialPort *device)
Set a new handle to the serial device.
bool openSerialPort(const char *serialPort)
Open the serial port.
void run() override
Run main thread function.
Definition: frameThread.cpp:26
void setSerialStatus(const QString &message)
Signal emmitted to change connection status with the serial device on the status bar.
FrameThread(Communication *communication=nullptr, QObject *parent=nullptr)
Construct a new FrameThread object.
Definition: frameThread.cpp:21
Communication * _communication
Communication class handle.
Definition: frameThread.hh:29
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.
Communication class declaration.
FrameThread class declaration.