/*------------------------------------------------------------------------------ -- This file is a part of the SocExplorer Software -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------------*/ /*-- Author : Alexis Jeandet -- Mail : alexis.jeandet@lpp.polytechnique.fr ----------------------------------------------------------------------------*/ #include "memctrlrplugin.h" memctrlrplugin::memctrlrplugin(QWidget *parent):socexplorerplugin(parent,false) { this->UI = new memctrlrPluginUi(); this->setWidget((QWidget*)this->UI); connect(this->UI,SIGNAL(WriteSig(uint*,uint,uint)),this,SLOT(Write(uint*,uint,uint))); connect(this->UI,SIGNAL(ReadSig(uint*,uint,uint)),this,SLOT(Read(uint*,uint,uint))); // this->pyObject = new memctrlrPyWrapper(this); // connect(this->pyObject,SIGNAL(launchTest(uint,uint)),this,SLOT(launchTest(uint,uint))); } memctrlrplugin::~memctrlrplugin() {} int memctrlrplugin::registermenu(QMainWindow *menuHolder) { this->menu = menuHolder->menuBar()->addMenu(tr("&Memory Controler")); this->closeAction = this->menu->addAction(tr("Close plugin")); QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe())); return 1; } unsigned int memctrlrplugin::Write(unsigned int *Value,unsigned int count,unsigned int address) { if(parent) return parent->Write(Value,count,address); return 0; } unsigned int memctrlrplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) { if(parent) return parent->Read(Value,count,address); return 0; } bool memctrlrplugin::launchTest(unsigned int baseAddress,unsigned int size) { if(parent==NULL)return false; unsigned int* dataLocal = (unsigned int*)malloc(size); unsigned int* dataOnBoard = (unsigned int*)malloc(size); bool res=true; for(int i=0;(unsigned int)i<(size>>2);i++) { dataLocal[i]= (0xFFFF&rand())+(rand()<<16); } parent->Write(dataLocal,size>>2,baseAddress); parent->Read(dataOnBoard,size>>2,baseAddress); for(int i=0;(unsigned int)i<(size>>2);i++) { if(dataLocal[i]!=dataOnBoard[i]) res=false; } free(dataLocal); free(dataOnBoard); return res; }