updated udpserver
This commit is contained in:
parent
7f3075d061
commit
417615709d
@ -1,5 +1,5 @@
|
|||||||
#include "eventbuilder.h"
|
#include "eventbuilder.h"
|
||||||
#include "udpserver.h" // Include the UDP server header
|
#include "udpserver.h"
|
||||||
|
|
||||||
EventBuilder::EventBuilder(QObject *parent) : QObject(parent)
|
EventBuilder::EventBuilder(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
@ -10,9 +10,6 @@ EventBuilder::EventBuilder(QObject *parent) : QObject(parent)
|
|||||||
connect(this, EventBuilder::sigStartTakingHistos, this, EventBuilder::onStartTakingHistos);
|
connect(this, EventBuilder::sigStartTakingHistos, this, EventBuilder::onStartTakingHistos);
|
||||||
connect(this, EventBuilder::sigStopTakingHistos, this, EventBuilder::onStopTakingHistos);
|
connect(this, EventBuilder::sigStopTakingHistos, this, EventBuilder::onStopTakingHistos);
|
||||||
|
|
||||||
// Create an instance of your UDP server class
|
|
||||||
udpServer = new UdpServer(this);
|
|
||||||
|
|
||||||
moveToThread(&thread);
|
moveToThread(&thread);
|
||||||
thread.start();
|
thread.start();
|
||||||
init();
|
init();
|
||||||
@ -88,7 +85,7 @@ void EventBuilder::onNewData(DataReceiver* receiver)
|
|||||||
// Call sendData method of the UDP server
|
// Call sendData method of the UDP server
|
||||||
QString dataString = QString::number(intensity) + ',' + QString::number(position) + ',' + QString::number(focus);
|
QString dataString = QString::number(intensity) + ',' + QString::number(position) + ',' + QString::number(focus);
|
||||||
QByteArray data = dataString.toUtf8();
|
QByteArray data = dataString.toUtf8();
|
||||||
udpServer->sendData(data);
|
udpServer.sendData(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ protected slots:
|
|||||||
void onStartTakingHistos(int sample_count);
|
void onStartTakingHistos(int sample_count);
|
||||||
void onStopTakingHistos();
|
void onStopTakingHistos();
|
||||||
private:
|
private:
|
||||||
UdpServer* udpServer; // Declare a member variable for the UDP server
|
|
||||||
double intensity = 0.0;
|
double intensity = 0.0;
|
||||||
double position = 0.0;
|
double position = 0.0;
|
||||||
double focus = 0.0;
|
double focus = 0.0;
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "udpserver.h" // Include udpserver header
|
#include "udpserver.h" // Include udpserver header
|
||||||
|
|
||||||
|
// Define the global UdpServer object
|
||||||
|
UdpServer udpServer; // This allocates memory for udpServer
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
// Create and start the UDP server
|
|
||||||
UdpServer udpServer; // Assuming your UdpServer class is properly defined
|
// Create the UdpServer object on the heap and store a pointer to it
|
||||||
udpServer.startServer();
|
udpServer.startServer();
|
||||||
|
|
||||||
// Apply the stylesheet to each display
|
// Apply the stylesheet to each display
|
||||||
|
Binary file not shown.
@ -5,6 +5,8 @@
|
|||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QTimer> // Add this line to include QTimer
|
#include <QTimer> // Add this line to include QTimer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UdpServer : public QObject
|
class UdpServer : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -23,4 +25,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Declare the global UdpServer object as an external variable
|
||||||
|
extern UdpServer udpServer;
|
||||||
|
|
||||||
#endif // UDPSERVER_H
|
#endif // UDPSERVER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user