##// END OF EJS Templates
Sync
Jeandet Alexis -
r20:d09469239955 default
parent child
Show More
@@ -1,68 +1,124
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>
25 #include <QByteArray>
24
26
25 SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) :
27 SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) :
26 QWidget(parent),
28 QWidget(parent),
27 ui(new Ui::SpwTcpPacketServer)
29 ui(new Ui::SpwTcpPacketServer)
28 {
30 {
29 ui->setupUi(this);
31 ui->setupUi(this);
30 this->p_bridge = NULL;
32 this->p_bridge = NULL;
31 this->p_server = new QTcpServer();
33 this->p_server = new QTcpServer();
32 connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer()));
34 connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer()));
35 updateHostIP();
36 this->ui->PortLineEdit->setText("2200");
33 }
37 }
34
38
35 SpwTcpPacketServer::~SpwTcpPacketServer()
39 SpwTcpPacketServer::~SpwTcpPacketServer()
36 {
40 {
37 delete ui;
41 delete ui;
38 }
42 }
39
43
40 void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge)
44 void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge)
41 {
45 {
42 if(this->p_bridge!=NULL)
46 if(this->p_bridge!=NULL)
43 {
47 {
44 disconnect(this,SLOT(pushPacket(char*,int)));
48 disconnect(this,SLOT(pushPacket(char*,int)));
45 }
49 }
46 this->p_bridge = bridge;
50 this->p_bridge = bridge;
47 connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int)));
51 connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int)));
48 }
52 }
49
53
50 void SpwTcpPacketServer::pushPacket(char *packet, int size)
54 void SpwTcpPacketServer::pushPacket(char *packet, int size)
51 {
55 {
52
56 QByteArray data;
57 char sizech[3];
58 data.append((char)0);
59 sizech[0]=size & 0x0FF;
60 sizech[1]=(size>>8) & 0x0FF;
61 sizech[2]=(size>>16) & 0x0FF;
62 data.append(sizech,3);
63 data.append(packet,size);
64 for(int i=0;i<connectedClients.count();i++)
65 {
66 QTcpSocket* soc=connectedClients.at(i);
67 if(soc->state()!=QAbstractSocket::ConnectedState)
68 {
69 connectedClients.removeAt(i);
70 delete soc;
71 }
72 else
73 {
74 connectedClients.at(i)->write(data);
75 }
76 }
53 }
77 }
54
78
55 void SpwTcpPacketServer::toggleServer()
79 void SpwTcpPacketServer::toggleServer()
56 {
80 {
57 if(this->p_server->isListening())
81 if(this->p_server->isListening())
58 {
82 {
59 this->ui->startServeQpb->setText("Start Server");
83 disconnectServer();
60 this->p_server->close();
61 }
84 }
62 else
85 else
63 {
86 {
64 this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt());
87 connectServer();
65
66 this->ui->startServeQpb->setText("Stop Server");
67 }
88 }
68 }
89 }
90
91 void SpwTcpPacketServer::connectServer()
92 {
93 this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt());
94 this->ui->startServeQpb->setText("Stop Server");
95 }
96
97 void SpwTcpPacketServer::disconnectServer()
98 {
99 this->ui->startServeQpb->setText("Start Server");
100 this->p_server->close();
101 }
102
103 void SpwTcpPacketServer::setServerPort(qint32 port)
104 {
105 this->ui->PortLineEdit->setText(QString("%1").arg(port));
106 }
107
108 void SpwTcpPacketServer::newConnection()
109 {
110 this->connectedClients.append(this->p_server->nextPendingConnection());
111 }
112
113 void SpwTcpPacketServer::updateHostIP()
114 {
115 QList<QHostAddress> list = QNetworkInterface::allAddresses();
116
117 for(int nIter=0; nIter<list.count(); nIter++)
118
119 {
120 if(!list[nIter].isLoopback())
121 if (list[nIter].protocol() == QAbstractSocket::IPv4Protocol )
122 this->ui->IPLineEdit->setText(list[nIter].toString());
123 }
124 }
@@ -1,52 +1,60
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>
29 #include <QTcpSocket>
28
30
29 namespace Ui {
31 namespace Ui {
30 class SpwTcpPacketServer;
32 class SpwTcpPacketServer;
31 }
33 }
32
34
33 class SpwTcpPacketServer : public QWidget
35 class SpwTcpPacketServer : public QWidget
34 {
36 {
35 Q_OBJECT
37 Q_OBJECT
36
38
37 public:
39 public:
38 explicit SpwTcpPacketServer(QWidget *parent = 0);
40 explicit SpwTcpPacketServer(QWidget *parent = 0);
39 ~SpwTcpPacketServer();
41 ~SpwTcpPacketServer();
40
42
41 void setBridge(abstractSpwBridge* bridge);
43 void setBridge(abstractSpwBridge* bridge);
42
44
43 public slots:
45 public slots:
44 void pushPacket(char* packet,int size);
46 void pushPacket(char* packet,int size);
45 void toggleServer();
47 void toggleServer();
48 void connectServer();
49 void disconnectServer();
50 void setServerPort(qint32 port);
51 void newConnection();
46 private:
52 private:
53 void updateHostIP();
47 Ui::SpwTcpPacketServer *ui;
54 Ui::SpwTcpPacketServer *ui;
48 abstractSpwBridge* p_bridge;
55 abstractSpwBridge* p_bridge;
49 QTcpServer* p_server;
56 QTcpServer* p_server;
57 QList<QTcpSocket*> connectedClients;
50 };
58 };
51
59
52 #endif // SPWTCPPACKETSERVER_H
60 #endif // SPWTCPPACKETSERVER_H
@@ -1,147 +1,150
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()));
50 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
51 connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
49 }
52 }
50
53
51
54
52 spwplugin::~spwplugin()
55 spwplugin::~spwplugin()
53 {
56 {
54
57
55 }
58 }
56
59
57
60
58
61
59 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
62 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
60 {
63 {
61 if(Connected)
64 if(Connected)
62 {
65 {
63 return bridge->Read(Value,count,address);
66 return bridge->Read(Value,count,address);
64 }
67 }
65 return 0;
68 return 0;
66 }
69 }
67
70
68 void spwplugin::bridgeSelectionChanged(const QString &text)
71 void spwplugin::bridgeSelectionChanged(const QString &text)
69 {
72 {
70 printf("test");
73 printf("test");
71 if(text=="none")
74 if(text=="none")
72 {
75 {
73 if(this->bridge!=NULL)
76 if(this->bridge!=NULL)
74 {
77 {
75 this->mainLayout->removeWidget(this->bridge->getGUI());
78 this->mainLayout->removeWidget(this->bridge->getGUI());
76 this->disconnect(this,SLOT(setConnected(bool)));
79 this->disconnect(this,SLOT(setConnected(bool)));
77 delete this->bridge;
80 delete this->bridge;
78 this->bridge= NULL;
81 this->bridge= NULL;
79 }
82 }
80 }
83 }
81 if(text=="STAR-Dundee Spw USB Brick")
84 if(text=="STAR-Dundee Spw USB Brick")
82 {
85 {
83 if(this->bridge!=NULL)
86 if(this->bridge!=NULL)
84 {
87 {
85 this->mainLayout->removeWidget(this->bridge->getGUI());
88 this->mainLayout->removeWidget(this->bridge->getGUI());
86 this->disconnect(this,SLOT(setConnected(bool)));
89 this->disconnect(this,SLOT(setConnected(bool)));
87 delete this->bridge;
90 delete this->bridge;
88 }
91 }
89 this->bridge = new stardundeeSPW_USB(this);
92 this->bridge = new stardundeeSPW_USB(this);
90 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
93 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
91 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
94 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
96 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
96 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
101 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
102 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
103 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
101 }
104 }
105 }
102
106
103 }
104
107
105 void spwplugin::selectBridge(const QString &text)
108 void spwplugin::selectBridge(const QString &text)
106 {
109 {
107
110
108 if(text=="none")
111 if(text=="none")
109 {
112 {
110 this->bridgeSelector->setCurrentIndex(0);
113 this->bridgeSelector->setCurrentIndex(0);
111 }
114 }
112 if(text=="STAR-Dundee Spw USB Brick")
115 if(text=="STAR-Dundee Spw USB Brick")
113 {
116 {
114 this->bridgeSelector->setCurrentIndex(1);
117 this->bridgeSelector->setCurrentIndex(1);
115 }
118 }
116 }
119 }
117
120
118 void spwplugin::setConnected(bool connected)
121 void spwplugin::setConnected(bool connected)
119 {
122 {
120 this->bridgeSelector->setDisabled(connected);
123 this->bridgeSelector->setDisabled(connected);
121 this->Connected = connected;
124 this->Connected = connected;
122 emit activateSig(connected);
125 emit activateSig(connected);
123 if(!this->scanDone)
126 if(!this->scanDone)
124 {
127 {
125 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
128 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
126 this->scanDone=true;
129 this->scanDone=true;
127 }
130 }
128 }
131 }
129
132
130
133
131
134
132 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
135 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
133 {
136 {
134 if(Connected)
137 if(Connected)
135 {
138 {
136 return bridge->Write(Value,count,address);
139 return bridge->Write(Value,count,address);
137 }
140 }
138 return 0;
141 return 0;
139 }
142 }
140
143
141
144
142
145
143
146
144
147
145
148
146
149
147
150
@@ -1,76 +1,76
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 spwplugin_H
22 #ifndef spwplugin_H
23 #define spwplugin_H
23 #define spwplugin_H
24 #include <QMenuBar>
24 #include <QMenuBar>
25 #include <QMenu>
25 #include <QMenu>
26 #include <QAction>
26 #include <QAction>
27 #include <QLayout>
27 #include <QLayout>
28 #include <QGroupBox>
28 #include <QGroupBox>
29 #include <QComboBox>
29 #include <QComboBox>
30 #include <QLabel>
30 #include <QLabel>
31 #include <QTabWidget>
31 #include <QTabWidget>
32
32
33 #include <abstractspwbridge.h>
33 #include <abstractspwbridge.h>
34 #include <socexplorerplugin.h>
34 #include <socexplorerplugin.h>
35
35
36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
37
37
38 class spwplugin : public socexplorerplugin
38 class spwplugin : public socexplorerplugin
39 {
39 {
40 Q_OBJECT
40 Q_OBJECT
41 public:
41 public:
42 explicit spwplugin(QWidget *parent = 0);
42 explicit spwplugin(QWidget *parent = 0);
43 ~spwplugin();
43 ~spwplugin();
44 /* You can implement the folowing function if you want to overwrite
44 /* You can implement the folowing function if you want to overwrite
45 * their default behavior
45 * their default behavior
46 */
46 */
47 /*
47 /*
48 int registermenu(QMainWindow *menuHolder);
48 int registermenu(QMainWindow *menuHolder);
49 int isConnected();
49 int isConnected();
50 int connect();
50 int connect();
51 int VID(){return driver_VID;}
51 int VID(){return driver_VID;}
52 int PID(){return driver_PID;}
52 int PID(){return driver_PID;}
53 */
53 */
54
54
55 public slots:
55 public slots:
56 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
56 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
57 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
57 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
58
58
59 void bridgeSelectionChanged( const QString & text );
59 void bridgeSelectionChanged( const QString & text );
60 void selectBridge( const QString & text );
60 void selectBridge( const QString & text );
61 void setConnected(bool connected);
61 void setConnected(bool connected);
62
62
63 signals:
63 signals:
64
64
65 private:
65 private:
66 SpwTcpPacketServer* tcpServer;
66 abstractSpwBridge* bridge;
67 abstractSpwBridge* bridge;
67 SpwTcpPacketServer* tcpServer;
68 bool scanDone;
68 bool scanDone;
69 QTabWidget* mainTabWidgt;
69 QTabWidget* mainTabWidgt;
70 QGroupBox* mainGroupBox;
70 QGroupBox* mainGroupBox;
71 QComboBox* bridgeSelector;
71 QComboBox* bridgeSelector;
72 QGridLayout* mainLayout;
72 QGridLayout* mainLayout;
73 };
73 };
74
74
75 #endif // spwplugin_H
75 #endif // spwplugin_H
76
76
@@ -1,26 +1,29
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
11 signals:
10 signals:
12 void selectBridge(const QString &bridgeName);
11 void selectBridge(const QString &bridgeName);
13 bool connectBridge();
12 bool connectBridge();
14 bool disconnectBridge();
13 bool disconnectBridge();
15 void StarDundeeSelectBrick(int brickIndex);
14 void StarDundeeSelectBrick(int brickIndex);
16 void StarDundeeSelectLinkNumber(int linkIndex);
15 void StarDundeeSelectLinkNumber(int linkIndex);
17 void StarDundeeSelectLinkSpeed(int linkSpeed);
16 void StarDundeeSelectLinkSpeed(int linkSpeed);
18 void StarDundeeSetDestinationKey(const QString & destKey);
17 void StarDundeeSetDestinationKey(const QString & destKey);
19 void StarDundeeSetRmapAddress(const QString & address);
18 void StarDundeeSetRmapAddress(const QString & address);
20 void StarDundeeSetRmapKey(const QString & key);
19 void StarDundeeSetRmapKey(const QString & key);
21 void StarDundeeSetRmapTimeout(const QString & timeout);
20 void StarDundeeSetRmapTimeout(const QString & timeout);
21
22 void TCPServerConnect();
23 void TCPServerDisconnect();
24 void TCPServerSetPort(qint32 port);
22 public slots:
25 public slots:
23
26
24 };
27 };
25
28
26 #endif // SPWPYWRAPPER_H
29 #endif // SPWPYWRAPPER_H
General Comments 0
You need to be logged in to leave comments. Login now