@@ -1,146 +1,147 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 3 | -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 3 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | |
|
23 | 23 | #include "spwplugin.h" |
|
24 | 24 | #include "stardundeespw_usb.h" |
|
25 | 25 | #include <socexplorerproxy.h> |
|
26 | 26 | #include "spwpywrapper.h" |
|
27 | 27 | |
|
28 | 28 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
29 | 29 | { |
|
30 | 30 | Q_UNUSED(parent) |
|
31 | 31 | this->bridge = NULL; |
|
32 | 32 | this->scanDone = false; |
|
33 | 33 | this->pyObject = new spwPyWrapper(this); |
|
34 | 34 | this->tcpServer = new SpwTcpPacketServer(this); |
|
35 | 35 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
36 | 36 | this->bridgeSelector = new QComboBox(this); |
|
37 | 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 | 40 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
40 | 41 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
41 | 42 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
42 | this->mainGroupBox->setLayout(this->mainLayout); | |
|
43 |
this->setWidget(this->main |
|
|
43 | //this->mainGroupBox->setLayout(this->mainLayout); | |
|
44 | this->setWidget(this->mainTabWidgt); | |
|
44 | 45 | this->bridgeSelector->addItem("none"); |
|
45 | 46 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
46 | 47 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
47 | 48 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
48 | 49 | } |
|
49 | 50 | |
|
50 | 51 | |
|
51 | 52 | spwplugin::~spwplugin() |
|
52 | 53 | { |
|
53 | 54 | |
|
54 | 55 | } |
|
55 | 56 | |
|
56 | 57 | |
|
57 | 58 | |
|
58 | 59 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
59 | 60 | { |
|
60 | 61 | if(Connected) |
|
61 | 62 | { |
|
62 | 63 | return bridge->Read(Value,count,address); |
|
63 | 64 | } |
|
64 | 65 | return 0; |
|
65 | 66 | } |
|
66 | 67 | |
|
67 | 68 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
68 | 69 | { |
|
69 | 70 | printf("test"); |
|
70 | 71 | if(text=="none") |
|
71 | 72 | { |
|
72 | 73 | if(this->bridge!=NULL) |
|
73 | 74 | { |
|
74 | 75 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
75 | 76 | this->disconnect(this,SLOT(setConnected(bool))); |
|
76 | 77 | delete this->bridge; |
|
77 | 78 | this->bridge= NULL; |
|
78 | 79 | } |
|
79 | 80 | } |
|
80 | 81 | if(text=="STAR-Dundee Spw USB Brick") |
|
81 | 82 | { |
|
82 | 83 | if(this->bridge!=NULL) |
|
83 | 84 | { |
|
84 | 85 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
85 | 86 | this->disconnect(this,SLOT(setConnected(bool))); |
|
86 | 87 | delete this->bridge; |
|
87 | 88 | } |
|
88 | 89 | this->bridge = new stardundeeSPW_USB(this); |
|
89 | 90 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
90 | 91 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
91 | 92 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
92 | 93 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
93 | 94 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
94 | 95 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
95 | 96 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString))); |
|
96 | 97 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString))); |
|
97 | 98 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
98 | 99 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
99 | 100 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
100 | 101 | } |
|
101 | 102 | |
|
102 | 103 | } |
|
103 | 104 | |
|
104 | 105 | void spwplugin::selectBridge(const QString &text) |
|
105 | 106 | { |
|
106 | 107 | |
|
107 | 108 | if(text=="none") |
|
108 | 109 | { |
|
109 | 110 | this->bridgeSelector->setCurrentIndex(0); |
|
110 | 111 | } |
|
111 | 112 | if(text=="STAR-Dundee Spw USB Brick") |
|
112 | 113 | { |
|
113 | 114 | this->bridgeSelector->setCurrentIndex(1); |
|
114 | 115 | } |
|
115 | 116 | } |
|
116 | 117 | |
|
117 | 118 | void spwplugin::setConnected(bool connected) |
|
118 | 119 | { |
|
119 | 120 | this->bridgeSelector->setDisabled(connected); |
|
120 | 121 | this->Connected = connected; |
|
121 | 122 | emit activateSig(connected); |
|
122 | 123 | if(!this->scanDone) |
|
123 | 124 | { |
|
124 | 125 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
125 | 126 | this->scanDone=true; |
|
126 | 127 | } |
|
127 | 128 | } |
|
128 | 129 | |
|
129 | 130 | |
|
130 | 131 | |
|
131 | 132 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
132 | 133 | { |
|
133 | 134 | if(Connected) |
|
134 | 135 | { |
|
135 | 136 | return bridge->Write(Value,count,address); |
|
136 | 137 | } |
|
137 | 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