diff --git a/logic/include/model/DataSender.h b/logic/include/model/DataSender.h index e0f4ad6..3b5873c 100644 --- a/logic/include/model/DataSender.h +++ b/logic/include/model/DataSender.h @@ -10,12 +10,14 @@ class DataSender : public QObject public: virtual void send(const QByteArray& data) = 0; + virtual void sendProbeSlots(const QByteArray& data) = 0; virtual ~DataSender() { } signals: void dataReady(const QByteArray& data); + void probeSlotsDataReady(const QByteArray& data); }; #endif //DATASENDER_H diff --git a/logic/include/network/UdpDataSender.h b/logic/include/network/UdpDataSender.h index 6a38573..f3b225b 100644 --- a/logic/include/network/UdpDataSender.h +++ b/logic/include/network/UdpDataSender.h @@ -10,18 +10,21 @@ class UdpDataSender : public DataSender Q_OBJECT private: - QUdpSocket* _socket; + QUdpSocket* _socketDashboard; + QUdpSocket* _socketProbeSlots; public: UdpDataSender(); ~UdpDataSender() override; void send(const QByteArray& data) override; + void sendProbeSlots(const QByteArray& data) override; //uncrustify off public slots: //uncrustify on void read(); + void readProbeSlots(); }; #endif //UDPDATASENDER_H diff --git a/logic/src/network/UdpDataSender.cpp b/logic/src/network/UdpDataSender.cpp index 2f3f65e..57e1ec4 100644 --- a/logic/src/network/UdpDataSender.cpp +++ b/logic/src/network/UdpDataSender.cpp @@ -4,31 +4,51 @@ void UdpDataSender::send(const QByteArray& data) { - _socket->writeDatagram(data, QHostAddress::LocalHost, 5446); + _socketDashboard->writeDatagram(data, QHostAddress::LocalHost, 5446); +} + +/*************************************************************************************************/ +void UdpDataSender::sendProbeSlots(const QByteArray& data) +{ + _socketProbeSlots->writeDatagram(data, QHostAddress::LocalHost, 5450); } /*************************************************************************************************/ void UdpDataSender::read() { char data[DATAGRAM_SIZE]; - int cnt = _socket->readDatagram(data, DATAGRAM_SIZE); + int cnt = _socketDashboard->readDatagram(data, DATAGRAM_SIZE); QByteArray a(data, cnt); emit dataReady(a); } /*************************************************************************************************/ -UdpDataSender::UdpDataSender() +void UdpDataSender::readProbeSlots() { - _socket = new QUdpSocket(); + char data[DATAGRAM_SIZE]; + int cnt = _socketProbeSlots->readDatagram(data, DATAGRAM_SIZE); + QByteArray a(data, cnt); + emit probeSlotsDataReady(a); +} - _socket->bind(QHostAddress::Any, 5445); +/*************************************************************************************************/ +UdpDataSender::UdpDataSender() +{ + _socketDashboard = new QUdpSocket(); + _socketDashboard->bind(QHostAddress::Any, 5445); + connect(_socketDashboard, SIGNAL(readyRead()), this, SLOT(read())); - connect(_socket, SIGNAL(readyRead()), this, SLOT(read())); + _socketProbeSlots = new QUdpSocket(); + _socketProbeSlots->bind(QHostAddress::Any, 5449); + connect(_socketProbeSlots, SIGNAL(readyRead()), this, SLOT(readProbeSlots())); } /*************************************************************************************************/ UdpDataSender::~UdpDataSender() { - _socket->close(); - delete _socket; + _socketDashboard->close(); + delete _socketDashboard; + + _socketProbeSlots->close(); + delete _socketProbeSlots; }