##// END OF EJS Templates
Sync
jeandet -
r19:3d3921dcdd34 default
parent child
Show More
@@ -1,146 +1,147
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->mainLayout = new QGridLayout(this->mainGroupBox);
40 this->mainLayout = new QGridLayout(this->mainGroupBox);
40 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);
41 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
42 this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1);
42 this->mainGroupBox->setLayout(this->mainLayout);
43 //this->mainGroupBox->setLayout(this->mainLayout);
43 this->setWidget(this->mainGroupBox);
44 this->setWidget(this->mainTabWidgt);
44 this->bridgeSelector->addItem("none");
45 this->bridgeSelector->addItem("none");
45 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
46 this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
46 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
47 connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
47 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
48 connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
48 }
49 }
49
50
50
51
51 spwplugin::~spwplugin()
52 spwplugin::~spwplugin()
52 {
53 {
53
54
54 }
55 }
55
56
56
57
57
58
58 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
59 unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address)
59 {
60 {
60 if(Connected)
61 if(Connected)
61 {
62 {
62 return bridge->Read(Value,count,address);
63 return bridge->Read(Value,count,address);
63 }
64 }
64 return 0;
65 return 0;
65 }
66 }
66
67
67 void spwplugin::bridgeSelectionChanged(const QString &text)
68 void spwplugin::bridgeSelectionChanged(const QString &text)
68 {
69 {
69 printf("test");
70 printf("test");
70 if(text=="none")
71 if(text=="none")
71 {
72 {
72 if(this->bridge!=NULL)
73 if(this->bridge!=NULL)
73 {
74 {
74 this->mainLayout->removeWidget(this->bridge->getGUI());
75 this->mainLayout->removeWidget(this->bridge->getGUI());
75 this->disconnect(this,SLOT(setConnected(bool)));
76 this->disconnect(this,SLOT(setConnected(bool)));
76 delete this->bridge;
77 delete this->bridge;
77 this->bridge= NULL;
78 this->bridge= NULL;
78 }
79 }
79 }
80 }
80 if(text=="STAR-Dundee Spw USB Brick")
81 if(text=="STAR-Dundee Spw USB Brick")
81 {
82 {
82 if(this->bridge!=NULL)
83 if(this->bridge!=NULL)
83 {
84 {
84 this->mainLayout->removeWidget(this->bridge->getGUI());
85 this->mainLayout->removeWidget(this->bridge->getGUI());
85 this->disconnect(this,SLOT(setConnected(bool)));
86 this->disconnect(this,SLOT(setConnected(bool)));
86 delete this->bridge;
87 delete this->bridge;
87 }
88 }
88 this->bridge = new stardundeeSPW_USB(this);
89 this->bridge = new stardundeeSPW_USB(this);
89 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
90 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
90 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
91 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
91 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
92 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
93 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
94 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
95 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
96 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString)));
96 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString)));
97 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
98 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
99 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
100 connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
100 }
101 }
101
102
102 }
103 }
103
104
104 void spwplugin::selectBridge(const QString &text)
105 void spwplugin::selectBridge(const QString &text)
105 {
106 {
106
107
107 if(text=="none")
108 if(text=="none")
108 {
109 {
109 this->bridgeSelector->setCurrentIndex(0);
110 this->bridgeSelector->setCurrentIndex(0);
110 }
111 }
111 if(text=="STAR-Dundee Spw USB Brick")
112 if(text=="STAR-Dundee Spw USB Brick")
112 {
113 {
113 this->bridgeSelector->setCurrentIndex(1);
114 this->bridgeSelector->setCurrentIndex(1);
114 }
115 }
115 }
116 }
116
117
117 void spwplugin::setConnected(bool connected)
118 void spwplugin::setConnected(bool connected)
118 {
119 {
119 this->bridgeSelector->setDisabled(connected);
120 this->bridgeSelector->setDisabled(connected);
120 this->Connected = connected;
121 this->Connected = connected;
121 emit activateSig(connected);
122 emit activateSig(connected);
122 if(!this->scanDone)
123 if(!this->scanDone)
123 {
124 {
124 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
125 socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
125 this->scanDone=true;
126 this->scanDone=true;
126 }
127 }
127 }
128 }
128
129
129
130
130
131
131 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
132 unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
132 {
133 {
133 if(Connected)
134 if(Connected)
134 {
135 {
135 return bridge->Write(Value,count,address);
136 return bridge->Write(Value,count,address);
136 }
137 }
137 return 0;
138 return 0;
138 }
139 }
139
140
140
141
141
142
142
143
143
144
144
145
145
146
146
147
General Comments 0
You need to be logged in to leave comments. Login now