diff --git a/simulation/VirtualLedBoard/mainwindow.cpp b/simulation/VirtualLedBoard/mainwindow.cpp index 41a26bd..7f7f6fa 100644 --- a/simulation/VirtualLedBoard/mainwindow.cpp +++ b/simulation/VirtualLedBoard/mainwindow.cpp @@ -6,6 +6,7 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + this->server = new UdpLedServer (); } MainWindow::~MainWindow() diff --git a/simulation/VirtualLedBoard/mainwindow.h b/simulation/VirtualLedBoard/mainwindow.h index 4643e32..fe5b0ba 100644 --- a/simulation/VirtualLedBoard/mainwindow.h +++ b/simulation/VirtualLedBoard/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include "udpserver.h" QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -17,5 +18,6 @@ public: private: Ui::MainWindow *ui; + UdpLedServer *server; }; #endif // MAINWINDOW_H diff --git a/simulation/VirtualLedBoard/udpserver.cpp b/simulation/VirtualLedBoard/udpserver.cpp index b884803..9887cea 100644 --- a/simulation/VirtualLedBoard/udpserver.cpp +++ b/simulation/VirtualLedBoard/udpserver.cpp @@ -4,23 +4,23 @@ #define UDP_IMAGE_PORT 4242 -UdpServer::UdpServer(QObject *parent) - : QAbstractItemModel(parent) +UdpLedServer ::UdpLedServer (QObject *parent) + : QObject(parent) { initSocket(); } -void UdpServer::initSocket() +void UdpLedServer ::initSocket() { this->mUdpSocket = new QUdpSocket(this); this->mUdpSocket->bind(QHostAddress::LocalHost, UDP_IMAGE_PORT); connect(this->mUdpSocket, &QUdpSocket::readyRead, - this, &UdpServer::readPendingDatagrams); + this, &UdpLedServer ::readPendingDatagrams); } -void UdpServer::readPendingDatagrams() +void UdpLedServer ::readPendingDatagrams() { while (this->mUdpSocket->hasPendingDatagrams()) { QNetworkDatagram datagram = this->mUdpSocket->receiveDatagram(); @@ -28,7 +28,7 @@ void UdpServer::readPendingDatagrams() } } -void UdpServer::processTheDatagram(QNetworkDatagram datagram) { +void UdpLedServer::processTheDatagram(QNetworkDatagram datagram) { if (datagram.isValid()) { qDebug() << "Received datagram:" << datagram.data().size(); } diff --git a/simulation/VirtualLedBoard/udpserver.h b/simulation/VirtualLedBoard/udpserver.h index 8c91894..8acbe3f 100644 --- a/simulation/VirtualLedBoard/udpserver.h +++ b/simulation/VirtualLedBoard/udpserver.h @@ -4,12 +4,12 @@ #include #include -class UdpServer : public QAbstractItemModel +class UdpLedServer : public QObject { Q_OBJECT public: - explicit UdpServer(QObject *parent = nullptr); + explicit UdpLedServer (QObject *parent = nullptr); private: