##// END OF EJS Templates
Fixed some cli bugs....
Jeandet Alexis -
r98:d744963be984 default
parent child
Show More
@@ -1,119 +1,103
1 #include "pythonconsole.h"
1 #include "pythonconsole.h"
2 #include <QPushButton>
2 #include <QPushButton>
3 #include <QFile>
3 #include <QFile>
4 #include <QTextStream>
4 #include <QTextStream>
5 #include <QCustomPlot/qcustomplot.h>
5 #include <QCustomPlot/qcustomplot.h>
6 #include "../common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h"
6 #include "../common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h"
7
7
8 #include <PythonQt.h>
8 #include <PythonQt.h>
9 #include "pluginloader.h"
9 #include "pluginloader.h"
10 #include <socexplorer.h>
10 #include <socexplorer.h>
11
11
12 void PythonQt_init_PySocExplorer(PyObject* module);
12 void PythonQt_init_PySocExplorer(PyObject* module);
13 void PythonQt_init_PySocExplorerEngine(PyObject* module) ;
13 void PythonQt_init_PySocExplorerEngine(PyObject* module) ;
14
14
15 PythonConsole::PythonConsole(socexplorerproxy *proxy, QWidget *parent) :
15 PythonConsole::PythonConsole(socexplorerproxy *proxy, QWidget *parent) :
16 QWidget(parent)
16 QWidget(parent)
17 {
17 {
18 //PythonQt::init();
19 PythonQt::init(PythonQt::RedirectStdOut);
18 PythonQt::init(PythonQt::RedirectStdOut);
20 PythonQt_QtAll::init();
19 PythonQt_QtAll::init();
21 this->proxy = proxy;
20 this->proxy = proxy;
22 this->mainlayout = new QHBoxLayout;
21 this->mainlayout = new QHBoxLayout;
23 this->mainContext = new PythonQtObjectPtr(PythonQt::self()->getMainModule());
22 this->mainContext = new PythonQtObjectPtr(PythonQt::self()->getMainModule());
24 this->mainContext->addVariable(QString("PYMODULES"),QVariant(QString(PYMODULES)));
23 this->mainContext->addVariable(QString("PYMODULES"),QVariant(QString(PYMODULES)));
25 this->console = new PythonQtScriptingConsoleDandD(NULL, PythonQt::self()->getMainModule());
24 this->console = new PythonQtScriptingConsoleDandD(NULL, PythonQt::self()->getMainModule());
26 this->mainlayout->addWidget(this->console);
25 this->mainlayout->addWidget(this->console);
27 this->setWindowTitle(tr("Python Scripting Console"));
26 this->setWindowTitle(tr("Python Scripting Console"));
28 this->bussdriver = 0;
29 this->setAcceptDrops(true);
27 this->setAcceptDrops(true);
30 this->setLayout(this->mainlayout);
28 this->setLayout(this->mainlayout);
31 connect(this->console,SIGNAL(pyConsoleRunFiles(QStringList)),this,SLOT(pyConsoleRunFiles(QStringList)));
29 connect(this->console,SIGNAL(pyConsoleRunFiles(QStringList)),this,SLOT(pyConsoleRunFiles(QStringList)));
32 this->mainContext->addObject("proxy", proxy);
30 this->mainContext->addObject("proxy", proxy);
33 PythonQt_init_PySocExplorer(0);
31 PythonQt_init_PySocExplorer(0);
34 PythonQt_init_PySocExplorerEngine(0);
32 PythonQt_init_PySocExplorerEngine(0);
35 this->mainContext->evalScript(QString("from PythonQt import *"));
33 this->mainContext->evalScript(QString("from PythonQt import *"));
36 }
34 }
37
35
38 void PythonConsole::addObject(const QString& name, QObject* object)
36 void PythonConsole::addObject(const QString& name, QObject* object)
39 {
37 {
40 this->mainContext->addObject(name, object);
38 this->mainContext->addObject(name, object);
41 }
39 }
42
40
43 void PythonConsole::removeVariable(const QString& name)
41 void PythonConsole::removeVariable(const QString& name)
44 {
42 {
45 this->mainContext->removeVariable(name);
43 this->mainContext->removeVariable(name);
46 }
44 }
47
45
48
49 void PythonConsole::setBussDriver(socexplorerplugin *driver)
50 {
51 this->bussdriver = driver;
52 this->mainContext->addObject("buss", this->bussdriver);
53 }
54
55 void PythonConsole::registerObject(QObject* object,const QString& instanceName)
46 void PythonConsole::registerObject(QObject* object,const QString& instanceName)
56 {
47 {
57 this->mainContext->addObject(instanceName,object);
48 this->mainContext->addObject(instanceName,object);
58 }
49 }
59
50
60 void PythonConsole::changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName)
51 void PythonConsole::changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName)
61 {
52 {
62 socexplorerplugin* obj= this->proxy->getSysDriver(previnstanceName);
53 socexplorerplugin* obj= this->proxy->getSysDriver(previnstanceName);
63 if(obj==NULL)obj= this->proxy->getSysDriver(newinstanceName);
54 if(obj==NULL)obj= this->proxy->getSysDriver(newinstanceName);
64 if(obj==NULL)return;
55 if(obj==NULL)return;
65 // this->mainContext->addObject(newinstanceName,obj->getPyObjectWrapper());
56 // this->mainContext->addObject(newinstanceName,obj->getPyObjectWrapper());
66 this->mainContext->addObject(newinstanceName,obj);
57 this->mainContext->addObject(newinstanceName,obj);
67 this->mainContext->removeVariable(previnstanceName);
58 this->mainContext->removeVariable(previnstanceName);
68 }
59 }
69
60
70 void PythonConsole::removeDriver(const QString& instanceName)
61 void PythonConsole::removeDriver(const QString& instanceName)
71 {
62 {
72 this->mainContext->removeVariable(instanceName);
63 this->mainContext->removeVariable(instanceName);
73 }
64 }
74
65
75 void PythonConsole::removeBussDriver()
76 {
77 this->bussdriver = 0;
78 this->mainContext->removeVariable("buss");
79 emit this->rootDriverDelete();
80 }
81
82
66
83 void PythonConsole::pyConsoleRunFiles(const QStringList & pathList)
67 void PythonConsole::pyConsoleRunFiles(const QStringList & pathList)
84 {
68 {
85 for (int i = 0; i < pathList.size() && i < 32; ++i)
69 for (int i = 0; i < pathList.size() && i < 32; ++i)
86 {
70 {
87 this->pyConsoleRunFile(pathList.at(i));
71 this->pyConsoleRunFile(pathList.at(i));
88 }
72 }
89 }
73 }
90
74
91 void PythonConsole::pyConsoleRunFile(const QString& fileName)
75 void PythonConsole::pyConsoleRunFile(const QString& fileName)
92 {
76 {
93 QString code;
77 QString code;
94 QFile file;
78 QFile file;
95 QFileInfo fileinfo;
79 QFileInfo fileinfo;
96
80
97 code.clear();
81 code.clear();
98 file.setFileName(fileName);
82 file.setFileName(fileName);
99 fileinfo.setFile(fileName);
83 fileinfo.setFile(fileName);
100 if(!fileinfo.suffix().compare("py"))
84 if(!fileinfo.suffix().compare("py"))
101 {
85 {
102 QString CMD="execfile(\'"+fileName+"\')";
86 QString CMD="execfile(\'"+fileName+"\')";
103 this->console->executePythonCommand(CMD);
87 this->console->executePythonCommand(CMD);
104 }
88 }
105 }
89 }
106
90
107
91
108 QSize PythonConsole::sizeHint()
92 QSize PythonConsole::sizeHint()
109 {
93 {
110 return QSize(800,80);
94 return QSize(800,80);
111 }
95 }
112
96
113
97
114
98
115
99
116
100
117
101
118
102
119
103
@@ -1,73 +1,69
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 #ifndef PYTHONCONSOLE_H
22 #ifndef PYTHONCONSOLE_H
23 #define PYTHONCONSOLE_H
23 #define PYTHONCONSOLE_H
24
24
25 #include <QWidget>
25 #include <QWidget>
26 #include <QDockWidget>
26 #include <QDockWidget>
27 #include <QHBoxLayout>
27 #include <QHBoxLayout>
28 #include <QtGui/QDragEnterEvent>
28 #include <QtGui/QDragEnterEvent>
29 #include <QtGui/QDragLeaveEvent>
29 #include <QtGui/QDragLeaveEvent>
30 #include <QtGui/QDragMoveEvent>
30 #include <QtGui/QDragMoveEvent>
31 #include <QtGui/QDropEvent>
31 #include <QtGui/QDropEvent>
32 #include <QtCore/QMimeData>
32 #include <QtCore/QMimeData>
33 #include <QtCore/QUrl>
33 #include <QtCore/QUrl>
34 #include <QtCore/QList>
34 #include <QtCore/QList>
35 #include "PythonQt.h"
35 #include "PythonQt.h"
36 #include "PythonQt_QtAll.h"
36 #include "PythonQt_QtAll.h"
37 #include <gui/PythonQtScriptingConsole.h>
37 #include <gui/PythonQtScriptingConsole.h>
38 #include "../plugins/socexplorerplugin.h"
38 #include "../plugins/socexplorerplugin.h"
39 #include "pythonqtscriptingconsoledandd.h"
39 #include "pythonqtscriptingconsoledandd.h"
40 #include <QMainWindow>
40 #include <QMainWindow>
41 #include "../proxy/socexplorerproxy.h"
41 #include "../proxy/socexplorerproxy.h"
42 class SocExplorerMainWindow;
42 class SocExplorerMainWindow;
43 class PythonConsole : public QWidget
43 class PythonConsole : public QWidget
44 {
44 {
45 Q_OBJECT
45 Q_OBJECT
46 public:
46 public:
47 explicit PythonConsole(socexplorerproxy* proxy,QWidget *parent = 0);
47 explicit PythonConsole(socexplorerproxy* proxy,QWidget *parent = 0);
48
48
49 signals:
49 signals:
50 void rootDriverDelete();
50 void rootDriverDelete();
51 public slots:
51 public slots:
52 void setBussDriver(socexplorerplugin* driver);
53 void removeBussDriver();
54 void removeDriver(const QString& instanceName);
52 void removeDriver(const QString& instanceName);
55 void pyConsoleRunFiles(const QStringList&);
53 void pyConsoleRunFiles(const QStringList&);
56 void pyConsoleRunFile(const QString& fileName);
54 void pyConsoleRunFile(const QString& fileName);
57 void registerObject(QObject* object,const QString& instanceName);
55 void registerObject(QObject* object,const QString& instanceName);
58 void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
56 void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
59 void addObject(const QString& name, QObject* object);
57 void addObject(const QString& name, QObject* object);
60 void removeVariable(const QString& name);
58 void removeVariable(const QString& name);
61 protected:
59 protected:
62 QSize sizeHint();
60 QSize sizeHint();
63
61
64 private:
62 private:
65 QHBoxLayout* mainlayout;
63 QHBoxLayout* mainlayout;
66 socexplorerplugin* bussdriver;
67 PythonQtScriptingConsoleDandD* console;
64 PythonQtScriptingConsoleDandD* console;
68 PythonQtObjectPtr* mainContext;
65 PythonQtObjectPtr* mainContext;
69 socexplorerproxy* proxy;
66 socexplorerproxy* proxy;
70 //LPMONMainWindow* mainwin;
71 };
67 };
72
68
73 #endif // PYTHONCONSOLE_H
69 #endif // PYTHONCONSOLE_H
@@ -1,143 +1,99
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 "pluginmanagerWDGT.h"
22 #include "pluginmanagerWDGT.h"
23 #include "pluginloader.h"
23 #include "pluginloader.h"
24 #include <QFileDialog>
24 #include <QFileDialog>
25 #include <unistd.h>
25 #include <unistd.h>
26 #include <qsvgicon.h>
26 #include <qsvgicon.h>
27 #include <socexplorerengine.h>
27 #include <socexplorerengine.h>
28
28
29 #define mkbutton(button,text,image)button = new QPushButton();\
29 #define mkbutton(button,text,image)button = new QPushButton();\
30 button->setIcon(QSvgIcon(image));\
30 button->setIcon(QSvgIcon(image));\
31 button->setIconSize(QSize(16,16));\
31 button->setIconSize(QSize(16,16));\
32 button->setToolTip(text)
32 button->setToolTip(text)
33
33
34
34
35
35
36 pluginmanagerWDGT::pluginmanagerWDGT(QWidget *parent) :
36 pluginmanagerWDGT::pluginmanagerWDGT(QWidget *parent) :
37 QSplitter(parent)
37 QSplitter(parent)
38 {
38 {
39 this->setWindowTitle("Plugin Manager");
39 this->setWindowTitle("Plugin Manager");
40 this->setOrientation(Qt::Vertical);
40 this->setOrientation(Qt::Vertical);
41 this->pluginListWidgetContainer = new QWidget();
41 this->pluginListWidgetContainer = new QWidget();
42 this->mainlayoutSpliter = new QSplitter;
42 this->mainlayoutSpliter = new QSplitter;
43 this->pluginListLayout = new QVBoxLayout();
43 this->pluginListLayout = new QVBoxLayout();
44 this->mainlayoutSpliter->setOrientation(Qt::Vertical);
44 this->mainlayoutSpliter->setOrientation(Qt::Vertical);
45 this->treeview = new plugintree();
45 this->treeview = new plugintree();
46 this->pluginTable = new PluginList;
46 this->pluginTable = new PluginList;
47 this->ButtonsLayout = new QHBoxLayout();
47 this->ButtonsLayout = new QHBoxLayout();
48 this->ButtonsLayout->addStretch();
48 this->ButtonsLayout->addStretch();
49 this->pluginListLayout->addLayout(this->ButtonsLayout);
49 this->pluginListLayout->addLayout(this->ButtonsLayout);
50 this->addWidget(this->treeview);
50 this->addWidget(this->treeview);
51 this->pluginListWidgetContainer->setLayout(this->pluginListLayout);
51 this->pluginListWidgetContainer->setLayout(this->pluginListLayout);
52 this->addWidget(this->pluginListWidgetContainer);
52 this->addWidget(this->pluginListWidgetContainer);
53 this->pluginListLayout->addWidget(this->pluginTable);
53 this->pluginListLayout->addWidget(this->pluginTable);
54 this->pluginInfos = new pluginInfosWdgt;
54 this->pluginInfos = new pluginInfosWdgt;
55
55
56 mkbutton(this->addPluginBt,tr("add plugin"),":/images/open.svg");
56 mkbutton(this->addPluginBt,tr("add plugin"),":/images/open.svg");
57 mkbutton(this->removePluginBt,tr("remove plugin(s)"),":/images/trash.svg");
57 mkbutton(this->removePluginBt,tr("remove plugin(s)"),":/images/trash.svg");
58 mkbutton(this->refreshPluginListBt,tr("Refresh Plugin(s) list"),":/images/refresh.svg");
58 mkbutton(this->refreshPluginListBt,tr("Refresh Plugin(s) list"),":/images/refresh.svg");
59
59
60 this->ButtonsLayout->addWidget(this->addPluginBt);
60 this->ButtonsLayout->addWidget(this->addPluginBt);
61 this->ButtonsLayout->addWidget(this->refreshPluginListBt);
61 this->ButtonsLayout->addWidget(this->refreshPluginListBt);
62 this->ButtonsLayout->addWidget(this->removePluginBt);
62 this->ButtonsLayout->addWidget(this->removePluginBt);
63
63
64 this->addWidget(this->pluginInfos);
64 this->addWidget(this->pluginInfos);
65
65
66 connect(this->treeview,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree()));
66 connect(this->treeview,SIGNAL(geteplugintree()),this,SIGNAL(geteplugintree()));
67 connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->treeview,SLOT(treeChanged(QList<socexplorerplugin*>)));
67 connect(this,SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->treeview,SLOT(treeChanged(QList<socexplorerplugin*>)));
68 connect(this->pluginTable,SIGNAL(currentRowChanged(int)),this,SLOT(libselected(int)));
68 connect(this->pluginTable,SIGNAL(currentRowChanged(int)),this,SLOT(libselected(int)));
69 connect(this->pluginTable,SIGNAL(itemSelectionChanged(QStringList)),this->pluginInfos,SLOT(updateInfos(QStringList)));
69 connect(this->pluginTable,SIGNAL(itemSelectionChanged(QStringList)),this->pluginInfos,SLOT(updateInfos(QStringList)));
70 connect(this->addPluginBt,SIGNAL(clicked()),this,SLOT(addPlugin()));
70 connect(this->addPluginBt,SIGNAL(clicked()),this,SLOT(addPlugin()));
71 connect(this->removePluginBt,SIGNAL(clicked()),this,SLOT(removePlugin()));
71 connect(this->removePluginBt,SIGNAL(clicked()),this,SLOT(removePlugin()));
72 connect(this->pluginTable,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(loadplugin(QListWidgetItem*)));
72 connect(this->pluginTable,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(loadplugin(QListWidgetItem*)));
73 connect(this->refreshPluginListBt,SIGNAL(clicked()),this->pluginTable,SLOT(refreshPluginList()));
73 connect(this->refreshPluginListBt,SIGNAL(clicked()),this->pluginTable,SLOT(refreshPluginList()));
74 connect(this->treeview,SIGNAL(loadSysDriver(QString)),this,SIGNAL(loadSysDrviver(QString)));
74 connect(this->treeview,SIGNAL(loadSysDriver(QString)),this,SIGNAL(loadSysDrviver(QString)));
75 connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString)));
75 connect(this->treeview,SIGNAL(loadSysDriverToParent(QString,QString)),this,SIGNAL(loadSysDriverToParent(QString,QString)));
76 connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString)));
76 connect(this->treeview,SIGNAL(changeSysDriverInstName(QString,QString)),this,SIGNAL(changeSysDriverInstName(QString,QString)));
77 connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString)));
77 connect(this->treeview,SIGNAL(closeSysDriver(QString)),this,SIGNAL(closeSysDriver(QString)));
78 connect(this->treeview,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString)));
78 connect(this->treeview,SIGNAL(pluginselected(QString)),this,SIGNAL(pluginselected(QString)));
79 this->rootLoadable = false;
79 this->rootLoadable = false;
80 this->childLoadable = false;
80 this->childLoadable = false;
81 this->pluginTable->refreshPluginList();
81 this->pluginTable->refreshPluginList();
82 this->pluginTable->refreshPluginList();
82 this->pluginTable->refreshPluginList();
83 }
83 }
84
84
85
85
86 void pluginmanagerWDGT::setRootLoadable(bool flag)
86 void pluginmanagerWDGT::setRootLoadable(bool flag)
87 {
87 {
88 this->rootLoadable = flag;
88 this->rootLoadable = flag;
89 }
89 }
90
90
91
91
92 void pluginmanagerWDGT::setChildLoadable(bool flag)
92 void pluginmanagerWDGT::setChildLoadable(bool flag)
93 {
93 {
94 this->childLoadable = flag;
94 this->childLoadable = flag;
95 }
95 }
96
96
97
97
98
98
99
99
100 void pluginmanagerWDGT::addPlugin()
101 {
102 // /!\ TODO update it remove maximum operation from widget
103 // QString fileName = QFileDialog::getOpenFileName(this,tr("Open Plugin"), QDir::homePath(), tr("Plugin Files Files (*.dll *.so *.so.*)"));
104 // if(pluginloader::checklibrary(fileName))
105 // {
106 // QFile::copy(fileName,QString(SocExplorerEngine::pluginFolder())+"/"+ fileName.section('/',-1));
107 // }
108 // this->pluginTable->refreshPluginList();
109 }
110
111
112 void pluginmanagerWDGT::removePlugin()
113 {
114 // for(int i=0;i<this->pluginTable->selectedItems().count();i++)
115 // {
116 // QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
117 // if(item!=NULL)
118 // {
119 // QFile::remove(QString(SocExplorerEngine::pluginFolder())+"/"+item->text());
120 // }
121 // }
122 // this->pluginTable->refreshPluginList();
123 }
124
125
126
127 void pluginmanagerWDGT::loadplugin()
128 {
129 // for(int i=0;i<this->pluginTable->selectedItems().count();i++)
130 // {
131 // QListWidgetItem* item = this->pluginTable->selectedItems().at(i);
132 // if(item!=NULL)
133 // {
134 // QString plugin = QString(SocExplorerEngine::pluginFolder())+"/"+item->text();
135 // emit this->loadSysDrviver(plugin);
136 // }
137 // }
138 // this->pluginTable->refreshPluginList();
139 }
140
141
142
143
@@ -1,94 +1,90
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 #ifndef PLUGINMANAGERWDGT_H
22 #ifndef PLUGINMANAGERWDGT_H
23 #define PLUGINMANAGERWDGT_H
23 #define PLUGINMANAGERWDGT_H
24
24
25 #include <QApplication>
25 #include <QApplication>
26 #include <QWidget>
26 #include <QWidget>
27 #include <QDockWidget>
27 #include <QDockWidget>
28 #include <QVBoxLayout>
28 #include <QVBoxLayout>
29 #include <QHBoxLayout>
29 #include <QHBoxLayout>
30 #include <QTableWidget>
30 #include <QTableWidget>
31 #include <QDir>
31 #include <QDir>
32 #include <QStringList>
32 #include <QStringList>
33 #include <QFileInfoList>
33 #include <QFileInfoList>
34 #include <QFileInfo>
34 #include <QFileInfo>
35 #include <QTextEdit>
35 #include <QTextEdit>
36 #include <QPushButton>
36 #include <QPushButton>
37 #include <QSplitter>
37 #include <QSplitter>
38 #include "plugininfoswdgt.h"
38 #include "plugininfoswdgt.h"
39 #include "pluginlist.h"
39 #include "pluginlist.h"
40 #include <socexplorerplugin.h>
40 #include <socexplorerplugin.h>
41 #include <QList>
41 #include <QList>
42 #include "plugintree.h"
42 #include "plugintree.h"
43
43
44 #if defined(SOCEXPLORER_SDK_BUILD)
44 #if defined(SOCEXPLORER_SDK_BUILD)
45 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
45 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
46 #else
46 #else
47 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
47 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
48 #endif
48 #endif
49
49
50 class pluginmanagerWDGT : public QSplitter
50 class pluginmanagerWDGT : public QSplitter
51 {
51 {
52 Q_OBJECT
52 Q_OBJECT
53 public:
53 public:
54 SOCEXPLORER_SDK_EXPORT explicit pluginmanagerWDGT(QWidget *parent = 0);
54 SOCEXPLORER_SDK_EXPORT explicit pluginmanagerWDGT(QWidget *parent = 0);
55 SOCEXPLORER_SDK_EXPORT void setRootLoadable(bool flag);
55 SOCEXPLORER_SDK_EXPORT void setRootLoadable(bool flag);
56 SOCEXPLORER_SDK_EXPORT void setChildLoadable(bool flag);
56 SOCEXPLORER_SDK_EXPORT void setChildLoadable(bool flag);
57
57
58 signals:
58 signals:
59 void updatepluginInfo(const QString libname);
59 void updatepluginInfo(const QString libname);
60 void loadSysDrviver(const QString name);
60 void loadSysDrviver(const QString name);
61 void loadSysDriverToParent(const QString name, const QString instanceName);
61 void loadSysDriverToParent(const QString name, const QString instanceName);
62 void geteplugintree(void);
62 void geteplugintree(void);
63 void treeChanged(const QList<socexplorerplugin*>& drivers);
63 void treeChanged(const QList<socexplorerplugin*>& drivers);
64 void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
64 void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
65 void closeSysDriver(const QString instanceName);
65 void closeSysDriver(const QString instanceName);
66 void pluginselected(const QString& instanceName);
66 void pluginselected(const QString& instanceName);
67
67
68 public slots:
68 public slots:
69 //void libselected(int row);
69
70 void addPlugin();
71 void removePlugin();
72 void loadplugin();
73 //void loadplugin(QListWidgetItem*);
74
70
75 private:
71 private:
76
72
77 bool rootLoadable;
73 bool rootLoadable;
78 bool childLoadable;
74 bool childLoadable;
79 QWidget* pluginListWidgetContainer;
75 QWidget* pluginListWidgetContainer;
80 QVBoxLayout* pluginListLayout;
76 QVBoxLayout* pluginListLayout;
81 QHBoxLayout* ButtonsLayout;
77 QHBoxLayout* ButtonsLayout;
82 QSplitter* mainlayoutSpliter;
78 QSplitter* mainlayoutSpliter;
83 PluginList* pluginTable;
79 PluginList* pluginTable;
84 pluginInfosWdgt* pluginInfos;
80 pluginInfosWdgt* pluginInfos;
85 plugintree* treeview;
81 plugintree* treeview;
86 QPushButton* addPluginBt;
82 QPushButton* addPluginBt;
87 QPushButton* removePluginBt;
83 QPushButton* removePluginBt;
88 QPushButton* loadPluginBt;
84 QPushButton* loadPluginBt;
89 QPushButton* refreshPluginListBt;
85 QPushButton* refreshPluginListBt;
90
86
91
87
92 };
88 };
93
89
94 #endif // PLUGINMANAGERWDGT_H
90 #endif // PLUGINMANAGERWDGT_H
@@ -1,265 +1,264
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) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, 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
22
23 #include <socexplorerplugin.h>
23 #include <socexplorerplugin.h>
24 #include <abstractbinfile.h>
24 #include <abstractbinfile.h>
25 #include <srec/srecfile.h>
25 #include <srec/srecfile.h>
26 #include <BinFile/binaryfile.h>
26 #include <BinFile/binaryfile.h>
27
27
28 int socexplorerplugin::isConnected(){return this->Connected;}
28 int socexplorerplugin::isConnected(){return this->Connected;}
29
29
30 QString socexplorerplugin::baseName(){return *_Name;}
30 QString socexplorerplugin::baseName(){return *_Name;}
31
31
32 int socexplorerplugin::baseAddress(){return this->BaseAddress;}
32 int socexplorerplugin::baseAddress(){return this->BaseAddress;}
33
33
34 void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;}
34 void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;}
35
35
36 QString socexplorerplugin::instanceName()
36 QString socexplorerplugin::instanceName()
37 {
37 {
38 return this->_instanceName;
38 return this->_instanceName;
39 }
39 }
40
40
41 int socexplorerplugin::registermenu(QMenu *menu)
41 int socexplorerplugin::registermenu(QMenu *menu)
42 {
42 {
43 this->menu = menu->addMenu(this->_instanceName);
43 this->menu = menu->addMenu(this->_instanceName);
44 this->closeAction = this->menu->addAction(tr("Close plugin"));
44 this->closeAction = this->menu->addAction(tr("Close plugin"));
45 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
45 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
46 this->ChildsMenu = this->menu->addMenu(QString("Childs"));
46 this->ChildsMenu = this->menu->addMenu(QString("Childs"));
47 for(int i=0;i<this->childs.count();i++)
47 for(int i=0;i<this->childs.count();i++)
48 {
48 {
49 this->childs.at(i)->registermenu(this->ChildsMenu);
49 this->childs.at(i)->registermenu(this->ChildsMenu);
50 }
50 }
51 emit this->registerObject((QObject*)this,this->instanceName());
51 emit this->registerObject((QObject*)this,this->instanceName());
52 return 0;
52 return 0;
53 }
53 }
54
54
55 void socexplorerplugin::postInstantiationTrigger()
55 void socexplorerplugin::postInstantiationTrigger()
56 {
56 {
57 return;
57 return;
58 }
58 }
59
59
60 unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address)
60 unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address)
61 {
61 {
62 if(parent!=NULL)
62 if(parent!=NULL)
63 {
63 {
64 return parent->Write(Value,count,address);
64 return parent->Write(Value,count,address);
65 }
65 }
66 return 0;
66 return 0;
67 }
67 }
68
68
69 unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address)
69 unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address)
70 {
70 {
71 if(parent!=NULL)
71 if(parent!=NULL)
72 {
72 {
73 return parent->Read(Value,count,address);
73 return parent->Read(Value,count,address);
74 }
74 }
75 return 0;
75 return 0;
76 }
76 }
77
77
78 QVariantList socexplorerplugin::Read(unsigned int address,unsigned int count)
78 QVariantList socexplorerplugin::Read(unsigned int address,unsigned int count)
79 {
79 {
80 unsigned int data[count];
80 unsigned int data[count];
81 QVariantList result;
81 QVariantList result;
82 Read(data,count,address);
82 Read(data,count,address);
83 for(unsigned int i = 0;i<count;i++)
83 for(unsigned int i = 0;i<count;i++)
84 {
84 {
85 result.append(QVariant((int)data[i]));
85 result.append(QVariant((int)data[i]));
86 }
86 }
87 return result;
87 return result;
88 }
88 }
89 void socexplorerplugin::Write(unsigned int address,QList<QVariant> dataList)
89 void socexplorerplugin::Write(unsigned int address,QList<QVariant> dataList)
90 {
90 {
91 unsigned int data[dataList.count()];
91 unsigned int data[dataList.count()];
92 for(int i = 0;i<dataList.count();i++)
92 for(int i = 0;i<dataList.count();i++)
93 {
93 {
94 data[i] = (unsigned int)dataList.at(i).toUInt();
94 data[i] = (unsigned int)dataList.at(i).toUInt();
95 }
95 }
96 Write(data,dataList.count(),address);
96 Write(data,dataList.count(),address);
97 }
97 }
98
98
99
99
100
100
101 void socexplorerplugin::closeMe(){emit this->closePlugin(this);}
101 void socexplorerplugin::closeMe(){emit this->closePlugin(this);}
102
102
103 void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);}
103 void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);}
104
104
105 void socexplorerplugin::setInstanceName(const QString &newName)
105 void socexplorerplugin::setInstanceName(const QString &newName)
106 {
106 {
107 this->_instanceName = newName;
107 this->_instanceName = newName;
108 if(this->menu)
108 if(this->menu)
109 this->menu->setTitle(this->_instanceName);
109 this->menu->setTitle(this->_instanceName);
110 this->setWindowTitle(newName);
110 this->setWindowTitle(newName);
111 this->setObjectName(newName);
111 this->setObjectName(newName);
112 }
112 }
113
113
114 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file)
114 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file)
115 {
115 {
116 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
116 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
117 if(buffer!=NULL)
117 if(buffer!=NULL)
118 {
118 {
119 this->Read(buffer,count,address);
119 this->Read(buffer,count,address);
120 QFile outfile(file);
120 QFile outfile(file);
121 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
121 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
122 return false;
122 return false;
123 QTextStream out(&outfile);
123 QTextStream out(&outfile);
124 for(int i=0;(unsigned int)i<count;i++)
124 for(int i=0;(unsigned int)i<count;i++)
125 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
125 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
126 free(buffer);
126 free(buffer);
127 out.flush();
127 out.flush();
128 outfile.close();
128 outfile.close();
129 return true;
129 return true;
130 }
130 }
131 return false;
131 return false;
132 }
132 }
133
133
134 bool socexplorerplugin::memSet(unsigned int address, int value, unsigned int count)
134 bool socexplorerplugin::memSet(unsigned int address, int value, unsigned int count)
135 {
135 {
136 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
136 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
137 if(buffer!=NULL)
137 if(buffer!=NULL)
138 {
138 {
139 memset((void*)buffer,value,count*sizeof(unsigned int));
139 memset((void*)buffer,value,count*sizeof(unsigned int));
140 this->Write(buffer,count,address);
140 this->Write(buffer,count,address);
141 free(buffer );
141 free(buffer );
142 return true;
142 return true;
143 }
143 }
144 return false;
144 return false;
145 }
145 }
146
146
147 bool socexplorerplugin::loadbin(unsigned int address, QString file)
147 bool socexplorerplugin::loadbin(unsigned int address, QString file)
148 {
148 {
149 QFile infile(file);
149 QFile infile(file);
150 if (!infile.open(QIODevice::ReadOnly))
150 if (!infile.open(QIODevice::ReadOnly))
151 return false;
151 return false;
152 uint32_t* buffer = (uint32_t*)malloc(infile.size());
152 uint32_t* buffer = (uint32_t*)malloc(infile.size());
153 if(buffer!=NULL)
153 if(buffer!=NULL)
154 {
154 {
155 infile.read((char*)buffer,infile.size());
155 infile.read((char*)buffer,infile.size());
156 for(int i=0;i<(infile.size()/4);i++)
156 for(int i=0;i<(infile.size()/4);i++)
157 {
157 {
158 buffer[i] = socexplorerBswap32(buffer[i]);
158 buffer[i] = socexplorerBswap32(buffer[i]);
159 }
159 }
160 this->Write(buffer,infile.size()/4,address);
160 this->Write(buffer,infile.size()/4,address);
161 free(buffer);
161 free(buffer);
162 return true;
162 return true;
163 }
163 }
164 return false;
164 return false;
165
165
166 }
166 }
167
167
168 bool socexplorerplugin::loadfile(abstractBinFile *file)
168 bool socexplorerplugin::loadfile(abstractBinFile *file)
169 {
169 {
170 if(file->isopened())
170 if(file->isopened())
171 {
171 {
172 QList<codeFragment*> fragments= file->getFragments();
172 QList<codeFragment*> fragments= file->getFragments();
173 for(int i=0;i<fragments.count();i++)
173 for(int i=0;i<fragments.count();i++)
174 {
174 {
175 int size = fragments.at(i)->size/4;
175 int size = fragments.at(i)->size/4;
176 // TODO fixme, should be the oposite
176 // TODO fixme, should be the oposite
177 #if __BYTE_ORDER == __LITTLE_ENDIAN
177 #if __BYTE_ORDER == __LITTLE_ENDIAN
178 if(!file->litleendian)
178 if(!file->litleendian)
179 {
179 {
180 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
180 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
181 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
181 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
182 if(buffer!=NULL)
182 if(buffer!=NULL)
183 {
183 {
184 for(int l=0;l<(size);l++)
184 for(int l=0;l<(size);l++)
185 {
185 {
186 buffer[l] = socexplorerBswap32(buffer[l]);
186 buffer[l] = socexplorerBswap32(buffer[l]);
187 }
187 }
188 this->Write(buffer,size,fragments.at(i)->address);
188 this->Write(buffer,size,fragments.at(i)->address);
189 free(buffer);
189 free(buffer);
190 }
190 }
191 }
191 }
192 else
192 else
193 {
193 {
194 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
194 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
195 }
195 }
196 #elif __BYTE_ORDER == __BIG_ENDIAN
196 #elif __BYTE_ORDER == __BIG_ENDIAN
197 if(file->litleendian)
197 if(file->litleendian)
198 {
198 {
199 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
199 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
200 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
200 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
201 if(buffer!=NULL)
201 if(buffer!=NULL)
202 {
202 {
203 for(int l=0;l<(size);l++)
203 for(int l=0;l<(size);l++)
204 {
204 {
205 buffer[l] = socexplorerBswap32(buffer[l]);
205 buffer[l] = socexplorerBswap32(buffer[l]);
206 }
206 }
207 this->Write(buffer,size,fragments.at(i)->address);
207 this->Write(buffer,size,fragments.at(i)->address);
208 free(buffer);
208 free(buffer);
209 }
209 }
210 }
210 }
211 else
211 else
212 {
212 {
213 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
213 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
214 }
214 }
215 #endif
215 #endif
216 }
216 }
217 }
217 }
218 return true;
218 return true;
219 }
219 }
220
220
221 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file, const QString &format)
221 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file, const QString &format)
222 {
222 {
223 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
223 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
224 if(buffer!=NULL)
224 if(buffer!=NULL)
225 {
225 {
226 this->Read(buffer,count,address);
226 this->Read(buffer,count,address);
227 if(!format.compare("srec",Qt::CaseInsensitive))
227 if(!format.compare("srec",Qt::CaseInsensitive))
228 {
228 {
229 //need to convert from in memory endianness to file endianness
229 //need to convert from in memory endianness to file endianness
230 //SREC is always big endian
230 //SREC is always big endian
231 #if __BYTE_ORDER == __LITTLE_ENDIAN
231 #if __BYTE_ORDER == __LITTLE_ENDIAN
232 for(int l=0;l<(count);l++)
232 for(int l=0;l<(count);l++)
233 {
233 {
234 buffer[l] = socexplorerBswap32(buffer[l]);
234 buffer[l] = socexplorerBswap32(buffer[l]);
235 }
235 }
236 #elif __BYTE_ORDER == __BIG_ENDIAN
236 #elif __BYTE_ORDER == __BIG_ENDIAN
237
237
238 #endif
238 #endif
239 codeFragment fragment((char*)buffer,count*4,address);
239 codeFragment fragment((char*)buffer,count*4,address);
240 srecFile::toSrec(QList<codeFragment*>()<<&fragment,file);
240 srecFile::toSrec(QList<codeFragment*>()<<&fragment,file);
241 }
241 }
242 if(!format.compare("bin",Qt::CaseInsensitive))
242 if(!format.compare("bin",Qt::CaseInsensitive))
243 {
243 {
244 //beware this format is not portable from a big endian host to a litle endian one
244 //beware this format is not portable from a big endian host to a litle endian one
245 codeFragment fragment((char*)buffer,count*4,address);
245 codeFragment fragment((char*)buffer,count*4,address);
246 binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file);
246 binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file);
247 }
247 }
248 if(!format.compare("hexa",Qt::CaseInsensitive))
248 if(!format.compare("hexa",Qt::CaseInsensitive))
249 {
249 {
250 QFile outfile(file);
250 QFile outfile(file);
251 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
251 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
252 return false;
252 return false;
253 QTextStream out(&outfile);
253 QTextStream out(&outfile);
254 for(int i=0;(unsigned int)i<count;i++)
254 for(int i=0;(unsigned int)i<count;i++)
255 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
255 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
256 free(buffer);
256 free(buffer);
257 out.flush();
257 out.flush();
258 outfile.close();
258 outfile.close();
259 }
259 }
260 return true;
260 return true;
261 }
261 }
262 return false;
262 return false;
263 }
263 }
264
264
265
@@ -1,182 +1,182
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗
2 ███████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██████╗
3 ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
3 ██╔════╝██╔═══██╗██╔════╝ ██╔════╝╚██╗██╔╝██╔══██╗██║ ██╔═══██╗██╔══██╗██╔════╝██╔══██╗
4 ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝
4 ███████╗██║ ██║██║ █████╗ ╚███╔╝ ██████╔╝██║ ██║ ██║██████╔╝█████╗ ██████╔╝
5 ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗
5 ╚════██║██║ ██║██║ ██╔══╝ ██╔██╗ ██╔═══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ██╔══██╗
6 ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║
6 ███████║╚██████╔╝╚██████╗ ███████╗██╔╝ ██╗██║ ███████╗╚██████╔╝██║ ██║███████╗██║ ██║
7 ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
7 ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
8
8
9 -- This file is a part of the SOC Explorer Software
9 -- This file is a part of the SOC Explorer Software
10 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
10 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
11 --
11 --
12 -- This program is free software; you can redistribute it and/or modify
12 -- This program is free software; you can redistribute it and/or modify
13 -- it under the terms of the GNU General Public License as published by
13 -- it under the terms of the GNU General Public License as published by
14 -- the Free Software Foundation; either version 2 of the License, or
14 -- the Free Software Foundation; either version 2 of the License, or
15 -- (at your option) any later version.
15 -- (at your option) any later version.
16 --
16 --
17 -- This program is distributed in the hope that it will be useful,
17 -- This program is distributed in the hope that it will be useful,
18 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
18 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
19 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 -- GNU General Public License for more details.
20 -- GNU General Public License for more details.
21 --
21 --
22 -- You should have received a copy of the GNU General Public License
22 -- You should have received a copy of the GNU General Public License
23 -- along with this program; if not, write to the Free Software
23 -- along with this program; if not, write to the Free Software
24 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 -------------------------------------------------------------------------------*/
25 -------------------------------------------------------------------------------*/
26 /*-- Author : Alexis Jeandet
26 /*-- Author : Alexis Jeandet
27 -- Mail : alexis.jeandet@lpp.polytechnique.fr
27 -- Mail : alexis.jeandet@lpp.polytechnique.fr
28 ----------------------------------------------------------------------------*/
28 ----------------------------------------------------------------------------*/
29 #ifndef SOCEXPLORERPLUGIN_H
29 #ifndef SOCEXPLORERPLUGIN_H
30 #define SOCEXPLORERPLUGIN_H
30 #define SOCEXPLORERPLUGIN_H
31 #include <QWidget>
31 #include <QWidget>
32 #include <QAction>
32 #include <QAction>
33 #include <QDockWidget>
33 #include <QDockWidget>
34 #include <QMainWindow>
34 #include <QMainWindow>
35 #include <QList>
35 #include <QList>
36 #include <QMenu>
36 #include <QMenu>
37 #include <socexplorer.h>
37 #include <socexplorer.h>
38 #include <QObject>
38 #include <QObject>
39 #include <QVariant>
39 #include <QVariant>
40 #include <QVariantList>
40 #include <QVariantList>
41 #include <malloc.h>
41 #include <malloc.h>
42 #include <QFile>
42 #include <QFile>
43 #include <stdint.h>
43 #include <stdint.h>
44 #include <QTextStream>
44 #include <QTextStream>
45 #include <abstractbinfile.h>
45 #include <abstractbinfile.h>
46 #ifndef driver_Name
46 #ifndef driver_Name
47 #define driver_Name "Plugin"
47 #define driver_Name "Plugin"
48 #endif
48 #endif
49 #ifndef driver_Author
49 #ifndef driver_Author
50 #define driver_Author "No Author"
50 #define driver_Author "No Author"
51 #endif
51 #endif
52 #ifndef driver_Version
52 #ifndef driver_Version
53 #define driver_Version "0.0.0"
53 #define driver_Version "0.0.0"
54 #endif
54 #endif
55 #ifndef driver_Description
55 #ifndef driver_Description
56 #define driver_Description "No description."
56 #define driver_Description "No description."
57 #endif
57 #endif
58 #ifndef driver_can_be_root
58 #ifndef driver_can_be_root
59 #define driver_can_be_root 0
59 #define driver_can_be_root 0
60 #endif
60 #endif
61 #ifndef driver_can_be_child
61 #ifndef driver_can_be_child
62 #define driver_can_be_child 0
62 #define driver_can_be_child 0
63 #endif
63 #endif
64 #ifndef driver_VID
64 #ifndef driver_VID
65 #define driver_VID 0
65 #define driver_VID 0
66 #endif
66 #endif
67 #ifndef driver_PID
67 #ifndef driver_PID
68 #define driver_PID 0
68 #define driver_PID 0
69 #endif
69 #endif
70
70
71 #if defined(SOCEXPLORER_SDK_BUILD)
71 #if defined(SOCEXPLORER_SDK_BUILD)
72 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
72 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
73 #else
73 #else
74 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
74 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
75 #endif
75 #endif
76
76
77
77
78 //! socexplorerplugin is the base class for any SocExplorer plugin, it gives a standard interface to communicate
78 //! socexplorerplugin is the base class for any SocExplorer plugin, it gives a standard interface to communicate
79 //! between each plugins and to interact with SocExplorer software.
79 //! between each plugins and to interact with SocExplorer software.
80
80
81 class SOCEXPLORER_SDK_EXPORT socexplorerplugin : public QDockWidget
81 class SOCEXPLORER_SDK_EXPORT socexplorerplugin : public QDockWidget
82 {
82 {
83 Q_OBJECT
83 Q_OBJECT
84 public:
84 public:
85 //! Default plugin constructor, any plugin should call this constructor.
85 //! Default plugin constructor, any plugin should call this constructor.
86 socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent)
86 socexplorerplugin(QWidget *parent = 0,bool createPyObject=true):QDockWidget(parent)
87 {
87 {
88 Q_UNUSED(createPyObject)
88 Q_UNUSED(createPyObject)
89 closeAction=NULL;
89 closeAction=NULL;
90 menu=NULL;
90 menu=NULL;
91 ChildsMenu=NULL;
91 ChildsMenu=NULL;
92 this->Connected = false;
92 this->Connected = false;
93 this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar);
93 this->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetVerticalTitleBar);
94 _Name = new QString(driver_Name);
94 _Name = new QString(driver_Name);
95 _Author = new QString(driver_Author);
95 _Author = new QString(driver_Author);
96 _Version = new QString(driver_Version);
96 _Version = new QString(driver_Version);
97 _Description = new QString(driver_Description);
97 _Description = new QString(driver_Description);
98 _canBeChild = driver_can_be_child;
98 _canBeChild = driver_can_be_child;
99 _canBeRoot = driver_can_be_root;
99 _canBeRoot = driver_can_be_root;
100 _VID = driver_VID;
100 _VID = driver_VID;
101 _PID = driver_PID;
101 _PID = driver_PID;
102 }
102 }
103 //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces.
103 //! Tells if the plugin is connected, it is used to enable or disable all childrens interfaces.
104 virtual int isConnected();
104 virtual int isConnected();
105 //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found
105 //! Gives the associated Vendor IDentifier, usefull to automatically associate plugins with found
106 //! hardware while board enumeration.
106 //! hardware while board enumeration.
107 virtual int VID(){return _PID;}
107 virtual int VID(){return _PID;}
108 //! Gives the associated Product IDentifier, usefull to automatically associate plugins with found
108 //! Gives the associated Product IDentifier, usefull to automatically associate plugins with found
109 //! hardware while board enumeration.
109 //! hardware while board enumeration.
110 virtual int PID(){return _VID;}
110 virtual int PID(){return _VID;}
111 //! Gives the plugin's base name, usefull to automatically generate instance name.
111 //! Gives the plugin's base name, usefull to automatically generate instance name.
112 virtual QString baseName();
112 virtual QString baseName();
113 //! Gives the base address of the current instance, for example if your plugin is supposed to drive
113 //! Gives the base address of the current instance, for example if your plugin is supposed to drive
114 //! an UART it will correspond to the address of it's first register. This address have at least to
114 //! an UART it will correspond to the address of it's first register. This address have at least to
115 //! be set by SocExplorer and it can be user accessible if you want.
115 //! be set by SocExplorer and it can be user accessible if you want.
116 virtual int baseAddress();
116 virtual int baseAddress();
117 //! Sets the base address of the current instance, for example if your plugin is supposed to drive
117 //! Sets the base address of the current instance, for example if your plugin is supposed to drive
118 //! an UART it will correspond to the address of it's first register. This address have at least to
118 //! an UART it will correspond to the address of it's first register. This address have at least to
119 //! be set by SocExplorer and it can be user accessible if you want.
119 //! be set by SocExplorer and it can be user accessible if you want.
120 virtual void setBaseAddress(unsigned int baseAddress);
120 virtual void setBaseAddress(unsigned int baseAddress);
121
121
122 QList<socexplorerplugin*> childs;
122 QList<socexplorerplugin*> childs;
123 socexplorerplugin* parent;
123 socexplorerplugin* parent;
124 QAction* closeAction;
124 QAction* closeAction;
125 QString instanceName();
125 QString instanceName();
126 QString instance(){return instanceName();}
126 QString instance(){return instanceName();}
127 QMenu* menu;
127 QMenu* menu;
128 QMenu* ChildsMenu;
128 QMenu* ChildsMenu;
129
129
130 signals:
130 signals:
131 //! Signal emited each time the plugin is about to be closed.
131 //! Signal emited each time the plugin is about to be closed.
132 void closePlugin(socexplorerplugin* driver);
132 void closePlugin(socexplorerplugin* driver);
133 void activateSig(bool flag);
133 void activateSig(bool flag);
134 void registerObject(QObject* object,const QString& instanceName);
134 void registerObject(QObject* object,const QString& instanceName);
135
135
136 public slots:
136 public slots:
137 virtual int registermenu(QMenu* menu);
137 virtual int registermenu(QMenu* menu);
138 virtual void postInstantiationTrigger();
138 virtual void postInstantiationTrigger();
139 //! Write slot this is the way your children plugins ask you for writing data.
139 //! Write slot this is the way your children plugins ask you for writing data.
140 //! If your plugin is supposed to have childern drivers you should implement this methode.
140 //! If your plugin is supposed to have childern drivers you should implement this methode.
141 //! By default this methode forward the write request to the parent plugin.
141 //! By default this methode forward the write request to the parent plugin.
142 //! \param Value Pointer the data buffer.
142 //! \param Value Pointer the data buffer.
143 //! \param count Number of 32 bits words you should to write.
143 //! \param count Number of 32 bits words you should to write.
144 //! \param address Address from where you should to start to write.
144 //! \param address Address from where you should to start to write.
145 //! \return Quantity of 32 bits words writtens.
145 //! \return Quantity of 32 bits words writtens.
146 virtual unsigned int Write(unsigned int* Value, unsigned int count,unsigned int address);
146 virtual unsigned int Write(unsigned int* Value, unsigned int count,unsigned int address);
147 //! Read slot this is the way your children plugins ask you for reading data.
147 //! Read slot this is the way your children plugins ask you for reading data.
148 //! If your plugin is supposed to have childern drivers you should implement this methode.
148 //! If your plugin is supposed to have childern drivers you should implement this methode.
149 //! By default this methode forward the write request to the parent plugin.
149 //! By default this methode forward the write request to the parent plugin.
150 //! \param Value Pointer the data buffer.
150 //! \param Value Pointer the data buffer.
151 //! \param count Number of 32 bits words you should to read.
151 //! \param count Number of 32 bits words you should to read.
152 //! \param address Address from where you should to start to read.
152 //! \param address Address from where you should to start to read.
153 //! \return Quantity of 32 bits words read.
153 //! \return Quantity of 32 bits words read.
154 virtual unsigned int Read(unsigned int* Value, unsigned int count,unsigned int address);
154 virtual unsigned int Read(unsigned int* Value, unsigned int count,unsigned int address);
155 virtual void closeMe();
155 virtual void closeMe();
156 virtual void activate(bool flag);
156 virtual void activate(bool flag);
157 virtual void setInstanceName(const QString& newName);
157 virtual void setInstanceName(const QString& newName);
158
158
159 virtual bool dumpMemory(unsigned int address,unsigned int count,QString file);
159 virtual bool dumpMemory(unsigned int address,unsigned int count,QString file);
160 virtual bool dumpMemory(unsigned int address,unsigned int count,QString file,const QString& format);
160 virtual bool memSet(unsigned int address,int value, unsigned int count);
161 virtual bool memSet(unsigned int address,int value, unsigned int count);
161 virtual bool loadbin(unsigned int address,QString file);
162 virtual bool loadbin(unsigned int address,QString file);
162 virtual bool loadfile(abstractBinFile* file);
163 virtual bool loadfile(abstractBinFile* file);
163 virtual bool dumpMemory(unsigned int address,unsigned int count,QString file,const QString& format);
164 QVariantList Read(unsigned int address, unsigned int count);
164 QVariantList Read(unsigned int address, unsigned int count);
165 void Write(unsigned int address, QList<QVariant> dataList);
165 void Write(unsigned int address, QList<QVariant> dataList);
166 socexplorerplugin* parentPlugin(){return this->parent;}
166 socexplorerplugin* parentPlugin(){return this->parent;}
167 socexplorerplugin* toPlugin(){return (socexplorerplugin*)this;}
167 socexplorerplugin* toPlugin(){return (socexplorerplugin*)this;}
168 protected:
168 protected:
169 int BaseAddress;
169 int BaseAddress;
170 bool Connected;
170 bool Connected;
171 QString* _Name;
171 QString* _Name;
172 QString* _Author;
172 QString* _Author;
173 QString* _Version;
173 QString* _Version;
174 QString* _Description;
174 QString* _Description;
175 QString _instanceName;
175 QString _instanceName;
176 int _canBeChild;
176 int _canBeChild;
177 int _canBeRoot;
177 int _canBeRoot;
178 int _VID;
178 int _VID;
179 int _PID;
179 int _PID;
180 };
180 };
181
181
182 #endif // SOCEXPLORERPLUGIN_H
182 #endif // SOCEXPLORERPLUGIN_H
@@ -1,113 +1,122
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 #include <QCommandLineOption>
32 #include <QCommandLineOption>
33 #include <QCommandLineParser>
33 #include <QCommandLineParser>
34
34
35
35
36 QCommandLineOption executeOption = QCommandLineOption (
36 QCommandLineOption executeOption = QCommandLineOption (
37 QStringList() << "e" << "execute",
37 QStringList() << "e" << "execute",
38 QCoreApplication::translate("main", "Execute given script <script>."),
38 QCoreApplication::translate("main", "Execute given script <script>."),
39 QCoreApplication::translate("main", "script"));
39 QCoreApplication::translate("main", "script"));
40
40
41 QCommandLineOption debugLevelOption = QCommandLineOption (
41 QCommandLineOption debugLevelOption = QCommandLineOption (
42 QStringList() << "d" << "debug-level",
42 QStringList() << "d" << "debug-level",
43 QCoreApplication::translate("main", "Execute given script <script>."),
43 QCoreApplication::translate("main", "Sets debug level to <level>, higher the level is more verbose the application will be."),
44 QCoreApplication::translate("main", "script"),
44 QCoreApplication::translate("main", "level"),
45 "1");
45 "1");
46
46
47 QCommandLineOption noGUIOption = QCommandLineOption (
47 QCommandLineOption noGUIOption = QCommandLineOption (
48 QStringList() << "n" << "no-gui",
48 QStringList() << "n" << "no-gui",
49 QCoreApplication::translate("main", "Starts SocExplorer in batch mode."));
49 QCoreApplication::translate("main", "Starts SocExplorer in batch mode[not fully implemented yet!]."));
50
50
51 const char* socexplorerDesc="\
51 const char* socexplorerDesc="\
52 SocExplorer is an open source generic System On Chip testing software/framework.\
52 SocExplorer is an open source generic System On Chip testing software/framework.\
53 We write this software for the development and the validation of our instrument,\
53 We write this software for the development and the validation of our instrument,\
54 the Low Frequency Receiver(LFR) for the Solar Orbiter mission. This instrument is\
54 the Low Frequency Receiver(LFR) for the Solar Orbiter mission. This instrument is\
55 based on an actel FPGA hosting a LEON3FT processor and some peripherals. To make\
55 based on an actel FPGA hosting a LEON3FT processor and some peripherals. To make\
56 it more collaborative, we use a plugin based system, the main executable is SocExplorer\
56 it more collaborative, we use a plugin based system, the main executable is SocExplorer\
57 then all the functionality are provided by plugins. Like this everybody can provide\
57 then all the functionality are provided by plugins. Like this everybody can provide\
58 his set of plugins to handle a new SOC or just a new peripheral. SocExplorer uses\
58 his set of plugins to handle a new SOC or just a new peripheral. SocExplorer uses\
59 PythonQt to allow user to automate some tasks such as loading some plugins, configuring\
59 PythonQt to allow user to automate some tasks such as loading some plugins, configuring\
60 them and talking with his device. SocExplorer is provided under the terms of the GNU\
60 them and talking with his device. SocExplorer is provided under the terms of the GNU\
61 General Public License as published by the Free Software Foundation; either version 2\
61 General Public License as published by the Free Software Foundation; either version 2\
62 of the License, or (at your option) any later version.";
62 of the License, or (at your option) any later version.";
63
63
64 int main(int argc, char *argv[])
64 int main(int argc, char *argv[])
65 {
65 {
66 QApplication a(argc, argv);
66 QApplication a(argc, argv);
67 QString scriptToEval;
67 QString scriptToEval;
68 QApplication::setOrganizationName("LPP");
68 QApplication::setOrganizationName("LPP");
69 QApplication::setOrganizationDomain("lpp.fr");
69 QApplication::setOrganizationDomain("lpp.fr");
70 QApplication::setApplicationName("SocExplorer");
70 QApplication::setApplicationName("SocExplorer");
71 QCommandLineParser parser;
71 QCommandLineParser parser;
72 parser.setApplicationDescription(socexplorerDesc);
72 parser.setApplicationDescription(socexplorerDesc);
73 parser.addHelpOption();
73 parser.addHelpOption();
74 parser.addVersionOption();
74 parser.addVersionOption();
75 bool noGUI=false;
75 bool noGUI=false;
76 parser.addPositionalArgument("file", QCoreApplication::translate("main", "The Python file to execute."));
76 parser.addOption(executeOption);
77 parser.addOption(executeOption);
77 parser.addOption(debugLevelOption);
78 parser.addOption(debugLevelOption);
78 parser.addOption(noGUIOption);
79 parser.addOption(noGUIOption);
79 parser.process(a);
80 parser.process(a);
80 if(parser.isSet(executeOption))
81 if(parser.isSet(executeOption))
81 {
82 {
82 scriptToEval = parser.value(executeOption);
83 scriptToEval = parser.value(executeOption);
83 if(!QFile::exists(scriptToEval))
84 if(!QFile::exists(scriptToEval))
84 {
85 {
85 scriptToEval.clear();
86 scriptToEval.clear();
86 }
87 }
87 }
88 }
89 else
90 {
91 scriptToEval = parser.positionalArguments().first();
92 if(!QFile::exists(scriptToEval))
93 {
94 scriptToEval.clear();
95 }
96 }
88 if(parser.isSet(debugLevelOption))
97 if(parser.isSet(debugLevelOption))
89 {
98 {
90 bool success;
99 bool success;
91 int lvl;
100 int lvl;
92 lvl = parser.value(debugLevelOption).toInt(&success,10);
101 lvl = parser.value(debugLevelOption).toInt(&success,10);
93 if(success)
102 if(success)
94 {
103 {
95 SocExplorerEngine::setLogLevel(lvl);
104 SocExplorerEngine::setLogLevel(lvl);
96 }
105 }
97 }
106 }
98 if(parser.isSet(noGUIOption))
107 if(parser.isSet(noGUIOption))
99 {
108 {
100 noGUI = true;
109 noGUI = true;
101 qDebug() << "CLI mode";
110 qDebug() << "CLI mode";
102 }
111 }
103 SocExplorerMainWindow w(scriptToEval);
112 SocExplorerMainWindow w(scriptToEval);
104 if(!noGUI)
113 if(!noGUI)
105 {
114 {
106 w.show();
115 w.show();
107 }
116 }
108 else
117 else
109 {
118 {
110
119
111 }
120 }
112 return a.exec();
121 return a.exec();
113 }
122 }
@@ -1,17 +1,17
1 [Desktop Entry]
1 [Desktop Entry]
2 Version=1.0
2 Version=1.0
3 Name=SocExplorer
3 Name=SocExplorer
4 Name[en_US]=SocExplorer
4 Name[en_US]=SocExplorer
5
5
6 Type=Application
6 Type=Application
7 GenericName=Soc Explorer
7 GenericName=Soc Explorer
8
8
9 Comment=Software to monitor and explore Soc devices.
9 Comment=Software to monitor and explore Soc devices.
10
10
11 Exec=socexplorer -e %U
11 Exec=socexplorer %U
12 Icon=/usr/share/SocExplorer/icon.png
12 Icon=/usr/share/SocExplorer/icon.png
13 Terminal=false
13 Terminal=false
14
14
15 Categories=Electronics;Engineering;
15 Categories=Development;Engineering;
16
16
17 MimeType=text/x-python;
17 MimeType=text/x-python;
General Comments 0
You need to be logged in to leave comments. Login now