rmappluginui.cpp
301 lines
| 13.3 KiB
| text/x-c
|
CppLexer
/ rmapplugin / rmappluginui.cpp
r0 | /*------------------------------------------------------------------------------ | |||
-- 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) | ||||
{ | ||||
spectralMatricesDMASimulator = new SpectralMatricesDMASimulator; | ||||
spwTabWidget = new QTabWidget; | ||||
QWidget* spwTabWidgetPage0 = new QWidget; | ||||
QWidget* spwTabWidgetPage1 = new QWidget; | ||||
QWidget* spwTabWidgetPage2 = new QWidget; | ||||
QWidget* spwTabWidgetPage3 = new QWidget; | ||||
QWidget* spwTabWidgetPage4 = new QWidget; | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | bridgeWidget = new QWidget; | ||
r0 | mainLayout = new QVBoxLayout; | |||
connectionLayout = new QGridLayout; | ||||
ccsdsLayout = new QVBoxLayout; | ||||
consoleLayout = new QVBoxLayout; | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | selectionLayout = new QVBoxLayout; | ||
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")); | ||||
r0 | ||||
//*** QLABEL ***// | ||||
r3 | gresbBridgeIPLabel = new QLabel(tr("Bridge IP: ")); | |||
gresbVirtualLinkLabel = new QLabel(tr("Virtual Link: ")); | ||||
spwLinkLabel = new QLabel(tr("SPW Link: ")); | ||||
r0 | rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: ")); | |||
rmapTargetLogicalAddressLabel = new QLabel(tr("RMAP Target Logical Address: ")); | ||||
logFileName = new QLabel; | ||||
r3 | gresbStatusQueryLabel = new QLabel(tr("Status query socket (port 3010): waiting for connection")); | |||
r0 | gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running")); | |||
sendCCSDSCommandLabel = new QLabel(tr("Address of the target")); | ||||
r13 | nbPacketInStore = new QLabel(tr("nb packets in store: -")); | |||
r0 | ||||
//*** QPUSHBUTTON ***// | ||||
r3 | rmapOpenCommunicationButton = new QPushButton(tr("Open selected bridge")); | |||
rmapCloseCommunicationButton = new QPushButton(tr("Close selected bridge")); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | rmapOpenCommunicationButton->setEnabled(false); | ||
r0 | rmapCloseCommunicationButton->setEnabled(false); | |||
logFileChooseButton = new QPushButton(tr("Choose file")); | ||||
gresbStatusQueryRetryButton = new QPushButton(tr("Retry")); | ||||
gresbStatusQueryAbortButton = new QPushButton(tr("Abort")); | ||||
sendCCSDSCommandButton = new QPushButton(tr("Send CCSDS Command")); | ||||
send_TC_LFR_UPDATE_TIME_Button = new QPushButton(tr("Send TC_LFR_UPDATE_TIME Packet")); | ||||
reset_TC_LFR_UPDATE_TIME_Button = new QPushButton(tr("reset the TC_LFR_UPDATE_TIME Packet coarse and fine times")); | ||||
clearConsoleButton = new QPushButton(tr("Clear")); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | selectGRESB_BUTTON = new QRadioButton(tr("GRESB")); | ||
selectStarDundee_BUTTON = new QRadioButton(tr("Star Dundee")); | ||||
r0 | //*** 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); | ||||
r11 | rmapSourceLogicalAddressSpinBox->setValue(0); | |||
r0 | rmapTargetLogicalAddressSpinBox->setRange(0, 255); | |||
spwLinkSpinBox->setRange(0, 2); | ||||
spwLinkSpinBox->setValue(0); | ||||
CCSDSTargetLogicalAddressSpinBox->setRange(0,255); | ||||
r11 | CCSDSTargetLogicalAddressSpinBox->setValue(0); | |||
r0 | ||||
//*** MISC **// | ||||
starDundee = new StarDundee; | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | gresbBridge = new gresb; | ||
r0 | console = new QTextEdit; | |||
r11 | //gresbBridgeIPDialogBox = new QIPDialogBox; | |||
r0 | 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")); | ||||
spwLinkStatusEnquiry = new gresbStatusEnquiry; | ||||
logFile = new QFile(); | ||||
logFileEn = false; | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | 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); | ||||
r0 | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | generalParameters_LAYOUT->addWidget(logEnableCheckBox, 0, 0, 1, 1); | ||
generalParameters_LAYOUT->addWidget(logFileChooseButton, 0, 1, 1, 1); | ||||
r11 | 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); | ||||
r13 | ||||
r11 | generalParameters_LAYOUT->setRowStretch(6, 1); | |||
paul@pc-solar1.lab-lpp.local
|
r1 | generalParameters_LAYOUT->setColumnStretch(2, 1); | ||
r9 | gresb_GROUPBOX->setLayout(gresbBridge->layout()); | |||
paul@pc-solar1.lab-lpp.local
|
r1 | 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); | ||||
r0 | ||||
ccsdsLayout->addWidget(sendCCSDSCommandButton); | ||||
ccsdsLayout->addWidget(send_TC_LFR_UPDATE_TIME_Button); | ||||
ccsdsLayout->addWidget(reset_TC_LFR_UPDATE_TIME_Button); | ||||
ccsdsLayout->addWidget(sendCCSDSCommandLabel); | ||||
ccsdsLayout->addWidget(CCSDSTargetLogicalAddressSpinBox); | ||||
consoleLayout->addWidget(console); | ||||
consoleLayout->addWidget(clearConsoleButton); | ||||
r13 | consoleLayout->addWidget(nbPacketInStore); | |||
r0 | ||||
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(spwTabWidgetPage1, tr("ccsds")); | ||||
spwTabWidget->addTab(spwTabWidgetPage2, tr("status")); | ||||
spwTabWidget->addTab(spwTabWidgetPage3, tr("console")); | ||||
spwTabWidget->addTab(spwTabWidgetPage4, tr("DMA")); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | |||
spwTabWidgetPage0->setLayout(selectionLayout); | ||||
r0 | spwTabWidgetPage1->setLayout(ccsdsLayout); | |||
spwTabWidgetPage2->setLayout(this->spwLinkStatusEnquiry->mainLayout); | ||||
spwTabWidgetPage3->setLayout(consoleLayout); | ||||
spwTabWidgetPage4->setLayout(spectralMatricesDMASimulator->mainLayout); | ||||
r9 | ||||
r0 | mainLayout->addWidget(spwTabWidget); | |||
setLayout(mainLayout); | ||||
connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear())); | ||||
r10 | ||||
r9 | // briges | |||
paul@pc-solar1.lab-lpp.local
|
r1 | connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); | ||
connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); | ||||
r3 | connect(this->starDundee, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); | |||
r9 | connect(this->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); | |||
r11 | 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))); | ||||
r3 | connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(targetHasChanged(int))); | |||
paul@pc-solar1.lab-lpp.local
|
r1 | |||
// command code | ||||
connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode())); | ||||
connect(this->RMAP_write_verify, SIGNAL(clicked()), this, SLOT(getCommandCode())); | ||||
r9 | 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))); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | |||
getCommandCode(); // init the command code value | ||||
r11 | rmapSourceLogicalAddressSpinBox->setValue(DEFAULT_SOURCE); | |||
rmapTargetLogicalAddressSpinBox->setValue(DEFAULT_TARGET); | ||||
r0 | } | |||
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() | ||||
{ | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | 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; | ||||
r0 | } | |||
paul@pc-solar1.lab-lpp.local
|
r1 | |||
// 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); | ||||
} | ||||
} | ||||
r3 | void rmapPluginUI::isOpen(bool flag) | |||
paul@pc-solar1.lab-lpp.local
|
r1 | { | ||
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); | ||||
} | ||||
} | ||||