@@ -1,94 +1,202 | |||
|
1 | 1 | #include "gr_esb_bridge.h" |
|
2 | 2 | #include "gr_esb_ui.h" |
|
3 | 3 | #include <unistd.h> |
|
4 | #include "spw.h" | |
|
5 | #include <socexplorerengine.h> | |
|
4 | 6 | |
|
5 | 7 | GR_ESB_bridge::GR_ESB_bridge(socexplorerplugin *parent) : |
|
6 | 8 | abstractSpwBridge(parent) |
|
7 | 9 | { |
|
8 | 10 | this->p_GUI = new GR_ESB_ui(); |
|
9 | this->Read_soc = new QTcpSocket(this); | |
|
10 | this->Write_soc = new QTcpSocket(this); | |
|
11 | this->manager = new GR_ESB_Manager(parent,this); | |
|
12 | ||
|
11 | 13 | connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(ipchanged(QString)),this,SLOT(setIP(QString))); |
|
12 |
connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(set |
|
|
14 | connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(vlinkchanged(QString)),this,SLOT(setVirtualLink(QString))); | |
|
15 | connect((GR_ESB_ui*)(this->p_GUI),SIGNAL(connectClicked()),this,SLOT(toggleBridgeConnection())); | |
|
16 | this->manager->virtualLinkIndex = 0; | |
|
17 | this->manager->start(); | |
|
13 | 18 | } |
|
14 | 19 | |
|
15 | 20 | GR_ESB_bridge::~GR_ESB_bridge() |
|
16 | 21 | { |
|
17 | 22 | } |
|
18 | 23 | |
|
24 | void GR_ESB_bridge::toggleBridgeConnection() | |
|
25 | { | |
|
26 | if(this->plugin->isConnected()) | |
|
27 | { | |
|
28 | this->disconnectBridge(); | |
|
29 | } | |
|
30 | else | |
|
31 | { | |
|
32 | this->connectBridge(); | |
|
33 | } | |
|
34 | } | |
|
35 | ||
|
19 | 36 | bool GR_ESB_bridge::connectBridge() |
|
20 | 37 | { |
|
38 | if(this->manager->connectBridge()) | |
|
39 | { | |
|
40 | ((GR_ESB_ui*)this->p_GUI)->lock(true); | |
|
41 | emit setConnected(true); | |
|
42 | return true; | |
|
43 | } | |
|
44 | return false; | |
|
45 | } | |
|
46 | ||
|
47 | bool GR_ESB_bridge::disconnectBridge() | |
|
48 | { | |
|
49 | if(this->manager->disconnectBridge()) | |
|
50 | { | |
|
51 | ((GR_ESB_ui*)this->p_GUI)->lock(false); | |
|
52 | emit setConnected(false); | |
|
53 | return true; | |
|
54 | } | |
|
55 | return false; | |
|
56 | } | |
|
57 | ||
|
58 | void GR_ESB_bridge::setIP(QString ip) | |
|
59 | { | |
|
60 | this->manager->IP = ip; | |
|
61 | } | |
|
62 | ||
|
63 | void GR_ESB_bridge::setVirtualLink(QString vlink) | |
|
64 | { | |
|
65 | vlink = vlink.section("Virtual link",0,0); | |
|
66 | bool success; | |
|
67 | int vlinkTmp = vlink.toInt(&success); | |
|
68 | if(success) | |
|
69 | { | |
|
70 | setVirtualLink(vlinkTmp); | |
|
71 | } | |
|
72 | } | |
|
73 | ||
|
74 | void GR_ESB_bridge::setVirtualLink(qint32 vlink) | |
|
75 | { | |
|
76 | if(vlink<6 && vlink>=0) | |
|
77 | { | |
|
78 | this->manager->virtualLinkIndex = vlink; | |
|
79 | } | |
|
80 | } | |
|
81 | ||
|
82 | ||
|
83 | unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
|
84 | { | |
|
85 | ||
|
86 | } | |
|
87 | ||
|
88 | unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
|
89 | { | |
|
90 | ||
|
91 | } | |
|
92 | ||
|
93 | int GR_ESB_bridge::pushRMAPPacket(char *packet, int size) | |
|
94 | { | |
|
95 | return this->manager->sendPacket(packet,size); | |
|
96 | } | |
|
97 | ||
|
98 | ||
|
99 | GR_ESB_Manager::GR_ESB_Manager(socexplorerplugin *plugin, QObject *parent) | |
|
100 | :QThread((QObject*)parent) | |
|
101 | { | |
|
102 | this->Read_soc = new QTcpSocket(this); | |
|
103 | this->Write_soc = new QTcpSocket(this); | |
|
104 | this->RMAPtimeout = 2000; | |
|
105 | this->handleMutex = new QMutex(QMutex::NonRecursive); | |
|
106 | this->RMAP_AnswersSem = new QSemaphore(0); | |
|
107 | this->RMAP_AnswersMtx=new QMutex(QMutex::Recursive); | |
|
108 | this->RMAP_pending_transaction_IDsMtx=new QMutex(QMutex::Recursive); | |
|
109 | this->plugin = plugin; | |
|
110 | connected = false; | |
|
111 | this->moveToThread(this); | |
|
112 | } | |
|
113 | ||
|
114 | GR_ESB_Manager::~GR_ESB_Manager() | |
|
115 | { | |
|
116 | ||
|
117 | } | |
|
118 | ||
|
119 | void GR_ESB_Manager::run() | |
|
120 | { | |
|
121 | SocExplorerEngine::message(this->plugin,"Starting GRESB pooling thread",1); | |
|
122 | while (!this->isInterruptionRequested()) | |
|
123 | { | |
|
124 | if(this->connected) | |
|
125 | { | |
|
126 | handleMutex->lock(); | |
|
127 | SocExplorerEngine::message(this->plugin,"Looking for new RMAP packets",4); | |
|
128 | ||
|
129 | } | |
|
130 | else | |
|
131 | { | |
|
132 | //do some sanity checks! | |
|
133 | ||
|
134 | usleep(RMAPtimeout/2); | |
|
135 | } | |
|
136 | usleep(1000); | |
|
137 | } | |
|
138 | SocExplorerEngine::message(this->plugin,"Exiting Startdundee USB pooling thread",1); | |
|
139 | } | |
|
140 | ||
|
141 | bool GR_ESB_Manager::connectBridge() | |
|
142 | { | |
|
21 | 143 | int timeout=60; |
|
22 | 144 | if(this->Read_soc->state()==QTcpSocket::UnconnectedState) |
|
23 | 145 | { |
|
24 | 146 | this->Read_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Read_port); |
|
25 | 147 | this->Read_soc->waitForConnected(30000); |
|
26 | 148 | } |
|
27 | 149 | if(this->Write_soc->state()==QTcpSocket::UnconnectedState) |
|
28 | 150 | { |
|
29 | 151 | this->Write_soc->connectToHost(IP,gresb_Conf[virtualLinkIndex].Write_port); |
|
30 | 152 | this->Write_soc->waitForConnected(30000); |
|
31 | 153 | } |
|
32 | 154 | while((this->Read_soc->state()!=QTcpSocket::ConnectedState) && (this->Write_soc->state()!=QTcpSocket::ConnectedState)) |
|
33 | 155 | { |
|
34 | 156 | usleep(100000); |
|
35 | 157 | if(timeout--==0)return false; |
|
36 | 158 | } |
|
37 | 159 | return true; |
|
160 | ||
|
38 | 161 | } |
|
39 | 162 | |
|
40 |
bool GR_ESB_ |
|
|
163 | bool GR_ESB_Manager::disconnectBridge() | |
|
41 | 164 | { |
|
42 | 165 | int timeout=60; |
|
43 | 166 | if(this->Read_soc->state()!=QTcpSocket::UnconnectedState) |
|
44 | 167 | { |
|
45 | 168 | this->Read_soc->disconnectFromHost(); |
|
46 | 169 | this->Read_soc->waitForDisconnected(30000); |
|
47 | while(this->Read_soc->state()!=QTcpSocket::UnconnectedState) | |
|
48 | { | |
|
49 | usleep(100000); | |
|
50 | if(timeout--==0)return false; | |
|
51 | } | |
|
170 | } | |
|
171 | if(this->Write_soc->state()!=QTcpSocket::UnconnectedState) | |
|
172 | { | |
|
173 | this->Write_soc->disconnectFromHost(); | |
|
174 | this->Write_soc->waitForDisconnected(30000); | |
|
175 | } | |
|
176 | while((this->Read_soc->state()!=QTcpSocket::UnconnectedState) && (this->Write_soc->state()!=QTcpSocket::UnconnectedState)) | |
|
177 | { | |
|
178 | usleep(100000); | |
|
179 | if(timeout--==0)return false; | |
|
52 | 180 | } |
|
53 | 181 | return true; |
|
54 | 182 | } |
|
55 | 183 | |
|
56 | void GR_ESB_bridge::setIP(QString ip) | |
|
184 | int GR_ESB_Manager::getRMAPtransactionID() | |
|
57 | 185 | { |
|
58 | this->IP = ip; | |
|
186 | ||
|
59 | 187 | } |
|
60 | 188 | |
|
61 | void GR_ESB_bridge::setVirtualLink(QString vlink) | |
|
62 | { | |
|
63 | vlink = vlink.section("Virtual link",0,0); | |
|
64 | bool success; | |
|
65 | int vlinkTmp = vlink.toInt(&success); | |
|
66 | if(success) | |
|
67 | { | |
|
68 | setVirtualLink(vlinkTmp); | |
|
69 | } | |
|
70 | } | |
|
71 | ||
|
72 | void GR_ESB_bridge::setVirtualLink(qint32 vlink) | |
|
73 | { | |
|
74 | if(vlink<6 && vlink>=0) | |
|
75 | { | |
|
76 | virtualLinkIndex = vlink; | |
|
77 | } | |
|
78 | } | |
|
79 | ||
|
80 | ||
|
81 | unsigned int GR_ESB_bridge::Write(unsigned int *Value, unsigned int count, unsigned int address) | |
|
189 | int GR_ESB_Manager::getRMAPanswer(int transactionID, char **buffer) | |
|
82 | 190 | { |
|
83 | 191 | |
|
84 | 192 | } |
|
85 | 193 | |
|
86 | unsigned int GR_ESB_bridge::Read(unsigned int *Value, unsigned int count, unsigned int address) | |
|
194 | bool GR_ESB_Manager::sendPacket(char *packet, int size) | |
|
87 | 195 | { |
|
88 | 196 | |
|
89 | 197 | } |
|
90 | 198 | |
|
91 |
|
|
|
199 | void GR_ESB_Manager::pushRmapPacket(char *packet, int len) | |
|
92 | 200 | { |
|
93 | 201 | |
|
94 | 202 | } |
@@ -1,50 +1,88 | |||
|
1 | 1 | #ifndef GR_ESB_BRIDGE_H |
|
2 | 2 | #define GR_ESB_BRIDGE_H |
|
3 | 3 | #include "abstractspwbridge.h" |
|
4 | 4 | #include <QTcpSocket> |
|
5 | #include <QThread> | |
|
6 | #include <QMutex> | |
|
7 | #include <QSemaphore> | |
|
5 | 8 | |
|
6 | 9 | struct gresb_Conf_str |
|
7 | 10 | { |
|
8 | 11 | qint32 Read_port; |
|
9 | 12 | qint32 Write_port; |
|
10 | 13 | }; |
|
11 | 14 | |
|
15 | ||
|
12 | 16 | const struct gresb_Conf_str gresb_Conf[]= |
|
13 | 17 | { |
|
14 | 18 | {3000,3001}, //Virtual link 0 |
|
15 | 19 | {3002,3003}, //Virtual link 1 |
|
16 | 20 | {3004,3005}, //Virtual link 2 |
|
17 | 21 | {3006,3007}, //Virtual link 3 |
|
18 | 22 | {3008,3009}, //Virtual link 4 |
|
19 | 23 | {3010,3011} //Virtual link 5 |
|
20 | 24 | }; |
|
21 | 25 | |
|
26 | ||
|
27 | class GR_ESB_Manager: public QThread | |
|
28 | { | |
|
29 | Q_OBJECT | |
|
30 | public: | |
|
31 | explicit GR_ESB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); | |
|
32 | ~GR_ESB_Manager(); | |
|
33 | void run(); | |
|
34 | bool connectBridge(); | |
|
35 | bool disconnectBridge(); | |
|
36 | int getRMAPtransactionID(); | |
|
37 | int getRMAPanswer(int transactionID,char** buffer); | |
|
38 | bool sendPacket(char* packet,int size); | |
|
39 | ||
|
40 | signals: | |
|
41 | void emitPacket(char* packet,int size); | |
|
42 | private: | |
|
43 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; | |
|
44 | QSemaphore* RMAP_AnswersSem; | |
|
45 | void pushRmapPacket(char* packet,int len); | |
|
46 | socexplorerplugin* plugin; | |
|
47 | bool connected; | |
|
48 | char* SPWPacketBuff; | |
|
49 | QList<RMAP_Answer*> RMAP_Answers; | |
|
50 | QList<int> RMAP_pending_transaction_IDs; | |
|
51 | ||
|
52 | public: | |
|
53 | QTcpSocket* Read_soc; | |
|
54 | QTcpSocket* Write_soc; | |
|
55 | QString IP; | |
|
56 | int virtualLinkIndex; | |
|
57 | int RMAPtimeout; | |
|
58 | }; | |
|
59 | ||
|
60 | ||
|
22 | 61 | class GR_ESB_bridge : public abstractSpwBridge |
|
23 | 62 | { |
|
24 | 63 | Q_OBJECT |
|
25 | 64 | public: |
|
26 | 65 | explicit GR_ESB_bridge(socexplorerplugin *parent = 0); |
|
27 | 66 | ~GR_ESB_bridge(); |
|
28 | 67 | signals: |
|
29 | 68 | |
|
30 | 69 | |
|
31 | 70 | public slots: |
|
71 | void toggleBridgeConnection(); | |
|
32 | 72 | bool connectBridge(); |
|
33 | 73 | bool disconnectBridge(); |
|
34 | 74 | void setIP(QString ip); |
|
35 | 75 | void setVirtualLink(QString vlink); |
|
36 | 76 | void setVirtualLink(qint32 vlink); |
|
37 | 77 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
38 | 78 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
39 | 79 | int pushRMAPPacket(char* packet,int size); |
|
40 | 80 | void packetReceived(); |
|
41 | 81 | |
|
42 | 82 | private: |
|
43 | QTcpSocket* Read_soc; | |
|
44 | QTcpSocket* Write_soc; | |
|
45 | QString IP; | |
|
46 | int virtualLinkIndex; | |
|
83 | ||
|
84 | GR_ESB_Manager* manager; | |
|
47 | 85 | |
|
48 | 86 | }; |
|
49 | 87 | |
|
50 | 88 | #endif // GR_ESB_BRIDGE_H |
@@ -1,19 +1,31 | |||
|
1 | 1 | #include "gr_esb_ui.h" |
|
2 | 2 | #include "ui_gr_esb_ui.h" |
|
3 | 3 | #include <QWebView> |
|
4 | 4 | |
|
5 | 5 | GR_ESB_ui::GR_ESB_ui(QWidget *parent) : |
|
6 | 6 | QWidget(parent), |
|
7 | 7 | ui(new Ui::GR_ESB_ui) |
|
8 | 8 | { |
|
9 | 9 | ui->setupUi(this); |
|
10 | 10 | connect(this->ui->GRESB_IP_lineEdit,SIGNAL(textChanged(QString)),this,SLOT(changeIp(QString))); |
|
11 | 11 | connect(this->ui->GRESB_Vlink_CmBx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(vlinkchanged(QString))); |
|
12 | connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked())); | |
|
12 | 13 | } |
|
13 | 14 | |
|
14 | 15 | void GR_ESB_ui::changeIp(QString ip) |
|
15 | 16 | { |
|
16 | 17 | this->ui->WebView->load(QUrl("http://"+ip)); |
|
17 | 18 | emit this->ipchanged(ip); |
|
18 | 19 | } |
|
19 | 20 | |
|
21 | void GR_ESB_ui::lock(bool lock) | |
|
22 | { | |
|
23 | this->ui->GRESB_IP_lineEdit->setDisabled(lock); | |
|
24 | this->ui->GRESB_LinkNum_CmBx->setDisabled(lock); | |
|
25 | this->ui->GRESB_Vlink_CmBx->setDisabled(lock); | |
|
26 | if(lock) | |
|
27 | this->ui->connectQpb->setText("Disconnect"); | |
|
28 | else | |
|
29 | this->ui->connectQpb->setText("Connect"); | |
|
30 | } | |
|
31 |
@@ -1,27 +1,28 | |||
|
1 | 1 | #ifndef GR_ESB_UI_H |
|
2 | 2 | #define GR_ESB_UI_H |
|
3 | 3 | |
|
4 | 4 | #include <QWidget> |
|
5 | 5 | |
|
6 | 6 | namespace Ui { |
|
7 | 7 | class GR_ESB_ui; |
|
8 | 8 | } |
|
9 | 9 | |
|
10 | 10 | class GR_ESB_ui : public QWidget |
|
11 | 11 | { |
|
12 | 12 | Q_OBJECT |
|
13 | 13 | |
|
14 | 14 | public: |
|
15 | 15 | explicit GR_ESB_ui(QWidget *parent = 0); |
|
16 | 16 | |
|
17 | 17 | public slots: |
|
18 | 18 | void changeIp(QString ip); |
|
19 | ||
|
19 | void lock(bool lock); | |
|
20 | 20 | signals: |
|
21 | 21 | void ipchanged(QString ip); |
|
22 | 22 | void vlinkchanged(QString vlink); |
|
23 | void connectClicked(); | |
|
23 | 24 | private: |
|
24 | 25 | Ui::GR_ESB_ui *ui; |
|
25 | 26 | }; |
|
26 | 27 | |
|
27 | 28 | #endif // GR_ESB_UI_H |
@@ -1,139 +1,146 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>GR_ESB_ui</class> |
|
4 | 4 | <widget class="QWidget" name="GR_ESB_ui"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 |
<width> |
|
|
10 |
<height> |
|
|
9 | <width>968</width> | |
|
10 | <height>392</height> | |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>Form</string> |
|
15 | 15 | </property> |
|
16 | 16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
17 | 17 | <item> |
|
18 | 18 | <widget class="QTabWidget" name="tabWidget"> |
|
19 | 19 | <property name="toolTip"> |
|
20 | 20 | <string/> |
|
21 | 21 | </property> |
|
22 | 22 | <property name="currentIndex"> |
|
23 | 23 | <number>0</number> |
|
24 | 24 | </property> |
|
25 | 25 | <widget class="QWidget" name="Config"> |
|
26 | 26 | <property name="toolTip"> |
|
27 | 27 | <string><html><head/><body><p>The Config tab allows you to configure the Ethernet conncetion to the GR-ESB and some spacewire parameters.</p></body></html></string> |
|
28 | 28 | </property> |
|
29 | 29 | <attribute name="title"> |
|
30 | 30 | <string>Config</string> |
|
31 | 31 | </attribute> |
|
32 | 32 | <layout class="QGridLayout" name="gridLayout_2"> |
|
33 | 33 | <item row="1" column="1"> |
|
34 | 34 | <widget class="QComboBox" name="GRESB_Vlink_CmBx"> |
|
35 | 35 | <item> |
|
36 | 36 | <property name="text"> |
|
37 | 37 | <string>Virtual link 0</string> |
|
38 | 38 | </property> |
|
39 | 39 | </item> |
|
40 | 40 | <item> |
|
41 | 41 | <property name="text"> |
|
42 | 42 | <string>Virtual link 1</string> |
|
43 | 43 | </property> |
|
44 | 44 | </item> |
|
45 | 45 | <item> |
|
46 | 46 | <property name="text"> |
|
47 | 47 | <string>Virtual link 2</string> |
|
48 | 48 | </property> |
|
49 | 49 | </item> |
|
50 | 50 | <item> |
|
51 | 51 | <property name="text"> |
|
52 | 52 | <string>Virtual link 3</string> |
|
53 | 53 | </property> |
|
54 | 54 | </item> |
|
55 | 55 | <item> |
|
56 | 56 | <property name="text"> |
|
57 | 57 | <string>Virtual link 4</string> |
|
58 | 58 | </property> |
|
59 | 59 | </item> |
|
60 | 60 | <item> |
|
61 | 61 | <property name="text"> |
|
62 | 62 | <string>Virtual link 5</string> |
|
63 | 63 | </property> |
|
64 | 64 | </item> |
|
65 | 65 | </widget> |
|
66 | 66 | </item> |
|
67 | 67 | <item row="1" column="0"> |
|
68 | 68 | <widget class="QLabel" name="GRESB_Vlink_Lbl"> |
|
69 | 69 | <property name="text"> |
|
70 | 70 | <string>GR-ESB Virtual link</string> |
|
71 | 71 | </property> |
|
72 | 72 | </widget> |
|
73 | 73 | </item> |
|
74 | 74 | <item row="2" column="1"> |
|
75 | 75 | <widget class="QComboBox" name="GRESB_LinkNum_CmBx"> |
|
76 | 76 | <item> |
|
77 | 77 | <property name="text"> |
|
78 | 78 | <string>SPW0</string> |
|
79 | 79 | </property> |
|
80 | 80 | </item> |
|
81 | 81 | <item> |
|
82 | 82 | <property name="text"> |
|
83 | 83 | <string>SPW1</string> |
|
84 | 84 | </property> |
|
85 | 85 | </item> |
|
86 | 86 | <item> |
|
87 | 87 | <property name="text"> |
|
88 | 88 | <string>SPW2</string> |
|
89 | 89 | </property> |
|
90 | 90 | </item> |
|
91 | 91 | </widget> |
|
92 | 92 | </item> |
|
93 | 93 | <item row="0" column="1"> |
|
94 | 94 | <widget class="QLineEdit" name="GRESB_IP_lineEdit"/> |
|
95 | 95 | </item> |
|
96 | 96 | <item row="2" column="0"> |
|
97 | 97 | <widget class="QLabel" name="GRESB_LinkNum_Lbl"> |
|
98 | 98 | <property name="text"> |
|
99 | 99 | <string>Select link number</string> |
|
100 | 100 | </property> |
|
101 | 101 | </widget> |
|
102 | 102 | </item> |
|
103 | 103 | <item row="0" column="0"> |
|
104 | 104 | <widget class="QLabel" name="GRESB_IP_Lbl"> |
|
105 | 105 | <property name="text"> |
|
106 | 106 | <string>GR-ESB IP Address</string> |
|
107 | 107 | </property> |
|
108 | 108 | </widget> |
|
109 | 109 | </item> |
|
110 | <item row="3" column="0" colspan="2"> | |
|
111 | <widget class="QPushButton" name="connectQpb"> | |
|
112 | <property name="text"> | |
|
113 | <string>Connect</string> | |
|
114 | </property> | |
|
115 | </widget> | |
|
116 | </item> | |
|
110 | 117 | </layout> |
|
111 | 118 | </widget> |
|
112 | 119 | <widget class="QWidget" name="Web"> |
|
113 | 120 | <property name="toolTip"> |
|
114 | 121 | <string><html><head/><body><p>The Web tab gives access to the GR-ESB web interface.</p></body></html></string> |
|
115 | 122 | </property> |
|
116 | 123 | <attribute name="title"> |
|
117 | 124 | <string>Web</string> |
|
118 | 125 | </attribute> |
|
119 | 126 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
120 | 127 | <item> |
|
121 | 128 | <widget class="QWebView" name="WebView" native="true"/> |
|
122 | 129 | </item> |
|
123 | 130 | </layout> |
|
124 | 131 | </widget> |
|
125 | 132 | </widget> |
|
126 | 133 | </item> |
|
127 | 134 | </layout> |
|
128 | 135 | </widget> |
|
129 | 136 | <customwidgets> |
|
130 | 137 | <customwidget> |
|
131 | 138 | <class>QWebView</class> |
|
132 | 139 | <extends>QWidget</extends> |
|
133 | 140 | <header location="global">QWebView</header> |
|
134 | 141 | <container>1</container> |
|
135 | 142 | </customwidget> |
|
136 | 143 | </customwidgets> |
|
137 | 144 | <resources/> |
|
138 | 145 | <connections/> |
|
139 | 146 | </ui> |
@@ -1,86 +1,115 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>SpwTcpPacketServer</class> |
|
4 | 4 | <widget class="QWidget" name="SpwTcpPacketServer"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 |
<width> |
|
|
10 |
<height> |
|
|
9 | <width>726</width> | |
|
10 | <height>535</height> | |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>Form</string> |
|
15 | 15 | </property> |
|
16 | 16 | <property name="toolTip"> |
|
17 | 17 | <string><html><head/><body><p>The spacewire plugin TCP server allows you to forward spacewire packets to any custom application, here you will configure the TCP connection and get some status information.</p></body></html></string> |
|
18 | 18 | </property> |
|
19 | 19 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
20 | 20 | <item> |
|
21 | 21 | <widget class="QGroupBox" name="configGroupBox"> |
|
22 | 22 | <property name="title"> |
|
23 | 23 | <string>Configuration</string> |
|
24 | 24 | </property> |
|
25 | 25 | <layout class="QFormLayout" name="formLayout_2"> |
|
26 | 26 | <item row="0" column="0"> |
|
27 | 27 | <widget class="QLabel" name="IPLbl"> |
|
28 | 28 | <property name="text"> |
|
29 | 29 | <string>Server IP</string> |
|
30 | 30 | </property> |
|
31 | 31 | </widget> |
|
32 | 32 | </item> |
|
33 | 33 | <item row="0" column="1"> |
|
34 | 34 | <widget class="QLineEdit" name="IPLineEdit"> |
|
35 | 35 | <property name="maxLength"> |
|
36 | 36 | <number>15</number> |
|
37 | 37 | </property> |
|
38 | 38 | <property name="readOnly"> |
|
39 | 39 | <bool>true</bool> |
|
40 | 40 | </property> |
|
41 | 41 | </widget> |
|
42 | 42 | </item> |
|
43 | 43 | <item row="1" column="0"> |
|
44 | 44 | <widget class="QLabel" name="PortLbl"> |
|
45 | 45 | <property name="text"> |
|
46 | 46 | <string>Server Port</string> |
|
47 | 47 | </property> |
|
48 | 48 | </widget> |
|
49 | 49 | </item> |
|
50 | 50 | <item row="1" column="1"> |
|
51 | 51 | <widget class="QLineEdit" name="PortLineEdit"> |
|
52 | 52 | <property name="toolTip"> |
|
53 | 53 | <string><html><head/><body><p>Set the port on which the server will listen and accept client connections.</p></body></html></string> |
|
54 | 54 | </property> |
|
55 | 55 | </widget> |
|
56 | 56 | </item> |
|
57 | 57 | <item row="2" column="1"> |
|
58 | 58 | <widget class="QPushButton" name="startServeQpb"> |
|
59 | 59 | <property name="text"> |
|
60 | 60 | <string>Start Server</string> |
|
61 | 61 | </property> |
|
62 | 62 | </widget> |
|
63 | 63 | </item> |
|
64 | 64 | </layout> |
|
65 | 65 | </widget> |
|
66 | 66 | </item> |
|
67 | 67 | <item> |
|
68 |
<widget class="QGroupBox" name=" |
|
|
68 | <widget class="QGroupBox" name="groupBox"> | |
|
69 | 69 | <property name="title"> |
|
70 |
<string> |
|
|
70 | <string>Server Statistics</string> | |
|
71 | 71 | </property> |
|
72 | <property name="flat"> | |
|
73 | <bool>false</bool> | |
|
74 | </property> | |
|
75 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
|
76 | <item> | |
|
77 | <widget class="QListWidget" name="listWidget"/> | |
|
72 | <layout class="QGridLayout" name="gridLayout"> | |
|
73 | <item row="2" column="0" colspan="2"> | |
|
74 | <widget class="QGroupBox" name="clientListGroupBox_2"> | |
|
75 | <property name="title"> | |
|
76 | <string>Connected clients</string> | |
|
77 | </property> | |
|
78 | <property name="flat"> | |
|
79 | <bool>false</bool> | |
|
80 | </property> | |
|
81 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
|
82 | <item> | |
|
83 | <widget class="QListWidget" name="listWidget"/> | |
|
84 | </item> | |
|
85 | </layout> | |
|
86 | </widget> | |
|
87 | </item> | |
|
88 | <item row="0" column="1"> | |
|
89 | <widget class="QLCDNumber" name="lcdNumber"/> | |
|
90 | </item> | |
|
91 | <item row="0" column="0"> | |
|
92 | <widget class="QLabel" name="label"> | |
|
93 | <property name="text"> | |
|
94 | <string>Sended Packets</string> | |
|
95 | </property> | |
|
96 | </widget> | |
|
97 | </item> | |
|
98 | <item row="1" column="0"> | |
|
99 | <widget class="QLabel" name="label_2"> | |
|
100 | <property name="text"> | |
|
101 | <string>Received Packets</string> | |
|
102 | </property> | |
|
103 | </widget> | |
|
104 | </item> | |
|
105 | <item row="1" column="1"> | |
|
106 | <widget class="QLCDNumber" name="lcdNumber_2"/> | |
|
78 | 107 | </item> |
|
79 | 108 | </layout> |
|
80 | 109 | </widget> |
|
81 | 110 | </item> |
|
82 | 111 | </layout> |
|
83 | 112 | </widget> |
|
84 | 113 | <resources/> |
|
85 | 114 | <connections/> |
|
86 | 115 | </ui> |
@@ -1,128 +1,116 | |||
|
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 | #ifndef STARDUNDEESPW_USB_H |
|
23 | 23 | #define STARDUNDEESPW_USB_H |
|
24 | 24 | |
|
25 | 25 | #include <QObject> |
|
26 | 26 | #include <spw_usb_api.h> |
|
27 | 27 | #include <spw_config_library.h> |
|
28 | 28 | #include <socexplorerplugin.h> |
|
29 | 29 | #include <abstractspwbridge.h> |
|
30 | 30 | #include <QThread> |
|
31 | 31 | #include <QMutex> |
|
32 | 32 | #include <QSemaphore> |
|
33 | 33 | #include <QGridLayout> |
|
34 | 34 | #include <QPushButton> |
|
35 | 35 | #include <QComboBox> |
|
36 | 36 | #include <QLabel> |
|
37 | 37 | #include "stardundeegui.h" |
|
38 | 38 | |
|
39 | class RMAP_Answer | |
|
40 | { | |
|
41 | public: | |
|
42 | RMAP_Answer(int ID,char* data,int len) | |
|
43 | { | |
|
44 | transactionID = ID; | |
|
45 | this->data = data; | |
|
46 | this->len = len; | |
|
47 | } | |
|
48 | int transactionID; | |
|
49 | char* data; | |
|
50 | int len; | |
|
51 | }; | |
|
39 | ||
|
52 | 40 | |
|
53 | 41 | class stardundeeSPW_USB_Manager: public QThread |
|
54 | 42 | { |
|
55 | 43 | Q_OBJECT |
|
56 | 44 | public: |
|
57 | 45 | explicit stardundeeSPW_USB_Manager(socexplorerplugin *plugin = 0,QObject* parent=0); |
|
58 | 46 | ~stardundeeSPW_USB_Manager(); |
|
59 | 47 | void run(); |
|
60 | 48 | bool connectBridge(); |
|
61 | 49 | bool disconnectBridge(); |
|
62 | 50 | int getRMAPtransactionID(); |
|
63 | 51 | int getRMAPanswer(int transactionID,char** buffer); |
|
64 | 52 | bool sendPacket(char* packet,int size); |
|
65 | 53 | |
|
66 | 54 | signals: |
|
67 | 55 | void updateAvailableBrickCount(int count); |
|
68 | 56 | void emitPacket(char* packet,int size); |
|
69 | 57 | private: |
|
70 | 58 | QMutex* handleMutex,*RMAP_AnswersMtx,*RMAP_pending_transaction_IDsMtx; |
|
71 | 59 | QSemaphore* RMAP_AnswersSem; |
|
72 | 60 | void pushRmapPacket(char* packet,int len); |
|
73 | 61 | star_device_handle hDevice; |
|
74 | 62 | socexplorerplugin* plugin; |
|
75 | 63 | bool connected; |
|
76 | 64 | char* SPWPacketBuff; |
|
77 | 65 | QList<RMAP_Answer*> RMAP_Answers; |
|
78 | 66 | QList<int> RMAP_pending_transaction_IDs; |
|
79 | 67 | |
|
80 | 68 | public: |
|
81 | 69 | int selectedBrick; |
|
82 | 70 | int linkNumber; |
|
83 | 71 | int brickList; |
|
84 | 72 | int linkSpeed; |
|
85 | 73 | int destinationKey; |
|
86 | 74 | int rmapAddress; |
|
87 | 75 | int rmapKey; |
|
88 | 76 | int RMAPtimeout; |
|
89 | 77 | }; |
|
90 | 78 | |
|
91 | 79 | class stardundeeSPW_USB : public abstractSpwBridge |
|
92 | 80 | { |
|
93 | 81 | Q_OBJECT |
|
94 | 82 | public: |
|
95 | 83 | explicit stardundeeSPW_USB(socexplorerplugin *parent = 0); |
|
96 | 84 | ~stardundeeSPW_USB(); |
|
97 | 85 | |
|
98 | 86 | signals: |
|
99 | 87 | |
|
100 | 88 | void setRmapTimeout(const QString & timeout); |
|
101 | 89 | void SelectBrick(int brickIndex); |
|
102 | 90 | void SelectLinkNumber(int linkIndex); |
|
103 | 91 | void SelectLinkSpeed(int linkSpeed); |
|
104 | 92 | void SetDestinationKey(const QString & destKey); |
|
105 | 93 | void SetRmapAddress(const QString & address); |
|
106 | 94 | void SetRmapKey(const QString & key); |
|
107 | 95 | void SetRmapTimeout(const QString & timeout); |
|
108 | 96 | |
|
109 | 97 | public slots: |
|
110 | 98 | void toggleBridgeConnection(); |
|
111 | 99 | bool connectBridge(); |
|
112 | 100 | bool disconnectBridge(); |
|
113 | 101 | int pushRMAPPacket(char* packet,int size); |
|
114 | 102 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
115 | 103 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
116 | 104 | void brickSelectionChanged(int brickIndex); |
|
117 | 105 | void linkNumberSelectionChanged(int linkIndex); |
|
118 | 106 | void linkSpeedSelectionChanged(const QString & linkSpeed); |
|
119 | 107 | void destinationKeyChanged(const QString & destKey); |
|
120 | 108 | void rmapAddressChanged(const QString & rmapaddress); |
|
121 | 109 | void rmapKeyChanged(const QString & key); |
|
122 | 110 | void rmapTimeoutChanged(const QString & timeout); |
|
123 | 111 | private: |
|
124 | 112 | void makeGUI(socexplorerplugin *parent); |
|
125 | 113 | stardundeeSPW_USB_Manager* manager; |
|
126 | 114 | }; |
|
127 | 115 | |
|
128 | 116 | #endif // STARDUNDEESPW_USB_H |
@@ -1,54 +1,68 | |||
|
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 | #ifndef ABSTRACTSPWBRIDGE_H |
|
23 | 23 | #define ABSTRACTSPWBRIDGE_H |
|
24 | 24 | |
|
25 | 25 | #include <QObject> |
|
26 | 26 | #include <socexplorerplugin.h> |
|
27 | 27 | #define RMAP_MAX_XFER_SIZE 4000 //slightly less than 16kBytes |
|
28 | 28 | #include <spw.h> |
|
29 | 29 | |
|
30 | class RMAP_Answer | |
|
31 | { | |
|
32 | public: | |
|
33 | RMAP_Answer(int ID,char* data,int len) | |
|
34 | { | |
|
35 | transactionID = ID; | |
|
36 | this->data = data; | |
|
37 | this->len = len; | |
|
38 | } | |
|
39 | int transactionID; | |
|
40 | char* data; | |
|
41 | int len; | |
|
42 | }; | |
|
43 | ||
|
30 | 44 | class abstractSpwBridge : public QObject |
|
31 | 45 | { |
|
32 | 46 | Q_OBJECT |
|
33 | 47 | public: |
|
34 | 48 | explicit abstractSpwBridge(socexplorerplugin *parent); |
|
35 | 49 | ~abstractSpwBridge(); |
|
36 | 50 | QWidget *getGUI(); |
|
37 | 51 | |
|
38 | 52 | public slots: |
|
39 | 53 | virtual bool connectBridge(); |
|
40 | 54 | virtual bool disconnectBridge(); |
|
41 | 55 | virtual unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
42 | 56 | virtual unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0)=0; |
|
43 | 57 | virtual int pushRMAPPacket(char* packet,int size)=0; |
|
44 | 58 | signals: |
|
45 | 59 | void setConnected(bool connected); |
|
46 | 60 | void pushPacketOverTCP(char* packet,int size); |
|
47 | 61 | protected: |
|
48 | 62 | socexplorerplugin* plugin; |
|
49 | 63 | QWidget* p_GUI; |
|
50 | 64 | private: |
|
51 | 65 | |
|
52 | 66 | }; |
|
53 | 67 | |
|
54 | 68 | #endif // ABSTRACTSPWBRIDGE_H |
@@ -1,165 +1,166 | |||
|
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 "gr_esb_bridge.h" |
|
26 | 26 | #include <socexplorerproxy.h> |
|
27 | 27 | #include "spwpywrapper.h" |
|
28 | 28 | |
|
29 | ||
|
29 | 30 | spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false) |
|
30 | 31 | { |
|
31 | 32 | Q_UNUSED(parent) |
|
32 | 33 | this->bridge = NULL; |
|
33 | 34 | this->scanDone = false; |
|
34 | 35 | this->pyObject = new spwPyWrapper(this); |
|
35 | 36 | this->tcpServer = new SpwTcpPacketServer(this); |
|
36 | 37 | this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); |
|
37 | 38 | this->bridgeSelector = new QComboBox(this); |
|
38 | 39 | this->mainTabWidgt = new QTabWidget(this); |
|
39 | 40 | this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration"); |
|
40 | 41 | this->mainTabWidgt->addTab(this->tcpServer,"TCP Server"); |
|
41 | 42 | this->mainLayout = new QGridLayout(this->mainGroupBox); |
|
42 | 43 | this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); |
|
43 | 44 | this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); |
|
44 | 45 | this->setWidget(this->mainTabWidgt); |
|
45 | 46 | this->bridgeSelector->addItem("none"); |
|
46 | 47 | this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); |
|
47 | 48 | this->bridgeSelector->addItem("GR-ESB"); |
|
48 | 49 | connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); |
|
49 | 50 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString))); |
|
50 | 51 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer())); |
|
51 | 52 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer())); |
|
52 | 53 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32))); |
|
53 | 54 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(QString))); |
|
54 | 55 | } |
|
55 | 56 | |
|
56 | 57 | |
|
57 | 58 | spwplugin::~spwplugin() |
|
58 | 59 | { |
|
59 | 60 | |
|
60 | 61 | } |
|
61 | 62 | |
|
62 | 63 | |
|
63 | 64 | |
|
64 | 65 | unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) |
|
65 | 66 | { |
|
66 | 67 | if(Connected) |
|
67 | 68 | { |
|
68 | 69 | return bridge->Read(Value,count,address); |
|
69 | 70 | } |
|
70 | 71 | return 0; |
|
71 | 72 | } |
|
72 | 73 | |
|
73 | 74 | void spwplugin::bridgeSelectionChanged(const QString &text) |
|
74 | 75 | { |
|
75 | 76 | printf("test"); |
|
76 | 77 | if(text=="none") |
|
77 | 78 | { |
|
78 | 79 | if(this->bridge!=NULL) |
|
79 | 80 | { |
|
80 | 81 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
81 | 82 | this->disconnect(this,SLOT(setConnected(bool))); |
|
82 | 83 | delete this->bridge; |
|
83 | 84 | this->bridge= NULL; |
|
84 | 85 | } |
|
85 | 86 | } |
|
86 | 87 | if(text=="STAR-Dundee Spw USB Brick") |
|
87 | 88 | { |
|
88 | 89 | if(this->bridge!=NULL) |
|
89 | 90 | { |
|
90 | 91 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
91 | 92 | this->disconnect(this,SLOT(setConnected(bool))); |
|
92 | 93 | delete this->bridge; |
|
93 | 94 | } |
|
94 | 95 | this->bridge = new stardundeeSPW_USB(this); |
|
95 | 96 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
96 | 97 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
97 | 98 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int))); |
|
98 | 99 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int))); |
|
99 | 100 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int))); |
|
100 | 101 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString))); |
|
101 | 102 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapAddress(QString))); |
|
102 | 103 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapKey(QString))); |
|
103 | 104 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString))); |
|
104 | 105 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge())); |
|
105 | 106 | connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge())); |
|
106 | 107 | connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int))); |
|
107 | 108 | } |
|
108 | 109 | if(text=="GR-ESB") |
|
109 | 110 | { |
|
110 | 111 | if(this->bridge!=NULL) |
|
111 | 112 | { |
|
112 | 113 | this->mainLayout->removeWidget(this->bridge->getGUI()); |
|
113 | 114 | this->disconnect(this,SLOT(setConnected(bool))); |
|
114 | 115 | delete this->bridge; |
|
115 | 116 | } |
|
116 | 117 | this->bridge = new GR_ESB_bridge(this); |
|
117 | 118 | this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); |
|
118 | 119 | connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); |
|
119 | 120 | } |
|
120 | 121 | } |
|
121 | 122 | |
|
122 | 123 | |
|
123 | 124 | void spwplugin::selectBridge(const QString &text) |
|
124 | 125 | { |
|
125 | 126 | |
|
126 | 127 | if(text=="none") |
|
127 | 128 | { |
|
128 | 129 | this->bridgeSelector->setCurrentIndex(0); |
|
129 | 130 | } |
|
130 | 131 | if(text=="STAR-Dundee Spw USB Brick") |
|
131 | 132 | { |
|
132 | 133 | this->bridgeSelector->setCurrentIndex(1); |
|
133 | 134 | } |
|
134 | 135 | } |
|
135 | 136 | |
|
136 | 137 | void spwplugin::setConnected(bool connected) |
|
137 | 138 | { |
|
138 | 139 | this->bridgeSelector->setDisabled(connected); |
|
139 | 140 | this->Connected = connected; |
|
140 | 141 | emit activateSig(connected); |
|
141 | 142 | if(!this->scanDone) |
|
142 | 143 | { |
|
143 | 144 | socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN"); |
|
144 | 145 | this->scanDone=true; |
|
145 | 146 | } |
|
146 | 147 | } |
|
147 | 148 | |
|
148 | 149 | |
|
149 | 150 | |
|
150 | 151 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) |
|
151 | 152 | { |
|
152 | 153 | if(Connected) |
|
153 | 154 | { |
|
154 | 155 | return bridge->Write(Value,count,address); |
|
155 | 156 | } |
|
156 | 157 | return 0; |
|
157 | 158 | } |
|
158 | 159 | |
|
159 | 160 | |
|
160 | 161 | |
|
161 | 162 | |
|
162 | 163 | |
|
163 | 164 | |
|
164 | 165 | |
|
165 | 166 |
@@ -1,76 +1,79 | |||
|
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 | #ifndef spwplugin_H |
|
23 | 23 | #define spwplugin_H |
|
24 | 24 | #include <QMenuBar> |
|
25 | 25 | #include <QMenu> |
|
26 | 26 | #include <QAction> |
|
27 | 27 | #include <QLayout> |
|
28 | 28 | #include <QGroupBox> |
|
29 | 29 | #include <QComboBox> |
|
30 | 30 | #include <QLabel> |
|
31 | 31 | #include <QTabWidget> |
|
32 | 32 | |
|
33 | 33 | #include <abstractspwbridge.h> |
|
34 | 34 | #include <socexplorerplugin.h> |
|
35 | 35 | |
|
36 | 36 | #include "SpwTcpPacketServer/spwtcppacketserver.h" |
|
37 | 37 | |
|
38 | // TODO switch to a class factory approach with self registration | |
|
39 | ||
|
38 | 40 | class spwplugin : public socexplorerplugin |
|
39 | 41 | { |
|
40 | 42 | Q_OBJECT |
|
41 | 43 | public: |
|
42 | 44 | explicit spwplugin(QWidget *parent = 0); |
|
43 | 45 | ~spwplugin(); |
|
44 | 46 | /* You can implement the folowing function if you want to overwrite |
|
45 | 47 | * their default behavior |
|
46 | 48 | */ |
|
47 | 49 | /* |
|
48 | 50 | int registermenu(QMainWindow *menuHolder); |
|
49 | 51 | int isConnected(); |
|
50 | 52 | int connect(); |
|
51 | 53 | int VID(){return driver_VID;} |
|
52 | 54 | int PID(){return driver_PID;} |
|
53 | 55 | */ |
|
54 | 56 | |
|
55 | 57 | public slots: |
|
56 | 58 | unsigned int Write(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
57 | 59 | unsigned int Read(unsigned int *Value,unsigned int count, unsigned int address=0); |
|
58 | 60 | |
|
59 | 61 | void bridgeSelectionChanged( const QString & text ); |
|
60 | 62 | void selectBridge( const QString & text ); |
|
61 | 63 | void setConnected(bool connected); |
|
62 | 64 | |
|
63 | 65 | signals: |
|
64 | 66 | |
|
65 | 67 | private: |
|
66 | 68 | SpwTcpPacketServer* tcpServer; |
|
67 | 69 | abstractSpwBridge* bridge; |
|
68 | 70 | bool scanDone; |
|
69 | 71 | QTabWidget* mainTabWidgt; |
|
70 | 72 | QGroupBox* mainGroupBox; |
|
71 | 73 | QComboBox* bridgeSelector; |
|
72 | 74 | QGridLayout* mainLayout; |
|
75 | ||
|
73 | 76 | }; |
|
74 | 77 | |
|
75 | 78 | #endif // spwplugin_H |
|
76 | 79 |
General Comments 0
You need to be logged in to leave comments.
Login now