##// END OF EJS Templates
Functions added to the plugin to get the number of CCSDS packets...
Functions added to the plugin to get the number of CCSDS packets transmitted (linked to the lfrcontrol plugin counter of TC transmitted, it is possible to flush the TC transmission before changing the spacewire link in use)

File last commit:

r40:cda6b4e8adc1 Patch 3 from Paul on spwplugin default
r40:cda6b4e8adc1 Patch 3 from Paul on spwplugin default
Show More
spwplugin.cpp
180 lines | 8.0 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- 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 "gr_esb_bridge.h"
#include <socexplorerproxy.h>
#include "spwpywrapper.h"
spwplugin::spwplugin(QWidget *parent):socexplorerplugin(parent,false)
{
Q_UNUSED(parent)
this->bridge = NULL;
this->scanDone = false;
this->pyObject = new spwPyWrapper(this);
this->tcpServer = new SpwTcpPacketServer(this);
this->mainGroupBox = new QGroupBox("SpaceWire Plugin Configuration",this);
this->bridgeSelector = new QComboBox(this);
this->mainTabWidgt = new QTabWidget(this);
this->mainTabWidgt->addTab(this->mainGroupBox,"Bridge Configuration");
this->mainTabWidgt->addTab(this->tcpServer,"TCP Server");
this->mainLayout = new QGridLayout(this->mainGroupBox);
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->setWidget(this->mainTabWidgt);
this->bridgeSelector->addItem("none");
this->bridgeSelector->addItem("STAR-Dundee Spw USB Brick");
this->bridgeSelector->addItem("GR-ESB");
connect(this->bridgeSelector,SIGNAL(currentIndexChanged(QString)),this,SLOT(bridgeSelectionChanged(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(selectBridge(QString)),this,SLOT(selectBridge(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerConnect()),this->tcpServer,SLOT(connectServer()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerDisconnect()),this->tcpServer,SLOT(disconnectServer()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetPort(qint32)),this->tcpServer,SLOT(setServerPort(qint32)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(TCPServerSetIP(QString)),this->tcpServer,SLOT(setServerSetIP(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)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectBrick(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectBrick(int)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkNumber(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkNumber(int)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSelectLinkSpeed(int)),((stardundeeSPW_USB*)bridge),SIGNAL(SelectLinkSpeed(int)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetSourceAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetSourceAddress(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationAddress(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationAddress(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetDestinationKey(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetDestinationKey(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetRmapTimeout(QString)),((stardundeeSPW_USB*)bridge),SIGNAL(SetRmapTimeout(QString)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(connectBridge()),((stardundeeSPW_USB*)bridge),SLOT(connectBridge()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(disconnectBridge()),((stardundeeSPW_USB*)bridge),SLOT(disconnectBridge()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetAvailableBrickCount()),
((stardundeeSPW_USB*)bridge),SIGNAL(GetAvailableBrickCount()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetNbPacketsTransmittedToSpw()),
((stardundeeSPW_USB*)bridge),SIGNAL(GetNbPacketsTransmittedToSpw()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetNbCCSDSPacketsTransmittedToSpw()),
((stardundeeSPW_USB*)bridge),SIGNAL(GetNbCCSDSPacketsTransmittedToSpw()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeGetLinkNumber()),((stardundeeSPW_USB*)bridge),SIGNAL(GetLinkNumber()));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsAninterface(bool)),
((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsAnInterface(bool)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetBrickAsARouter(bool)),
((stardundeeSPW_USB*)bridge),SIGNAL(SetBrickAsARouter(bool)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeStartTimecodes(bool)),
((stardundeeSPW_USB*)bridge),SIGNAL(StartSendingTimecodes(bool)));
connect(((spwPyWrapper*)this->pyObject),SIGNAL(StarDundeeSetTimecodeFrequency(double)),
((stardundeeSPW_USB*)bridge),SIGNAL(SetTimecodeFrequency(double)));
connect(this->bridge,SIGNAL(pushPacketOverTCP(char*,int)),this->tcpServer,SLOT(pushPacket(char*,int)));
connect(this->tcpServer, SIGNAL(sendSPWPacket(char*,int)), ((stardundeeSPW_USB*)bridge), SLOT(sendPacketComingFromTCPServer(char*,int)));
}
if(text=="GR-ESB")
{
if(this->bridge!=NULL)
{
this->mainLayout->removeWidget(this->bridge->getGUI());
this->disconnect(this,SLOT(setConnected(bool)));
delete this->bridge;
}
this->bridge = new GR_ESB_bridge(this);
this->mainLayout->addWidget(this->bridge->getGUI(),1,0,1,2);
connect(this->bridge,SIGNAL(setConnected(bool)),this,SLOT(setConnected(bool)));
}
}
void spwplugin::selectBridge(const QString &text)
{
if(text=="none")
{
this->bridgeSelector->setCurrentIndex(0);
}
if(text=="STAR-Dundee Spw USB Brick")
{
this->bridgeSelector->setCurrentIndex(1);
}
}
void spwplugin::setConnected(bool connected)
{
this->bridgeSelector->setDisabled(connected);
this->Connected = connected;
emit activateSig(connected);
if(!this->scanDone)
{
socexplorerproxy::loadChildSysDriver(this,"AMBA_PLUGIN");
this->scanDone=true;
}
}
unsigned int spwplugin::Write(unsigned int *Value,unsigned int count, unsigned int address)
{
if(Connected)
{
return bridge->Write(Value,count,address);
}
return 0;
}