spwplugin.cpp
103 lines
| 3.1 KiB
| text/x-c
|
CppLexer
/ spwplugin / spwplugin.cpp
r0 | /*------------------------------------------------------------------------------ | |||
Jeandet Alexis
|
r8 | -- This file is a part of the SocExplorer Software | ||
-- Copyright (C) 2014, Laboratory of Plasmas Physic - 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 | ||||
r0 | -------------------------------------------------------------------------------*/ | |||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
Jeandet Alexis
|
r8 | |||
r0 | #include "spwplugin.h" | |||
#include "stardundeespw_usb.h" | ||||
Jeandet Alexis
|
r7 | #include <socexplorerproxy.h> | ||
r0 | ||||
spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,true) | ||||
{ | ||||
Q_UNUSED(parent) | ||||
Jeandet Alexis
|
r8 | this->bridge = NULL; | ||
Jeandet Alexis
|
r7 | this->scanDone = false; | ||
Jeandet Alexis
|
r8 | 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))); | ||||
r0 | } | |||
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; | ||||
} | ||||
Jeandet Alexis
|
r8 | void spwplugin::bridgeSelectionChanged(const QString &text) | ||
{ | ||||
printf("test"); | ||||
if(text=="none") | ||||
{ | ||||
if(this->bridge!=NULL) | ||||
{ | ||||
this->mainLayout->removeWidget(this->bridge->getGUI()); | ||||
delete this->bridge; | ||||
this->bridge= NULL; | ||||
} | ||||
} | ||||
if(text=="STAR-Dundee Spw USB Brick") | ||||
{ | ||||
if(this->bridge!=NULL) | ||||
{ | ||||
this->mainLayout->removeWidget(this->bridge->getGUI()); | ||||
delete this->bridge; | ||||
} | ||||
this->bridge = new stardundeeSPW_USB(this); | ||||
this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2); | ||||
} | ||||
} | ||||
Jeandet Alexis
|
r7 | |||
r0 | unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address) | |||
{ | ||||
if(Connected) | ||||
{ | ||||
return bridge->Write(Value,count,address); | ||||
} | ||||
return 0; | ||||
} | ||||