@@ -1,231 +1,232 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "socexplorerengine.h" |
|
22 | #include "socexplorerengine.h" | |
23 | #include <proxy/socexplorerproxy.h> |
|
23 | #include <proxy/socexplorerproxy.h> | |
24 |
|
24 | |||
25 | SocExplorerEngine* SocExplorerEngine::_self = NULL; |
|
25 | SocExplorerEngine* SocExplorerEngine::_self = NULL; | |
26 | socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL; |
|
26 | socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL; | |
27 | QMainWindow* SocExplorerEngine::mainWindow=NULL; |
|
27 | QMainWindow* SocExplorerEngine::mainWindow=NULL; | |
28 | QList<SOCModel*>* SocExplorerEngine::SOCs=NULL; |
|
28 | QList<SOCModel*>* SocExplorerEngine::SOCs=NULL; | |
29 | int SocExplorerEngine::loglvl=1; |
|
29 | int SocExplorerEngine::loglvl=1; | |
30 |
|
30 | |||
31 | SocExplorerEngine::SocExplorerEngine(QObject *parent) : |
|
31 | SocExplorerEngine::SocExplorerEngine(QObject *parent) : | |
32 | QObject(parent) |
|
32 | QObject(parent) | |
33 | { |
|
33 | { | |
34 | if(SOCs==NULL) |
|
34 | if(SOCs==NULL) | |
35 | { |
|
35 | { | |
36 | SOCs = new QList<SOCModel*>; |
|
36 | SOCs = new QList<SOCModel*>; | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 |
|
41 | |||
42 | void SocExplorerEngine::init() |
|
42 | void SocExplorerEngine::init() | |
43 | { |
|
43 | { | |
44 | QDir dir; |
|
44 | QDir dir; | |
45 | if(!_self) |
|
45 | if(!_self) | |
46 | { |
|
46 | { | |
47 | _self= new SocExplorerEngine; |
|
47 | _self= new SocExplorerEngine; | |
48 | } |
|
48 | } | |
49 | if(!dir.exists(configFolder())) |
|
49 | if(!dir.exists(configFolder())) | |
50 | dir.mkdir(configFolder()); |
|
50 | dir.mkdir(configFolder()); | |
51 | p_xmlmodel = new socExplorerXmlModel(_self); |
|
51 | p_xmlmodel = new socExplorerXmlModel(_self); | |
52 | p_xmlmodel->updateSOClist(); |
|
52 | p_xmlmodel->updateSOClist(); | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 | QString SocExplorerEngine::configFolder() |
|
55 | QString SocExplorerEngine::configFolder() | |
56 | { |
|
56 | { | |
57 | return QString(SOCEXPLORER_CONFIG_PATH); |
|
57 | return QString(SOCEXPLORER_CONFIG_PATH); | |
58 | } |
|
58 | } | |
59 |
|
59 | |||
60 | SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) |
|
60 | SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) | |
61 | { |
|
61 | { | |
62 | if(!_self) |
|
62 | if(!_self) | |
63 | init(); |
|
63 | init(); | |
64 | if(plugin) |
|
64 | if(plugin) | |
65 | { |
|
65 | { | |
66 | while (plugin->parent!=NULL) { |
|
66 | while (plugin->parent!=NULL) { | |
67 | plugin = plugin->parent; |
|
67 | plugin = plugin->parent; | |
68 | } |
|
68 | } | |
69 | for(int i=0;i<SOCs->count();i++) |
|
69 | for(int i=0;i<SOCs->count();i++) | |
70 | { |
|
70 | { | |
71 | if(SOCs->at(i)->isRootDev(plugin)) |
|
71 | if(SOCs->at(i)->isRootDev(plugin)) | |
72 | return SOCs->at(i); |
|
72 | return SOCs->at(i); | |
73 | } |
|
73 | } | |
74 | //no soc found so create a new one |
|
74 | //no soc found so create a new one | |
75 | SOCModel* soc=new SOCModel(plugin); |
|
75 | SOCModel* soc=new SOCModel(plugin); | |
76 | SOCs->append(soc); |
|
76 | SOCs->append(soc); | |
77 | return soc; |
|
77 | return soc; | |
78 | } |
|
78 | } | |
79 | return NULL; |
|
79 | return NULL; | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name) |
|
83 | int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name) | |
84 | { |
|
84 | { | |
85 | if(!_self) |
|
85 | if(!_self) | |
86 | init(); |
|
86 | init(); | |
87 | SOCModel* soc = plugin2Soc(rootPlugin); |
|
87 | SOCModel* soc = plugin2Soc(rootPlugin); | |
88 | if(soc && !soc->enumDeviceExists(baseAddress)) |
|
88 | if(soc && !soc->enumDeviceExists(baseAddress)) | |
89 | { |
|
89 | { | |
90 | emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name)); |
|
90 | emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name)); | |
91 | return 1; |
|
91 | return 1; | |
92 | } |
|
92 | } | |
93 | return 0; |
|
93 | return 0; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | QList<SOCModel *> *SocExplorerEngine::getSOCs() |
|
96 | QList<SOCModel *> *SocExplorerEngine::getSOCs() | |
97 | { |
|
97 | { | |
98 | if(!_self) |
|
98 | if(!_self) | |
99 | init(); |
|
99 | init(); | |
100 | return SOCs; |
|
100 | return SOCs; | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count) |
|
103 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count) | |
104 | { |
|
104 | { | |
105 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
105 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); | |
106 | if(plugin==NULL)return -1; |
|
106 | if(plugin==NULL)return -1; | |
107 | SOCModel* soc = plugin2Soc(plugin); |
|
107 | SOCModel* soc = plugin2Soc(plugin); | |
108 | if(soc==NULL) |
|
108 | if(soc==NULL) | |
109 | return -1; |
|
109 | return -1; | |
110 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
110 | return soc->getEnumDeviceBaseAddress(VID,PID,count); | |
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count) |
|
113 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count) | |
114 | { |
|
114 | { | |
115 | if(plugin==NULL)return -1; |
|
115 | if(plugin==NULL)return -1; | |
116 | SOCModel* soc = plugin2Soc(plugin); |
|
116 | SOCModel* soc = plugin2Soc(plugin); | |
117 | if(soc==NULL) |
|
117 | if(soc==NULL) | |
118 | return -1; |
|
118 | return -1; | |
119 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
119 | return soc->getEnumDeviceBaseAddress(VID,PID,count); | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name) |
|
122 | int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name) | |
123 | { |
|
123 | { | |
124 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
124 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); | |
125 | if(plugin==NULL)return -1; |
|
125 | if(plugin==NULL)return -1; | |
126 | SOCModel* soc = plugin2Soc(plugin); |
|
126 | SOCModel* soc = plugin2Soc(plugin); | |
127 | if(soc==NULL) |
|
127 | if(soc==NULL) | |
128 | return -1; |
|
128 | return -1; | |
129 | soc->addEnumDevice(VID,PID,baseAddress,name); |
|
129 | soc->addEnumDevice(VID,PID,baseAddress,name); | |
130 | return 1; |
|
130 | return 1; | |
131 | } |
|
131 | } | |
132 |
|
132 | |||
133 |
|
133 | |||
134 | QString SocExplorerEngine::getDevName(int VID, int PID) |
|
134 | QString SocExplorerEngine::getDevName(int VID, int PID) | |
135 | { |
|
135 | { | |
136 | QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral"); |
|
136 | QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral"); | |
137 | for(int i=0;i<list.count();i++) |
|
137 | for(int i=0;i<list.count();i++) | |
138 | { |
|
138 | { | |
139 | QDomNodeList nodes=list.at(i); |
|
139 | QDomNodeList nodes=list.at(i); | |
140 | for(int l=0;l<nodes.count();l++) |
|
140 | for(int l=0;l<nodes.count();l++) | |
141 | { |
|
141 | { | |
142 | QDomElement node=nodes.at(l).toElement(); |
|
142 | QDomElement node=nodes.at(l).toElement(); | |
143 | int nodeVID=node.attribute("vid","0").toInt(); |
|
143 | int nodeVID=node.attribute("vid","0").toInt(); | |
144 | int nodePID=node.attribute("pid","0").toInt(); |
|
144 | int nodePID=node.attribute("pid","0").toInt(); | |
145 | if((nodeVID==VID)&&(nodePID==PID)) |
|
145 | if((nodeVID==VID)&&(nodePID==PID)) | |
146 | { |
|
146 | { | |
147 | return node.attribute("name","Unknow device"); |
|
147 | return node.attribute("name","Unknow device"); | |
148 | } |
|
148 | } | |
149 | } |
|
149 | } | |
150 | } |
|
150 | } | |
151 | return QString("Unknow device"); |
|
151 | return QString("Unknow device"); | |
152 | } |
|
152 | } | |
153 |
|
153 | |||
154 | QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);} |
|
154 | QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);} | |
155 |
|
155 | |||
156 | QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);} |
|
156 | QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);} | |
157 |
|
157 | |||
158 | QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);} |
|
158 | QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);} | |
159 |
|
159 | |||
160 | socExplorerXmlModel *SocExplorerEngine::xmlModel() |
|
160 | socExplorerXmlModel *SocExplorerEngine::xmlModel() | |
161 | { |
|
161 | { | |
162 | if(!_self) |
|
162 | if(!_self) | |
163 | init(); |
|
163 | init(); | |
164 | return p_xmlmodel; |
|
164 | return p_xmlmodel; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow) |
|
167 | void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow) | |
168 | { |
|
168 | { | |
169 | if(!_self) |
|
169 | if(!_self) | |
170 | init(); |
|
170 | init(); | |
171 | mainWindow=Mainwindow; |
|
171 | mainWindow=Mainwindow; | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max) |
|
174 | QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max) | |
175 | { |
|
175 | { | |
176 | if(!_self) |
|
176 | if(!_self) | |
177 | init(); |
|
177 | init(); | |
178 | QProgressBar* progressBar; |
|
178 | QProgressBar* progressBar; | |
179 | if(mainWindow!=NULL) |
|
179 | if(mainWindow!=NULL) | |
180 | { |
|
180 | { | |
181 | progressBar = new QProgressBar(mainWindow); |
|
181 | progressBar = new QProgressBar(mainWindow); | |
182 | mainWindow->statusBar()->addWidget(progressBar); |
|
182 | mainWindow->statusBar()->addWidget(progressBar); | |
183 | } |
|
183 | } | |
184 | else |
|
184 | else | |
185 | { |
|
185 | { | |
186 | progressBar = new QProgressBar(); |
|
186 | progressBar = new QProgressBar(); | |
187 | } |
|
187 | } | |
188 | progressBar->setMaximum(max); |
|
188 | progressBar->setMaximum(max); | |
189 | progressBar->setFormat(format); |
|
189 | progressBar->setFormat(format); | |
190 | return progressBar; |
|
190 | return progressBar; | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar) |
|
193 | void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar) | |
194 | { |
|
194 | { | |
195 | if(mainWindow!=NULL) |
|
195 | if(mainWindow!=NULL) | |
196 | { |
|
196 | { | |
197 | mainWindow->statusBar()->removeWidget(progressBar); |
|
197 | mainWindow->statusBar()->removeWidget(progressBar); | |
198 | } |
|
198 | } | |
199 | delete progressBar; |
|
199 | delete progressBar; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin) |
|
202 | void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin) | |
203 | { |
|
203 | { | |
204 | plugin2Soc(rootPlugin); |
|
204 | plugin2Soc(rootPlugin); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin) |
|
207 | void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin) | |
208 | { |
|
208 | { | |
209 | SOCModel* soc=plugin2Soc(rootPlugin); |
|
209 | SOCModel* soc=plugin2Soc(rootPlugin); | |
210 | SOCs->removeAll(soc); |
|
210 | SOCs->removeAll(soc); | |
211 | delete soc; |
|
211 | delete soc; | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel) |
|
214 | void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel) | |
215 | { |
|
215 | { | |
216 | // TODO add multi output message manager IE also log in files |
|
216 | // TODO add multi output message manager IE also log in files | |
217 | if(!_self) |
|
217 | if(!_self) | |
218 | init(); |
|
218 | init(); | |
219 | if(loglvl>=debugLevel) |
|
219 | if(loglvl>=debugLevel) | |
220 | qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message; |
|
220 | qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message; | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | void SocExplorerEngine::setLogLevel(int level) |
|
223 | void SocExplorerEngine::setLogLevel(int level) | |
224 | { |
|
224 | { | |
225 | if(!_self) |
|
225 | if(!_self) | |
226 | init(); |
|
226 | init(); | |
|
227 | printf("Set log level to %d\n",level); | |||
227 | loglvl = level; |
|
228 | loglvl = level; | |
228 | } |
|
229 | } | |
229 |
|
230 | |||
230 |
|
231 | |||
231 |
|
232 |
@@ -1,109 +1,134 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #ifndef SOCEXPLORERENGINE_H |
|
22 | #ifndef SOCEXPLORERENGINE_H | |
23 | #define SOCEXPLORERENGINE_H |
|
23 | #define SOCEXPLORERENGINE_H | |
24 |
|
24 | |||
25 | #include <stdint.h> |
|
25 | #include <stdint.h> | |
26 | #include <QObject> |
|
26 | #include <QObject> | |
27 | #include <QtWidgets> |
|
27 | #include <QtWidgets> | |
28 | #include <QStringList> |
|
28 | #include <QStringList> | |
29 | #include <QDomDocument> |
|
29 | #include <QDomDocument> | |
30 | #include <QDomElement> |
|
30 | #include <QDomElement> | |
31 | #include <QDomNodeList> |
|
31 | #include <QDomNodeList> | |
32 | #include <QFile> |
|
32 | #include <QFile> | |
33 | #include <QTextStream> |
|
33 | #include <QTextStream> | |
34 | #include <QDir> |
|
34 | #include <QDir> | |
35 | #include <QApplication> |
|
35 | #include <QApplication> | |
36 | #include <QtCore/qglobal.h> |
|
36 | #include <QtCore/qglobal.h> | |
37 | #include <QFileDialog> |
|
37 | #include <QFileDialog> | |
38 | #include <socexplorerxmlfile.h> |
|
38 | #include <socexplorerxmlfile.h> | |
39 | #include <socexplorerenumdevice.h> |
|
39 | #include <socexplorerenumdevice.h> | |
40 | #include <XMLmodel.h> |
|
40 | #include <XMLmodel.h> | |
41 | #include <peripheralwidget.h> |
|
41 | #include <peripheralwidget.h> | |
42 | #include <registerwidget.h> |
|
42 | #include <registerwidget.h> | |
43 | #include <socmodel.h> |
|
43 | #include <socmodel.h> | |
44 |
|
44 | |||
45 | #if defined(SOCEXPLORER_SDK_BUILD) |
|
45 | #if defined(SOCEXPLORER_SDK_BUILD) | |
46 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT |
|
46 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT | |
47 | #else |
|
47 | #else | |
48 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT |
|
48 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT | |
49 | #endif |
|
49 | #endif | |
50 |
|
50 | |||
51 |
|
51 | |||
|
52 | class SOCEXPLORER_SDK_EXPORT SocExplorerAutoProgressBar | |||
|
53 | { | |||
|
54 | public: | |||
|
55 | SocExplorerAutoProgressBar(QProgressBar* progressBar=NULL) | |||
|
56 | { | |||
|
57 | this->p_progressbar=progressBar; | |||
|
58 | } | |||
|
59 | ~SocExplorerAutoProgressBar() | |||
|
60 | { | |||
|
61 | if(p_progressbar) | |||
|
62 | { | |||
|
63 | delete p_progressbar; | |||
|
64 | } | |||
|
65 | } | |||
|
66 | void setProgressBar(QProgressBar* progressBar) | |||
|
67 | { | |||
|
68 | this->p_progressbar=progressBar; | |||
|
69 | } | |||
|
70 | void setValue(int value) | |||
|
71 | { | |||
|
72 | p_progressbar->setValue(value); | |||
|
73 | } | |||
|
74 | private: | |||
|
75 | QProgressBar* p_progressbar; | |||
|
76 | }; | |||
52 |
|
77 | |||
53 | //! SocExplorerEngine is a pure static class which aims to provide services for both SocExplorer software and plugins. |
|
78 | //! SocExplorerEngine is a pure static class which aims to provide services for both SocExplorer software and plugins. | |
54 |
|
79 | |||
55 | class SOCEXPLORER_SDK_EXPORT SocExplorerEngine : public QObject |
|
80 | class SOCEXPLORER_SDK_EXPORT SocExplorerEngine : public QObject | |
56 | { |
|
81 | { | |
57 | Q_OBJECT |
|
82 | Q_OBJECT | |
58 | private: |
|
83 | private: | |
59 | static SocExplorerEngine* _self; |
|
84 | static SocExplorerEngine* _self; | |
60 | SocExplorerEngine(QObject *parent = 0); |
|
85 | SocExplorerEngine(QObject *parent = 0); | |
61 | static void init(); |
|
86 | static void init(); | |
62 |
|
87 | |||
63 | public: |
|
88 | public: | |
64 | static SocExplorerEngine* self(){ if(!_self){_self= new SocExplorerEngine;}return _self;} |
|
89 | static SocExplorerEngine* self(){ if(!_self){_self= new SocExplorerEngine;}return _self;} | |
65 | //! Return the configuration folder path, OS dependant. |
|
90 | //! Return the configuration folder path, OS dependant. | |
66 | SOCEXPLORER_SDK_EXPORT static QString configFolder(); |
|
91 | SOCEXPLORER_SDK_EXPORT static QString configFolder(); | |
67 | //! Return the default plugin folder path, OS dependant. |
|
92 | //! Return the default plugin folder path, OS dependant. | |
68 | static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);} |
|
93 | static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);} | |
69 |
|
94 | |||
70 | static int addEnumDevice(socexplorerplugin* rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); |
|
95 | static int addEnumDevice(socexplorerplugin* rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); | |
71 | static QList<SOCModel*>* getSOCs(); |
|
96 | static QList<SOCModel*>* getSOCs(); | |
72 | static QString getDevName(int VID, int PID); |
|
97 | static QString getDevName(int VID, int PID); | |
73 | static QString SocExplorerVersion(); |
|
98 | static QString SocExplorerVersion(); | |
74 | static QString SocExplorerChangeset(); |
|
99 | static QString SocExplorerChangeset(); | |
75 | static QString SocExplorerBranch(); |
|
100 | static QString SocExplorerBranch(); | |
76 | static socExplorerXmlModel* xmlModel(); |
|
101 | static socExplorerXmlModel* xmlModel(); | |
77 | static void setMainWindow(QMainWindow* Mainwindow); |
|
102 | static void setMainWindow(QMainWindow* Mainwindow); | |
78 | static QProgressBar* getProgressBar(const QString &format, int max); |
|
103 | static QProgressBar* getProgressBar(const QString &format, int max); | |
79 | static void deleteProgressBar(QProgressBar* progressBar); |
|
104 | static void deleteProgressBar(QProgressBar* progressBar); | |
80 | static void addSOC(socexplorerplugin* rootPlugin); |
|
105 | static void addSOC(socexplorerplugin* rootPlugin); | |
81 | static void removeSOC(socexplorerplugin* rootPlugin); |
|
106 | static void removeSOC(socexplorerplugin* rootPlugin); | |
82 | static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0); |
|
107 | static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0); | |
83 | static void setLogLevel(int level); |
|
108 | static void setLogLevel(int level); | |
84 | signals: |
|
109 | signals: | |
85 | void enumDeviceAdded(socExplorerEnumDevice* device); |
|
110 | void enumDeviceAdded(socExplorerEnumDevice* device); | |
86 | public slots: |
|
111 | public slots: | |
87 | QString getSocExplorerVersion(){return SocExplorerEngine::SocExplorerVersion();} |
|
112 | QString getSocExplorerVersion(){return SocExplorerEngine::SocExplorerVersion();} | |
88 | QString getSocExplorerChangeset(){return SocExplorerEngine::SocExplorerChangeset();} |
|
113 | QString getSocExplorerChangeset(){return SocExplorerEngine::SocExplorerChangeset();} | |
89 | QString getSocExplorerBranch(){return SocExplorerEngine::SocExplorerBranch();} |
|
114 | QString getSocExplorerBranch(){return SocExplorerEngine::SocExplorerBranch();} | |
90 | qint32 getEnumDeviceBaseAddress(const QString& rootPlugin,int VID,int PID,int count=0); |
|
115 | qint32 getEnumDeviceBaseAddress(const QString& rootPlugin,int VID,int PID,int count=0); | |
91 | qint32 getEnumDeviceBaseAddress(socexplorerplugin* plugin,int VID,int PID,int count=0); |
|
116 | qint32 getEnumDeviceBaseAddress(socexplorerplugin* plugin,int VID,int PID,int count=0); | |
92 | int addEnumDevice(const QString& rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); |
|
117 | int addEnumDevice(const QString& rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); | |
93 |
|
118 | |||
94 | private: |
|
119 | private: | |
95 | static SOCModel* plugin2Soc(socexplorerplugin* plugin); |
|
120 | static SOCModel* plugin2Soc(socexplorerplugin* plugin); | |
96 | static socExplorerXmlModel* p_xmlmodel; |
|
121 | static socExplorerXmlModel* p_xmlmodel; | |
97 | static QMainWindow* mainWindow; |
|
122 | static QMainWindow* mainWindow; | |
98 | static QList<SOCModel*>* SOCs; |
|
123 | static QList<SOCModel*>* SOCs; | |
99 | static int loglvl; |
|
124 | static int loglvl; | |
100 | }; |
|
125 | }; | |
101 |
|
126 | |||
102 | #endif // SOCEXPLORERENGINE_H |
|
127 | #endif // SOCEXPLORERENGINE_H | |
103 |
|
128 | |||
104 |
|
129 | |||
105 |
|
130 | |||
106 |
|
131 | |||
107 |
|
132 | |||
108 |
|
133 | |||
109 |
|
134 |
@@ -1,69 +1,71 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SocExplorer Software |
|
2 | -- This file is a part of the SocExplorer Software | |
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr |
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include <QApplication> |
|
22 | #include <QApplication> | |
23 | #include "mainwindow.h" |
|
23 | #include "mainwindow.h" | |
24 | #include <PythonQt.h> |
|
24 | #include <PythonQt.h> | |
25 | #include <PythonQt_QtAll.h> |
|
25 | #include <PythonQt_QtAll.h> | |
26 | #include <gui/PythonQtScriptingConsole.h> |
|
26 | #include <gui/PythonQtScriptingConsole.h> | |
27 | #include <socexplorerplugin.h> |
|
27 | #include <socexplorerplugin.h> | |
28 | #include <QStyle> |
|
28 | #include <QStyle> | |
29 | #include <QStyleFactory> |
|
29 | #include <QStyleFactory> | |
30 | #include <QStringList> |
|
30 | #include <QStringList> | |
31 | #include <QFile> |
|
31 | #include <QFile> | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | int main(int argc, char *argv[]) |
|
34 | int main(int argc, char *argv[]) | |
35 | { |
|
35 | { | |
36 | // Q_INIT_RESOURCE(socexplorer); |
|
36 | // Q_INIT_RESOURCE(socexplorer); | |
37 | #ifdef Q_OS_LINUX |
|
37 | #ifdef Q_OS_LINUX | |
38 | // QApplication::setGraphicsSystem("raster"); |
|
38 | // QApplication::setGraphicsSystem("raster"); | |
39 | #endif |
|
39 | #endif | |
40 | QApplication a(argc, argv); |
|
40 | QApplication a(argc, argv); | |
41 | QString scriptToEval; |
|
41 | QString scriptToEval; | |
42 | QStringList args= a.arguments(); |
|
42 | QStringList args= a.arguments(); | |
43 | for(int i=0;i<args.count()-1;i++) |
|
43 | for(int i=0;i<args.count()-1;i++) | |
44 | { |
|
44 | { | |
45 | if((args.at(i).compare("-e")==0) || (args.at(i).compare("--execute")==0)) |
|
45 | if((args.at(i).compare("-e")==0) || (args.at(i).compare("--execute")==0)) | |
46 | { |
|
46 | { | |
47 | scriptToEval = args.at(i+1); |
|
47 | scriptToEval = args.at(i+1); | |
48 | if(!QFile::exists(scriptToEval)) |
|
48 | if(!QFile::exists(scriptToEval)) | |
49 | { |
|
49 | { | |
50 | scriptToEval.clear(); |
|
50 | scriptToEval.clear(); | |
51 | } |
|
51 | } | |
52 | else |
|
52 | else | |
53 | qDebug() << "Will execute" << scriptToEval; |
|
53 | qDebug() << "Will execute" << scriptToEval; | |
54 | break; |
|
54 | break; | |
55 | } |
|
55 | } | |
56 | if((args.at(i).compare("-d")==0) || (args.at(i).compare("--debug-level")==0)) |
|
56 | if((args.at(i).compare("-d")==0) || (args.at(i).compare("--debug-level")==0)) | |
57 | { |
|
57 | { | |
58 | bool success; |
|
58 | bool success; | |
59 | int lvl; |
|
59 | int lvl; | |
60 | lvl = args.at(i+1).toInt(&success,10); |
|
60 | lvl = args.at(i+1).toInt(&success,10); | |
61 | if(success) |
|
61 | if(success) | |
|
62 | { | |||
62 | SocExplorerEngine::setLogLevel(lvl); |
|
63 | SocExplorerEngine::setLogLevel(lvl); | |
|
64 | } | |||
63 | } |
|
65 | } | |
64 | } |
|
66 | } | |
65 |
|
67 | |||
66 | SocExplorerMainWindow w(scriptToEval); |
|
68 | SocExplorerMainWindow w(scriptToEval); | |
67 | w.show(); |
|
69 | w.show(); | |
68 | return a.exec(); |
|
70 | return a.exec(); | |
69 | } |
|
71 | } |
General Comments 0
You need to be logged in to leave comments.
Login now