##// END OF EJS Templates
Étiquette socexplorer-plugins-0.7-7 ajoutée à la révision b7137547140e
Étiquette socexplorer-plugins-0.7-7 ajoutée à la révision b7137547140e

File last commit:

r64:c92c4a05386a default
r102:21039a925364 tip default
Show More
apbpluginui.cpp
104 lines | 3.8 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- 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 "apbpluginui.h"
#include <stdint.h>
#include <socexplorerengine.h>
apbPluginUi::apbPluginUi(socexplorerplugin *plugin, QWidget *parent) :
QWidget(parent)
{
this->setWindowTitle(tr("APB Driver"));
this->mainlayout = new QHBoxLayout;
this->scanBp = new QPushButton(tr("Scan APB"));
this->deviceslst = new apbdevicelist;
this->mainlayout->addWidget(this->deviceslst);
this->mainlayout->addWidget(this->scanBp);
this->setLayout(this->mainlayout);
this->_plugin = plugin;
connect(this,SIGNAL(addAPBdevice(apbdeviceInfo*)),this->deviceslst,SLOT(addAPBdevice(apbdeviceInfo*)));
connect(this,SIGNAL(clearAPBdevicesList()),this->deviceslst,SLOT(clearAPBdevicesList()));
connect(this->scanBp,SIGNAL(clicked()),this,SLOT(scanAPB()));
}
void apbPluginUi::lockScanBp()
{
this->scanBp->setEnabled(false);
}
void apbPluginUi::unlockScanBp()
{
this->scanBp->setEnabled(true);
}
apbdeviceInfo* apbPluginUi::extractInfos(int *pnpregs)
{
APBbarreg BAR[1];
int VID;
int PID;
for(int i=0;i<1;i++)
{
BAR[i].address = ((uint32_t)(pnpregs[i+1] & 0xfff00000)>>12)+ APB_BUS_START;
BAR[i].size = ((pnpregs[i+1] & 0x00000ff0)>>4 )+1;
BAR[i].type = (unsigned char)(pnpregs[i+1]&0xf);
}
VID = (pnpregs[0]>>24)&0xff;
PID = (pnpregs[0]>>12)&0xfff;
QString devname = SocExplorerEngine::getDevName(VID,PID);
return new apbdeviceInfo(devname,BAR[0],VID,PID);
}
void apbPluginUi::scanAPB()
{
this->lockScanBp();
unsigned int size = (APB_PLUGNPLAY_STOP - APB_PLUGNPLAY_START)/4;
int j=0;
unsigned long long i = APB_PLUGNPLAY_START;
int pnpregs[size];
emit this->clearAPBdevicesList();
this->devList.clear();
if(this->_plugin->Read((unsigned int*)pnpregs,size,(unsigned int)APB_PLUGNPLAY_START)==size)
{
while(i<APB_PLUGNPLAY_STOP)
{
if(pnpregs[j]!=0)
{
apbdeviceInfo* devinfos=this->extractInfos(pnpregs+j);
SocExplorerEngine::addEnumDevice(this->_plugin,devinfos->VID,devinfos->PID,devinfos->BAR[0].address,devinfos->deviceName);
if(!this->devList.contains(devinfos->BAR[0].address))
{
this->devList.append(devinfos->BAR[0].address);
emit this->addAPBdevice(devinfos);
}
}
i+=8;
j+=2;
// if(pnpregs[0]!=0&&pnpregs[0]==pnpregs[j]&&pnpregs[1]==pnpregs[j+1])break;
}
}
this->unlockScanBp();
}