##// END OF EJS Templates
Defines fuzzing operations...
Defines fuzzing operations Fuzzinf operations are operations that can be executed on a variable during tests. For now, only the "variable creation" operation is implemented

File last commit:

r949:2da9b0f28a10
r1171:1d0fdfceb8fb
Show More
AmdaResultParser.cpp
133 lines | 4.0 KiB | text/x-c | CppLexer
/ plugins / amda / src / AmdaResultParser.cpp
Alexandre Leroux
Amda provider (3)...
r380 #include "AmdaResultParser.h"
Alexandre Leroux
Parser refactoring (5)...
r948 #include "AmdaResultParserHelper.h"
Alexandre Leroux
Amda provider (3)...
r380
#include <QFile>
Add the cmath include missing
r400 #include <cmath>
Alexandre Leroux
Amda provider (3)...
r380 Q_LOGGING_CATEGORY(LOG_AmdaResultParser, "AmdaResultParser")
namespace {
Alexandre Leroux
Handles "Not found" error for AMDA result parser
r446 /// Message in result file when the file was not found on server
const auto FILE_NOT_FOUND_MESSAGE = QStringLiteral("Not Found");
Alexandre Leroux
Improves AMDA result parsing...
r492 /// Checks if a line is a comment line
bool isCommentLine(const QString &line)
{
return line.startsWith("#");
}
Alexandre Leroux
Parser refactoring (5)...
r948 /**
* Creates helper that will be used to read AMDA file, according to the type passed as parameter
* @param valueType the type of values expected in the AMDA file (scalars, vectors, spectrograms...)
* @return the helper created
*/
std::unique_ptr<IAmdaResultParserHelper> createHelper(AmdaResultParser::ValueType valueType)
Alexandre Leroux
Updates method for reading results according to the value type (vector or scalar)
r564 {
switch (valueType) {
case AmdaResultParser::ValueType::SCALAR:
Alexandre Leroux
Parser refactoring (5)...
r948 return std::make_unique<ScalarParserHelper>();
Alexandre Leroux
Spectrograms implementation (1)...
r949 case AmdaResultParser::ValueType::SPECTROGRAM:
return std::make_unique<SpectrogramParserHelper>();
Alexandre Leroux
Updates method for reading results according to the value type (vector or scalar)
r564 case AmdaResultParser::ValueType::VECTOR:
Alexandre Leroux
Parser refactoring (5)...
r948 return std::make_unique<VectorParserHelper>();
Alexandre Leroux
Updates method for reading results according to the value type (vector or scalar)
r564 case AmdaResultParser::ValueType::UNKNOWN:
// Invalid case
break;
}
// Invalid cases
qCCritical(LOG_AmdaResultParser())
Alexandre Leroux
Parser refactoring (5)...
r948 << QObject::tr("Can't create helper to read result file: unsupported type");
return nullptr;
Alexandre Leroux
Updates method for reading results according to the value type (vector or scalar)
r564 }
Alexandre Leroux
Reads x-axis unit in result file
r393 /**
Alexandre Leroux
Parser refactoring (5)...
r948 * Reads properties of the stream passed as parameter
* @param helper the helper used to read properties line by line
Alexandre Leroux
Reads x-axis unit in result file
r393 * @param stream the stream to read
*/
Alexandre Leroux
Parser refactoring (5)...
r948 void readProperties(IAmdaResultParserHelper &helper, QTextStream &stream)
Alexandre Leroux
Reads x-axis unit in result file
r393 {
Alexandre Leroux
Parser refactoring (5)...
r948 // Searches properties in the comment lines (as long as the reading has not reached the data)
Alexandre Leroux
Changes way to retrieve unit
r791 // AMDA V2: while (stream.readLineInto(&line) && !line.contains(DATA_HEADER_REGEX)) {
Alexandre Leroux
Parser refactoring (5)...
r948 QString line{};
Alexandre Leroux
Changes way to retrieve unit
r791 while (stream.readLineInto(&line) && isCommentLine(line)) {
Alexandre Leroux
Parser refactoring (5)...
r948 helper.readPropertyLine(line);
Alexandre Leroux
Reads x-axis unit in result file
r393 }
}
Alexandre Leroux
Improves controls when reading results
r394 /**
Alexandre Leroux
Parser refactoring (5)...
r948 * Reads results of the stream passed as parameter
* @param helper the helper used to read results line by line
Alexandre Leroux
Improves controls when reading results
r394 * @param stream the stream to read
*/
Alexandre Leroux
Parser refactoring (5)...
r948 void readResults(IAmdaResultParserHelper &helper, QTextStream &stream)
Alexandre Leroux
Improves controls when reading results
r394 {
QString line{};
Alexandre Leroux
Improves AMDA result parsing...
r492
Alexandre Leroux
- Changes the way to retrieve unit in AMDA result file: The generated header in the result file differs from the first version...
r775 // Skip comment lines
while (stream.readLineInto(&line) && isCommentLine(line)) {
}
if (!stream.atEnd()) {
do {
Alexandre Leroux
Parser refactoring (5)...
r948 helper.readResultLine(line);
Alexandre Leroux
- Changes the way to retrieve unit in AMDA result file: The generated header in the result file differs from the first version...
r775 } while (stream.readLineInto(&line));
Alexandre Leroux
Improves controls when reading results
r394 }
}
Alexandre Leroux
Amda provider (3)...
r380 } // namespace
Alexandre Leroux
Creates enum that represents the value types that can be read in AMDA...
r563 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath,
ValueType valueType) noexcept
Alexandre Leroux
Amda provider (3)...
r380 {
Alexandre Leroux
Creates enum that represents the value types that can be read in AMDA...
r563 if (valueType == ValueType::UNKNOWN) {
qCCritical(LOG_AmdaResultParser())
<< QObject::tr("Can't retrieve AMDA data: the type of values to be read is unknown");
return nullptr;
}
Alexandre Leroux
Amda provider (3)...
r380 QFile file{filePath};
if (!file.open(QFile::ReadOnly | QIODevice::Text)) {
qCCritical(LOG_AmdaResultParser())
<< QObject::tr("Can't retrieve AMDA data from file %1: %2")
.arg(filePath, file.errorString());
return nullptr;
}
QTextStream stream{&file};
Alexandre Leroux
Handles "Not found" error for AMDA result parser
r446 // Checks if the file was found on the server
auto firstLine = stream.readLine();
if (firstLine.compare(FILE_NOT_FOUND_MESSAGE) == 0) {
qCCritical(LOG_AmdaResultParser())
<< QObject::tr("Can't retrieve AMDA data from file %1: file was not found on server")
.arg(filePath);
return nullptr;
}
Alexandre Leroux
Parser refactoring (5)...
r948 auto helper = createHelper(valueType);
Q_ASSERT(helper != nullptr);
Alexandre Leroux
Reads x-axis unit in result file
r393
Alexandre Leroux
Parser refactoring (5)...
r948 // Reads header file to retrieve properties
Alexandre Leroux
Changes way to retrieve unit
r791 stream.seek(0); // returns to the beginning of the file
Alexandre Leroux
Parser refactoring (5)...
r948 readProperties(*helper, stream);
Alexandre Leroux
Updates method for reading results according to the value type (vector or scalar)
r564
Alexandre Leroux
Parser refactoring (5)...
r948 // Checks properties
if (helper->checkProperties()) {
// Reads results
// AMDA V2: remove line
stream.seek(0); // returns to the beginning of the file
readResults(*helper, stream);
Alexandre Leroux
Amda provider (3)...
r380
Alexandre Leroux
Parser refactoring (5)...
r948 // Creates data series
return helper->createSeries();
}
else {
return nullptr;
}
Alexandre Leroux
Amda provider (3)...
r380 }