@@ -1,124 +1,131 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "spwtcppacketserver.h" |
|
22 | #include "spwtcppacketserver.h" | |
23 | #include "ui_spwtcppacketserver.h" |
|
23 | #include "ui_spwtcppacketserver.h" | |
24 | #include <QNetworkInterface> |
|
24 | #include <QNetworkInterface> | |
25 | #include <QByteArray> |
|
25 | #include <QByteArray> | |
26 |
|
26 | |||
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : |
|
27 | SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) : | |
28 | QWidget(parent), |
|
28 | QWidget(parent), | |
29 | ui(new Ui::SpwTcpPacketServer) |
|
29 | ui(new Ui::SpwTcpPacketServer) | |
30 | { |
|
30 | { | |
31 | ui->setupUi(this); |
|
31 | ui->setupUi(this); | |
32 | this->p_bridge = NULL; |
|
32 | this->p_bridge = NULL; | |
33 | this->p_server = new QTcpServer(); |
|
33 | this->p_server = new QTcpServer(); | |
34 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); |
|
34 | connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer())); | |
35 | updateHostIP(); |
|
35 | updateHostIP(); | |
36 | this->ui->PortLineEdit->setText("2200"); |
|
36 | this->ui->PortLineEdit->setText("2200"); | |
|
37 | connect(this->p_server,SIGNAL(newConnection()),this,SLOT(newConnection())); | |||
37 | } |
|
38 | } | |
38 |
|
39 | |||
39 | SpwTcpPacketServer::~SpwTcpPacketServer() |
|
40 | SpwTcpPacketServer::~SpwTcpPacketServer() | |
40 | { |
|
41 | { | |
41 | delete ui; |
|
42 | delete ui; | |
42 | } |
|
43 | } | |
43 |
|
44 | |||
44 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) |
|
45 | void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge) | |
45 | { |
|
46 | { | |
46 | if(this->p_bridge!=NULL) |
|
47 | if(this->p_bridge!=NULL) | |
47 | { |
|
48 | { | |
48 | disconnect(this,SLOT(pushPacket(char*,int))); |
|
49 | disconnect(this,SLOT(pushPacket(char*,int))); | |
49 | } |
|
50 | } | |
50 | this->p_bridge = bridge; |
|
51 | this->p_bridge = bridge; | |
51 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); |
|
52 | connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int))); | |
52 | } |
|
53 | } | |
53 |
|
54 | |||
54 | void SpwTcpPacketServer::pushPacket(char *packet, int size) |
|
55 | void SpwTcpPacketServer::pushPacket(char *packet, int size) | |
55 | { |
|
56 | { | |
56 | QByteArray data; |
|
57 | QByteArray data; | |
57 | char sizech[3]; |
|
58 | char sizech[3]; | |
58 | data.append((char)0); |
|
59 | data.append((char)0); | |
59 | sizech[0]=size & 0x0FF; |
|
60 | sizech[0]=size & 0x0FF; | |
60 | sizech[1]=(size>>8) & 0x0FF; |
|
61 | sizech[1]=(size>>8) & 0x0FF; | |
61 | sizech[2]=(size>>16) & 0x0FF; |
|
62 | sizech[2]=(size>>16) & 0x0FF; | |
62 | data.append(sizech,3); |
|
63 | data.append(sizech,3); | |
63 | data.append(packet,size); |
|
64 | data.append(packet,size); | |
64 | for(int i=0;i<connectedClients.count();i++) |
|
65 | for(int i=0;i<connectedClients.count();i++) | |
65 | { |
|
66 | { | |
66 | QTcpSocket* soc=connectedClients.at(i); |
|
67 | QTcpSocket* soc=connectedClients.at(i); | |
67 | if(soc->state()!=QAbstractSocket::ConnectedState) |
|
68 | if(soc->state()!=QAbstractSocket::ConnectedState) | |
68 | { |
|
69 | { | |
69 | connectedClients.removeAt(i); |
|
70 | connectedClients.removeAt(i); | |
70 | delete soc; |
|
71 | delete soc; | |
71 | } |
|
72 | } | |
72 | else |
|
73 | else | |
73 | { |
|
74 | { | |
74 | connectedClients.at(i)->write(data); |
|
75 | connectedClients.at(i)->write(data); | |
75 | } |
|
76 | } | |
76 | } |
|
77 | } | |
77 | } |
|
78 | } | |
78 |
|
79 | |||
79 | void SpwTcpPacketServer::toggleServer() |
|
80 | void SpwTcpPacketServer::toggleServer() | |
80 | { |
|
81 | { | |
81 | if(this->p_server->isListening()) |
|
82 | if(this->p_server->isListening()) | |
82 | { |
|
83 | { | |
83 | disconnectServer(); |
|
84 | disconnectServer(); | |
84 | } |
|
85 | } | |
85 | else |
|
86 | else | |
86 | { |
|
87 | { | |
87 | connectServer(); |
|
88 | connectServer(); | |
88 | } |
|
89 | } | |
89 | } |
|
90 | } | |
90 |
|
91 | |||
91 | void SpwTcpPacketServer::connectServer() |
|
92 | void SpwTcpPacketServer::connectServer() | |
92 | { |
|
93 | { | |
93 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); |
|
94 | this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt()); | |
94 | this->ui->startServeQpb->setText("Stop Server"); |
|
95 | this->ui->startServeQpb->setText("Stop Server"); | |
95 | } |
|
96 | } | |
96 |
|
97 | |||
97 | void SpwTcpPacketServer::disconnectServer() |
|
98 | void SpwTcpPacketServer::disconnectServer() | |
98 | { |
|
99 | { | |
99 | this->ui->startServeQpb->setText("Start Server"); |
|
100 | this->ui->startServeQpb->setText("Start Server"); | |
100 | this->p_server->close(); |
|
101 | this->p_server->close(); | |
101 | } |
|
102 | } | |
102 |
|
103 | |||
103 | void SpwTcpPacketServer::setServerPort(qint32 port) |
|
104 | void SpwTcpPacketServer::setServerPort(qint32 port) | |
104 | { |
|
105 | { | |
105 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); |
|
106 | this->ui->PortLineEdit->setText(QString("%1").arg(port)); | |
106 | } |
|
107 | } | |
107 |
|
108 | |||
|
109 | void SpwTcpPacketServer::setServerSetIP(QString ip) | |||
|
110 | { | |||
|
111 | this->ui->IPLineEdit->setText(ip); | |||
|
112 | } | |||
|
113 | ||||
108 | void SpwTcpPacketServer::newConnection() |
|
114 | void SpwTcpPacketServer::newConnection() | |
109 | { |
|
115 | { | |
110 | this->connectedClients.append(this->p_server->nextPendingConnection()); |
|
116 | this->connectedClients.append(this->p_server->nextPendingConnection()); | |
|
117 | this->ui->listWidget->addItem(this->connectedClients.last()->peerAddress().toString()); | |||
111 | } |
|
118 | } | |
112 |
|
119 | |||
113 | void SpwTcpPacketServer::updateHostIP() |
|
120 | void SpwTcpPacketServer::updateHostIP() | |
114 | { |
|
121 | { | |
115 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); |
|
122 | QList<QHostAddress> list = QNetworkInterface::allAddresses(); | |
116 |
|
123 | |||
117 | for(int nIter=0; nIter<list.count(); nIter++) |
|
124 | for(int nIter=0; nIter<list.count(); nIter++) | |
118 |
|
125 | |||
119 | { |
|
126 | { | |
120 | if(!list[nIter].isLoopback()) |
|
127 | if(!list[nIter].isLoopback()) | |
121 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) |
|
128 | if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol ) | |
122 | this->ui->IPLineEdit->setText(list[nIter].toString()); |
|
129 | this->ui->IPLineEdit->setText(list[nIter].toString()); | |
123 | } |
|
130 | } | |
124 | } |
|
131 | } |
@@ -1,60 +1,61 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #ifndef SPWTCPPACKETSERVER_H |
|
22 | #ifndef SPWTCPPACKETSERVER_H | |
23 | #define SPWTCPPACKETSERVER_H |
|
23 | #define SPWTCPPACKETSERVER_H | |
24 |
|
24 | |||
25 | #include <QWidget> |
|
25 | #include <QWidget> | |
26 | #include <abstractspwbridge.h> |
|
26 | #include <abstractspwbridge.h> | |
27 | #include <QTcpServer> |
|
27 | #include <QTcpServer> | |
28 | #include <QList> |
|
28 | #include <QList> | |
29 | #include <QTcpSocket> |
|
29 | #include <QTcpSocket> | |
30 |
|
30 | |||
31 | namespace Ui { |
|
31 | namespace Ui { | |
32 | class SpwTcpPacketServer; |
|
32 | class SpwTcpPacketServer; | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | class SpwTcpPacketServer : public QWidget |
|
35 | class SpwTcpPacketServer : public QWidget | |
36 | { |
|
36 | { | |
37 | Q_OBJECT |
|
37 | Q_OBJECT | |
38 |
|
38 | |||
39 | public: |
|
39 | public: | |
40 | explicit SpwTcpPacketServer(QWidget *parent = 0); |
|
40 | explicit SpwTcpPacketServer(QWidget *parent = 0); | |
41 | ~SpwTcpPacketServer(); |
|
41 | ~SpwTcpPacketServer(); | |
42 |
|
42 | |||
43 | void setBridge(abstractSpwBridge* bridge); |
|
43 | void setBridge(abstractSpwBridge* bridge); | |
44 |
|
44 | |||
45 | public slots: |
|
45 | public slots: | |
46 | void pushPacket(char* packet,int size); |
|
46 | void pushPacket(char* packet,int size); | |
47 | void toggleServer(); |
|
47 | void toggleServer(); | |
48 | void connectServer(); |
|
48 | void connectServer(); | |
49 | void disconnectServer(); |
|
49 | void disconnectServer(); | |
50 | void setServerPort(qint32 port); |
|
50 | void setServerPort(qint32 port); | |
|
51 | void setServerSetIP(QString ip); | |||
51 | void newConnection(); |
|
52 | void newConnection(); | |
52 | private: |
|
53 | private: | |
53 | void updateHostIP(); |
|
54 | void updateHostIP(); | |
54 | Ui::SpwTcpPacketServer *ui; |
|
55 | Ui::SpwTcpPacketServer *ui; | |
55 | abstractSpwBridge* p_bridge; |
|
56 | abstractSpwBridge* p_bridge; | |
56 | QTcpServer* p_server; |
|
57 | QTcpServer* p_server; | |
57 | QList<QTcpSocket*> connectedClients; |
|
58 | QList<QTcpSocket*> connectedClients; | |
58 | }; |
|
59 | }; | |
59 |
|
60 | |||
60 | #endif // SPWTCPPACKETSERVER_H |
|
61 | #endif // SPWTCPPACKETSERVER_H |
@@ -1,150 +1,151 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 3 of the License, or |
|
7 | -- the Free Software Foundation; either version 3 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 |
|
22 | |||
23 | #include "spwplugin.h" |
|
23 | #include "spwplugin.h" | |
24 | #include "stardundeespw_usb.h" |
|
24 | #include "stardundeespw_usb.h" | |
25 | #include <socexplorerproxy.h> |
|
25 | #include <socexplorerproxy.h> | |
26 | #include "spwpywrapper.h" |
|
26 | #include "spwpywrapper.h" | |
27 |
|
27 | |||
28 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
28 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) | |
29 | { |
|
29 | { | |
30 | Q_UNUSED(parent) |
|
30 | Q_UNUSED(parent) | |
31 | this->bridge = NULL; |
|
31 | this->bridge = NULL; | |
32 | this->scanDone = false; |
|
32 | this->scanDone = false; | |
33 | this->pyObject = new spwPyWrapper(this); |
|
33 | this->pyObject = new spwPyWrapper(this); | |
34 | this->tcpServer = new SpwTcpPacketServer(this); |
|
34 | this->tcpServer = new SpwTcpPacketServer(this); | |
35 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
35 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); | |
36 | this->bridgeSelector = new QComboBox(this); |
|
36 | this->bridgeSelector = new QComboBox(this); | |
37 | this->mainTabWidgt = new QTabWidget(this); |
|
37 | this->mainTabWidgt = new QTabWidget(this); | |
38 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
38 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); | |
39 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
39 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); | |
40 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
40 | this->mainLayout = new QGridLayout(this->mainGroupBox); | |
41 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
41 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); | |
42 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
42 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); | |
43 | //this->mainGroupBox->setLayout(this->mainLayout); |
|
43 | //this->mainGroupBox->setLayout(this->mainLayout); | |
44 | this->setWidget(this->mainTabWidgt); |
|
44 | this->setWidget(this->mainTabWidgt); | |
45 | this->bridgeSelector->addItem("none"); |
|
45 | this->bridgeSelector->addItem("none"); | |
46 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
46 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); | |
47 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
47 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); | |
48 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
48 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); | |
49 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
49 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); | |
50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); | |
51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); |
|
51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); | |
|
52 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); | |||
52 | } |
|
53 | } | |
53 |
|
54 | |||
54 |
|
55 | |||
55 | spwplugin::~spwplugin() |
|
56 | spwplugin::~spwplugin() | |
56 | { |
|
57 | { | |
57 |
|
58 | |||
58 | } |
|
59 | } | |
59 |
|
60 | |||
60 |
|
61 | |||
61 |
|
62 | |||
62 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
63 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) | |
63 | { |
|
64 | { | |
64 | if(Connected) |
|
65 | if(Connected) | |
65 | { |
|
66 | { | |
66 | return bridge->Read(Value,count,address); |
|
67 | return bridge->Read(Value,count,address); | |
67 | } |
|
68 | } | |
68 | return 0; |
|
69 | return 0; | |
69 | } |
|
70 | } | |
70 |
|
71 | |||
71 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
72 | void spwplugin::bridgeSelectionChanged(const QString &text) | |
72 | { |
|
73 | { | |
73 | printf("test"); |
|
74 | printf("test"); | |
74 | if(text=="none") |
|
75 | if(text=="none") | |
75 | { |
|
76 | { | |
76 | if(this->bridge!=NULL) |
|
77 | if(this->bridge!=NULL) | |
77 | { |
|
78 | { | |
78 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
79 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
79 | this->disconnect(this,SLOT(setConnected(bool))); |
|
80 | this->disconnect(this,SLOT(setConnected(bool))); | |
80 | delete this->bridge; |
|
81 | delete this->bridge; | |
81 | this->bridge= NULL; |
|
82 | this->bridge= NULL; | |
82 | } |
|
83 | } | |
83 | } |
|
84 | } | |
84 | if(text=="STAR-Dundee Spw USB Brick") |
|
85 | if(text=="STAR-Dundee Spw USB Brick") | |
85 | { |
|
86 | { | |
86 | if(this->bridge!=NULL) |
|
87 | if(this->bridge!=NULL) | |
87 | { |
|
88 | { | |
88 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
89 | this->mainLayout->removeWidget(this->bridge->getGUI()); | |
89 | this->disconnect(this,SLOT(setConnected(bool))); |
|
90 | this->disconnect(this,SLOT(setConnected(bool))); | |
90 | delete this->bridge; |
|
91 | delete this->bridge; | |
91 | } |
|
92 | } | |
92 | this->bridge = new stardundeeSPW_USB(this); |
|
93 | this->bridge = new stardundeeSPW_USB(this); | |
93 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
94 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | |
94 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
95 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); | |
95 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
96 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); | |
96 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
97 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); | |
97 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
98 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); | |
98 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
99 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); | |
99 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString))); |
|
100 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString))); | |
100 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString))); |
|
101 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString))); | |
101 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
102 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); | |
102 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
103 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); | |
103 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
104 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); | |
104 | } |
|
105 | } | |
105 | } |
|
106 | } | |
106 |
|
107 | |||
107 |
|
108 | |||
108 | void spwplugin::selectBridge(const QString &text) |
|
109 | void spwplugin::selectBridge(const QString &text) | |
109 | { |
|
110 | { | |
110 |
|
111 | |||
111 | if(text=="none") |
|
112 | if(text=="none") | |
112 | { |
|
113 | { | |
113 | this->bridgeSelector->setCurrentIndex(0); |
|
114 | this->bridgeSelector->setCurrentIndex(0); | |
114 | } |
|
115 | } | |
115 | if(text=="STAR-Dundee Spw USB Brick") |
|
116 | if(text=="STAR-Dundee Spw USB Brick") | |
116 | { |
|
117 | { | |
117 | this->bridgeSelector->setCurrentIndex(1); |
|
118 | this->bridgeSelector->setCurrentIndex(1); | |
118 | } |
|
119 | } | |
119 | } |
|
120 | } | |
120 |
|
121 | |||
121 | void spwplugin::setConnected(bool connected) |
|
122 | void spwplugin::setConnected(bool connected) | |
122 | { |
|
123 | { | |
123 | this->bridgeSelector->setDisabled(connected); |
|
124 | this->bridgeSelector->setDisabled(connected); | |
124 | this->Connected = connected; |
|
125 | this->Connected = connected; | |
125 | emit activateSig(connected); |
|
126 | emit activateSig(connected); | |
126 | if(!this->scanDone) |
|
127 | if(!this->scanDone) | |
127 | { |
|
128 | { | |
128 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
129 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); | |
129 | this->scanDone=true; |
|
130 | this->scanDone=true; | |
130 | } |
|
131 | } | |
131 | } |
|
132 | } | |
132 |
|
133 | |||
133 |
|
134 | |||
134 |
|
135 | |||
135 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
136 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |
136 | { |
|
137 | { | |
137 | if(Connected) |
|
138 | if(Connected) | |
138 | { |
|
139 | { | |
139 | return bridge->Write(Value,count,address); |
|
140 | return bridge->Write(Value,count,address); | |
140 | } |
|
141 | } | |
141 | return 0; |
|
142 | return 0; | |
142 | } |
|
143 | } | |
143 |
|
144 | |||
144 |
|
145 | |||
145 |
|
146 | |||
146 |
|
147 | |||
147 |
|
148 | |||
148 |
|
149 | |||
149 |
|
150 | |||
150 |
|
151 |
@@ -1,29 +1,30 | |||||
1 | #ifndef SPWPYWRAPPER_H |
|
1 | #ifndef SPWPYWRAPPER_H | |
2 | #define SPWPYWRAPPER_H |
|
2 | #define SPWPYWRAPPER_H | |
3 | #include <genericPySysdriver.h> |
|
3 | #include <genericPySysdriver.h> | |
4 |
|
4 | |||
5 | class spwPyWrapper : public genericPySysdriver |
|
5 | class spwPyWrapper : public genericPySysdriver | |
6 | { |
|
6 | { | |
7 | Q_OBJECT |
|
7 | Q_OBJECT | |
8 | public: |
|
8 | public: | |
9 | explicit spwPyWrapper(socexplorerplugin *parent = 0); |
|
9 | explicit spwPyWrapper(socexplorerplugin *parent = 0); | |
10 | signals: |
|
10 | signals: | |
11 | void selectBridge(const QString &bridgeName); |
|
11 | void selectBridge(const QString &bridgeName); | |
12 | bool connectBridge(); |
|
12 | bool connectBridge(); | |
13 | bool disconnectBridge(); |
|
13 | bool disconnectBridge(); | |
14 | void StarDundeeSelectBrick(int brickIndex); |
|
14 | void StarDundeeSelectBrick(int brickIndex); | |
15 | void StarDundeeSelectLinkNumber(int linkIndex); |
|
15 | void StarDundeeSelectLinkNumber(int linkIndex); | |
16 | void StarDundeeSelectLinkSpeed(int linkSpeed); |
|
16 | void StarDundeeSelectLinkSpeed(int linkSpeed); | |
17 | void StarDundeeSetDestinationKey(const QString & destKey); |
|
17 | void StarDundeeSetDestinationKey(const QString & destKey); | |
18 | void StarDundeeSetRmapAddress(const QString & address); |
|
18 | void StarDundeeSetRmapAddress(const QString & address); | |
19 | void StarDundeeSetRmapKey(const QString & key); |
|
19 | void StarDundeeSetRmapKey(const QString & key); | |
20 | void StarDundeeSetRmapTimeout(const QString & timeout); |
|
20 | void StarDundeeSetRmapTimeout(const QString & timeout); | |
21 |
|
21 | |||
22 | void TCPServerConnect(); |
|
22 | void TCPServerConnect(); | |
23 | void TCPServerDisconnect(); |
|
23 | void TCPServerDisconnect(); | |
24 | void TCPServerSetPort(qint32 port); |
|
24 | void TCPServerSetPort(qint32 port); | |
|
25 | void TCPServerSetIP(QString ip); | |||
25 | public slots: |
|
26 | public slots: | |
26 |
|
27 | |||
27 | }; |
|
28 | }; | |
28 |
|
29 | |||
29 | #endif // SPWPYWRAPPER_H |
|
30 | #endif // SPWPYWRAPPER_H |
General Comments 0
You need to be logged in to leave comments.
Login now