194 lines
6.7 KiB
C++
194 lines
6.7 KiB
C++
#include "TestReport.h"
|
|
#include <QDateTime>
|
|
#include <QFile>
|
|
#include <QTextStream>
|
|
#include <QMessageBox>
|
|
#include <QTextCodec>
|
|
#include "TestBenchSettings.h"
|
|
|
|
CTestReport::CTestReport()
|
|
{
|
|
mSoftwareVersion = QString(TEST_BENCH_VERSION);
|
|
CreateNewTestReport();
|
|
mReportFileDirectory = "./Rapports/";
|
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
|
}
|
|
|
|
CVisualInspectionResult * CTestReport::GetInspectionResult()
|
|
{
|
|
return &mVisualInspectionResultReport;
|
|
}
|
|
|
|
CCableParametersData *CTestReport::GetReportCableParameters()
|
|
{
|
|
return &mCableParameters;
|
|
}
|
|
|
|
int CTestReport::CreateNewTestReport()
|
|
{
|
|
mVisualInspectionResultReport.ClearResults();
|
|
mCableParameters.ResetData();
|
|
mAutomatedTestReport.ClearAutomatedTestReport();
|
|
mTestLog.clear();
|
|
mLastReportName.clear();
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
int CTestReport::AddLogEntry(QString NewEntry, bool IncludeTime, bool Propagate)
|
|
{
|
|
if(NewEntry.isEmpty())
|
|
{
|
|
return RET_ERROR;
|
|
}
|
|
|
|
if(IncludeTime)
|
|
{
|
|
QString Time = QDateTime::currentDateTime().toString("hh:mm:ss.zzz - ");
|
|
NewEntry.prepend(Time);
|
|
}
|
|
|
|
qDebug(NewEntry.toAscii().data());
|
|
|
|
if(NewEntry.endsWith(QChar('\n')) == false)
|
|
{
|
|
NewEntry.append(QChar('\n'));
|
|
}
|
|
|
|
if(Propagate)
|
|
{
|
|
emit NewTestLogEntry(NewEntry);
|
|
}
|
|
|
|
mTestLog.append(NewEntry);
|
|
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
CAutomatedTestReport *CTestReport::GetAutomatedTestReport()
|
|
{
|
|
return &mAutomatedTestReport;
|
|
}
|
|
|
|
int CTestReport::SaveReportToFile(CTestBenchSettings *BenchSettings)
|
|
{
|
|
QFile *ReportFile;
|
|
//QTextStream ReportStream;
|
|
|
|
|
|
QString Filename = QDateTime::currentDateTime().toString("yyMMdd_hhmmss_");
|
|
Filename.append(mCableParameters.mStationCodeName);
|
|
Filename.append(mCableParameters.mCableIdentification);
|
|
Filename.append(".txt");
|
|
Filename.prepend(mReportFileDirectory);
|
|
|
|
|
|
ReportFile = new QFile(Filename);
|
|
|
|
if (!ReportFile->open(QIODevice::ReadWrite |QIODevice::Truncate | QIODevice::Text))
|
|
{
|
|
AddLogEntry(QString("Impossible de sauvegarder le rapport %1").arg(Filename),false);
|
|
QMessageBox::critical(NULL,"Erreur de sauvegarde",QString("Impossible de sauvegarder le fichier rapport \n%1").arg(Filename));
|
|
|
|
return RET_ERROR;
|
|
}
|
|
|
|
mLastReportName = Filename;
|
|
|
|
QTextStream ReportStream(ReportFile);
|
|
ReportStream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
ReportStream << QString("Rapport de test - Câble SEI\n");
|
|
ReportStream << QString("Date de l'essai: ") << QDateTime::currentDateTime().toString("yyyy-MM-dd") << "\n";
|
|
ReportStream << "Version du logiciel de test: " << mSoftwareVersion << "\n\n";
|
|
ReportStream << "-----------------------------------------\n";
|
|
ReportStream << QString("Paramètres du test: \n");
|
|
ReportStream << QString("Temps de maintien des contacts: %1ms\n").arg(BenchSettings->mPinHoldTime);
|
|
if(BenchSettings->mIgnoreVisualInspection)
|
|
{
|
|
ReportStream << QString("Ignorer inspection visuelle: OUI\n");
|
|
}
|
|
else
|
|
{
|
|
ReportStream << QString("Ignorer inspection visuelle: NON\n");
|
|
}
|
|
ReportStream << QString("Adresse IP des modules d'I/O : %1\n\n").arg(BenchSettings->mIOModuleIPAddress);
|
|
ReportStream << "-----------------------------------------\n";
|
|
ReportStream << QString("Paramètres du câble: \n");
|
|
ReportStream << QString("Identification du câble: ") << mCableParameters.mCableIdentification << "\n";
|
|
ReportStream << "Station: " << mCableParameters.mStationCodeName << " - "<< mCableParameters.mStationName << "\n";
|
|
ReportStream << "Type: " << mCableParameters.mCableType << "\n";
|
|
ReportStream << QString("Opérateur du test: ") << mCableParameters.mTestOperatorName << "\n";
|
|
ReportStream << QString("Connecteur d'entrée: ") << mCableParameters.mInputConnectorType << "\n";
|
|
ReportStream << "Connecteur de sortie: " << mCableParameters.mOutputConnectorType << "\n\n";
|
|
ReportStream << "-----------------------------------------\n";
|
|
ReportStream << QString("Résultats de l'inspection visuelle:\n");
|
|
ReportStream << QString("Section 5.2 exécutée: ") << mVisualInspectionResultReport.mVerif52ExecResultText << "\n";
|
|
ReportStream << QString("Section 5.3 exécutée: ") << mVisualInspectionResultReport.mVerif53ExecResultText << "\n";
|
|
ReportStream << QString("Section 5.4 exécutée: ") << mVisualInspectionResultReport.mVerif54ExecResultText << "\n";
|
|
ReportStream << QString("Section 5.5 exécutée: ") << mVisualInspectionResultReport.mVerif55ExecResultText << "\n";
|
|
ReportStream << QString("Section 5.6 exécutée: ") << mVisualInspectionResultReport.mVerif56ExecResultText << "\n\n";
|
|
ReportStream << "Notes d'inspection:\n\n";
|
|
ReportStream << mVisualInspectionResultReport.mVerifNotesText << "\n\n";
|
|
ReportStream << "-----------------------------------------\n";
|
|
ReportStream << QString("Résultats du test automatique du câble:\n");
|
|
ReportStream << QString("Pré-test des modules d'I/O: ") << mAutomatedTestReport.GetPretestResult() << "\n";
|
|
ReportStream << QString("Lorsqu'applicable, les valeurs entre crochets [] correspondent aux contacts en défaut.\n\n");
|
|
ReportStream.setFieldWidth(15);
|
|
ReportStream.setFieldAlignment(QTextStream::AlignCenter);
|
|
ReportStream << "No. Contact" << QString("Continuité") << "Isolation" << "Assignation" << QString("2è test") << qSetFieldWidth(0) << "\n";
|
|
|
|
|
|
|
|
for(int pin = 1; pin <= mAutomatedTestReport.mPinCount; pin++)
|
|
{
|
|
ReportStream.setFieldWidth(15);
|
|
ReportStream.setFieldAlignment(QTextStream::AlignCenter);
|
|
|
|
ReportStream << QString("%1").arg(pin) <<
|
|
mAutomatedTestReport.GetPinContinuityResult(pin) <<
|
|
mAutomatedTestReport.GetPinIsolationResult(pin) <<
|
|
mAutomatedTestReport.GetPinConcordanceResult(pin) <<
|
|
mAutomatedTestReport.GetPinSecondTestResult(pin) << qSetFieldWidth(0) <<
|
|
" \n";
|
|
|
|
}
|
|
|
|
|
|
|
|
ReportStream << QString("\n\n\n Signature de l'opérateur de test: _________________________________________\n\n");
|
|
ReportStream << QString(" Date: _________________________________________\n\n");
|
|
ReportStream << "-----------------------------------------\n";
|
|
|
|
if(BenchSettings->mIncludeLogInReport)
|
|
{
|
|
ReportStream << "Log du test:\n";
|
|
ReportStream << mTestLog;
|
|
}
|
|
|
|
ReportFile->close();
|
|
delete ReportFile;
|
|
|
|
return RET_OK;
|
|
}
|
|
|
|
bool CTestReport::IsAutoTestReportReady()
|
|
{
|
|
if(mAutomatedTestReport.GetPinCount() == 0)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool CTestReport::GetGlobalAutoTestResult()
|
|
{
|
|
return mAutomatedTestReport.IsAutomatedTestSuccess();
|
|
}
|
|
|
|
QString CTestReport::GetLastReportFileName()
|
|
{
|
|
return mLastReportName;
|
|
}
|