diff --git a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.cpp b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.cpp --- a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.cpp +++ b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.cpp @@ -27,9 +27,42 @@ SpwTcpPacketServer::SpwTcpPacketServer(Q ui(new Ui::SpwTcpPacketServer) { ui->setupUi(this); + this->p_bridge = NULL; + this->p_server = new QTcpServer(); + connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); } SpwTcpPacketServer::~SpwTcpPacketServer() { delete ui; } + +void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) +{ + if(this->p_bridge!=NULL) + { + disconnect(this,SLOT(pushPacket(char*,int))); + } + this->p_bridge = bridge; + connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); +} + +void SpwTcpPacketServer::pushPacket(char *packet, int size) +{ + +} + +void SpwTcpPacketServer::toggleServer() +{ + if(this->p_server->isListening()) + { + this->ui->startServeQpb->setText("Start Server"); + this->p_server->close(); + } + else + { + this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); + + this->ui->startServeQpb->setText("Stop Server"); + } +} diff --git a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.h b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.h --- a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.h +++ b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.h @@ -23,6 +23,8 @@ #define SPWTCPPACKETSERVER_H #include +#include +#include namespace Ui { class SpwTcpPacketServer; @@ -36,8 +38,15 @@ public: explicit SpwTcpPacketServer(QWidget *parent = 0); ~SpwTcpPacketServer(); + void setBridge(abstractSpwBridge* bridge); + +public slots: + void pushPacket(char* packet,int size); + void toggleServer(); private: Ui::SpwTcpPacketServer *ui; + abstractSpwBridge* p_bridge; + QTcpServer* p_server; }; #endif // SPWTCPPACKETSERVER_H diff --git a/spwplugin/abstractspwbridge.h b/spwplugin/abstractspwbridge.h --- a/spwplugin/abstractspwbridge.h +++ b/spwplugin/abstractspwbridge.h @@ -42,6 +42,7 @@ public slots: virtual int pushRMAPPacket(char* packet,int size)=0; signals: void setConnected(bool connected); + void pushPacketOverTCP(char* packet,int size); protected: socexplorerplugin* plugin; QWidget* p_GUI; diff --git a/spwplugin/spwplugin.cpp b/spwplugin/spwplugin.cpp --- a/spwplugin/spwplugin.cpp +++ b/spwplugin/spwplugin.cpp @@ -24,14 +24,18 @@ #include "stardundeespw_usb.h" #include #include "spwpywrapper.h" + spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) { Q_UNUSED(parent) this->bridge = NULL; this->scanDone = false; this->pyObject = new spwPyWrapper(this); + this->tcpServer = new SpwTcpPacketServer(this); this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); this->bridgeSelector = new QComboBox(this); + this->mainTabWidgt = new QTabWidget(this); + this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration") this->mainLayout = new QGridLayout(this->mainGroupBox); this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); diff --git a/spwplugin/spwplugin.h b/spwplugin/spwplugin.h --- a/spwplugin/spwplugin.h +++ b/spwplugin/spwplugin.h @@ -28,10 +28,12 @@ #include #include #include +#include #include #include +#include "SpwTcpPacketServer/spwtcppacketserver.h" class spwplugin : public socexplorerplugin { @@ -62,7 +64,9 @@ signals: private: abstractSpwBridge* bridge; + SpwTcpPacketServer* tcpServer; bool scanDone; + QTabWidget* mainTabWidgt; QGroupBox* mainGroupBox; QComboBox* bridgeSelector; QGridLayout* mainLayout; diff --git a/spwplugin/spwplugin.pro b/spwplugin/spwplugin.pro --- a/spwplugin/spwplugin.pro +++ b/spwplugin/spwplugin.pro @@ -4,6 +4,7 @@ #------------------------------------------------- CONFIG += socexplorerplugin +QT += network win32:CONFIG += dll win32:CONFIG -= static CONFIG(debug, debug|release) { diff --git a/spwplugin/stardundeespw_usb.h b/spwplugin/stardundeespw_usb.h --- a/spwplugin/stardundeespw_usb.h +++ b/spwplugin/stardundeespw_usb.h @@ -122,7 +122,6 @@ public slots: private: void makeGUI(socexplorerplugin *parent); stardundeeSPW_USB_Manager* manager; -// QGridLayout* mainLayout; }; #endif // STARDUNDEESPW_USB_H