diff --git a/spwplugin/GR-ESB/gr_esb_bridge.cpp b/spwplugin/GR-ESB/gr_esb_bridge.cpp --- a/spwplugin/GR-ESB/gr_esb_bridge.cpp +++ b/spwplugin/GR-ESB/gr_esb_bridge.cpp @@ -1,11 +1,15 @@ #include "gr_esb_bridge.h" #include "gr_esb_ui.h" +#include GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) : abstractSpwBridge(parent) { this->p_GUI = new GR_ESB_ui(); - this->soc = new QTcpSocket(this); + this->Read_soc = new QTcpSocket(this); + this->Write_soc = new QTcpSocket(this); + connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString))); + connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setPort(QString))); } GR_ESB_bridge::~GR_ESB_bridge() @@ -14,14 +18,66 @@ GR_ESB_bridge::~GR_ESB_bridge() bool GR_ESB_bridge::connectBridge() { - + int timeout=60; + if(this->Read_soc->state()==QTcpSocket::UnconnectedState) + { + this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port); + this->Read_soc->waitForConnected(30000); + } + if(this->Write_soc->state()==QTcpSocket::UnconnectedState) + { + this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port); + this->Write_soc->waitForConnected(30000); + } + while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState)) + { + usleep(100000); + if(timeout--==0)return false; + } + return true; } bool GR_ESB_bridge::disconnectBridge() { + int timeout=60; + if(this->Read_soc->state()!=QTcpSocket::UnconnectedState) + { + this->Read_soc->disconnectFromHost(); + this->Read_soc->waitForDisconnected(30000); + while(this->Read_soc->state()!=QTcpSocket::UnconnectedState) + { + usleep(100000); + if(timeout--==0)return false; + } + } + return true; +} +void GR_ESB_bridge::setIP(QString ip) +{ + this->IP = ip; } +void GR_ESB_bridge::setVirtualLink(QString vlink) +{ + vlink = vlink.section("Virtual link",0,0); + bool success; + int vlinkTmp = vlink.toInt(&success); + if(success) + { + setVirtualLink(vlinkTmp); + } +} + +void GR_ESB_bridge::setVirtualLink(qint32 vlink) +{ + if(vlink<6 && vlink>=0) + { + virtualLinkIndex = vlink; + } +} + + unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address) { diff --git a/spwplugin/GR-ESB/gr_esb_bridge.h b/spwplugin/GR-ESB/gr_esb_bridge.h --- a/spwplugin/GR-ESB/gr_esb_bridge.h +++ b/spwplugin/GR-ESB/gr_esb_bridge.h @@ -3,6 +3,22 @@ #include "abstractspwbridge.h" #include +struct gresb_Conf_str +{ + qint32 Read_port; + qint32 Write_port; +}; + +const struct gresb_Conf_str gresb_Conf[]= +{ + {3000,3001}, //Virtual link 0 + {3002,3003}, //Virtual link 1 + {3004,3005}, //Virtual link 2 + {3006,3007}, //Virtual link 3 + {3008,3009}, //Virtual link 4 + {3010,3011} //Virtual link 5 +}; + class GR_ESB_bridge : public abstractSpwBridge { Q_OBJECT @@ -15,12 +31,19 @@ signals: public slots: bool connectBridge(); bool disconnectBridge(); + void setIP(QString ip); + void setVirtualLink(QString vlink); + void setVirtualLink(qint32 vlink); unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); int pushRMAPPacket(char* packet,int size); void packetReceived(); - QTcpSocket* soc; +private: + QTcpSocket* Read_soc; + QTcpSocket* Write_soc; + QString IP; + int virtualLinkIndex; }; diff --git a/spwplugin/GR-ESB/gr_esb_ui.cpp b/spwplugin/GR-ESB/gr_esb_ui.cpp --- a/spwplugin/GR-ESB/gr_esb_ui.cpp +++ b/spwplugin/GR-ESB/gr_esb_ui.cpp @@ -1,14 +1,19 @@ #include "gr_esb_ui.h" #include "ui_gr_esb_ui.h" +#include GR_ESB_ui::GR_ESB_ui(QWidget *parent) : QWidget(parent), ui(new Ui::GR_ESB_ui) { ui->setupUi(this); + connect(this->ui->GRESB_IP_lineEdit,SIGNAL(textChanged(QString)),this,SLOT(changeIp(QString))); + connect(this->ui->GRESB_Vlink_CmBx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(vlinkchanged(QString))); } -GR_ESB_ui::~GR_ESB_ui() +void GR_ESB_ui::changeIp(QString ip) { - delete ui; + this->ui->WebView->load(QUrl("http://"+ip)); + emit this->ipchanged(ip); } + diff --git a/spwplugin/GR-ESB/gr_esb_ui.h b/spwplugin/GR-ESB/gr_esb_ui.h --- a/spwplugin/GR-ESB/gr_esb_ui.h +++ b/spwplugin/GR-ESB/gr_esb_ui.h @@ -13,8 +13,13 @@ class GR_ESB_ui : public QWidget public: explicit GR_ESB_ui(QWidget *parent = 0); - ~GR_ESB_ui(); + +public slots: + void changeIp(QString ip); +signals: + void ipchanged(QString ip); + void vlinkchanged(QString vlink); private: Ui::GR_ESB_ui *ui; }; diff --git a/spwplugin/GR-ESB/gr_esb_ui.ui b/spwplugin/GR-ESB/gr_esb_ui.ui --- a/spwplugin/GR-ESB/gr_esb_ui.ui +++ b/spwplugin/GR-ESB/gr_esb_ui.ui @@ -13,55 +13,127 @@ Form - - - - - - - - GR-ESB Port + + + + + - - - - - - - - - GR-ESB IP Address + + 0 - - - - - - Select link number - - - - - - - - SPW0 + + + <html><head/><body><p>The Config tab allows you to configure the Ethernet conncetion to the GR-ESB and some spacewire parameters.</p></body></html> - - - - SPW1 + + Config + + + + + + + Virtual link 0 + + + + + Virtual link 1 + + + + + Virtual link 2 + + + + + Virtual link 3 + + + + + Virtual link 4 + + + + + Virtual link 5 + + + + + + + + GR-ESB Virtual link + + + + + + + + SPW0 + + + + + SPW1 + + + + + SPW2 + + + + + + + + + + + Select link number + + + + + + + GR-ESB IP Address + + + + + + + + <html><head/><body><p>The Web tab gives access to the GR-ESB web interface.</p></body></html> - - - - SPW2 - - + + Web + + + + + + + + + + QWebView + QWidget +
QWebView
+ 1 +
+
diff --git a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.ui b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.ui --- a/spwplugin/SpwTcpPacketServer/spwtcppacketserver.ui +++ b/spwplugin/SpwTcpPacketServer/spwtcppacketserver.ui @@ -13,6 +13,9 @@ Form + + <html><head/><body><p>The spacewire plugin TCP server allows you to forward spacewire packets to any custom application, here you will configure the TCP connection and get some status information.</p></body></html> + @@ -45,7 +48,11 @@ - + + + <html><head/><body><p>Set the port on which the server will listen and accept client connections.</p></body></html> + + diff --git a/spwplugin/StarDundee/stardundeespw_usb.cpp b/spwplugin/StarDundee/stardundeespw_usb.cpp --- a/spwplugin/StarDundee/stardundeespw_usb.cpp +++ b/spwplugin/StarDundee/stardundeespw_usb.cpp @@ -37,7 +37,6 @@ stardundeeSPW_USB::stardundeeSPW_USB(soc stardundeeSPW_USB::~stardundeeSPW_USB() { this->manager->requestInterruption(); - delete this->p_GUI; } void stardundeeSPW_USB::toggleBridgeConnection() diff --git a/spwplugin/abstractspwbridge.cpp b/spwplugin/abstractspwbridge.cpp --- a/spwplugin/abstractspwbridge.cpp +++ b/spwplugin/abstractspwbridge.cpp @@ -28,6 +28,11 @@ abstractSpwBridge::abstractSpwBridge(soc this->p_GUI=NULL; } +abstractSpwBridge::~abstractSpwBridge() +{ + delete this->p_GUI; +} + QWidget *abstractSpwBridge::getGUI() { return this->p_GUI; diff --git a/spwplugin/abstractspwbridge.h b/spwplugin/abstractspwbridge.h --- a/spwplugin/abstractspwbridge.h +++ b/spwplugin/abstractspwbridge.h @@ -32,6 +32,7 @@ class abstractSpwBridge : public QObject Q_OBJECT public: explicit abstractSpwBridge(socexplorerplugin *parent); + ~abstractSpwBridge(); QWidget *getGUI(); public slots: diff --git a/spwplugin/spwplugin.pro b/spwplugin/spwplugin.pro --- a/spwplugin/spwplugin.pro +++ b/spwplugin/spwplugin.pro @@ -4,7 +4,9 @@ #------------------------------------------------- CONFIG += socexplorerplugin -QT += network +QT += network webkit +greaterThan(QT_MAJOR_VERSION, 4): QT += webkitwidgets + win32:CONFIG += dll win32:CONFIG -= static CONFIG(debug, debug|release) {