##// END OF EJS Templates
Changes to lfrsge...
Changes to lfrsge Minor changes to the rmap plugin

File last commit:

r50:47b677d190ee default
r58:6bfd3f59df14 default
Show More
rmappluginui.cpp
299 lines | 12.8 KiB | text/x-c | CppLexer
/*------------------------------------------------------------------------------
-- This file is a part of the LPPMON Software
-- Copyright (C) 2011, 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
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@lpp.polytechnique.fr
----------------------------------------------------------------------------*/
#include "rmapplugin.h"
rmapPluginUI::rmapPluginUI(QWidget *parent) :
QWidget(parent)
{
spwTabWidget = new QTabWidget;
//
QWidget* spwTabWidgetPage0 = new QWidget;
QWidget* spwTabWidgetPage2 = new QWidget;
QWidget* spwTabWidgetPage3 = new QWidget;
QWidget* spwTabWidgetPage4 = new QWidget;
QWidget* spwTabWidgetPage5 = new QWidget;
QWidget* spwTabWidgetPage6 = new QWidget;
//
bridgeWidget = new QWidget;
mainLayout = new QVBoxLayout;
ccsdsLayout = new QVBoxLayout;
consoleLayout = new QVBoxLayout;
selectionLayout = new QVBoxLayout;
connectionLayout = new QGridLayout;
bridgeSelection_LAYOUT = new QGridLayout;
generalParameters_LAYOUT = new QGridLayout;
gresb_GROUPBOX = new QGroupBox(tr("GRESB bridge parameters"));
stardundee_GROUPBOX = new QGroupBox(tr("Star Dundee brick parameters"));
selection_GROUPBOX = new QGroupBox(tr("Bridge selection"));
generalParameters_GROUPBOX = new QGroupBox(tr("General parameters"));
//*** QLABEL ***//
gresbBridgeIPLabel = new QLabel(tr("Bridge IP: "));
gresbVirtualLinkLabel = new QLabel(tr("Virtual Link: "));
spwLinkLabel = new QLabel(tr("SPW Link: "));
rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: "));
rmapTargetLogicalAddressLabel = new QLabel(tr("RMAP Target Logical Address: "));
logFileName = new QLabel;
gresbStatusQueryLabel = new QLabel(tr("Status query socket (port 3010): waiting for connection"));
gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running"));
nbPacketInStore = new QLabel(tr("nb packets in store: -"));
//*** QPUSHBUTTON ***//
rmapOpenCommunicationButton = new QPushButton(tr("Open selected bridge"));
rmapCloseCommunicationButton = new QPushButton(tr("Close selected bridge"));
rmapOpenCommunicationButton->setEnabled(false);
rmapCloseCommunicationButton->setEnabled(false);
logFileChooseButton = new QPushButton(tr("Choose file"));
gresbStatusQueryRetryButton = new QPushButton(tr("Retry"));
gresbStatusQueryAbortButton = new QPushButton(tr("Abort"));
clearConsoleButton = new QPushButton(tr("Clear"));
selectGRESB_BUTTON = new QRadioButton(tr("GRESB"));
selectStarDundee_BUTTON = new QRadioButton(tr("Star Dundee"));
//*** SPINBOX ***//
gresbVirtualLinkSpinBox = new QSpinBox;
rmapSourceLogicalAddressSpinBox = new QSpinBox;
rmapTargetLogicalAddressSpinBox = new QSpinBox;
spwLinkSpinBox = new QSpinBox;;
CCSDSTargetLogicalAddressSpinBox = new QSpinBox;
gresbVirtualLinkSpinBox->setRange(0, 4);
gresbVirtualLinkSpinBox->setValue(1);
rmapSourceLogicalAddressSpinBox->setRange(0, 255);
rmapTargetLogicalAddressSpinBox->setRange(0, 255);
spwLinkSpinBox->setRange(0, 2);
spwLinkSpinBox->setValue(0);
//*** MISC **//
starDundee = new StarDundee;
gresbBridge = new gresb;
tmEchoBridge = new TMEchoBridge();
console = new QTextEdit;
gresbStatusQueryDialog = new QDialog;
logEnableCheckBox = new QCheckBox(tr("Enable Logs"));
RMAP_write_verify = new QCheckBox(tr("data checked before write\nlimited to 4 bytes\nNOT IMPLEMENTED"));
RMAP_write_reply = new QCheckBox(tr("reply to the write command required\nlast reply status: unavailable"));
logFile = new QFile();
wfDisplay = new WFDisplay();
tmStatistics = new TMStatistics();
lfrActions = new LFRActions();
logFileEn = false;
connectionLayout->setRowStretch(7, 1);
connectionLayout->setColumnStretch(2, 1);
bridgeSelection_LAYOUT->addWidget(selectGRESB_BUTTON, 0, 0, 1, 1);
bridgeSelection_LAYOUT->addWidget(selectStarDundee_BUTTON, 0, 1, 1, 1);
bridgeSelection_LAYOUT->setRowStretch(1, 1);
bridgeSelection_LAYOUT->setColumnStretch(2, 1);
generalParameters_LAYOUT->addWidget(logEnableCheckBox, 0, 0, 1, 1);
generalParameters_LAYOUT->addWidget(logFileChooseButton, 0, 1, 1, 1);
generalParameters_LAYOUT->addWidget(rmapSourceLogicalAddressLabel, 1, 0, 0);
generalParameters_LAYOUT->addWidget(rmapSourceLogicalAddressSpinBox, 1, 1, 0);
generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressLabel, 2, 0, 0);
generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressSpinBox, 2, 1, 0);
generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 3, 0, 1, 1);
generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 3, 1, 1, 1);
generalParameters_LAYOUT->addWidget(RMAP_write_verify, 4, 0, 1, 2);
generalParameters_LAYOUT->addWidget(RMAP_write_reply, 5, 0, 1, 2);
generalParameters_LAYOUT->setRowStretch(6, 1);
generalParameters_LAYOUT->setColumnStretch(2, 1);
gresb_GROUPBOX->setLayout(gresbBridge->layout());
gresb_GROUPBOX->setVisible(false);
stardundee_GROUPBOX->setLayout(starDundee->layout());
stardundee_GROUPBOX->setVisible(false);
selection_GROUPBOX->setLayout(bridgeSelection_LAYOUT);
generalParameters_GROUPBOX->setLayout(generalParameters_LAYOUT);
selectionLayout->addWidget(selection_GROUPBOX);
selectionLayout->addWidget(generalParameters_GROUPBOX);
selectionLayout->addWidget(gresb_GROUPBOX);
selectionLayout->addWidget(stardundee_GROUPBOX);
selectionLayout->addStretch(1);
//********
// CONSOLE
consoleLayout->addWidget(console);
consoleLayout->addWidget(clearConsoleButton);
consoleLayout->addWidget(nbPacketInStore);
connect(this->logFileChooseButton, SIGNAL(clicked()), this, SLOT(chooseLogFile()));
connect(this, SIGNAL(setLogFileName(QString)), this->logFileName, SLOT(setText(QString)));
connect(this->logEnableCheckBox, SIGNAL(stateChanged(int)), this, SLOT(logFileEnDisable(int)));
spwTabWidget->addTab(spwTabWidgetPage0, tr("connection"));
//spwTabWidget->addTab(spwTabWidgetPage2, tr("status"));
spwTabWidget->addTab(spwTabWidgetPage3, tr("console"));
spwTabWidget->addTab(spwTabWidgetPage4, tr("TM statistics"));
spwTabWidget->addTab(lfrActions, tr("dashboard"));
//spwTabWidget->addTab(spwTabWidgetPage5, tr("waveforms"));
spwTabWidget->addTab(spwTabWidgetPage6, tr("TM Echo Bridge"));
spwTabWidgetPage0->setLayout(selectionLayout);
spwTabWidgetPage2->setLayout(this->gresbBridge->spwLinkStatusEnquiry->mainLayout);
spwTabWidgetPage3->setLayout(consoleLayout);
spwTabWidgetPage4->setLayout(tmStatistics->layout());
spwTabWidgetPage5->setLayout(wfDisplay->layout());
spwTabWidgetPage6->setLayout(tmEchoBridge->layout());
mainLayout->addWidget(spwTabWidget);
setLayout(mainLayout);
connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear()));
// briges
connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee()));
connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee()));
connect(this->starDundee, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool)));
connect(this->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool)));
connect(this->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(sourceHasChanged(int)));
connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(targetHasChanged(int)));
connect(this->rmapSourceLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(sourceHasChanged(int)));
connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(targetHasChanged(int)));
// command code
connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode()));
connect(this->RMAP_write_verify, SIGNAL(clicked()), this, SLOT(getCommandCode()));
connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)),
this->starDundee, SLOT(commandCodeHasChanged(RMAP_command_codes)));
connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)),
this->gresbBridge, SLOT(commandCodeHasChanged(RMAP_command_codes)));
getCommandCode(); // init the command code value
rmapSourceLogicalAddressSpinBox->setValue(DEFAULT_SOURCE);
rmapTargetLogicalAddressSpinBox->setValue(DEFAULT_TARGET);
}
rmapPluginUI::~rmapPluginUI()
{
//delete ui;
}
void rmapPluginUI::chooseLogFile()
{
if(this->logFile->isOpen())
this->logFile->close();
this->logFile->setFileName(QFileDialog::getSaveFileName(this,tr("Open Log file"),
QDir::homePath()
+ "/"
+ QDate::currentDate().toString()
+ "_"
+ QTime::currentTime().toString()
+ "_rmapPluginUI.log",
tr("Log Files (*.txt *.log)")));
if(this->logFile->open(QIODevice::WriteOnly))
{
this->logFileStrm = new QTextStream(this->logFile);
emit this->setLogFileName(this->logFile->fileName());
}
}
void rmapPluginUI::logFileEnDisable(int state)
{
if(state==Qt::Checked)
{
this->logFileEn = true;
}
else if(state==Qt::Unchecked)
{
this->logFileEn = false;
}
}
bool rmapPluginUI::islogfileenable()
{
return this->logFileEn;
}
void rmapPluginUI::appendToLogFile(const QString & text)
{
if(this->logFileEn && this->logFile->isOpen())
{
*(this->logFileStrm) << text << endl;
}
}
void rmapPluginUI::closeEvent(QCloseEvent *event)
{
if(this->logFile->isOpen())
{
this->logFileStrm->flush();
this->logFile->waitForBytesWritten(3000);
this->logFile->close();
}
event->accept();
}
RMAP_command_codes rmapPluginUI::getCommandCode()
{
RMAP_command_codes commandCode = invalid0;
if (RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_rep;
if (RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_ver_noRep;
if (!RMAP_write_verify->isChecked() and RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_Rep;
if (!RMAP_write_verify->isChecked() and !RMAP_write_reply->isChecked()) commandCode = writeSingle_noVer_noRep;
emit commandCodeHasChanged(commandCode);
return commandCode;
}
// SLOT
void rmapPluginUI::selectionBetweenGresbAndStarDundee() //SLOT
{
if (selectGRESB_BUTTON->isChecked())
{
gresb_GROUPBOX->setVisible(true);
stardundee_GROUPBOX->setVisible(false);
rmapOpenCommunicationButton->setEnabled(true);
emit bridgeHasChanged(selectedBridgeIsGRESB);
}
if (selectStarDundee_BUTTON->isChecked())
{
stardundee_GROUPBOX->setVisible(true);
gresb_GROUPBOX->setVisible(false);
rmapOpenCommunicationButton->setEnabled(true);
emit bridgeHasChanged(selectedBridgeIsStarDundee);
}
}
void rmapPluginUI::isOpen(bool flag)
{
if (flag == true)
{
selection_GROUPBOX->setEnabled(false);
this->rmapOpenCommunicationButton->setEnabled(false);
this->rmapCloseCommunicationButton->setEnabled(true);
}
if (flag == false)
{
selection_GROUPBOX->setEnabled(true);
this->rmapOpenCommunicationButton->setEnabled(true);
this->rmapCloseCommunicationButton->setEnabled(false);
}
}