@@ -1,99 +1,112 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 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 |
|
7 | 7 | -- the Free Software Foundation; either version 2 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@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "socmodel.h" |
|
23 | 23 | #include <socexplorerenumdevice.h> |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | SOCModel::SOCModel(socexplorerplugin *rootDev, QObject *parent): |
|
27 | 27 | QObject(parent) |
|
28 | 28 | { |
|
29 | 29 | p_rootDev = rootDev; |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | qint32 SOCModel::getEnumDeviceBaseAddress(int VID, int PID, int count) |
|
33 | 33 | { |
|
34 | 34 | for(int i=0;i<p_enumeratedDevices.count();i++) |
|
35 | 35 | { |
|
36 | 36 | if((p_enumeratedDevices.at(i)->VID()==VID) && (p_enumeratedDevices.at(i)->PID()==PID)) |
|
37 | 37 | { |
|
38 | 38 | if(count==0) |
|
39 | 39 | { |
|
40 | 40 | return p_enumeratedDevices.at(i)->baseAddress(); |
|
41 | 41 | } |
|
42 | 42 | count--; |
|
43 | 43 | } |
|
44 | 44 | } |
|
45 | 45 | return -1; |
|
46 | 46 | } |
|
47 | 47 | |
|
48 | qint32 SOCModel::getEnumDeviceCount(int VID, int PID) | |
|
49 | { | |
|
50 | qint32 count =0; | |
|
51 | for(int i=0;i<p_enumeratedDevices.count();i++) | |
|
52 | { | |
|
53 | if((p_enumeratedDevices.at(i)->VID()==VID) && (p_enumeratedDevices.at(i)->PID()==PID)) | |
|
54 | { | |
|
55 | count++; | |
|
56 | } | |
|
57 | } | |
|
58 | return count; | |
|
59 | } | |
|
60 | ||
|
48 | 61 | socExplorerEnumDevice *SOCModel::addEnumDevice( int VID, int PID, qint32 baseAddress, const QString &name) |
|
49 | 62 | { |
|
50 | 63 | if(enumDeviceExists(baseAddress)) |
|
51 | 64 | return getEnumDevice(baseAddress); |
|
52 | 65 | socExplorerEnumDevice* device= new socExplorerEnumDevice(this,VID,PID,baseAddress,name); |
|
53 | 66 | p_enumeratedDevices.append(device); |
|
54 | 67 | return device; |
|
55 | 68 | } |
|
56 | 69 | |
|
57 | 70 | int SOCModel::addEnumDevice(socExplorerEnumDevice *device) |
|
58 | 71 | { |
|
59 | 72 | if(enumDeviceExists(device->baseAddress())) |
|
60 | 73 | return 0; |
|
61 | 74 | p_enumeratedDevices.append(device); |
|
62 | 75 | return 1; |
|
63 | 76 | } |
|
64 | 77 | |
|
65 | 78 | |
|
66 | 79 | |
|
67 | 80 | bool SOCModel::enumDeviceExists(qint32 baseAddress) |
|
68 | 81 | { |
|
69 | 82 | for(int i=0;i<p_enumeratedDevices.count();i++) |
|
70 | 83 | { |
|
71 | 84 | if(p_enumeratedDevices.at(i)->baseAddress()==baseAddress) |
|
72 | 85 | return true; |
|
73 | 86 | } |
|
74 | 87 | return false; |
|
75 | 88 | } |
|
76 | 89 | |
|
77 | 90 | socExplorerEnumDevice *SOCModel::getEnumDevice(qint32 baseAddress) |
|
78 | 91 | { |
|
79 | 92 | for(int i=0;i<p_enumeratedDevices.count();i++) |
|
80 | 93 | { |
|
81 | 94 | if(p_enumeratedDevices.at(i)->baseAddress()==baseAddress) |
|
82 | 95 | return p_enumeratedDevices.at(i); |
|
83 | 96 | } |
|
84 | 97 | return NULL; |
|
85 | 98 | } |
|
86 | 99 | |
|
87 | 100 | |
|
88 | 101 | void SOCModel::writeReg(qint32 address, qint32 value) |
|
89 | 102 | { |
|
90 | 103 | uint valueInt=value,addressInt=address; |
|
91 | 104 | p_rootDev->Write(&valueInt,1,addressInt); |
|
92 | 105 | } |
|
93 | 106 | |
|
94 | 107 | qint32 SOCModel::readReg(qint32 address) |
|
95 | 108 | { |
|
96 | 109 | uint valueInt=0,addressInt=address; |
|
97 | 110 | p_rootDev->Read(&valueInt,1,addressInt); |
|
98 | 111 | return (qint32)valueInt; |
|
99 | 112 | } |
@@ -1,115 +1,116 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 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 |
|
7 | 7 | -- the Free Software Foundation; either version 2 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@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | |
|
23 | 23 | #ifndef REGISTERSMODEL_H |
|
24 | 24 | #define REGISTERSMODEL_H |
|
25 | 25 | #include <QString> |
|
26 | 26 | #include <QList> |
|
27 | 27 | #include <QObject> |
|
28 | 28 | #include <QDomDocument> |
|
29 | 29 | #include <QDomElement> |
|
30 | 30 | #include "registerdata.h" |
|
31 | 31 | #include <socclk.h> |
|
32 | 32 | #include <socexplorerplugin.h> |
|
33 | 33 | //#include <socexplorerenumdevice.h> |
|
34 | 34 | class socExplorerEnumDevice; |
|
35 | 35 | |
|
36 | 36 | class registerBitFieldModel |
|
37 | 37 | { |
|
38 | 38 | public: |
|
39 | 39 | registerBitFieldModel(const QString& name,const QString& description, |
|
40 | 40 | int size, int offset, bool rw) |
|
41 | 41 | { |
|
42 | 42 | this->name = name; |
|
43 | 43 | this->description = description; |
|
44 | 44 | this->size = size; |
|
45 | 45 | this->offset = offset; |
|
46 | 46 | this->rw = rw; |
|
47 | 47 | } |
|
48 | 48 | QString name; |
|
49 | 49 | QString description; |
|
50 | 50 | int size; |
|
51 | 51 | int offset; |
|
52 | 52 | bool rw; |
|
53 | 53 | }; |
|
54 | 54 | |
|
55 | 55 | class registerModel |
|
56 | 56 | { |
|
57 | 57 | public: |
|
58 | 58 | registerModel(const QString& name,qint32 offset) |
|
59 | 59 | { |
|
60 | 60 | this->name = name; |
|
61 | 61 | this->offset = offset; |
|
62 | 62 | } |
|
63 | 63 | QString name; |
|
64 | 64 | qint32 offset; |
|
65 | 65 | QList<registerBitFieldModel> bitfields; |
|
66 | 66 | }; |
|
67 | 67 | |
|
68 | 68 | class peripheralModel |
|
69 | 69 | { |
|
70 | 70 | public: |
|
71 | 71 | peripheralModel(const QString& name) |
|
72 | 72 | { |
|
73 | 73 | this->name = name; |
|
74 | 74 | } |
|
75 | 75 | QString name; |
|
76 | 76 | QList<registerModel> registers; |
|
77 | 77 | }; |
|
78 | 78 | |
|
79 | 79 | |
|
80 | 80 | class SOCEXPLORER_EXPORT SOCModel :public QObject |
|
81 | 81 | { |
|
82 | 82 | Q_OBJECT |
|
83 | 83 | public: |
|
84 | 84 | SOCModel(socexplorerplugin* rootDev,QObject* parent=0); |
|
85 | 85 | // qint32 getRegValue(qint32 baseAddress); |
|
86 | 86 | bool isRootDev(socexplorerplugin* rootDev) |
|
87 | 87 | { |
|
88 | 88 | return rootDev==p_rootDev; |
|
89 | 89 | } |
|
90 | 90 | bool enumDeviceExists(qint32 baseAddress); |
|
91 | 91 | socExplorerEnumDevice *getEnumDevice(qint32 baseAddress); |
|
92 | 92 | public slots: |
|
93 | 93 | //void setRegValue(qint32 baseAddress,qint32 value); |
|
94 | 94 | qint32 getEnumDeviceBaseAddress(int VID,int PID,int count=0); |
|
95 | qint32 getEnumDeviceCount(int VID,int PID); | |
|
95 | 96 | socExplorerEnumDevice* addEnumDevice(int VID, int PID, qint32 baseAddress, const QString& name); |
|
96 | 97 | int addEnumDevice(socExplorerEnumDevice* device); |
|
97 | 98 | void writeReg(qint32 address,qint32 value); |
|
98 | 99 | qint32 readReg(qint32 address); |
|
99 | 100 | private: |
|
100 | 101 | socexplorerplugin* p_rootDev; |
|
101 | 102 | QList<socExplorerEnumDevice*> p_enumeratedDevices; |
|
102 | 103 | QList<SOCclk*> clktree; |
|
103 | 104 | }; |
|
104 | 105 | |
|
105 | 106 | |
|
106 | 107 | |
|
107 | 108 | |
|
108 | 109 | #endif // REGISTERSMODEL_H |
|
109 | 110 | |
|
110 | 111 | |
|
111 | 112 | |
|
112 | 113 | |
|
113 | 114 | |
|
114 | 115 | |
|
115 | 116 |
@@ -1,232 +1,251 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 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 |
|
7 | 7 | -- the Free Software Foundation; either version 2 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@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "socexplorerengine.h" |
|
23 | 23 | #include <proxy/socexplorerproxy.h> |
|
24 | 24 | |
|
25 | 25 | SocExplorerEngine* SocExplorerEngine::_self = NULL; |
|
26 | 26 | socExplorerXmlModel* SocExplorerEngine::p_xmlmodel=NULL; |
|
27 | 27 | QMainWindow* SocExplorerEngine::mainWindow=NULL; |
|
28 | 28 | QList<SOCModel*>* SocExplorerEngine::SOCs=NULL; |
|
29 | 29 | int SocExplorerEngine::loglvl=1; |
|
30 | 30 | |
|
31 | 31 | SocExplorerEngine::SocExplorerEngine(QObject *parent) : |
|
32 | 32 | QObject(parent) |
|
33 | 33 | { |
|
34 | 34 | if(SOCs==NULL) |
|
35 | 35 | { |
|
36 | 36 | SOCs = new QList<SOCModel*>; |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | |
|
42 | 42 | void SocExplorerEngine::init() |
|
43 | 43 | { |
|
44 | 44 | QDir dir; |
|
45 | 45 | if(!_self) |
|
46 | 46 | { |
|
47 | 47 | _self= new SocExplorerEngine; |
|
48 | 48 | } |
|
49 | 49 | if(!dir.exists(configFolder())) |
|
50 | 50 | dir.mkdir(configFolder()); |
|
51 | 51 | p_xmlmodel = new socExplorerXmlModel(_self); |
|
52 | 52 | p_xmlmodel->updateSOClist(); |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | QString SocExplorerEngine::configFolder() |
|
56 | 56 | { |
|
57 | 57 | return QString(SOCEXPLORER_CONFIG_PATH); |
|
58 | 58 | } |
|
59 | 59 | |
|
60 | 60 | SOCModel *SocExplorerEngine::plugin2Soc(socexplorerplugin *plugin) |
|
61 | 61 | { |
|
62 | 62 | if(!_self) |
|
63 | 63 | init(); |
|
64 | 64 | if(plugin) |
|
65 | 65 | { |
|
66 | 66 | while (plugin->parent!=NULL) { |
|
67 | 67 | plugin = plugin->parent; |
|
68 | 68 | } |
|
69 | 69 | for(int i=0;i<SOCs->count();i++) |
|
70 | 70 | { |
|
71 | 71 | if(SOCs->at(i)->isRootDev(plugin)) |
|
72 | 72 | return SOCs->at(i); |
|
73 | 73 | } |
|
74 | 74 | //no soc found so create a new one |
|
75 | 75 | SOCModel* soc=new SOCModel(plugin); |
|
76 | 76 | SOCs->append(soc); |
|
77 | 77 | return soc; |
|
78 | 78 | } |
|
79 | 79 | return NULL; |
|
80 | 80 | } |
|
81 | 81 | |
|
82 | 82 | |
|
83 | 83 | int SocExplorerEngine::addEnumDevice(socexplorerplugin* rootPlugin,int VID, int PID, qint32 baseAddress, const QString &name) |
|
84 | 84 | { |
|
85 | 85 | if(!_self) |
|
86 | 86 | init(); |
|
87 | 87 | SOCModel* soc = plugin2Soc(rootPlugin); |
|
88 | 88 | if(soc && !soc->enumDeviceExists(baseAddress)) |
|
89 | 89 | { |
|
90 | 90 | emit _self->enumDeviceAdded(soc->addEnumDevice(VID,PID,baseAddress,name)); |
|
91 | 91 | return 1; |
|
92 | 92 | } |
|
93 | 93 | return 0; |
|
94 | 94 | } |
|
95 | 95 | |
|
96 | 96 | QList<SOCModel *> *SocExplorerEngine::getSOCs() |
|
97 | 97 | { |
|
98 | 98 | if(!_self) |
|
99 | 99 | init(); |
|
100 | 100 | return SOCs; |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | 103 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(const QString& rootPlugin,int VID, int PID, int count) |
|
104 | 104 | { |
|
105 | 105 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
106 | 106 | if(plugin==NULL)return -1; |
|
107 | 107 | SOCModel* soc = plugin2Soc(plugin); |
|
108 | 108 | if(soc==NULL) |
|
109 | 109 | return -1; |
|
110 | 110 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | qint32 SocExplorerEngine::getEnumDeviceBaseAddress(socexplorerplugin *plugin, int VID, int PID, int count) |
|
114 | 114 | { |
|
115 | 115 | if(plugin==NULL)return -1; |
|
116 | 116 | SOCModel* soc = plugin2Soc(plugin); |
|
117 | 117 | if(soc==NULL) |
|
118 | 118 | return -1; |
|
119 | 119 | return soc->getEnumDeviceBaseAddress(VID,PID,count); |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | qint32 SocExplorerEngine::getEnumDeviceCount(socexplorerplugin *plugin, int VID, int PID) | |
|
123 | { | |
|
124 | if(plugin==NULL)return 0; | |
|
125 | SOCModel* soc = plugin2Soc(plugin); | |
|
126 | if(soc==NULL) | |
|
127 | return 0; | |
|
128 | return soc->getEnumDeviceCount(VID,PID); | |
|
129 | } | |
|
130 | ||
|
131 | qint32 SocExplorerEngine::getEnumDeviceCount(const QString &rootPlugin, int VID, int PID) | |
|
132 | { | |
|
133 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); | |
|
134 | if(plugin==NULL)return 0; | |
|
135 | SOCModel* soc = plugin2Soc(plugin); | |
|
136 | if(soc==NULL) | |
|
137 | return 0; | |
|
138 | return soc->getEnumDeviceCount(VID,PID); | |
|
139 | } | |
|
140 | ||
|
122 | 141 | int SocExplorerEngine::addEnumDevice(const QString &rootPlugin, int VID, int PID, qint32 baseAddress, const QString &name) |
|
123 | 142 | { |
|
124 | 143 | socexplorerplugin* plugin = socexplorerproxy::findPlugin(rootPlugin); |
|
125 | 144 | if(plugin==NULL)return -1; |
|
126 | 145 | SOCModel* soc = plugin2Soc(plugin); |
|
127 | 146 | if(soc==NULL) |
|
128 | 147 | return -1; |
|
129 | 148 | soc->addEnumDevice(VID,PID,baseAddress,name); |
|
130 | 149 | return 1; |
|
131 | 150 | } |
|
132 | 151 | |
|
133 | 152 | |
|
134 | 153 | QString SocExplorerEngine::getDevName(int VID, int PID) |
|
135 | 154 | { |
|
136 | 155 | QList<QDomNodeList> list=p_xmlmodel->getAllNodes("peripheral"); |
|
137 | 156 | for(int i=0;i<list.count();i++) |
|
138 | 157 | { |
|
139 | 158 | QDomNodeList nodes=list.at(i); |
|
140 | 159 | for(int l=0;l<nodes.count();l++) |
|
141 | 160 | { |
|
142 | 161 | QDomElement node=nodes.at(l).toElement(); |
|
143 | 162 | int nodeVID=node.attribute("vid","0").toInt(); |
|
144 | 163 | int nodePID=node.attribute("pid","0").toInt(); |
|
145 | 164 | if((nodeVID==VID)&&(nodePID==PID)) |
|
146 | 165 | { |
|
147 | 166 | return node.attribute("name","Unknow device"); |
|
148 | 167 | } |
|
149 | 168 | } |
|
150 | 169 | } |
|
151 | 170 | return QString("Unknow device"); |
|
152 | 171 | } |
|
153 | 172 | |
|
154 | 173 | QString SocExplorerEngine::SocExplorerVersion(){return QString(SOCEXPLORER_VERSION);} |
|
155 | 174 | |
|
156 | 175 | QString SocExplorerEngine::SocExplorerChangeset(){return QString(SOCEXPLORER_CHAGESET).split(" ").at(0);} |
|
157 | 176 | |
|
158 | 177 | QString SocExplorerEngine::SocExplorerBranch(){return QString(SOCEXPLORER_BRANCH);} |
|
159 | 178 | |
|
160 | 179 | socExplorerXmlModel *SocExplorerEngine::xmlModel() |
|
161 | 180 | { |
|
162 | 181 | if(!_self) |
|
163 | 182 | init(); |
|
164 | 183 | return p_xmlmodel; |
|
165 | 184 | } |
|
166 | 185 | |
|
167 | 186 | void SocExplorerEngine::setMainWindow(QMainWindow *Mainwindow) |
|
168 | 187 | { |
|
169 | 188 | if(!_self) |
|
170 | 189 | init(); |
|
171 | 190 | mainWindow=Mainwindow; |
|
172 | 191 | } |
|
173 | 192 | |
|
174 | 193 | QProgressBar *SocExplorerEngine::getProgressBar(const QString& format, int max) |
|
175 | 194 | { |
|
176 | 195 | if(!_self) |
|
177 | 196 | init(); |
|
178 | 197 | QProgressBar* progressBar; |
|
179 | 198 | if(mainWindow!=NULL) |
|
180 | 199 | { |
|
181 | 200 | progressBar = new QProgressBar(mainWindow); |
|
182 | 201 | mainWindow->statusBar()->addWidget(progressBar); |
|
183 | 202 | } |
|
184 | 203 | else |
|
185 | 204 | { |
|
186 | 205 | progressBar = new QProgressBar(); |
|
187 | 206 | } |
|
188 | 207 | progressBar->setMaximum(max); |
|
189 | 208 | progressBar->setFormat(format); |
|
190 | 209 | return progressBar; |
|
191 | 210 | } |
|
192 | 211 | |
|
193 | 212 | void SocExplorerEngine::deleteProgressBar(QProgressBar *progressBar) |
|
194 | 213 | { |
|
195 | 214 | if(mainWindow!=NULL) |
|
196 | 215 | { |
|
197 | 216 | mainWindow->statusBar()->removeWidget(progressBar); |
|
198 | 217 | } |
|
199 | 218 | delete progressBar; |
|
200 | 219 | } |
|
201 | 220 | |
|
202 | 221 | void SocExplorerEngine::addSOC(socexplorerplugin *rootPlugin) |
|
203 | 222 | { |
|
204 | 223 | plugin2Soc(rootPlugin); |
|
205 | 224 | } |
|
206 | 225 | |
|
207 | 226 | void SocExplorerEngine::removeSOC(socexplorerplugin *rootPlugin) |
|
208 | 227 | { |
|
209 | 228 | SOCModel* soc=plugin2Soc(rootPlugin); |
|
210 | 229 | SOCs->removeAll(soc); |
|
211 | 230 | delete soc; |
|
212 | 231 | } |
|
213 | 232 | |
|
214 | 233 | void SocExplorerEngine::message(socexplorerplugin *sender, const QString &message, int debugLevel) |
|
215 | 234 | { |
|
216 | 235 | // TODO add multi output message manager IE also log in files |
|
217 | 236 | if(!_self) |
|
218 | 237 | init(); |
|
219 | 238 | if(loglvl>=debugLevel) |
|
220 | 239 | qDebug()<< QTime::currentTime().toString()+" " + sender->instanceName()+":"+message; |
|
221 | 240 | } |
|
222 | 241 | |
|
223 | 242 | void SocExplorerEngine::setLogLevel(int level) |
|
224 | 243 | { |
|
225 | 244 | if(!_self) |
|
226 | 245 | init(); |
|
227 | 246 | printf("Set log level to %d\n",level); |
|
228 | 247 | loglvl = level; |
|
229 | 248 | } |
|
230 | 249 | |
|
231 | 250 | |
|
232 | 251 |
@@ -1,134 +1,136 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SocExplorer Software |
|
3 | 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 |
|
7 | 7 | -- the Free Software Foundation; either version 2 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@lpp.polytechnique.fr |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #ifndef SOCEXPLORERENGINE_H |
|
23 | 23 | #define SOCEXPLORERENGINE_H |
|
24 | 24 | |
|
25 | 25 | #include <stdint.h> |
|
26 | 26 | #include <QObject> |
|
27 | 27 | #include <QtWidgets> |
|
28 | 28 | #include <QStringList> |
|
29 | 29 | #include <QDomDocument> |
|
30 | 30 | #include <QDomElement> |
|
31 | 31 | #include <QDomNodeList> |
|
32 | 32 | #include <QFile> |
|
33 | 33 | #include <QTextStream> |
|
34 | 34 | #include <QDir> |
|
35 | 35 | #include <QApplication> |
|
36 | 36 | #include <QtCore/qglobal.h> |
|
37 | 37 | #include <QFileDialog> |
|
38 | 38 | #include <socexplorerxmlfile.h> |
|
39 | 39 | #include <socexplorerenumdevice.h> |
|
40 | 40 | #include <XMLmodel.h> |
|
41 | 41 | #include <peripheralwidget.h> |
|
42 | 42 | #include <registerwidget.h> |
|
43 | 43 | #include <socmodel.h> |
|
44 | 44 | |
|
45 | 45 | #if defined(SOCEXPLORER_SDK_BUILD) |
|
46 | 46 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT |
|
47 | 47 | #else |
|
48 | 48 | # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT |
|
49 | 49 | #endif |
|
50 | 50 | |
|
51 | 51 | |
|
52 | 52 | class SOCEXPLORER_SDK_EXPORT SocExplorerAutoProgressBar |
|
53 | 53 | { |
|
54 | 54 | public: |
|
55 | 55 | SocExplorerAutoProgressBar(QProgressBar* progressBar=NULL) |
|
56 | 56 | { |
|
57 | 57 | this->p_progressbar=progressBar; |
|
58 | 58 | } |
|
59 | 59 | ~SocExplorerAutoProgressBar() |
|
60 | 60 | { |
|
61 | 61 | if(p_progressbar) |
|
62 | 62 | { |
|
63 | 63 | delete p_progressbar; |
|
64 | 64 | } |
|
65 | 65 | } |
|
66 | 66 | void setProgressBar(QProgressBar* progressBar) |
|
67 | 67 | { |
|
68 | 68 | this->p_progressbar=progressBar; |
|
69 | 69 | } |
|
70 | 70 | void setValue(int value) |
|
71 | 71 | { |
|
72 | 72 | p_progressbar->setValue(value); |
|
73 | 73 | } |
|
74 | 74 | private: |
|
75 | 75 | QProgressBar* p_progressbar; |
|
76 | 76 | }; |
|
77 | 77 | |
|
78 | 78 | //! SocExplorerEngine is a pure static class which aims to provide services for both SocExplorer software and plugins. |
|
79 | 79 | |
|
80 | 80 | class SOCEXPLORER_SDK_EXPORT SocExplorerEngine : public QObject |
|
81 | 81 | { |
|
82 | 82 | Q_OBJECT |
|
83 | 83 | private: |
|
84 | 84 | static SocExplorerEngine* _self; |
|
85 | 85 | SocExplorerEngine(QObject *parent = 0); |
|
86 | 86 | static void init(); |
|
87 | 87 | |
|
88 | 88 | public: |
|
89 | 89 | static SocExplorerEngine* self(){ if(!_self){_self= new SocExplorerEngine;}return _self;} |
|
90 | 90 | //! Return the configuration folder path, OS dependant. |
|
91 | 91 | SOCEXPLORER_SDK_EXPORT static QString configFolder(); |
|
92 | 92 | //! Return the default plugin folder path, OS dependant. |
|
93 | 93 | static QString pluginFolder(){return QString(SOCEXPLORER_PLUGINS_INSTALL_PATH);} |
|
94 | 94 | |
|
95 | 95 | static int addEnumDevice(socexplorerplugin* rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); |
|
96 | 96 | static QList<SOCModel*>* getSOCs(); |
|
97 | 97 | static QString getDevName(int VID, int PID); |
|
98 | 98 | static QString SocExplorerVersion(); |
|
99 | 99 | static QString SocExplorerChangeset(); |
|
100 | 100 | static QString SocExplorerBranch(); |
|
101 | 101 | static socExplorerXmlModel* xmlModel(); |
|
102 | 102 | static void setMainWindow(QMainWindow* Mainwindow); |
|
103 | 103 | static QProgressBar* getProgressBar(const QString &format, int max); |
|
104 | 104 | static void deleteProgressBar(QProgressBar* progressBar); |
|
105 | 105 | static void addSOC(socexplorerplugin* rootPlugin); |
|
106 | 106 | static void removeSOC(socexplorerplugin* rootPlugin); |
|
107 | 107 | static void message(socexplorerplugin* sender,const QString& message,int debugLevel=0); |
|
108 | 108 | static void setLogLevel(int level); |
|
109 | 109 | signals: |
|
110 | 110 | void enumDeviceAdded(socExplorerEnumDevice* device); |
|
111 | 111 | public slots: |
|
112 | 112 | QString getSocExplorerVersion(){return SocExplorerEngine::SocExplorerVersion();} |
|
113 | 113 | QString getSocExplorerChangeset(){return SocExplorerEngine::SocExplorerChangeset();} |
|
114 | 114 | QString getSocExplorerBranch(){return SocExplorerEngine::SocExplorerBranch();} |
|
115 | 115 | qint32 getEnumDeviceBaseAddress(const QString& rootPlugin,int VID,int PID,int count=0); |
|
116 | 116 | qint32 getEnumDeviceBaseAddress(socexplorerplugin* plugin,int VID,int PID,int count=0); |
|
117 | qint32 getEnumDeviceCount(socexplorerplugin* plugin,int VID,int PID); | |
|
118 | qint32 getEnumDeviceCount(const QString& rootPlugin,int VID,int PID); | |
|
117 | 119 | int addEnumDevice(const QString& rootPlugin,int VID,int PID,qint32 baseAddress,const QString& name); |
|
118 | 120 | |
|
119 | 121 | private: |
|
120 | 122 | static SOCModel* plugin2Soc(socexplorerplugin* plugin); |
|
121 | 123 | static socExplorerXmlModel* p_xmlmodel; |
|
122 | 124 | static QMainWindow* mainWindow; |
|
123 | 125 | static QList<SOCModel*>* SOCs; |
|
124 | 126 | static int loglvl; |
|
125 | 127 | }; |
|
126 | 128 | |
|
127 | 129 | #endif // SOCEXPLORERENGINE_H |
|
128 | 130 | |
|
129 | 131 | |
|
130 | 132 | |
|
131 | 133 | |
|
132 | 134 | |
|
133 | 135 | |
|
134 | 136 |
@@ -1,70 +1,70 | |||
|
1 | 1 | |
|
2 | 2 | |
|
3 | 3 | win32 { |
|
4 | 4 | DEFINES += WIN32 |
|
5 | 5 | DEFINES += WINTRANSLATIONPATH |
|
6 | 6 | DEFINES += SOCEXPLORER_TRANSLATION_PATH="\"\\\"./translations"\\\"\" |
|
7 | 7 | SOCEXPLORER_TRANSLATION_INSTALL_PATH = translations |
|
8 | 8 | SOCEXPLORER_INSTALL_PATH = |
|
9 | 9 | SOCEXPLORER_PLUGINS_INSTALL_PATH = $$SOCEXPLORER_PLUGIN_PATH |
|
10 | 10 | } |
|
11 | 11 | |
|
12 | 12 | unix { |
|
13 | 13 | DEFINES += UNIX |
|
14 | 14 | DEFINES += UNIXTRANSLATIONPATH |
|
15 | 15 | DEFINES += SOCEXPLORER_TRANSLATION_PATH="\"\\\"/etc/SocExplorer/translations"\\\"\" |
|
16 | 16 | SOCEXPLORER_TRANSLATION_INSTALL_PATH = /etc/SocExplorer/translations |
|
17 | 17 | SOCEXPLORER_INSTALL_PATH = /usr/local/SocExplorer |
|
18 | 18 | SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH = $$system(echo $HOME) |
|
19 | 19 | SOCEXPLORER_PLUGINS_INSTALL_PATH = $${SOCEXPLORER_ROOT_PLUGINS_INSTALL_PATH}"/.SocExplorer/plugins" |
|
20 | 20 | } |
|
21 | 21 | |
|
22 | isEmpty(SOCEXPLORER_SDK_BUILD){ | |
|
22 | isEmpty( SOCEXPLORER_SDK_BUILD ){ | |
|
23 | 23 | message( "building a plugin" ) |
|
24 | 24 | QT += core gui xml |
|
25 | 25 | contains(QT_MAJOR_VERSION, 5) { |
|
26 | 26 | QT += widgets |
|
27 | 27 | } |
|
28 | 28 | CONFIG += pythonqt |
|
29 | 29 | TEMPLATE = lib |
|
30 | 30 | win32:CONFIG += dll |
|
31 | 31 | win32:CONFIG -= static |
|
32 | 32 | OBJECTS_DIR = obj |
|
33 | 33 | MOC_DIR = moc |
|
34 | 34 | DESTDIR = bin |
|
35 | 35 | CONFIG(debug, debug|release) { |
|
36 | 36 | DEBUG_EXT = _d |
|
37 | 37 | } else { |
|
38 | 38 | DEBUG_EXT = |
|
39 | 39 | } |
|
40 | 40 | unix{ |
|
41 | 41 | target.path = $${SOCEXPLORER_PLUGINS_INSTALL_PATH} |
|
42 | 42 | INSTALLS += target |
|
43 | 43 | LIBS+= -lsocexplorerengine$${DEBUG_EXT} -lsocexplorercommon$${DEBUG_EXT} |
|
44 | 44 | } |
|
45 | 45 | win32{ |
|
46 | 46 | INCLUDEPATH += $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf |
|
47 | 47 | LIBS+=$$[QT_INSTALL_LIBS]/socexplorerengine$${DEBUG_EXT}.dll $$[QT_INSTALL_LIBS]/socexplorercommon$${DEBUG_EXT}.dll |
|
48 | 48 | } |
|
49 | 49 | DEFINES += SOCEXPLORER_LIBRARY |
|
50 | 50 | |
|
51 | 51 | SOURCES += \ |
|
52 | 52 | $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface/socexplorerplugininterface.cpp |
|
53 | 53 | |
|
54 | 54 | HEADERS += \ |
|
55 | 55 | $$[QT_INSTALL_HEADERS]/SocExplorer/genericPySysdriver.h \ |
|
56 | 56 | $$[QT_INSTALL_HEADERS]/SocExplorer/socexplorerplugin.h |
|
57 | 57 | |
|
58 | 58 | INCLUDEPATH += $$[QT_INSTALL_HEADERS]/SocExplorer/common \ |
|
59 | 59 | $$[QT_INSTALL_HEADERS]/SocExplorer \ |
|
60 | 60 | $$[QT_INSTALL_HEADERS]/SocExplorer/pluginsInterface |
|
61 | 61 | |
|
62 | 62 | |
|
63 | 63 | }else{ |
|
64 | 64 | message( "building SocExplorer" ) |
|
65 | 65 | HEADERS += \ |
|
66 | 66 | $$[QT_INSTALL_HEADERS]/SocExplorer/genericPySysdriver.h \ |
|
67 | 67 | $$[QT_INSTALL_HEADERS]/SocExplorer/socexplorerplugin.h |
|
68 | 68 | } |
|
69 | 69 | |
|
70 | 70 |
General Comments 0
You need to be logged in to leave comments.
Login now