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