rmappluginui.cpp
323 lines
| 14.1 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; | ||||
QWidget* spwTabWidgetPage5 = 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 ***// | ||||
gresbBridgeIPLabel = new QLabel(tr("GRESB Bridge IP: ")); | ||||
gresbVirtualLinkLabel = new QLabel(tr("GRESB Virtual Link: ")); | ||||
spwLinkLabel = new QLabel(tr("GRESB SPW Link: ")); | ||||
rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: ")); | ||||
rmapTargetLogicalAddressLabel = new QLabel(tr("RMAP Target Logical Address: ")); | ||||
rmapSendStateLabel = new QLabel(tr("RMAP Send Socket State: waiting for connection")); | ||||
rmapReceiveStateLabel = new QLabel(tr("RMAP Receive Socket State: waiting for connection")); | ||||
logFileName = new QLabel; | ||||
gresbStatusQueryLabel = new QLabel(tr("GRESB status query socket (port 3010): waiting for connection")); | ||||
gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running")); | ||||
sendCCSDSCommandLabel = new QLabel(tr("Address of the target")); | ||||
//*** QPUSHBUTTON ***// | ||||
rmapOpenCommunicationButton = new QPushButton(tr("Open RMAP Communication")); | ||||
rmapCloseCommunicationButton = new QPushButton(tr("Close RMAP Communication")); | ||||
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); | ||||
rmapSourceLogicalAddressSpinBox->setValue(33); | ||||
rmapTargetLogicalAddressSpinBox->setRange(0, 255); | ||||
rmapTargetLogicalAddressSpinBox->setValue(254); | ||||
spwLinkSpinBox->setRange(0, 2); | ||||
spwLinkSpinBox->setValue(0); | ||||
CCSDSTargetLogicalAddressSpinBox->setRange(0,255); | ||||
CCSDSTargetLogicalAddressSpinBox->setValue(254); | ||||
//*** MISC **// | ||||
starDundee = new StarDundee; | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | gresbBridge = new gresb; | ||
r0 | console = new QTextEdit; | |||
gresbBridgeIPDialogBox = new QIPDialogBox; | ||||
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; | ||||
connectionLayout->addWidget(gresbBridgeIPLabel, 0, 0, 0); | ||||
connectionLayout->addWidget(gresbBridgeIPDialogBox, 0, 1, 0); | ||||
connectionLayout->addWidget(gresbVirtualLinkLabel, 1, 0, 0); | ||||
connectionLayout->addWidget(gresbVirtualLinkSpinBox, 1, 1, 0); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | connectionLayout->addWidget(spwLinkLabel, 2, 0, 0); | ||
connectionLayout->addWidget(spwLinkSpinBox, 2, 1, 0); | ||||
connectionLayout->addWidget(rmapSourceLogicalAddressLabel, 3, 0, 0); | ||||
connectionLayout->addWidget(rmapSourceLogicalAddressSpinBox, 3, 1, 0); | ||||
connectionLayout->addWidget(rmapSendStateLabel, 4, 0, 1, 2); | ||||
connectionLayout->addWidget(rmapReceiveStateLabel, 5, 0, 1, 2); | ||||
connectionLayout->addWidget(gresbStatusQueryLabel, 6, 0, 1, 2); | ||||
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); | ||||
generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressLabel, 1, 0, 0); | ||||
generalParameters_LAYOUT->addWidget(rmapTargetLogicalAddressSpinBox, 1, 1, 0); | ||||
generalParameters_LAYOUT->addWidget(rmapOpenCommunicationButton, 2, 0, 1, 2); | ||||
generalParameters_LAYOUT->addWidget(rmapCloseCommunicationButton, 3, 0, 1, 2); | ||||
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(connectionLayout); | ||||
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); | ||||
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 | spwTabWidget->addTab(spwTabWidgetPage5, tr("gresb")); | ||
spwTabWidgetPage0->setLayout(selectionLayout); | ||||
r0 | spwTabWidgetPage1->setLayout(ccsdsLayout); | |||
spwTabWidgetPage2->setLayout(this->spwLinkStatusEnquiry->mainLayout); | ||||
spwTabWidgetPage3->setLayout(consoleLayout); | ||||
spwTabWidgetPage4->setLayout(spectralMatricesDMASimulator->mainLayout); | ||||
paul@pc-solar1.lab-lpp.local
|
r1 | spwTabWidgetPage5->setLayout(gresbBridge->layout()); | ||
r0 | mainLayout->addWidget(spwTabWidget); | |||
setLayout(mainLayout); | ||||
// GRESB STATUS QUERY DIALOG | ||||
gresbStatusQueryDialogLayout = new QGridLayout; | ||||
gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryDialogLabel, 0, 0, 1, 2); | ||||
gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryRetryButton, 1, 0, 0); | ||||
gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryAbortButton, 1, 1, 0); | ||||
gresbStatusQueryDialog->setLayout(gresbStatusQueryDialogLayout); | ||||
connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); | ||||
connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear())); | ||||
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())); | ||||
connect(this->starDundee, SIGNAL(starDundeeIsOpen(bool)), this, SLOT(starDundeeIsOpen(bool))); | ||||
// 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(updateCommandCode(RMAP_command_codes))); | ||||
getCommandCode(); // init the command code value | ||||
r0 | } | |||
void rmapPluginUI::connectPort() | ||||
{ | ||||
//emit this->connectPortsig(ui->PortName->text(),ui->PortspeedSlider->value()); | ||||
} | ||||
void rmapPluginUI::setConnected(bool connected) | ||||
{ | ||||
/*if(connected == true) | ||||
{ | ||||
ui->OpenPort->setText(tr("Close port")); | ||||
} | ||||
else | ||||
ui->OpenPort->setText(tr("Open port"));*/ | ||||
} | ||||
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); | ||||
} | ||||
} | ||||
void rmapPluginUI::starDundeeIsOpen(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); | ||||
} | ||||
} | ||||