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

File last commit:

r58:6bfd3f59df14 default
r58:6bfd3f59df14 default
Show More
tmstatistics.cpp
983 lines | 33.3 KiB | text/x-c | CppLexer
#include "tmstatistics.h"
#include <QtWidgets>
#include <QFontInfo>
#include <stdio.h>
#include <QFileDialog>
TMStatistics::TMStatistics(QWidget *parent) :
QWidget(parent)
{
// Create Fonts
QFont font;
font = QFont(this->fontInfo().family(), STATISTICS_FONT_SIZE, QFont::Light);
label_UNKNOWN = new QLabel("UNKNOWN");
label_UNKNOWN_nb = new QLabel("-");
mainLayout = new QGridLayout();
layout_stat = new QGridLayout(); // TM stastictics
layout_NORM = new QGridLayout(); // TM_LFR_SCIENCE_NORMAL_
layout_BURST = new QGridLayout(); // TM_LFR_SCIENCE_BURST_
layout_SBM1 = new QGridLayout(); // TM_LFR_SCIENCE_SBM1_
layout_SBM2 = new QGridLayout(); // TM_LFR_SCIENCE_SBM2_
layout_last = new QGridLayout(); // last TM description
layout_record = new QVBoxLayout();
//***************
// TM_LFR_TC_EXE_
label_SUCC = new QLabel("SUCCESS");
label_INCO = new QLabel("INCONSISTENT");
label_NOTE = new QLabel("NOT_EXECUTABLE");
label_NOTI = new QLabel("NOT_IMPLEMENTED");
label_ERRO = new QLabel("ERROR");
label_CORR = new QLabel("CORRUPTED");
label_HK = new QLabel("TM_LFR_HK");
label_DUMP = new QLabel("TM_LFR_PARAMETER_DUMP");
//
label_SUCC_nb = new QLabel("-");
label_INCO_nb = new QLabel("-");
label_NOTE_nb = new QLabel("-");
label_NOTI_nb = new QLabel("-");
label_ERRO_nb = new QLabel("-");
label_CORR_nb = new QLabel("-");
label_HK_nb = new QLabel("-");
label_DUMP_nb = new QLabel("-");
//***********************
// TM_LFR_SCIENCE_NORMAL_
label_NORM_SWF_F0 = new QLabel("SWF_F0");
label_NORM_SWF_F1 = new QLabel("SWF_F1");
label_NORM_SWF_F2 = new QLabel("SWF_F2");
label_NORM_CWF_F3 = new QLabel("CWF_F3");
label_NORM_CWF_LONG_F3 = new QLabel("LONG_F3");
label_NORM_ASM_F0 = new QLabel("ASM_F0");
label_NORM_ASM_F1 = new QLabel("ASM_F1");
label_NORM_ASM_F2 = new QLabel("ASM_F2");
label_NORM_BP1_F0 = new QLabel("BP1_F0");
label_NORM_BP1_F1 = new QLabel("BP1_F1");
label_NORM_BP1_F2 = new QLabel("BP1_F2");
label_NORM_BP2_F0 = new QLabel("BP2_F0");
label_NORM_BP2_F1 = new QLabel("BP2_F1");
label_NORM_BP2_F2 = new QLabel("BP2_F2");
//
label_NORM_SWF_F0_nb = new QLabel("-");
label_NORM_SWF_F1_nb = new QLabel("-");
label_NORM_SWF_F2_nb = new QLabel("-");
label_NORM_CWF_F3_nb = new QLabel("-");
label_NORM_CWF_LONG_F3_nb = new QLabel("-");
label_NORM_ASM_F0_nb = new QLabel("-");
label_NORM_ASM_F1_nb = new QLabel("-");
label_NORM_ASM_F2_nb = new QLabel("-");
label_NORM_BP1_F0_nb = new QLabel("-");
label_NORM_BP1_F1_nb = new QLabel("-");
label_NORM_BP1_F2_nb = new QLabel("-");
label_NORM_BP2_F0_nb = new QLabel("-");
label_NORM_BP2_F1_nb = new QLabel("-");
label_NORM_BP2_F2_nb = new QLabel("-");
//**********************
// TM_LFR_SCIENCE_BURST_
label_BURST_CWF_F2 = new QLabel("CWF_F2");
label_BURST_BP1_F0 = new QLabel("BP1_F0");
label_BURST_BP2_F0 = new QLabel("BP2_F0");
label_BURST_BP1_F1 = new QLabel("BP1_F1");
label_BURST_BP2_F1 = new QLabel("BP2_F1");
//
label_BURST_CWF_F2_nb = new QLabel("-");
label_BURST_BP1_F0_nb = new QLabel("-");
label_BURST_BP2_F0_nb = new QLabel("-");
label_BURST_BP1_F1_nb = new QLabel("-");
label_BURST_BP2_F1_nb = new QLabel("-");
//*********************
// TM_LFR_SCIENCE_SBM1_
label_SBM1_CWF_F1 = new QLabel("CWF_F1");
label_SBM1_BP1_F0 = new QLabel("BP1_F0");
label_SBM1_BP2_F0 = new QLabel("BP2_F0");
//
label_SBM1_CWF_F1_nb = new QLabel("-");
label_SBM1_BP1_F0_nb = new QLabel("-");
label_SBM1_BP2_F0_nb = new QLabel("-");
//*********************
// TM_LFR_SCIENCE_SBM2_
label_SBM2_CWF_F2 = new QLabel("CWF_F2");
label_SBM2_BP1_F0 = new QLabel("BP1_F0");
label_SBM2_BP2_F0 = new QLabel("BP2_F0");
label_SBM2_BP1_F1 = new QLabel("BP1_F1");
label_SBM2_BP2_F1 = new QLabel("BP2_F1");
//
label_SBM2_CWF_F2_nb = new QLabel("-");
label_SBM2_BP1_F0_nb = new QLabel("-");
label_SBM2_BP2_F0_nb = new QLabel("-");
label_SBM2_BP1_F1_nb = new QLabel("-");
label_SBM2_BP2_F1_nb = new QLabel("-");
//********
// LAST TM
label_PID = new QLabel("PID");
label_CAT = new QLabel("CAT");
label_TYP = new QLabel("Type");
label_SUB = new QLabel("Subtype");
label_SID = new QLabel("SID");
label_SIZ = new QLabel("Length");
label_coarse_time = new QLabel("Coarse time: ");
label_fine_time = new QLabel("Fine time: ");
//
label_PID_is = new QLabel("-");
label_CAT_is = new QLabel("-");
label_TYP_is = new QLabel("-");
label_SUB_is = new QLabel("-");
label_SID_is = new QLabel("-");
label_SIZ_is = new QLabel("-");
label_coarse_time_val = new QLabel("-");
label_fine_time_val = new QLabel("-");
// QPushButton
button_reset_stat = new QPushButton("reset stat");
button_chooseDir = new QPushButton("choose dir");
//QCheckBox
checkbox_packetLog = new QCheckBox("Log packets");
checkbox_packetRecording = new QCheckBox("Store packets (RAW)");
checkbox_CSVPacketRecording = new QCheckBox("Store Packets (CSV)");
label_currentDir = new QLabel("Current Dir: -");
//**********
// QGroupBox
this->setStyleSheet("QGroupBox {border: 1px solid black; }");
groupbox_stat = new QGroupBox("TM_LFR_TC_EXE_");
groupbox_NORM = new QGroupBox("TM_LFR_SCIENCE_NORMAL_");
groupbox_BURST = new QGroupBox("TM_LFR_SCIENCE_BURST_");
groupbox_SBM1 = new QGroupBox("TM_LFR_SCIENCE_SBM1_");
groupbox_SBM2 = new QGroupBox("TM_LFR_SCIENCE_SBM2_");
groupbox_last = new QGroupBox("Last TM received");
groupbox_record = new QGroupBox("Packet recording");
this->readSettings();
logFile = new QFile();
packetLogFile = new QFile();
csvPacketRecordFile = new QFile();
logFileEn = false;
packetLogFileEn = false;
csvPacketRecordFileEn = false;
initConstants();
buildMonitor_NORM();
buildMonitor_BURST();
buildMonitor_SBM1();
buildMonitor_SBM2();
buildMonitor();
groupbox_stat->setFont(font);
groupbox_NORM->setFont(font);
groupbox_BURST->setFont(font);
groupbox_SBM1->setFont(font);
groupbox_SBM2->setFont(font);
groupbox_last->setFont(font);
groupbox_record->setFont(font);
connect(this->button_reset_stat, SIGNAL(clicked()), this, SLOT(resetStatistics()));
connect(this->button_chooseDir, SIGNAL(clicked()), this, SLOT(chooseDir()));
connect(this->checkbox_packetLog, SIGNAL(stateChanged(int)),
this, SLOT(logPackets(int)));
connect(this->checkbox_packetRecording, SIGNAL(stateChanged(int)),
this, SLOT(storePackets(int)));
connect(this->checkbox_CSVPacketRecording, SIGNAL(stateChanged(int)),
this, SLOT(storeCSVPackets(int)));
}
TMStatistics::~TMStatistics()
{
this->writeSettings();
}
void TMStatistics::initConstants()
{
UNKNOWN_nb = 0;
// TM_LFR_TC_EXE_
SUCC_nb = 0;
INCO_nb = 0;
NOTE_nb = 0;
NOTI_nb = 0;
ERRO_nb = 0;
CORR_nb = 0;
HK_nb = 0;
DUMP_nb = 0;
// TM_LFR_SCIENCE_NORMAL_
NORM_SWF_F0_nb = 0;
NORM_SWF_F1_nb = 0;
NORM_SWF_F2_nb = 0;
NORM_CWF_F3_nb = 0;
NORM_CWF_LONG_F3_nb = 0;
NORM_ASM_F0_nb = 0;
NORM_ASM_F1_nb = 0;
NORM_ASM_F2_nb = 0;
NORM_BP1_F0_nb = 0;
NORM_BP1_F1_nb = 0;
NORM_BP1_F2_nb = 0;
NORM_BP2_F0_nb = 0;
NORM_BP2_F1_nb = 0;
NORM_BP2_F2_nb = 0;
BURST_CWF_F2_nb = 0;
BURST_BP1_F0_nb = 0;
BURST_BP2_F0_nb = 0;
BURST_BP1_F1_nb = 0;
BURST_BP2_F1_nb = 0;
SBM1_CWF_F1_nb = 0;
SBM1_BP1_F0_nb = 0;
SBM1_BP2_F0_nb = 0;
SBM2_CWF_F2_nb = 0;
SBM2_BP1_F0_nb = 0;
SBM2_BP2_F0_nb = 0;
SBM2_BP1_F1_nb = 0;
SBM2_BP2_F1_nb = 0;
}
void TMStatistics::buildMonitor_NORM()
{
layout_NORM->addWidget(label_NORM_SWF_F0, 0, 0, 1, 1);
layout_NORM->addWidget(label_NORM_SWF_F1, 1, 0, 1, 1);
layout_NORM->addWidget(label_NORM_SWF_F2, 2, 0, 1, 1);
layout_NORM->addWidget(label_NORM_CWF_F3, 3, 0, 1, 1);
//
layout_NORM->addWidget(label_NORM_SWF_F0_nb, 0, 1, 1, 1);
layout_NORM->addWidget(label_NORM_SWF_F1_nb, 1, 1, 1, 1);
layout_NORM->addWidget(label_NORM_SWF_F2_nb, 2, 1, 1, 1);
layout_NORM->addWidget(label_NORM_CWF_F3_nb, 3, 1, 1, 1);
//
layout_NORM->addWidget(label_NORM_ASM_F0, 4, 0, 1, 1);
layout_NORM->addWidget(label_NORM_ASM_F1, 5, 0, 1, 1);
layout_NORM->addWidget(label_NORM_ASM_F2, 6, 0, 1, 1);
//
layout_NORM->addWidget(label_NORM_ASM_F0_nb, 4, 1, 1, 1);
layout_NORM->addWidget(label_NORM_ASM_F1_nb, 5, 1, 1, 1);
layout_NORM->addWidget(label_NORM_ASM_F2_nb, 6, 1, 1, 1);
//
layout_NORM->addWidget(label_NORM_BP1_F0, 0, 2, 1, 1);
layout_NORM->addWidget(label_NORM_BP1_F1, 1, 2, 1, 1);
layout_NORM->addWidget(label_NORM_BP1_F2, 2, 2, 1, 1);
layout_NORM->addWidget(label_NORM_CWF_LONG_F3, 3, 2, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F0, 4, 2, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F1, 5, 2, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F2, 6, 2, 1, 1);
//
layout_NORM->addWidget(label_NORM_BP1_F0_nb, 0, 3, 1, 1);
layout_NORM->addWidget(label_NORM_BP1_F1_nb, 1, 3, 1, 1);
layout_NORM->addWidget(label_NORM_BP1_F2_nb, 2, 3, 1, 1);
layout_NORM->addWidget(label_NORM_CWF_LONG_F3_nb, 3, 3, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F0_nb, 4, 3, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F1_nb, 5, 3, 1, 1);
layout_NORM->addWidget(label_NORM_BP2_F2_nb, 6, 3, 1, 1);
}
void TMStatistics::buildMonitor_BURST()
{
layout_BURST->addWidget(label_BURST_CWF_F2, 0, 0, 1, 1);
layout_BURST->addWidget(label_BURST_BP1_F0, 1, 0, 1, 1);
layout_BURST->addWidget(label_BURST_BP2_F0, 2, 0, 1, 1);
layout_BURST->addWidget(label_BURST_BP1_F1, 3, 0, 1, 1);
layout_BURST->addWidget(label_BURST_BP2_F1, 4, 0, 1, 1);
//
layout_BURST->addWidget(label_BURST_CWF_F2_nb, 0, 1, 1, 1);
layout_BURST->addWidget(label_BURST_BP1_F0_nb, 1, 1, 1, 1);
layout_BURST->addWidget(label_BURST_BP2_F0_nb, 2, 1, 1, 1);
layout_BURST->addWidget(label_BURST_BP1_F1_nb, 3, 1, 1, 1);
layout_BURST->addWidget(label_BURST_BP2_F1_nb, 4, 1, 1, 1);
//
layout_BURST->setRowStretch(5, 1);
layout_BURST->setColumnStretch(2,1);
}
void TMStatistics::buildMonitor_SBM1()
{
layout_SBM1->addWidget(label_SBM1_CWF_F1, 0, 0, 1, 1);
layout_SBM1->addWidget(label_SBM1_BP1_F0, 1, 0, 1, 1);
layout_SBM1->addWidget(label_SBM1_BP2_F0, 2, 0, 1, 1);
//
layout_SBM1->addWidget(label_SBM1_CWF_F1_nb, 0, 1, 1, 1);
layout_SBM1->addWidget(label_SBM1_BP1_F0_nb, 1, 1, 1, 1);
layout_SBM1->addWidget(label_SBM1_BP2_F0_nb, 2, 1, 1, 1);
//
layout_SBM1->setRowStretch(3, 1);
layout_SBM1->setColumnStretch(2,1);
}
void TMStatistics::buildMonitor_SBM2()
{
layout_SBM2->addWidget(label_SBM2_CWF_F2, 0, 0, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP1_F0, 1, 0, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP2_F0, 2, 0, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP1_F1, 3, 0, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP2_F1, 4, 0, 1, 1);
//
layout_SBM2->addWidget(label_SBM2_CWF_F2_nb, 0, 1, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP1_F0_nb, 1, 1, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP2_F0_nb, 2, 1, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP1_F1_nb, 3, 1, 1, 1);
layout_SBM2->addWidget(label_SBM2_BP2_F1_nb, 4, 1, 1, 1);
//
layout_SBM2->setRowStretch(5, 1);
layout_SBM2->setColumnStretch(2,1);
}
void TMStatistics::buildMonitor()
{
//***************
// TM_LFR_TC_EXE_
layout_stat->addWidget(label_SUCC, 0, 0, 1, 1);
layout_stat->addWidget(label_INCO, 1, 0, 1, 1);
layout_stat->addWidget(label_NOTE, 2, 0, 1, 1);
layout_stat->addWidget(label_NOTI, 3, 0, 1, 1);
layout_stat->addWidget(label_ERRO, 4, 0, 1, 1);
layout_stat->addWidget(label_CORR, 5, 0, 1, 1);
layout_stat->addWidget(label_HK, 6, 0, 1, 1);
layout_stat->addWidget(label_DUMP, 7, 0, 1, 1);
//
layout_stat->addWidget(label_SUCC_nb, 0, 1, 1, 1);
layout_stat->addWidget(label_INCO_nb, 1, 1, 1, 1);
layout_stat->addWidget(label_NOTE_nb, 2, 1, 1, 1);
layout_stat->addWidget(label_NOTI_nb, 3, 1, 1, 1);
layout_stat->addWidget(label_ERRO_nb, 4, 1, 1, 1);
layout_stat->addWidget(label_CORR_nb, 5, 1, 1, 1);
layout_stat->addWidget(label_HK_nb, 6, 1, 1, 1);
layout_stat->addWidget(label_DUMP_nb, 7, 1, 1, 1);
//********
// LAST TM
layout_last->addWidget(label_PID, 0, 0, 1, 1);
layout_last->addWidget(label_CAT, 0, 1, 1, 1);
layout_last->addWidget(label_TYP, 0, 2, 1, 1);
layout_last->addWidget(label_SUB, 0, 3, 1, 1);
layout_last->addWidget(label_SID, 0, 4, 1, 1);
layout_last->addWidget(label_SIZ, 0, 5, 1, 1);
//
layout_last->addWidget(label_PID_is, 1, 0, 1, 1);
layout_last->addWidget(label_CAT_is, 1, 1, 1, 1);
layout_last->addWidget(label_TYP_is, 1, 2, 1, 1);
layout_last->addWidget(label_SUB_is, 1, 3, 1, 1);
layout_last->addWidget(label_SID_is, 1, 4, 1, 1);
layout_last->addWidget(label_SIZ_is, 1, 5, 1, 1);
//
layout_last->addWidget(label_coarse_time, 2, 0, 1, 1);
layout_last->addWidget(label_coarse_time_val, 2, 1, 1, 1);
layout_last->addWidget(label_fine_time, 2, 2, 1, 1);
layout_last->addWidget(label_fine_time_val, 2, 3, 1, 1);
//
layout_last->addWidget(label_UNKNOWN, 3, 0, 1, 1);
layout_last->addWidget(label_UNKNOWN_nb, 3, 1, 1, 1);
layout_record->addWidget(checkbox_packetLog);
layout_record->addWidget(checkbox_packetRecording);
layout_record->addWidget(checkbox_CSVPacketRecording);
layout_record->addWidget(button_chooseDir);
layout_record->addWidget(label_currentDir);
layout_record->insertStretch(4, 1);
//***********
// groupboxes
groupbox_stat->setLayout(layout_stat);
groupbox_NORM->setLayout(layout_NORM);
groupbox_BURST->setLayout(layout_BURST);
groupbox_SBM1->setLayout(layout_SBM1);
groupbox_SBM2->setLayout(layout_SBM2);
groupbox_last->setLayout(layout_last);
groupbox_record->setLayout(layout_record);
//
mainLayout->addWidget(groupbox_stat, 0, 0, 1, 1);
mainLayout->addWidget(groupbox_NORM, 1, 0, 1, 1);
mainLayout->addWidget(groupbox_last, 2, 0, 1, 2);
mainLayout->addWidget(groupbox_SBM1, 0, 1, 1, 1);
mainLayout->addWidget(groupbox_SBM2, 0, 2, 1, 1);
mainLayout->addWidget(groupbox_BURST, 1, 1, 1, 1);
mainLayout->addWidget(groupbox_record, 1, 2, 1, 1);
mainLayout->addWidget(button_reset_stat, 3, 0, 1, 3);
mainLayout->setColumnStretch(3, 1);
mainLayout->setRowStretch(4, 1);
//
this->setLayout(mainLayout);
}
void TMStatistics::resetStatistics()
{
initConstants();
//
label_UNKNOWN_nb->setText("-");
label_SUCC_nb->setText("-");
label_INCO_nb->setText("-");
label_NOTE_nb->setText("-");
label_NOTI_nb->setText("-");
label_ERRO_nb->setText("-");
label_CORR_nb->setText("-");
label_HK_nb->setText("-");
label_DUMP_nb->setText("-");
//
label_NORM_SWF_F0_nb->setText("-");
label_NORM_SWF_F1_nb->setText("-");
label_NORM_SWF_F2_nb->setText("-");
label_NORM_CWF_F3_nb->setText("-");
label_NORM_CWF_LONG_F3_nb->setText("-");
label_NORM_ASM_F0_nb->setText("-");
//
label_BURST_CWF_F2_nb->setText("-");
//
label_SBM1_CWF_F1_nb->setText("-");
//
label_SBM2_CWF_F2_nb->setText("-");
//
label_PID_is->setText("-");
label_CAT_is->setText("-");
label_TYP_is->setText("-");
label_SUB_is->setText("-");
label_SID_is->setText("-");
label_SIZ_is->setText("-");
//
label_coarse_time_val->setText("-");
label_fine_time_val->setText("-");
}
void TMStatistics::updateStatistics(unsigned char pid, unsigned char cat,
unsigned char typ, unsigned char sub,
unsigned int sid, unsigned int length,
unsigned int coarse_t, unsigned int fine_t)
{
if (cat == TM_PACKET_CAT_TC_EXE)
{
if (typ == TM_TYPE_TC_EXE)
{
if (sub == TM_SUBTYPE_EXE_OK)
{
SUCC_nb = SUCC_nb + 1;
label_SUCC_nb->setText(QString::number(SUCC_nb));
}
else if (sub == TM_SUBTYPE_EXE_NOK)
{
if (sid == WRONG_APP_DATA)
{
INCO_nb = INCO_nb + 1;
label_INCO_nb->setText(QString::number(INCO_nb));
}
else if (sid == TC_NOT_EXE)
{
NOTE_nb = NOTE_nb + 1;
label_NOTE_nb->setText(QString::number(NOTE_nb));
}
else if (sid == FUNCT_NOT_IMPL)
{
NOTI_nb = NOTI_nb + 1;
label_NOTI_nb->setText(QString::number(NOTI_nb));
}
else if (sid == FAIL_DETECTED)
{
ERRO_nb = ERRO_nb + 1;
label_ERRO_nb->setText(QString::number(ERRO_nb));
}
else if (sid == CORRUPTED)
{
CORR_nb = CORR_nb + 1;
label_CORR_nb->setText(QString::number(CORR_nb));
}
else incrementUnknown();
}
else incrementUnknown();
}
else
incrementUnknown();
}
else if (cat == TM_PACKET_CAT_HK)
{
if (typ == TM_TYPE_HK)
{
if (sub == TM_SUBTYPE_HK)
if (sid == SID_HK)
{
HK_nb = HK_nb + 1;
label_HK_nb->setText(QString::number(HK_nb));
}
else
{
incrementUnknown();
}
else
{
incrementUnknown();
}
}
else
{
incrementUnknown();
}
}
else if (cat == TM_PACKET_CAT_PARAMETER_DUMP)
{
if (typ == TM_TYPE_PARAMETER_DUMP)
{
if (sub == TM_SUBTYPE_PARAMETER_DUMP)
if (sid == SID_PARAMETER_DUMP)
{
DUMP_nb = DUMP_nb + 1;
label_DUMP_nb->setText(QString::number(DUMP_nb));
}
else
{
incrementUnknown();
}
else
{
incrementUnknown();
}
}
else
{
incrementUnknown();
}
}
else if (cat == TM_PACKET_CAT_SCIENCE)
{
if (typ == TM_TYPE_LFR_SCIENCE)
{
if (sub == TM_SUBTYPE_SCIENCE)
{
if (sid == SID_NORM_CWF_F3)
{
NORM_CWF_F3_nb = NORM_CWF_F3_nb + 1;
label_NORM_CWF_F3_nb->setText(QString::number(NORM_CWF_F3_nb));
}
if (sid == SID_NORM_CWF_LONG_F3)
{
NORM_CWF_LONG_F3_nb = NORM_CWF_LONG_F3_nb + 1;
label_NORM_CWF_LONG_F3_nb->setText(QString::number(NORM_CWF_LONG_F3_nb));
}
else if (sid == SID_BURST_CWF_F2)
{
BURST_CWF_F2_nb = BURST_CWF_F2_nb + 1;
label_BURST_CWF_F2_nb->setText(QString::number(BURST_CWF_F2_nb));
}
else if (sid == SID_NORM_SWF_F0)
{
NORM_SWF_F0_nb = NORM_SWF_F0_nb + 1;
label_NORM_SWF_F0_nb->setText(QString::number(NORM_SWF_F0_nb));
}
else if (sid == SID_NORM_SWF_F1)
{
NORM_SWF_F1_nb = NORM_SWF_F1_nb + 1;
label_NORM_SWF_F1_nb->setText(QString::number(NORM_SWF_F1_nb));
}
else if (sid == SID_NORM_SWF_F2)
{
NORM_SWF_F2_nb = NORM_SWF_F2_nb + 1;
label_NORM_SWF_F2_nb->setText(QString::number(NORM_SWF_F2_nb));
}
else if (sid == SID_NORM_ASM_F0)
{
NORM_ASM_F0_nb = NORM_ASM_F0_nb + 1;
label_NORM_ASM_F0_nb->setText(QString::number(NORM_ASM_F0_nb));
}
else if (sid == SID_SBM1_CWF_F1)
{
SBM1_CWF_F1_nb = SBM1_CWF_F1_nb + 1;
label_SBM1_CWF_F1_nb->setText(QString::number(SBM1_CWF_F1_nb));
}
else if (sid == SID_SBM2_CWF_F2)
{
SBM2_CWF_F2_nb = SBM2_CWF_F2_nb + 1;
label_SBM2_CWF_F2_nb->setText(QString::number(SBM2_CWF_F2_nb));
}
else
{
incrementUnknown();
}
}
}
else
{
incrementUnknown();
}
}
else
{
incrementUnknown();
}
label_PID_is->setText(QString::number(pid));
label_CAT_is->setText(QString::number(cat));
label_TYP_is->setText(QString::number(typ));
label_SUB_is->setText(QString::number(sub));
label_SID_is->setText(QString::number(sid));
label_SIZ_is->setText(QString::number(length));
label_coarse_time_val->setText(QString::number(coarse_t, 16));
label_fine_time_val->setText(QString::number(fine_t, 16));
}
void TMStatistics::incrementUnknown()
{
UNKNOWN_nb = UNKNOWN_nb + 1;
label_UNKNOWN_nb->setText(QString::number(UNKNOWN_nb));
}
unsigned char TMStatistics::getPID(TMPacketToRead *packet)
{
unsigned char pid = 0;
pid = ((packet->Value[4] & 0x07) << 4) + ((packet->Value[5] & 0xf0) >> 4);
return pid;
}
unsigned char TMStatistics::getCAT(TMPacketToRead *packet)
{
unsigned char cat = 0;
cat = packet->Value[5] & 0x0f;
return cat;
}
unsigned char TMStatistics::getSegmentationGroupingFlag(TMPacketToRead *packet)
{
unsigned char segmentationGroupingFlag;
segmentationGroupingFlag = (unsigned char) (packet->Value[6] >> 6);
return segmentationGroupingFlag;
}
unsigned char TMStatistics::getTYPE(TMPacketToRead *packet)
{
unsigned char typ = 0;
typ = packet->Value[11]; // TYPE
return typ;
}
unsigned char TMStatistics::getSUBTYPE(TMPacketToRead *packet)
{
unsigned char sub = 0;
sub = packet->Value[12]; // SUBTYPE
return sub;
}
unsigned int TMStatistics::getLENGTH(TMPacketToRead *packet)
{
unsigned int length = 0;
length = packet->Value[8] * 256 + packet->Value[9];
return length;
}
unsigned int TMStatistics::getCoarseTime(TMPacketToRead *packet)
{
unsigned int coarse = 0;
coarse = packet->Value[14] * pow(2, 24) + packet->Value[15] * pow(2, 16)
+ packet->Value[16] * pow(2, 8) + packet->Value[17];
return coarse;
}
unsigned int TMStatistics::getFineTime(TMPacketToRead *packet)
{
unsigned int fine = 0;
fine = packet->Value[18] * pow(2, 8) + packet->Value[19];
return fine;
}
unsigned int TMStatistics::getSID(TMPacketToRead *packet,
unsigned char pid, unsigned char cat,
unsigned char typ, unsigned char sub)
{
unsigned int sid = 0;
QString packetName;
QTime currentTime;
QDate currentDate;
unsigned int i;
if ((pid == TM_PACKET_PID_DEFAULT) & (cat == TM_PACKET_CAT_TC_EXE)
& (typ == TM_TYPE_TC_EXE) & (sub == TM_SUBTYPE_EXE_NOK))
sid = packet->Value[20] * 256 + packet->Value[21];
else if ((pid == TM_PACKET_PID_DEFAULT) & (cat == TM_PACKET_CAT_HK)
& (typ == TM_TYPE_HK) & (sub == TM_SUBTYPE_HK))
sid = SID_HK;
else if ((pid == TM_PACKET_PID_DEFAULT) & (cat == TM_PACKET_CAT_PARAMETER_DUMP)
& (typ == TM_TYPE_PARAMETER_DUMP) & (sub == TM_SUBTYPE_PARAMETER_DUMP))
sid = SID_PARAMETER_DUMP;
else if ((pid == TM_PACKET_PID_DEFAULT) & (cat == TM_PACKET_CAT_SCIENCE)
& (typ == TM_TYPE_LFR_SCIENCE) & (sub == TM_SUBTYPE_LFR_SCIENCE))
sid = packet->Value[20];
else if ((pid == TM_PACKET_PID_BURST_SBM1_SBM2) & (cat == TM_PACKET_CAT_SCIENCE)
& (typ == TM_TYPE_LFR_SCIENCE) & (sub == TM_SUBTYPE_LFR_SCIENCE))
sid = packet->Value[20];
if (logFileEn == true)
{
logFile->write((char *) &packet->Value[4], (packet->size-4));
}
currentTime = QTime::currentTime();
currentDate = QDate::currentDate();
if (packetLogFileEn == true)
{
packetName = getPacketName( typ, sub, sid);
*(this->packetLogFileStrm)
<< QString::number(currentDate.year()) + " "
<< QString::number(currentDate.month()) + " "
<< QString::number(currentDate.day()) + " "
<< QTime::currentTime().toString() + ":"
<< QString::number(currentTime.msec()) + " "
<< packetName
<< " time = 0x " + QString::number(
(packet->Value[14] << 24) + (packet->Value[15] << 16) + (packet->Value[16] << 8) + packet->Value[17],
16).right(8)
<< " " + QString::number( (packet->Value[18] << 8) + packet->Value[19], 16)
<< endl;
}
if (csvPacketRecordFileEn == true)
{
*(this->csvPacketRecordFileStrm)
<< QString::number(currentDate.year()) + " "
<< QString::number(currentDate.month()) + " "
<< QString::number(currentDate.day()) + " "
<< QTime::currentTime().toString() + ":"
<< QString::number(currentTime.msec());
for (i=0; i< packet->size; i++)
{
*(this->csvPacketRecordFileStrm)
<< ", " + QString::number( packet->Value[i] );
}
*(this->csvPacketRecordFileStrm)
<< endl;
}
return sid;
}
void TMStatistics::buildFileName()
{
QTime time;
QDate date;
QString dateTime;
QString prefix;
date = QDate::currentDate();
time = QTime::currentTime();
dateTime = QString::number( date.year() ) + "_"
+ QString::number( date.month() ) + "_"
+ QString::number( date.day() ) + "-"
+ QString::number( time.hour() ) + "_"
+ QString::number( time.minute() ) + "_"
+ QString::number( time.second() );
prefix = defaultStorageDirectory + "/" + dateTime + "_" ;
if(this->logFile->isOpen()) this->logFile->close();
this->logFile->setFileName( prefix + "packet_record.data");
if(this->logFile->open(QIODevice::WriteOnly))
this->logFileStrm = new QTextStream(this->logFile);
}
void TMStatistics::buildPacketLogFileName()
{
QTime time;
QDate date;
QString dateTime;
QString prefix;
date = QDate::currentDate();
time = QTime::currentTime();
dateTime = QString::number( date.year() ) + "_"
+ QString::number( date.month() ) + "_"
+ QString::number( date.day() ) + "-"
+ QString::number( time.hour() ) + "_"
+ QString::number( time.minute() ) + "_"
+ QString::number( time.second() );
prefix = defaultStorageDirectory + "/" + dateTime + "_" ;
if(this->packetLogFile->isOpen()) this->packetLogFile->close();
this->packetLogFile->setFileName( prefix + "packet_log.data");
if(this->packetLogFile->open(QIODevice::WriteOnly))
this->packetLogFileStrm = new QTextStream(this->packetLogFile);
}
void TMStatistics::buildCSVPacketRecordFileName()
{
QTime time;
QDate date;
QString dateTime;
QString prefix;
date = QDate::currentDate();
time = QTime::currentTime();
dateTime = QString::number( date.year() ) + "_"
+ QString::number( date.month() ) + "_"
+ QString::number( date.day() ) + "-"
+ QString::number( time.hour() ) + "_"
+ QString::number( time.minute() ) + "_"
+ QString::number( time.second() );
prefix = defaultStorageDirectory + "/" + dateTime + "_" ;
if(this->csvPacketRecordFile->isOpen()) this->csvPacketRecordFile->close();
this->csvPacketRecordFile->setFileName( prefix + "packet_record.csv");
if(this->csvPacketRecordFile->open(QIODevice::WriteOnly))
this->csvPacketRecordFileStrm = new QTextStream(this->csvPacketRecordFile);
}
void TMStatistics::storePackets( int state )
{
if (state == Qt::Checked)
{
buildFileName();
logFileEn = true;
}
else
{
if(this->logFile->isOpen()) this->logFile->close();
logFileEn = false;
}
}
void TMStatistics::storeCSVPackets( int state )
{
if (state == Qt::Checked)
{
buildCSVPacketRecordFileName();
csvPacketRecordFileEn = true;
}
else
{
if(this->csvPacketRecordFile->isOpen()) this->csvPacketRecordFile->close();
csvPacketRecordFileEn = false;
}
}
void TMStatistics::logPackets( int state )
{
if (state == Qt::Checked)
{
buildPacketLogFileName();
packetLogFileEn = true;
}
else
{
if(this->packetLogFile->isOpen()) this->packetLogFile->close();
packetLogFileEn = false;
}
}
void TMStatistics::chooseDir()
{
QString tmpDefaultStorageDirectory;
tmpDefaultStorageDirectory = QFileDialog::getExistingDirectory(this,
"choose the directory",
QDir::homePath(),
QFileDialog::ShowDirsOnly);
if( !tmpDefaultStorageDirectory.isEmpty() )
{
defaultStorageDirectory = tmpDefaultStorageDirectory;
}
label_currentDir->setText(defaultStorageDirectory);
}
void TMStatistics::closeEvent(QCloseEvent *event)
{
if(this->logFile->isOpen())
{
this->logFileStrm->flush();
this->logFile->waitForBytesWritten(3000);
this->logFile->close();
}
event->accept();
}
QString TMStatistics::getPacketName(unsigned char type, unsigned char subtype, unsigned int sid)
{
QString packetName = "default";
if (type == TM_TYPE_TC_EXE)
{
if (subtype== TM_SUBTYPE_EXE_OK) packetName = "TM_LFR_TC_EXE_SUCCESS";
if (subtype == TM_SUBTYPE_EXE_NOK)
{
if (sid == WRONG_APP_DATA) packetName = "TM_LFR_TC_EXE_INCONSISTENT";
if (sid == TC_NOT_EXE) packetName = "TM_LFR_TC_EXE_NOT_EXECUTABLE";
if (sid == FUNCT_NOT_IMPL) packetName = "TM_LFR_TC_EXE_NOT_IMPLEMENTED";
if (sid == FAIL_DETECTED) packetName = "TM_LFR_TC_EXE_ERROR";
if (sid == CORRUPTED) packetName = "TM_LFR_TC_EXE_CORRUPTED";
}
}
if (type == TM_TYPE_HK)
{
if (subtype == TM_SUBTYPE_HK)
{
if (sid == SID_HK) packetName = "TM_LFR_HK";
if (sid == SID_PARAMETER_DUMP) packetName = "TM_LFR_PARAMETER_DUMP";
}
}
if (type == TM_TYPE_LFR_SCIENCE)
{
if (subtype == TM_SUBTYPE_SCIENCE)
{
if (sid == SID_NORM_SWF_F0) packetName = "TM_LFR_SCIENCE_NORMAL_SWF_F0";
if (sid == SID_NORM_SWF_F1) packetName = "TM_LFR_SCIENCE_NORMAL_SWF_F1";
if (sid == SID_NORM_SWF_F2) packetName = "TM_LFR_SCIENCE_NORMAL_SWF_F2";
if (sid == SID_NORM_CWF_F3) packetName = "TM_LFR_SCIENCE_NORMAL_CWF_F3";
if (sid == SID_BURST_CWF_F2) packetName = "TM_LFR_SCIENCE_BURST_CWF_F2";
if (sid == SID_SBM1_CWF_F1) packetName = "TM_LFR_SCIENCE_SBM1_CWF_F1";
if (sid == SID_SBM2_CWF_F2) packetName = "TM_LFR_SCIENCE_SBM2_CWF_F2";
if (sid == SID_NORM_ASM_F0) packetName = "TM_LFR_SCIENCE_NORMAL_ASM_F0";
if (sid == SID_NORM_ASM_F1) packetName = "TM_LFR_SCIENCE_NORMAL_ASM_F1";
if (sid == SID_NORM_ASM_F2) packetName = "TM_LFR_SCIENCE_NORMAL_ASM_F2";
if (sid == SID_NORM_BP1_F0) packetName = "TM_LFR_SCIENCE_NORMAL_BP1_F0";
if (sid == SID_NORM_BP1_F1) packetName = "TM_LFR_SCIENCE_NORMAL_BP1_F1";
if (sid == SID_NORM_BP1_F2) packetName = "TM_LFR_SCIENCE_NORMAL_BP1_F2";
if (sid == SID_NORM_BP2_F0) packetName = "TM_LFR_SCIENCE_NORMAL_BP2_F0";
if (sid == SID_NORM_BP2_F1) packetName = "TM_LFR_SCIENCE_NORMAL_BP2_F1";
if (sid == SID_NORM_BP2_F2) packetName = "TM_LFR_SCIENCE_NORMAL_BP2_F2";
if (sid == SID_BURST_BP1_F0) packetName = "TM_LFR_SCIENCE_BURST_BP1_F0";
if (sid == SID_BURST_BP2_F0) packetName = "TM_LFR_SCIENCE_BURST_BP2_F0";
if (sid == SID_BURST_BP1_F1) packetName = "TM_LFR_SCIENCE_BURST_BP1_F1";
if (sid == SID_BURST_BP2_F1) packetName = "TM_LFR_SCIENCE_BURST_BP2_F1";
if (sid == SID_SBM1_BP1_F0) packetName = "TM_LFR_SCIENCE_SBM1_BP1_F0";
if (sid == SID_SBM1_BP2_F0) packetName = "TM_LFR_SCIENCE_SBM1_BP2_F0";
if (sid == SID_SBM2_BP1_F0) packetName = "TM_LFR_SCIENCE_SBM2_BP1_F0";
if (sid == SID_SBM2_BP2_F0) packetName = "TM_LFR_SCIENCE_SBM2_BP2_F0";
if (sid == SID_SBM2_BP1_F1) packetName = "TM_LFR_SCIENCE_SBM2_BP1_F1";
if (sid == SID_SBM2_BP2_F1) packetName = "TM_LFR_SCIENCE_SBM2_BP2_F1";
}
}
return packetName;
}
void TMStatistics::readSettings()
{
QSettings settings("lpp", "lfrsgse");
defaultStorageDirectory = settings.value( "defaultStorageDirectory", QDir::homePath() ).toString();
label_currentDir->setText(defaultStorageDirectory);
}
void TMStatistics::writeSettings()
{
QSettings settings("lpp", "lfrsgse");
settings.setValue("defaultStorageDirectory", defaultStorageDirectory);
}