##// END OF EJS Templates
Added disconnection auto-detection to the spacewire plugin.
Jeandet Alexis -
r11:27ed47eb6044 default
parent child
Show More
@@ -1,3 +1,7
1 1 syntax: glob
2 2 *.pro.user
3 3 *.o
4 moc_*
5 *.so*
6 ui_*.h
7 Makefile
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2013, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2013, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2012, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2012, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2011, 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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -40,6 +40,8 public slots:
40 40 virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
41 41 virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0;
42 42 virtual int pushRMAPPacket(char* packet,int size)=0;
43 signals:
44 void setConnected(bool connected);
43 45 protected:
44 46 socexplorerplugin* plugin;
45 47 QWidget* p_GUI;
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -66,6 +66,7 void spwplugin::bridgeSelectionChanged(c
66 66 if(this->bridge!=NULL)
67 67 {
68 68 this->mainLayout->removeWidget(this->bridge->getGUI());
69 this->disconnect(this,SLOT(setConnected(bool)));
69 70 delete this->bridge;
70 71 this->bridge= NULL;
71 72 }
@@ -75,12 +76,20 void spwplugin::bridgeSelectionChanged(c
75 76 if(this->bridge!=NULL)
76 77 {
77 78 this->mainLayout->removeWidget(this->bridge->getGUI());
79 this->disconnect(this,SLOT(setConnected(bool)));
78 80 delete this->bridge;
79 81 }
80 82 this->bridge = new stardundeeSPW_USB(this);
81 83 this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
84 connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
85 }
86
82 87 }
83 88
89 void spwplugin::setConnected(bool connected)
90 {
91 this->Connected = connected;
92 emit activateSig(connected);
84 93 }
85 94
86 95
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -55,6 +55,7 public slots:
55 55 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
56 56
57 57 void bridgeSelectionChanged( const QString & text );
58 void setConnected(bool connected);
58 59
59 60 signals:
60 61
@@ -6,8 +6,8
6 6 <rect>
7 7 <x>0</x>
8 8 <y>0</y>
9 <width>614</width>
10 <height>152</height>
9 <width>645</width>
10 <height>231</height>
11 11 </rect>
12 12 </property>
13 13 <property name="windowTitle">
@@ -80,7 +80,7
80 80 <item row="3" column="1">
81 81 <widget class="QLineEdit" name="destKeyLineEdit">
82 82 <property name="inputMask">
83 <string comment="009"/>
83 <string comment="ddD"/>
84 84 </property>
85 85 <property name="text">
86 86 <string>32</string>
@@ -90,8 +90,48
90 90 </property>
91 91 </widget>
92 92 </item>
93 <item row="4" column="0">
94 <widget class="QLabel" name="RMAPaddressLbl">
95 <property name="text">
96 <string>RMAP Target address</string>
97 </property>
98 </widget>
99 </item>
93 100 <item row="4" column="1">
94 <widget class="QPushButton" name="pushButton">
101 <widget class="QLineEdit" name="RMAPAddresslineEdit">
102 <property name="inputMask">
103 <string comment="ddD"/>
104 </property>
105 <property name="text">
106 <string>254</string>
107 </property>
108 <property name="maxLength">
109 <number>3</number>
110 </property>
111 </widget>
112 </item>
113 <item row="5" column="0">
114 <widget class="QLabel" name="RMAPKeyLbl">
115 <property name="text">
116 <string>RMAP Target key</string>
117 </property>
118 </widget>
119 </item>
120 <item row="5" column="1">
121 <widget class="QLineEdit" name="RMAPKeylineEdit">
122 <property name="inputMask">
123 <string comment="ddD"/>
124 </property>
125 <property name="text">
126 <string comment="ddD">2</string>
127 </property>
128 <property name="maxLength">
129 <number>3</number>
130 </property>
131 </widget>
132 </item>
133 <item row="6" column="1">
134 <widget class="QPushButton" name="connectQpb">
95 135 <property name="text">
96 136 <string>Connect</string>
97 137 </property>
@@ -1,3 +1,24
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
1 22 #include "stardundeegui.h"
2 23
3 24 #include "ui_stardundeeGUI.h"
@@ -6,4 +27,72 StarDundeeGUI::StarDundeeGUI(QWidget *pa
6 27 QWidget(parent),ui(new Ui::StarDundeeUI)
7 28 {
8 29 this->ui->setupUi(this);
30 connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int)));
31 connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int)));
32 connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString)));
33 connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString)));
34 connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString)));
35 connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString)));
36 connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked()));
37
9 38 }
39
40 int StarDundeeGUI::getBrickSelection()
41 {
42 return ui->selectBrickCmbx->currentIndex();
43 }
44
45 int StarDundeeGUI::getLinkNumberSelection()
46 {
47 return ui->selectLinkCmbx->currentIndex();
48 }
49
50 QString StarDundeeGUI::getLinkSpeedSelection()
51 {
52 return ui->setLinkSpeedCmbx->currentText();
53 }
54
55 QString StarDundeeGUI::getDestinationKey()
56 {
57 return ui->destKeyLineEdit->text();
58 }
59
60 QString StarDundeeGUI::getRmapAddress()
61 {
62 return ui->RMAPAddresslineEdit->text();
63 }
64
65 QString StarDundeeGUI::getRmapKey()
66 {
67 return ui->RMAPKeylineEdit->text();
68 }
69
70
71
72 void StarDundeeGUI::lock(bool lock)
73 {
74 this->ui->selectBrickCmbx->setDisabled(lock);
75 this->ui->selectLinkCmbx->setDisabled(lock);
76 this->ui->setLinkSpeedCmbx->setDisabled(lock);
77 this->ui->destKeyLineEdit->setDisabled(lock);
78 this->ui->RMAPAddresslineEdit->setDisabled(lock);
79 this->ui->RMAPKeylineEdit->setDisabled(lock);
80 if(lock)
81 this->ui->connectQpb->setText("Disconnect");
82 else
83 this->ui->connectQpb->setText("Connect");
84 }
85
86 void StarDundeeGUI::updateAvailableBrickCount(int count)
87 {
88 this->ui->selectBrickCmbx->clear();
89 this->ui->selectBrickCmbx->addItem("none");
90 for(int i =0;i<32;i++)
91 {
92 if((count&1)==1)
93 {
94 this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i));
95 }
96 count>>=1;
97 }
98 }
@@ -1,3 +1,24
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
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
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
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
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
1 22 #ifndef STARDUNDEEGUI_H
2 23 #define STARDUNDEEGUI_H
3 24
@@ -12,10 +33,23 class StarDundeeGUI : public QWidget
12 33 Q_OBJECT
13 34 public:
14 35 explicit StarDundeeGUI(QWidget *parent = 0);
15
36 int getBrickSelection();
37 int getLinkNumberSelection();
38 QString getLinkSpeedSelection();
39 QString getDestinationKey();
40 QString getRmapAddress();
41 QString getRmapKey();
16 42 signals:
17
43 void brickSelectionChanged(int brickIndex);
44 void linkNumberSelectionChanged(int linkIndex);
45 void linkSpeedSelectionChanged(const QString & linkSpeed);
46 void destinationKeyChanged(const QString & destKey);
47 void rmapAddressChanged(const QString & address);
48 void rmapKeyChanged(const QString & key);
49 void connectClicked();
18 50 public slots:
51 void lock(bool lock);
52 void updateAvailableBrickCount(int count);
19 53
20 54 private:
21 55 Ui::StarDundeeUI *ui;
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -45,14 +45,16 void stardundeeSPW_USB::toggleBridgeConn
45 45 {
46 46 if(this->disconnectBridge())
47 47 {
48 this->connectBridgeButton->setText("Connect");
48 ((StarDundeeGUI*)this->p_GUI)->lock(false);
49 emit setConnected(false);
49 50 }
50 51 }
51 52 else
52 53 {
53 54 if(this->connectBridge())
54 55 {
55 this->connectBridgeButton->setText("Disconnect");
56 ((StarDundeeGUI*)this->p_GUI)->lock(true);
57 emit setConnected(true);
56 58 }
57 59 }
58 60 }
@@ -75,10 +77,10 int stardundeeSPW_USB::pushRMAPPacket(ch
75 77 unsigned int stardundeeSPW_USB::Write(unsigned int *Value, unsigned int count, unsigned int address)
76 78 {
77 79 char writeBuffer[RMAP_WRITE_PACKET_MIN_SZ((RMAP_MAX_XFER_SIZE*4))+1];
78 writeBuffer[0]=1;//Link number
80 writeBuffer[0]=this->manager->linkNumber;//Link number
79 81 int transactionID = 0;
80 82 int written=0;
81 SocExplorerEngine::message(this->plugin,"Enter Write function");
83 SocExplorerEngine::message(this->plugin,"Enter Write function",2);
82 84 QProgressBar* progress=NULL;
83 85 if(count>RMAP_MAX_XFER_SIZE)
84 86 progress= SocExplorerEngine::getProgressBar("Writing on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
@@ -92,7 +94,7 unsigned int stardundeeSPW_USB::Write(un
92 94 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
93 95 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
94 96 }
95 RMAP_build_tx_request_header(254,2,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1);
97 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),RMAP_MAX_XFER_SIZE*4,writeBuffer+1);
96 98 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(RMAP_MAX_XFER_SIZE*4)+1);
97 99 written+=RMAP_MAX_XFER_SIZE;
98 100 count-=RMAP_MAX_XFER_SIZE;
@@ -108,7 +110,7 unsigned int stardundeeSPW_USB::Write(un
108 110 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+3] = (char)(((unsigned int)Value[i+written]>>8)&0xFF);
109 111 writeBuffer[RMAP_WRITE_HEADER_MIN_SZ+(i*4)+4] = (char)(((unsigned int)Value[i+written])&0xFF);
110 112 }
111 RMAP_build_tx_request_header(254,2,1,transactionID,address+(written*4),count*4,writeBuffer+1);
113 RMAP_build_tx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(written*4),count*4,writeBuffer+1);
112 114 manager->sendPacket(writeBuffer,RMAP_WRITE_PACKET_MIN_SZ(count*4) +1);
113 115 written+=count;
114 116 if(progress!=NULL)
@@ -128,22 +130,27 unsigned int stardundeeSPW_USB::Read(uns
128 130 {
129 131 char requestBuffer[RMAP_READ_HEADER_MIN_SZ+1];
130 132 char* RMAP_AnswerBuffer;
131 requestBuffer[0]=1;//Link number
133 requestBuffer[0]=this->manager->linkNumber;//Link number
132 134 int transactionID = 0;
133 135 int read=0;
134 136 QProgressBar* progress=NULL;
135 137 if(count>RMAP_MAX_XFER_SIZE)
136 138 progress= SocExplorerEngine::getProgressBar("Reading on SPW @0x"+QString::number(address,16)+" %v of "+QString::number(count)+" words ",count);
137 SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE));
139 SocExplorerEngine::message(this->plugin,QString("Enter read function, count=%1, RMAP_MAX_XFER_SIZE=%2").arg(count).arg(RMAP_MAX_XFER_SIZE),2);
138 140
139 141 //Quite stupide loop, I guess that I always get the number of byte I asked for!
140 142 while((int)count>=(int)RMAP_MAX_XFER_SIZE)
141 143 {
142 144 transactionID = manager->getRMAPtransactionID();
143 SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID));
144 RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1);
145 SocExplorerEngine::message(this->plugin,QString("New transactionID:%1").arg(transactionID),2);
146 RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),RMAP_MAX_XFER_SIZE*4,requestBuffer+1);
145 147 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
146 148 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
149 if(len==-1)
150 {
151 this->toggleBridgeConnection();
152 return 0;
153 }
147 154 for(int i=0;i<((len-13)/4);i++)
148 155 {
149 156 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
@@ -160,14 +167,19 unsigned int stardundeeSPW_USB::Read(uns
160 167 if((int)count>0)
161 168 {
162 169 transactionID = manager->getRMAPtransactionID();
163 SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID));
164 SocExplorerEngine::message(this->plugin,QString("Building request with:"));
165 SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16));
166 SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4));
167 SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13));
168 RMAP_build_rx_request_header(254,2,1,transactionID,address+(read*4),count*4,requestBuffer+1);
170 SocExplorerEngine::message(this->plugin,QString("New transactionID: %1").arg(transactionID),2);
171 SocExplorerEngine::message(this->plugin,QString("Building request with:"),2);
172 SocExplorerEngine::message(this->plugin,QString("Address = %1").arg(address+(read*4),8,16),2);
173 SocExplorerEngine::message(this->plugin,QString("Size = %1").arg(count*4),2);
174 SocExplorerEngine::message(this->plugin,QString("Size + 13 = %1").arg((count*4)+13),2);
175 RMAP_build_rx_request_header(this->manager->rmapAddress,this->manager->rmapKey,1,transactionID,address+(read*4),count*4,requestBuffer+1);
169 176 manager->sendPacket(requestBuffer,RMAP_READ_HEADER_MIN_SZ+1);
170 177 int len=manager->getRMAPanswer(transactionID,&RMAP_AnswerBuffer);
178 if(len==-1)
179 {
180 this->toggleBridgeConnection();
181 return 0;
182 }
171 183 for(int i=0;i<((len-13)/4);i++)
172 184 {
173 185 Value[read+i] = 0x0FF & ((unsigned int)RMAP_AnswerBuffer[(4*i)+12]);
@@ -190,21 +202,68 unsigned int stardundeeSPW_USB::Read(uns
190 202 return read;
191 203 }
192 204
193 void stardundeeSPW_USB::updateAvailableBrickCount(int count)
205 void stardundeeSPW_USB::brickSelectionChanged(int brickIndex)
206 {
207 this->manager->selectedBrick = brickIndex-1;
208 SocExplorerEngine::message(plugin,QString("Changing brick index: %1").arg(manager->selectedBrick));
209 }
210
211 void stardundeeSPW_USB::linkNumberSelectionChanged(int linkIndex)
212 {
213 this->manager->linkNumber = linkIndex + 1;
214 SocExplorerEngine::message(plugin,QString("Changing Link Number: %1").arg(manager->linkNumber));
215 }
216
217 void stardundeeSPW_USB::linkSpeedSelectionChanged(const QString &linkSpeed)
194 218 {
219 this->manager->linkSpeed = linkSpeed.toInt();
195 220
221 SocExplorerEngine::message(plugin,QString("Changing Link Speed: %1").arg(manager->linkSpeed));
222 }
223
224 void stardundeeSPW_USB::destinationKeyChanged(const QString &destKey)
225 {
226 this->manager->destinationKey = destKey.toInt();
227 SocExplorerEngine::message(plugin,QString("Changing Destination Key: %1").arg(manager->destinationKey));
228 }
229
230 void stardundeeSPW_USB::rmapAddressChanged(const QString &rmapaddress)
231 {
232 this->manager->rmapAddress = rmapaddress.toInt();
233 SocExplorerEngine::message(plugin,QString("Changing RMAP address: %1").arg(manager->rmapAddress));
234 }
235
236 void stardundeeSPW_USB::rmapKeyChanged(const QString &key)
237 {
238 this->manager->rmapKey = key.toInt();
239 SocExplorerEngine::message(plugin,QString("Changing RMAP Key: %1").arg(manager->rmapKey));
196 240 }
197 241
198 242 void stardundeeSPW_USB::makeGUI(socexplorerplugin *parent)
199 243 {
200 this->p_GUI = new StarDundeeGUI(plugin);
201 this->mainLayout = new QGridLayout(this->p_GUI);
202 // connect(this->connectBridgeButton,SIGNAL(clicked()),this,SLOT(toggleBridgeConnection()));
244 this->p_GUI = new StarDundeeGUI();
245 // this->mainLayout = new QGridLayout(this->p_GUI);
246 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection()));
247 connect(this->manager,SIGNAL(updateAvailableBrickCount(int)),((StarDundeeGUI*)this->p_GUI),SLOT(updateAvailableBrickCount(int)));
248 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(brickSelectionChanged(int)),this,SLOT(brickSelectionChanged(int)));
249 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkNumberSelectionChanged(int)),this,SLOT(linkNumberSelectionChanged(int)));
250 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(linkSpeedSelectionChanged(QString)),this,SLOT(linkSpeedSelectionChanged(QString)));
251 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(destinationKeyChanged(QString)),this,SLOT(destinationKeyChanged(QString)));
252 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapAddressChanged(QString)),this,SLOT(rmapAddressChanged(QString)));
253 connect(((StarDundeeGUI*)this->p_GUI),SIGNAL(rmapKeyChanged(QString)),this,SLOT(rmapKeyChanged(QString)));
254 this->brickSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getBrickSelection());
255 this->linkNumberSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkNumberSelection());
256 this->linkSpeedSelectionChanged(((StarDundeeGUI*)this->p_GUI)->getLinkSpeedSelection());
257 this->destinationKeyChanged(((StarDundeeGUI*)this->p_GUI)->getDestinationKey());
258 this->rmapAddressChanged(((StarDundeeGUI*)this->p_GUI)->getRmapAddress());
259 this->rmapKeyChanged(((StarDundeeGUI*)this->p_GUI)->getRmapKey());
260
203 261 }
204 262
205 263 stardundeeSPW_USB_Manager::stardundeeSPW_USB_Manager(socexplorerplugin *plugin, QObject *parent)
206 264 :QThread((QObject*)parent)
207 265 {
266 this->RMAPtimeout = 2000;
208 267 this->handleMutex = new QMutex(QMutex::NonRecursive);
209 268 this->RMAP_AnswersSem = new QSemaphore(0);
210 269 this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive);
@@ -227,7 +286,7 void stardundeeSPW_USB_Manager::run()
227 286 USB_SPACEWIRE_PACKET_PROPERTIES properties;
228 287 USB_SPACEWIRE_ID pIdentifier=NULL;
229 288 USB_SPACEWIRE_STATUS stat;
230 SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread");
289 SocExplorerEngine::message(this->plugin,"Starting Startdundee USB pooling thread",1);
231 290 char buffer[(RMAP_MAX_XFER_SIZE*4)+50];
232 291 while (!this->isInterruptionRequested())
233 292 {
@@ -237,20 +296,20 void stardundeeSPW_USB_Manager::run()
237 296 //SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets");
238 297 if(USBSpaceWire_WaitOnReadPacketAvailable(hDevice,0.01))
239 298 {
240 SocExplorerEngine::message(this->plugin,"Got packet");
299 SocExplorerEngine::message(this->plugin,"Got packet",2);
241 300 stat = USBSpaceWire_ReadPackets(hDevice, buffer, (RMAP_MAX_XFER_SIZE*4)+50,1, 1, &properties, &pIdentifier);
242 301 if (stat == TRANSFER_SUCCESS)
243 302 {
244 303 if(USBSpaceWire_GetReadTrafficType(&properties, 0) ==SPACEWIRE_TRAFFIC_PACKET)
245 304 {
246 SocExplorerEngine::message(this->plugin,"It's a SPW packet");
305 SocExplorerEngine::message(this->plugin,"It's a SPW packet",2);
247 306 if(USBSpaceWire_GetReadEOPStatus(&properties, 0)== SPACEWIRE_USB_EOP)
248 307 {
249 308 SocExplorerEngine::message(this->plugin,"Got end of packet");
250 309 if(buffer[1]==(char)SPW_PROTO_ID_RMAP) //RMAP packet
251 310 {
252 SocExplorerEngine::message(this->plugin,"Got RMAP packet");
253 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len));
311 SocExplorerEngine::message(this->plugin,"Got RMAP packet",2);
312 SocExplorerEngine::message(this->plugin,QString("Rmap packet size %1").arg(properties.len),2);
254 313 if(properties.len>8)
255 314 {
256 315 char* packetbuffer = (char*)malloc(properties.len);
@@ -277,12 +336,12 void stardundeeSPW_USB_Manager::run()
277 336 {
278 337 USBSpaceWire_FreeRead(hDevice, pIdentifier);
279 338 handleMutex->unlock();
280 SocExplorerEngine::message(this->plugin,"Got SPW packet");
339 SocExplorerEngine::message(this->plugin,"Got SPW packet",2);
281 340 }
282 341 }
283 342 else
284 343 {
285 SocExplorerEngine::message(this->plugin,"No EOP received");
344 SocExplorerEngine::message(this->plugin,"No EOP received",2);
286 345 }
287 346 }
288 347
@@ -302,28 +361,30 void stardundeeSPW_USB_Manager::run()
302 361 else
303 362 {
304 363 sleep(1);
305 this->brickList = USBSpaceWire_ListDevices();
364 int list = USBSpaceWire_ListDevices();
365 if(this->brickList!=list)
366 {
367 this->brickList = list;
368 emit updateAvailableBrickCount(this->brickList);
369 }
306 370 }
307 371 usleep(1000);
308 372 }
309 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread");
373 SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1);
310 374 }
311 375
312 376 bool stardundeeSPW_USB_Manager::connectBridge()
313 377 {
314 this->handleMutex->lock();
378 QMutexLocker mlock(this->handleMutex);
315 379 int status;
316 380 U32 statusControl;
317 int brickNumber=0;
318 int linkNumber=1;
319 381 this->connected = false;
320 if (!USBSpaceWire_Open(&hDevice, brickNumber)) // Open the USB device
382 if (!USBSpaceWire_Open(&hDevice, this->selectedBrick)) // Open the USB device
321 383 {
322 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))");
323 this->handleMutex->unlock();
384 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** ERROR: USBSpaceWire_Open(&hDevice, 0))",0);
324 385 return false;
325 386 }
326 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful");
387 SocExplorerEngine::message(this->plugin,"stardundee *** Open *** USBSpaceWire_Open successful",0);
327 388
328 389 USBSpaceWire_EnableNetworkMode(hDevice, 0); // deactivate the network mode
329 390 CFGSpaceWire_EnableRMAP(1); // Enable the use of RMAP for the StarDundee brick configuration
@@ -338,23 +399,23 bool stardundeeSPW_USB_Manager::connectB
338 399 status = CFGSpaceWire_SetBrickBaseTransmitRate( hDevice, CFG_BRK_CLK_100_MHZ, CFG_BRK_DVDR_1, 0xff);
339 400 if (status != CFG_TRANSFER_SUCCESS)
340 401 {
341 SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate");
402 SocExplorerEngine::message(this->plugin,"ERROR CFGSpaceWire_SetBrickBaseTransmitRate",1);
342 403 return false;
343 404 }
344 405 else
345 406 {
346 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz");
407 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_SetBrickBaseTransmitRate, base rate = 100 MHz",1);
347 408 }
348 409
349 410 // read the link status
350 if (CFGSpaceWire_GetLinkStatusControl(hDevice, linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
411 if (CFGSpaceWire_GetLinkStatusControl(hDevice, this->linkNumber, &statusControl) != CFG_TRANSFER_SUCCESS)
351 412 {
352 SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(linkNumber));
413 SocExplorerEngine::message(this->plugin,"Could not read link status control for link " + QString::number(this->linkNumber),1);
353 414 return false;
354 415 }
355 416 else
356 417 {
357 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(linkNumber));
418 SocExplorerEngine::message(this->plugin,"OK CFGSpaceWire_GetLinkStatusControl of link " + QString::number(this->linkNumber),1);
358 419
359 420 // Set the link status control register properties
360 421 CFGSpaceWire_LSEnableAutoStart(&statusControl, 1);
@@ -364,35 +425,34 bool stardundeeSPW_USB_Manager::connectB
364 425 CFGSpaceWire_LSSetOperatingSpeed(&statusControl, 9); // sets the link speed to ( 100 MHz / (9+1) ) = 10 MHz
365 426
366 427 // Set the link status control register
367 if (CFGSpaceWire_SetLinkStatusControl(hDevice, linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
428 if (CFGSpaceWire_SetLinkStatusControl(hDevice, this->linkNumber, statusControl) != CFG_TRANSFER_SUCCESS)
368 429 {
369 SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(linkNumber));
430 SocExplorerEngine::message(this->plugin,"Could not set the link status control for link " + QString::number(this->linkNumber),1);
370 431 return false;
371 432 }
372 433 else
373 434 {
374 SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(linkNumber));
435 SocExplorerEngine::message(this->plugin,"Set the link status control for link " + QString::number(this->linkNumber),1);
375 436 }
376 437 }
377 438
378 439 if (CFGSpaceWire_SetAsInterface(hDevice, 1, 0) != CFG_TRANSFER_SUCCESS)
379 440 {
380 SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface");
441 SocExplorerEngine::message(this->plugin,"Could not set the device to be an interface",1);
381 442 return false;
382 443 }
383 444 else
384 445 {
385 SocExplorerEngine::message(this->plugin,"Device set to be an interface");
446 SocExplorerEngine::message(this->plugin,"Device set to be an interface",1);
386 447 }
387 448
388 449 USBSpaceWire_RegisterReceiveOnAllPorts(hDevice); // Register to receive on all ports
389 450 USBSpaceWire_ClearEndpoints(hDevice); // clear the USB endpoints
390 451 USBSpaceWire_SetTimeout(hDevice,1.0);
391 SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes");
392 SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes");
393 SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)));
452 SocExplorerEngine::message(this->plugin,"The driver's current send buffer size is " + QString::number(USBSpaceWire_GetDriverSendBufferSize(hDevice)) + " bytes",1);
453 SocExplorerEngine::message(this->plugin,"The driver's current read buffer size is " + QString::number(USBSpaceWire_GetDriverReadBufferSize(hDevice)) + " bytes",1);
454 SocExplorerEngine::message(this->plugin,"USBSpaceWire_IsReadThrottling is " + QString::number(USBSpaceWire_IsReadThrottling(hDevice)),1);
394 455 this->connected = true;
395 this->handleMutex->unlock();
396 456 return true;
397 457 }
398 458
@@ -400,9 +460,16 bool stardundeeSPW_USB_Manager::disconne
400 460 {
401 461 this->handleMutex->lock();
402 462 USBSpaceWire_Close(hDevice); // Close the device
403 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0));
463 SocExplorerEngine::message(this->plugin,"stardundee *** Close *** USBSpaceWire_Close, device: " + QString::number(0),0);
404 464 USBSpaceWire_UnregisterReceiveOnAllPorts(hDevice); // Stop receiving on all ports
405 465 this->handleMutex->unlock();
466 this->RMAP_pending_transaction_IDsMtx->lock();
467 this->RMAP_pending_transaction_IDs.clear();
468 this->RMAP_pending_transaction_IDsMtx->unlock();
469 this->RMAP_AnswersMtx->lock();
470 this->RMAP_Answers.clear();
471 this->RMAP_AnswersMtx->unlock();
472 this->RMAP_AnswersSem->acquire(this->RMAP_AnswersSem->available());
406 473 return true;
407 474 }
408 475
@@ -411,7 +478,7 int stardundeeSPW_USB_Manager::getRMAPtr
411 478 this->RMAP_pending_transaction_IDsMtx->lock();
412 479 int ID=0;
413 480 bool found=true;
414 while(ID<65536)
481 while(ID<511)
415 482 {
416 483 for(int i=0;i<RMAP_pending_transaction_IDs.count();i++)
417 484 {
@@ -431,16 +498,22 int stardundeeSPW_USB_Manager::getRMAPtr
431 498
432 499 int stardundeeSPW_USB_Manager::getRMAPanswer(int transactionID, char **buffer)
433 500 {
501 QTime timeout;
434 502 *buffer=NULL;
435 503 int count=0;
504 SocExplorerEngine::message(this->plugin,"Looking for RMAP answer",2);
505 timeout.start();
436 506 while (*buffer==NULL)
437 507 {
438 508 this->RMAP_AnswersMtx->lock();
509 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_Answers stack",2);
510 SocExplorerEngine::message(this->plugin,QString("%2 packet(s) available in RMAP_Answers stack").arg(RMAP_Answers.count()),2);
439 511 for(int i=0;i<RMAP_Answers.count();i++)
440 512 {
441 513 if(RMAP_Answers[i]->transactionID==transactionID)
442 514 {
443 515 this->RMAP_pending_transaction_IDsMtx->lock();
516 SocExplorerEngine::message(this->plugin,"Got exclusive access on RMAP_pending_transaction_ID stack",2);
444 517 for(int j=0;j<RMAP_pending_transaction_IDs.count();j++)
445 518 {
446 519 if(RMAP_pending_transaction_IDs[j]==transactionID)
@@ -458,9 +531,19 int stardundeeSPW_USB_Manager::getRMAPan
458 531 }
459 532 this->RMAP_AnswersMtx->unlock();
460 533 //if no answer found in the stack wait until a new packet is pushed
461 if(!buffer)
534 SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed",2);
535 if(*buffer==NULL)
536 {
537 while (0==this->RMAP_AnswersSem->available())
462 538 {
463 SocExplorerEngine::message(this->plugin,"waiting until a new packet is pushed");
539 SocExplorerEngine::message(this->plugin,QString("this->RMAP_AnswersSem->available() = %1").arg(this->RMAP_AnswersSem->available()),2);
540 if(timeout.elapsed()>=RMAPtimeout)
541 {
542 SocExplorerEngine::message(this->plugin,"Timeout reached giving up!",2);
543 return -1;
544 }
545 usleep(1000);
546 }
464 547 this->RMAP_AnswersSem->acquire();
465 548 }
466 549 }
@@ -471,18 +554,18 bool stardundeeSPW_USB_Manager::sendPack
471 554 {
472 555 USB_SPACEWIRE_STATUS result;
473 556 USB_SPACEWIRE_ID pIdentifier;
474 SocExplorerEngine::message(this->plugin,"Sending SPW packet");
557 SocExplorerEngine::message(this->plugin,"Sending SPW packet",2);
475 558 this->handleMutex->lock();
476 559 result = USBSpaceWire_SendPacket(hDevice,packet,size,1, &pIdentifier);
477 560 if (result != TRANSFER_SUCCESS)
478 561 {
479 SocExplorerEngine::message(this->plugin,"ERR sending the READ command ");
562 SocExplorerEngine::message(this->plugin,"ERR sending the READ command ",2);
480 563 this->handleMutex->unlock();
481 564 return false;
482 565 }
483 566 else
484 567 {
485 SocExplorerEngine::message(this->plugin,"Packet sent");
568 SocExplorerEngine::message(this->plugin,"Packet sent",2);
486 569 USBSpaceWire_FreeSend(hDevice, pIdentifier);
487 570 }
488 571 this->handleMutex->unlock();
@@ -1,6 +1,6
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 -- Copyright (C) 2014, Laboratory of Plasmas Physic - CNRS
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
@@ -62,6 +62,9 public:
62 62 int getRMAPtransactionID();
63 63 int getRMAPanswer(int transactionID,char** buffer);
64 64 bool sendPacket(char* packet,int size);
65
66 signals:
67 void updateAvailableBrickCount(int count);
65 68 private:
66 69 QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx;
67 70 QSemaphore* RMAP_AnswersSem;
@@ -72,8 +75,16 private:
72 75 char* SPWPacketBuff;
73 76 QList<RMAP_Answer*> RMAP_Answers;
74 77 QList<int> RMAP_pending_transaction_IDs;
78
79 public:
80 int selectedBrick;
75 81 int linkNumber;
76 82 int brickList;
83 int linkSpeed;
84 int destinationKey;
85 int rmapAddress;
86 int rmapKey;
87 int RMAPtimeout;
77 88 };
78 89
79 90 class stardundeeSPW_USB : public abstractSpwBridge
@@ -92,13 +103,16 public slots:
92 103 int pushRMAPPacket(char* packet,int size);
93 104 unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0);
94 105 unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0);
95 void updateAvailableBrickCount(int count);
106 void brickSelectionChanged(int brickIndex);
107 void linkNumberSelectionChanged(int linkIndex);
108 void linkSpeedSelectionChanged(const QString & linkSpeed);
109 void destinationKeyChanged(const QString & destKey);
110 void rmapAddressChanged(const QString & rmapaddress);
111 void rmapKeyChanged(const QString & key);
96 112 private:
97 113 void makeGUI(socexplorerplugin *parent);
98 114 stardundeeSPW_USB_Manager* manager;
99 QGridLayout* mainLayout;
100 QPushButton* connectBridgeButton;
101 QComboBox* selectBrickQcmbx;
115 // QGridLayout* mainLayout;
102 116 };
103 117
104 118 #endif // STARDUNDEESPW_USB_H
General Comments 0
You need to be logged in to leave comments. Login now