/*------------------------------------------------------------------------------ -- This file is a part of the SocExplorer Software -- Copyright (C) 2014, 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@member.fsf.org ----------------------------------------------------------------------------*/ #include "spwplugin.h" #include "stardundeespw_usb.h" #include spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) { Q_UNUSED(parent) this->bridge = NULL; this->scanDone = false; this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this); this->bridgeSelector = new QComboBox(this); this->mainLayout = new QGridLayout(this); this->mainLayout->addWidget(new QLabel("Select SpaceWire bridge",this),0,0,1,1,Qt::AlignCenter); this->mainLayout->addWidget(this->bridgeSelector,0,1,1,1); this->mainGroupBox->setLayout(this->mainLayout); this->setWidget(this->mainGroupBox); this->bridgeSelector->addItem("none"); this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick"); connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString))); } spwplugin::~spwplugin() { } unsigned int spwplugin::Read(unsigned int *Value,unsigned int count,unsigned int address) { if(Connected) { return bridge->Read(Value,count,address); } return 0; } void spwplugin::bridgeSelectionChanged(const QString &text) { printf("test"); if(text=="none") { if(this->bridge!=NULL) { this->mainLayout->removeWidget(this->bridge->getGUI()); this->disconnect(this,SLOT(setConnected(bool))); delete this->bridge; this->bridge= NULL; } } if(text=="STAR-Dundee Spw USB Brick") { if(this->bridge!=NULL) { this->mainLayout->removeWidget(this->bridge->getGUI()); this->disconnect(this,SLOT(setConnected(bool))); delete this->bridge; } this->bridge = new stardundeeSPW_USB(this); this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool))); } } void spwplugin::setConnected(bool connected) { this->bridgeSelector->setDisabled(connected); this->Connected = connected; emit activateSig(connected); } unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) { if(Connected) { return bridge->Write(Value,count,address); } return 0; }