int main(int argc, char *argv[])
{
qRegisterMetaType<QSharedPointer<CPacket> >();
RodGui w;
w.show();
return a.exec();
}
Q_DECLARE_METATYPE(QSharedPointer<CPacket>)
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qRegisterMetaType<QSharedPointer<CPacket> >();
RodGui w;
w.show();
return a.exec();
}
Q_DECLARE_METATYPE(QSharedPointer<CPacket>)
To copy to clipboard, switch view to plain text mode
{
Q_OBJECT
public:
~RodGui();
private:
void setupAndStartNetwork();
Network* networkThreadMi;
Network* networkThreadBer;
Network* networkThreadBuffer;
Network* networkThreadQam;
//[qwt plot stuff and widgets]
private slots:
void updatePlot(QSharedPointer<CPacket> packet);
};
{
// [create widgets and qwt plots]
setupAndStartNetwork();
}
void RodGui::updatePlot(QSharedPointer<CPacket> packet) {
// [do some calculations with packet and update qwt plots]
}
void RodGui::setupAndStartNetwork() {
networkThreadMi
= new Network
(this,
QString::number(20004));
networkThreadBer
= new Network
(this,
QString::number(20005));
networkThreadBuffer
= new Network
(this,
QString::number(20006));
networkThreadQam
= new Network
(this,
QString::number(20007));
QObject::connect(networkThreadMi,
SIGNAL(processedDatagramsReady
(QSharedPointer<CPacket>
)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadBer,
SIGNAL(processedDatagramsReady
(QSharedPointer<CPacket>
)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadBuffer,
SIGNAL(processedDatagramsReady
(QSharedPointer<CPacket>
)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadQam,
SIGNAL(processedDatagramsReady
(QSharedPointer<CPacket>
)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
networkThreadMi->start();
networkThreadBer->start();
networkThreadBuffer->start();
networkThreadQam->start();
}
class RodGui : public QMainWindow
{
Q_OBJECT
public:
RodGui(QWidget *parent = 0);
~RodGui();
private:
void setupAndStartNetwork();
Network* networkThreadMi;
Network* networkThreadBer;
Network* networkThreadBuffer;
Network* networkThreadQam;
//[qwt plot stuff and widgets]
private slots:
void updatePlot(QSharedPointer<CPacket> packet);
};
RodGui::RodGui(QWidget *parent) : QMainWindow(parent)
{
// [create widgets and qwt plots]
setupAndStartNetwork();
}
void RodGui::updatePlot(QSharedPointer<CPacket> packet) {
// [do some calculations with packet and update qwt plots]
}
void RodGui::setupAndStartNetwork() {
networkThreadMi = new Network(this, QString::number(20004));
networkThreadBer = new Network(this, QString::number(20005));
networkThreadBuffer = new Network(this, QString::number(20006));
networkThreadQam = new Network(this, QString::number(20007));
QObject::connect(networkThreadMi, SIGNAL(processedDatagramsReady(QSharedPointer<CPacket>)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadBer, SIGNAL(processedDatagramsReady(QSharedPointer<CPacket>)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadBuffer, SIGNAL(processedDatagramsReady(QSharedPointer<CPacket>)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
QObject::connect(networkThreadQam, SIGNAL(processedDatagramsReady(QSharedPointer<CPacket>)),
this, SLOT(updatePlot(QSharedPointer<CPacket>)), Qt::QueuedConnection);
networkThreadMi->start();
networkThreadBer->start();
networkThreadBuffer->start();
networkThreadQam->start();
}
To copy to clipboard, switch view to plain text mode
Q_OBJECT
public:
signals:
void processedDatagramsReady(QSharedPointer<CPacket>);
private:
//[TCP stuff (boost asio)]
protected:
void run();
};
void Network::run() {
while (true) {
//[read some TCP packets via boost asio and deserialize to a class (derived from CPacket)]
qDebug() << "emit: " << port;
emit processedDatagramsReady(packet);
qDebug() << "emit complete: " << port;
}
}
class Network : public QThread {
Q_OBJECT
public:
Network(QWidget *parent = 0, QString port = 0);
signals:
void processedDatagramsReady(QSharedPointer<CPacket>);
private:
QString port;
//[TCP stuff (boost asio)]
protected:
void run();
};
void Network::run() {
while (true) {
//[read some TCP packets via boost asio and deserialize to a class (derived from CPacket)]
qDebug() << "emit: " << port;
emit processedDatagramsReady(packet);
qDebug() << "emit complete: " << port;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks