|
|
/*------------------------------------------------------------------------------
|
|
|
-- 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 "stardundeegui.h"
|
|
|
|
|
|
#include "ui_stardundeeGUI.h"
|
|
|
#include <spw_usb_api.h>
|
|
|
#include <spw_config_library.h>
|
|
|
|
|
|
StarDundeeGUI::StarDundeeGUI(QWidget *parent) :
|
|
|
QWidget(parent),ui(new Ui::StarDundeeUI)
|
|
|
{
|
|
|
this->ui->setupUi(this);
|
|
|
connect(this->ui->selectBrickCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(brickSelectionChanged(int)));
|
|
|
connect(this->ui->selectLinkCmbx,SIGNAL(currentIndexChanged(int)),this,SIGNAL(linkNumberSelectionChanged(int)));
|
|
|
connect(this->ui->setLinkSpeedCmbx,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(linkSpeedSelectionChanged(QString)));
|
|
|
connect(this->ui->destKeyLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(destinationKeyChanged(QString)));
|
|
|
connect(this->ui->RMAPAddresslineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapAddressChanged(QString)));
|
|
|
connect(this->ui->RMAPKeylineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapKeyChanged(QString)));
|
|
|
connect(this->ui->RMAPTimeoutLineEdit,SIGNAL(textChanged(QString)),this,SIGNAL(rmapTimeoutChanged(QString)));
|
|
|
connect(this->ui->connectQpb,SIGNAL(clicked()),this,SIGNAL(connectClicked()));
|
|
|
|
|
|
}
|
|
|
|
|
|
int StarDundeeGUI::getBrickSelection()
|
|
|
{
|
|
|
return ui->selectBrickCmbx->currentIndex();
|
|
|
}
|
|
|
|
|
|
int StarDundeeGUI::getLinkNumberSelection()
|
|
|
{
|
|
|
return ui->selectLinkCmbx->currentIndex();
|
|
|
}
|
|
|
|
|
|
QString StarDundeeGUI::getLinkSpeedSelection()
|
|
|
{
|
|
|
return ui->setLinkSpeedCmbx->currentText();
|
|
|
}
|
|
|
|
|
|
QString StarDundeeGUI::getDestinationKey()
|
|
|
{
|
|
|
return ui->destKeyLineEdit->text();
|
|
|
}
|
|
|
|
|
|
QString StarDundeeGUI::getRmapAddress()
|
|
|
{
|
|
|
return ui->RMAPAddresslineEdit->text();
|
|
|
}
|
|
|
|
|
|
QString StarDundeeGUI::getRmapKey()
|
|
|
{
|
|
|
return ui->RMAPKeylineEdit->text();
|
|
|
}
|
|
|
|
|
|
QString StarDundeeGUI::getRmapTimeout()
|
|
|
{
|
|
|
return ui->RMAPTimeoutLineEdit->text();
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void StarDundeeGUI::lock(bool lock)
|
|
|
{
|
|
|
this->ui->selectBrickCmbx->setDisabled(lock);
|
|
|
this->ui->selectLinkCmbx->setDisabled(lock);
|
|
|
this->ui->setLinkSpeedCmbx->setDisabled(lock);
|
|
|
this->ui->destKeyLineEdit->setDisabled(lock);
|
|
|
this->ui->RMAPAddresslineEdit->setDisabled(lock);
|
|
|
this->ui->RMAPKeylineEdit->setDisabled(lock);
|
|
|
this->ui->RMAPTimeoutLineEdit->setDisabled(lock);
|
|
|
if(lock)
|
|
|
this->ui->connectQpb->setText("Disconnect");
|
|
|
else
|
|
|
this->ui->connectQpb->setText("Connect");
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::updateAvailableBrickCount(int count)
|
|
|
{
|
|
|
this->ui->selectBrickCmbx->clear();
|
|
|
this->ui->selectBrickCmbx->addItem("none");
|
|
|
for(int i =0;i<32;i++)
|
|
|
{
|
|
|
if((count&1)==1)
|
|
|
{
|
|
|
star_device_handle hDevice;
|
|
|
char serial[11]="";
|
|
|
if (USBSpaceWire_Open(&hDevice, 0))
|
|
|
{
|
|
|
USBSpaceWire_GetSerialNumber(hDevice,(U8*) serial);
|
|
|
USBSpaceWire_Close(hDevice);
|
|
|
}
|
|
|
this->ui->selectBrickCmbx->addItem("STAR-Dundee USB brick "+QString::number(i)+" sn:" + serial);
|
|
|
}
|
|
|
count>>=1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::setRmapTimeout(const QString &timeout)
|
|
|
{
|
|
|
this->ui->RMAPTimeoutLineEdit->setText(timeout);
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::selectBrick(int brickIndex)
|
|
|
{
|
|
|
if(brickIndex>=0&& brickIndex<this->ui->selectBrickCmbx->count())
|
|
|
{
|
|
|
this->ui->selectBrickCmbx->setCurrentIndex(brickIndex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::selectLinkNumber(int linkNumber)
|
|
|
{
|
|
|
if(linkNumber==1 || linkNumber==2)
|
|
|
{
|
|
|
this->ui->selectLinkCmbx->setCurrentIndex(linkNumber-1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::selectLinkSpeed(int linkSpeed)
|
|
|
{
|
|
|
#define MHz *(1000*1000)
|
|
|
if(linkSpeed==10 MHz)
|
|
|
{
|
|
|
this->ui->selectLinkCmbx->setCurrentIndex(0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::setDestinationKey(const QString &destKey)
|
|
|
{
|
|
|
bool ok;
|
|
|
int Key=destKey.toInt(&ok,10);
|
|
|
if(ok)
|
|
|
{
|
|
|
this->ui->destKeyLineEdit->setText(destKey);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::setRmapAddress(const QString &address)
|
|
|
{
|
|
|
bool ok;
|
|
|
int tmp=address.toInt(&ok,10);
|
|
|
if(ok)
|
|
|
{
|
|
|
this->ui->RMAPAddresslineEdit->setText(address);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void StarDundeeGUI::setRmapKey(const QString &key)
|
|
|
{
|
|
|
bool ok;
|
|
|
int tmp=key.toInt(&ok,10);
|
|
|
if(ok)
|
|
|
{
|
|
|
this->ui->RMAPKeylineEdit->setText(key);
|
|
|
}
|
|
|
}
|
|
|
|