##// END OF EJS Templates
Sync
Jeandet Alexis -
r18:3b7afcb93195 default
parent child
Show More
@@ -1,35 +1,68
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
24
25 SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) :
25 SpwTcpPacketServer::SpwTcpPacketServer(QWidget *parent) :
26 QWidget(parent),
26 QWidget(parent),
27 ui(new Ui::SpwTcpPacketServer)
27 ui(new Ui::SpwTcpPacketServer)
28 {
28 {
29 ui->setupUi(this);
29 ui->setupUi(this);
30 this->p_bridge = NULL;
31 this->p_server = new QTcpServer();
32 connect(this->ui->startServeQpb,SIGNAL(clicked(bool)),SLOT(toggleServer()));
30 }
33 }
31
34
32 SpwTcpPacketServer::~SpwTcpPacketServer()
35 SpwTcpPacketServer::~SpwTcpPacketServer()
33 {
36 {
34 delete ui;
37 delete ui;
35 }
38 }
39
40 void SpwTcpPacketServer::setBridge(abstractSpwBridge *bridge)
41 {
42 if(this->p_bridge!=NULL)
43 {
44 disconnect(this,SLOT(pushPacket(char*,int)));
45 }
46 this->p_bridge = bridge;
47 connect(bridge,SIGNAL(pushPacketOverTCP(char*,int)),SLOT(pushPacket(char*,int)));
48 }
49
50 void SpwTcpPacketServer::pushPacket(char *packet, int size)
51 {
52
53 }
54
55 void SpwTcpPacketServer::toggleServer()
56 {
57 if(this->p_server->isListening())
58 {
59 this->ui->startServeQpb->setText("Start Server");
60 this->p_server->close();
61 }
62 else
63 {
64 this->p_server->listen(QHostAddress::Any,this->ui->PortLineEdit->text().toInt());
65
66 this->ui->startServeQpb->setText("Stop Server");
67 }
68 }
@@ -1,43 +1,52
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>
27 #include <QTcpServer>
26
28
27 namespace Ui {
29 namespace Ui {
28 class SpwTcpPacketServer;
30 class SpwTcpPacketServer;
29 }
31 }
30
32
31 class SpwTcpPacketServer : public QWidget
33 class SpwTcpPacketServer : public QWidget
32 {
34 {
33 Q_OBJECT
35 Q_OBJECT
34
36
35 public:
37 public:
36 explicit SpwTcpPacketServer(QWidget *parent = 0);
38 explicit SpwTcpPacketServer(QWidget *parent = 0);
37 ~SpwTcpPacketServer();
39 ~SpwTcpPacketServer();
38
40
41 void setBridge(abstractSpwBridge* bridge);
42
43 public slots:
44 void pushPacket(char* packet,int size);
45 void toggleServer();
39 private:
46 private:
40 Ui::SpwTcpPacketServer *ui;
47 Ui::SpwTcpPacketServer *ui;
48 abstractSpwBridge* p_bridge;
49 QTcpServer* p_server;
41 };
50 };
42
51
43 #endif // SPWTCPPACKETSERVER_H
52 #endif // SPWTCPPACKETSERVER_H
@@ -1,52 +1,53
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 ABSTRACTSPWBRIDGE_H
22 #ifndef ABSTRACTSPWBRIDGE_H
23 #define ABSTRACTSPWBRIDGE_H
23 #define ABSTRACTSPWBRIDGE_H
24
24
25 #include <QObject>
25 #include <QObject>
26 #include <socexplorerplugin.h>
26 #include <socexplorerplugin.h>
27 #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes
27 #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes
28 #include <spw.h>
28 #include <spw.h>
29
29
30 class abstractSpwBridge : public QObject
30 class abstractSpwBridge : public QObject
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33 public:
33 public:
34 explicit abstractSpwBridge(socexplorerplugin *parent);
34 explicit abstractSpwBridge(socexplorerplugin *parent);
35 QWidget *getGUI();
35 QWidget *getGUI();
36
36
37 public slots:
37 public slots:
38 virtual bool connectBridge();
38 virtual bool connectBridge();
39 virtual bool disconnectBridge();
39 virtual bool disconnectBridge();
40 virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
40 virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
41 virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
41 virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
42 virtual int pushRMAPPacket(char* packet,int size)=0;
42 virtual int pushRMAPPacket(char* packet,int size)=0;
43 signals:
43 signals:
44 void setConnected(bool connected);
44 void setConnected(bool connected);
45 void pushPacketOverTCP(char* packet,int size);
45 protected:
46 protected:
46 socexplorerplugin* plugin;
47 socexplorerplugin* plugin;
47 QWidget* p_GUI;
48 QWidget* p_GUI;
48 private:
49 private:
49
50
50 };
51 };
51
52
52 #endif // ABSTRACTSPWBRIDGE_H
53 #endif // ABSTRACTSPWBRIDGE_H
@@ -1,142 +1,146
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 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
28 spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
28 {
29 {
29 Q_UNUSED(parent)
30 Q_UNUSED(parent)
30 this->bridge = NULL;
31 this->bridge = NULL;
31 this->scanDone = false;
32 this->scanDone = false;
32 this->pyObject = new spwPyWrapper(this);
33 this->pyObject = new spwPyWrapper(this);
34 this->tcpServer = new SpwTcpPacketServer(this);
33 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
35 this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
34 this->bridgeSelector = new QComboBox(this);
36 this->bridgeSelector = new QComboBox(this);
37 this->mainTabWidgt = new QTabWidget(this);
38 this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration")
35 this->mainLayout = new QGridLayout(this->mainGroupBox);
39 this->mainLayout = new QGridLayout(this->mainGroupBox);
36 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
40 this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter);
37 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
41 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
38 this->mainGroupBox->setLayout(this->mainLayout);
42 this->mainGroupBox->setLayout(this->mainLayout);
39 this->setWidget(this->mainGroupBox);
43 this->setWidget(this->mainGroupBox);
40 this->bridgeSelector->addItem("none");
44 this->bridgeSelector->addItem("none");
41 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
45 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
42 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
46 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
43 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
47 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
44 }
48 }
45
49
46
50
47 spwplugin::~spwplugin()
51 spwplugin::~spwplugin()
48 {
52 {
49
53
50 }
54 }
51
55
52
56
53
57
54 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
58 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
55 {
59 {
56 if(Connected)
60 if(Connected)
57 {
61 {
58 return bridge->Read(Value,count,address);
62 return bridge->Read(Value,count,address);
59 }
63 }
60 return 0;
64 return 0;
61 }
65 }
62
66
63 void spwplugin::bridgeSelectionChanged(const QString &text)
67 void spwplugin::bridgeSelectionChanged(const QString &text)
64 {
68 {
65 printf("test");
69 printf("test");
66 if(text=="none")
70 if(text=="none")
67 {
71 {
68 if(this->bridge!=NULL)
72 if(this->bridge!=NULL)
69 {
73 {
70 this->mainLayout->removeWidget(this->bridge->getGUI());
74 this->mainLayout->removeWidget(this->bridge->getGUI());
71 this->disconnect(this,SLOT(setConnected(bool)));
75 this->disconnect(this,SLOT(setConnected(bool)));
72 delete this->bridge;
76 delete this->bridge;
73 this->bridge= NULL;
77 this->bridge= NULL;
74 }
78 }
75 }
79 }
76 if(text=="STAR-Dundee Spw USB Brick")
80 if(text=="STAR-Dundee Spw USB Brick")
77 {
81 {
78 if(this->bridge!=NULL)
82 if(this->bridge!=NULL)
79 {
83 {
80 this->mainLayout->removeWidget(this->bridge->getGUI());
84 this->mainLayout->removeWidget(this->bridge->getGUI());
81 this->disconnect(this,SLOT(setConnected(bool)));
85 this->disconnect(this,SLOT(setConnected(bool)));
82 delete this->bridge;
86 delete this->bridge;
83 }
87 }
84 this->bridge = new stardundeeSPW_USB(this);
88 this->bridge = new stardundeeSPW_USB(this);
85 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
89 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
86 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
90 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
87 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
91 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
88 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
89 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
90 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
91 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
96 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
96 }
100 }
97
101
98 }
102 }
99
103
100 void spwplugin::selectBridge(const QString &text)
104 void spwplugin::selectBridge(const QString &text)
101 {
105 {
102
106
103 if(text=="none")
107 if(text=="none")
104 {
108 {
105 this->bridgeSelector->setCurrentIndex(0);
109 this->bridgeSelector->setCurrentIndex(0);
106 }
110 }
107 if(text=="STAR-Dundee Spw USB Brick")
111 if(text=="STAR-Dundee Spw USB Brick")
108 {
112 {
109 this->bridgeSelector->setCurrentIndex(1);
113 this->bridgeSelector->setCurrentIndex(1);
110 }
114 }
111 }
115 }
112
116
113 void spwplugin::setConnected(bool connected)
117 void spwplugin::setConnected(bool connected)
114 {
118 {
115 this->bridgeSelector->setDisabled(connected);
119 this->bridgeSelector->setDisabled(connected);
116 this->Connected = connected;
120 this->Connected = connected;
117 emit activateSig(connected);
121 emit activateSig(connected);
118 if(!this->scanDone)
122 if(!this->scanDone)
119 {
123 {
120 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
124 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
121 this->scanDone=true;
125 this->scanDone=true;
122 }
126 }
123 }
127 }
124
128
125
129
126
130
127 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
131 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
128 {
132 {
129 if(Connected)
133 if(Connected)
130 {
134 {
131 return bridge->Write(Value,count,address);
135 return bridge->Write(Value,count,address);
132 }
136 }
133 return 0;
137 return 0;
134 }
138 }
135
139
136
140
137
141
138
142
139
143
140
144
141
145
142
146
@@ -1,72 +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
32
32 #include <abstractspwbridge.h>
33 #include <abstractspwbridge.h>
33 #include <socexplorerplugin.h>
34 #include <socexplorerplugin.h>
34
35
36 #include "SpwTcpPacketServer/spwtcppacketserver.h"
35
37
36 class spwplugin : public socexplorerplugin
38 class spwplugin : public socexplorerplugin
37 {
39 {
38 Q_OBJECT
40 Q_OBJECT
39 public:
41 public:
40 explicit spwplugin(QWidget *parent = 0);
42 explicit spwplugin(QWidget *parent = 0);
41 ~spwplugin();
43 ~spwplugin();
42 /* You can implement the folowing function if you want to overwrite
44 /* You can implement the folowing function if you want to overwrite
43 * their default behavior
45 * their default behavior
44 */
46 */
45 /*
47 /*
46 int registermenu(QMainWindow *menuHolder);
48 int registermenu(QMainWindow *menuHolder);
47 int isConnected();
49 int isConnected();
48 int connect();
50 int connect();
49 int VID(){return driver_VID;}
51 int VID(){return driver_VID;}
50 int PID(){return driver_PID;}
52 int PID(){return driver_PID;}
51 */
53 */
52
54
53 public slots:
55 public slots:
54 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);
55 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);
56
58
57 void bridgeSelectionChanged( const QString & text );
59 void bridgeSelectionChanged( const QString & text );
58 void selectBridge( const QString & text );
60 void selectBridge( const QString & text );
59 void setConnected(bool connected);
61 void setConnected(bool connected);
60
62
61 signals:
63 signals:
62
64
63 private:
65 private:
64 abstractSpwBridge* bridge;
66 abstractSpwBridge* bridge;
67 SpwTcpPacketServer* tcpServer;
65 bool scanDone;
68 bool scanDone;
69 QTabWidget* mainTabWidgt;
66 QGroupBox* mainGroupBox;
70 QGroupBox* mainGroupBox;
67 QComboBox* bridgeSelector;
71 QComboBox* bridgeSelector;
68 QGridLayout* mainLayout;
72 QGridLayout* mainLayout;
69 };
73 };
70
74
71 #endif // spwplugin_H
75 #endif // spwplugin_H
72
76
@@ -1,82 +1,83
1 #
1 #
2 # Project created by QtCreator 2011-09-20T08:15:30
2 # Project created by QtCreator 2011-09-20T08:15:30
3 #
3 #
4 #-------------------------------------------------
4 #-------------------------------------------------
5
5
6 CONFIG += socexplorerplugin
6 CONFIG += socexplorerplugin
7 QT += network
7 win32:CONFIG += dll
8 win32:CONFIG += dll
8 win32:CONFIG -= static
9 win32:CONFIG -= static
9 CONFIG(debug, debug|release) {
10 CONFIG(debug, debug|release) {
10 DEBUG_EXT = _d
11 DEBUG_EXT = _d
11 } else {
12 } else {
12 DEBUG_EXT =
13 DEBUG_EXT =
13 }
14 }
14 TARGET = spwplugin$${DEBUG_EXT}
15 TARGET = spwplugin$${DEBUG_EXT}
15 DEFINES += PLUGIN=spwplugin
16 DEFINES += PLUGIN=spwplugin
16 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
17 DEFINES += PLUGINHEADER="\"\\\"spwplugin.h"\\\"\"
17 DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"
18 DEFINES += driver_Name="\"\\\"SpwPlugin"\\\"\"
18 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
19 DEFINES += driver_Author="\"\\\"Alexis Jeandet alexis.jeandet@member.fsf.org"\\\"\"
19 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
20 DEFINES += driver_Version="\"\\\"0.0.1"\\\"\"
20 DEFINES += driver_Description="\"\\\"Driver description"\\\"\"
21 DEFINES += driver_Description="\"\\\"Driver description"\\\"\"
21 DEFINES += driver_can_be_root=1
22 DEFINES += driver_can_be_root=1
22 DEFINES += driver_can_be_child=0
23 DEFINES += driver_can_be_child=0
23 DEFINES += driver_VID=0
24 DEFINES += driver_VID=0
24 DEFINES += driver_PID=0
25 DEFINES += driver_PID=0
25
26
26 STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/
27 STARTDUNDEEPATH=/home/spacewire/usb/spw_usb_driver_v2.68/
27
28
28 LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \
29 LIBS += $$STARTDUNDEEPATH/lib/x86_64/libSpaceWireUSBAPI.so \
29 $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so
30 $$STARTDUNDEEPATH/lib/x86_64/libConfigLibraryUSB.so
30
31
31 INCLUDEPATH += \
32 INCLUDEPATH += \
32 $${PWD} \
33 $${PWD} \
33 $$STARTDUNDEEPATH/inc \
34 $$STARTDUNDEEPATH/inc \
34
35
35 HEADERS += \
36 HEADERS += \
36 spwplugin.h \
37 spwplugin.h \
37 stardundeespw_usb.h \
38 stardundeespw_usb.h \
38 abstractspwbridge.h \
39 abstractspwbridge.h \
39 spw.h \
40 spw.h \
40 stardundeegui.h \
41 stardundeegui.h \
41 SpwTcpPacketServer/spwtcppacketserver.h \
42 SpwTcpPacketServer/spwtcppacketserver.h \
42 spwpywrapper.h
43 spwpywrapper.h
43
44
44
45
45 SOURCES += \
46 SOURCES += \
46 spwplugin.cpp \
47 spwplugin.cpp \
47 stardundeespw_usb.cpp \
48 stardundeespw_usb.cpp \
48 abstractspwbridge.cpp \
49 abstractspwbridge.cpp \
49 stardundeegui.cpp \
50 stardundeegui.cpp \
50 SpwTcpPacketServer/spwtcppacketserver.cpp \
51 SpwTcpPacketServer/spwtcppacketserver.cpp \
51 spwpywrapper.cpp
52 spwpywrapper.cpp
52
53
53 FORMS += \
54 FORMS += \
54 stardundeeGUI.ui \
55 stardundeeGUI.ui \
55 SpwTcpPacketServer/spwtcppacketserver.ui
56 SpwTcpPacketServer/spwtcppacketserver.ui
56
57
57 RESOURCES += \
58 RESOURCES += \
58 spwRessources.qrc
59 spwRessources.qrc
59
60
60
61
61
62
62
63
63
64
64
65
65
66
66
67
67
68
68
69
69
70
70
71
71
72
72
73
73
74
74
75
75
76
76
77
77
78
78
79
79
80
80
81
81
82
82
83
@@ -1,128 +1,127
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 STARDUNDEESPW_USB_H
22 #ifndef STARDUNDEESPW_USB_H
23 #define STARDUNDEESPW_USB_H
23 #define STARDUNDEESPW_USB_H
24
24
25 #include <QObject>
25 #include <QObject>
26 #include <spw_usb_api.h>
26 #include <spw_usb_api.h>
27 #include <spw_config_library.h>
27 #include <spw_config_library.h>
28 #include <socexplorerplugin.h>
28 #include <socexplorerplugin.h>
29 #include <abstractspwbridge.h>
29 #include <abstractspwbridge.h>
30 #include <QThread>
30 #include <QThread>
31 #include <QMutex>
31 #include <QMutex>
32 #include <QSemaphore>
32 #include <QSemaphore>
33 #include <QGridLayout>
33 #include <QGridLayout>
34 #include <QPushButton>
34 #include <QPushButton>
35 #include <QComboBox>
35 #include <QComboBox>
36 #include <QLabel>
36 #include <QLabel>
37 #include "stardundeegui.h"
37 #include "stardundeegui.h"
38
38
39 class RMAP_Answer
39 class RMAP_Answer
40 {
40 {
41 public:
41 public:
42 RMAP_Answer(int ID,char* data,int len)
42 RMAP_Answer(int ID,char* data,int len)
43 {
43 {
44 transactionID = ID;
44 transactionID = ID;
45 this->data = data;
45 this->data = data;
46 this->len = len;
46 this->len = len;
47 }
47 }
48 int transactionID;
48 int transactionID;
49 char* data;
49 char* data;
50 int len;
50 int len;
51 };
51 };
52
52
53 class stardundeeSPW_USB_Manager: public QThread
53 class stardundeeSPW_USB_Manager: public QThread
54 {
54 {
55 Q_OBJECT
55 Q_OBJECT
56 public:
56 public:
57 explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
57 explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0);
58 ~stardundeeSPW_USB_Manager();
58 ~stardundeeSPW_USB_Manager();
59 void run();
59 void run();
60 bool connectBridge();
60 bool connectBridge();
61 bool disconnectBridge();
61 bool disconnectBridge();
62 int getRMAPtransactionID();
62 int getRMAPtransactionID();
63 int getRMAPanswer(int transactionID,char** buffer);
63 int getRMAPanswer(int transactionID,char** buffer);
64 bool sendPacket(char* packet,int size);
64 bool sendPacket(char* packet,int size);
65
65
66 signals:
66 signals:
67 void updateAvailableBrickCount(int count);
67 void updateAvailableBrickCount(int count);
68 private:
68 private:
69 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
69 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
70 QSemaphore* RMAP_AnswersSem;
70 QSemaphore* RMAP_AnswersSem;
71 void pushRmapPacket(char* packet,int len);
71 void pushRmapPacket(char* packet,int len);
72 star_device_handle hDevice;
72 star_device_handle hDevice;
73 socexplorerplugin* plugin;
73 socexplorerplugin* plugin;
74 bool connected;
74 bool connected;
75 char* SPWPacketBuff;
75 char* SPWPacketBuff;
76 QList<RMAP_Answer*> RMAP_Answers;
76 QList<RMAP_Answer*> RMAP_Answers;
77 QList<int> RMAP_pending_transaction_IDs;
77 QList<int> RMAP_pending_transaction_IDs;
78
78
79 public:
79 public:
80 int selectedBrick;
80 int selectedBrick;
81 int linkNumber;
81 int linkNumber;
82 int brickList;
82 int brickList;
83 int linkSpeed;
83 int linkSpeed;
84 int destinationKey;
84 int destinationKey;
85 int rmapAddress;
85 int rmapAddress;
86 int rmapKey;
86 int rmapKey;
87 int RMAPtimeout;
87 int RMAPtimeout;
88 };
88 };
89
89
90 class stardundeeSPW_USB : public abstractSpwBridge
90 class stardundeeSPW_USB : public abstractSpwBridge
91 {
91 {
92 Q_OBJECT
92 Q_OBJECT
93 public:
93 public:
94 explicit stardundeeSPW_USB(socexplorerplugin *parent = 0);
94 explicit stardundeeSPW_USB(socexplorerplugin *parent = 0);
95 ~stardundeeSPW_USB();
95 ~stardundeeSPW_USB();
96
96
97 signals:
97 signals:
98
98
99 void setRmapTimeout(const QString & timeout);
99 void setRmapTimeout(const QString & timeout);
100 void SelectBrick(int brickIndex);
100 void SelectBrick(int brickIndex);
101 void SelectLinkNumber(int linkIndex);
101 void SelectLinkNumber(int linkIndex);
102 void SelectLinkSpeed(int linkSpeed);
102 void SelectLinkSpeed(int linkSpeed);
103 void SetDestinationKey(const QString & destKey);
103 void SetDestinationKey(const QString & destKey);
104 void SetRmapAddress(const QString & address);
104 void SetRmapAddress(const QString & address);
105 void SetRmapKey(const QString & key);
105 void SetRmapKey(const QString & key);
106 void SetRmapTimeout(const QString & timeout);
106 void SetRmapTimeout(const QString & timeout);
107
107
108 public slots:
108 public slots:
109 void toggleBridgeConnection();
109 void toggleBridgeConnection();
110 bool connectBridge();
110 bool connectBridge();
111 bool disconnectBridge();
111 bool disconnectBridge();
112 int pushRMAPPacket(char* packet,int size);
112 int pushRMAPPacket(char* packet,int size);
113 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
113 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
114 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
114 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
115 void brickSelectionChanged(int brickIndex);
115 void brickSelectionChanged(int brickIndex);
116 void linkNumberSelectionChanged(int linkIndex);
116 void linkNumberSelectionChanged(int linkIndex);
117 void linkSpeedSelectionChanged(const QString & linkSpeed);
117 void linkSpeedSelectionChanged(const QString & linkSpeed);
118 void destinationKeyChanged(const QString & destKey);
118 void destinationKeyChanged(const QString & destKey);
119 void rmapAddressChanged(const QString & rmapaddress);
119 void rmapAddressChanged(const QString & rmapaddress);
120 void rmapKeyChanged(const QString & key);
120 void rmapKeyChanged(const QString & key);
121 void rmapTimeoutChanged(const QString & timeout);
121 void rmapTimeoutChanged(const QString & timeout);
122 private:
122 private:
123 void makeGUI(socexplorerplugin *parent);
123 void makeGUI(socexplorerplugin *parent);
124 stardundeeSPW_USB_Manager* manager;
124 stardundeeSPW_USB_Manager* manager;
125 // QGridLayout* mainLayout;
126 };
125 };
127
126
128 #endif // STARDUNDEESPW_USB_H
127 #endif // STARDUNDEESPW_USB_H
General Comments 0
You need to be logged in to leave comments. Login now