@@ -17,9 +17,6 namespace { | |||
|
17 | 17 | /// Message in result file when the file was not found on server |
|
18 | 18 | const auto FILE_NOT_FOUND_MESSAGE = QStringLiteral("Not Found"); |
|
19 | 19 | |
|
20 | /// Format for dates in result files | |
|
21 | const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); | |
|
22 | ||
|
23 | 20 | /// Separator between values in a result line |
|
24 | 21 | const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; |
|
25 | 22 | |
@@ -38,7 +35,8 const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\ | |||
|
38 | 35 | /// @return a double that represents the date in seconds, NaN if the string date can't be converted |
|
39 | 36 | double doubleDate(const QString &stringDate) noexcept |
|
40 | 37 | { |
|
41 | auto dateTime = QDateTime::fromString(stringDate, DATE_FORMAT); | |
|
38 | // Format: yyyy-MM-ddThh:mm:ss.zzz | |
|
39 | auto dateTime = QDateTime::fromString(stringDate, Qt::ISODateWithMs); | |
|
42 | 40 | dateTime.setTimeSpec(Qt::UTC); |
|
43 | 41 | return dateTime.isValid() ? DateUtils::secondsSinceEpoch(dateTime) |
|
44 | 42 | : std::numeric_limits<double>::quiet_NaN(); |
@@ -101,18 +99,21 Unit readXAxisUnit(QTextStream &stream) | |||
|
101 | 99 | std::pair<std::vector<double>, std::vector<double> > |
|
102 | 100 | readResults(QTextStream &stream, AmdaResultParser::ValueType valueType) |
|
103 | 101 | { |
|
104 | auto expectedNbValues = nbValues(valueType); | |
|
102 | auto expectedNbValues = nbValues(valueType) + 1; | |
|
105 | 103 | |
|
106 | 104 | auto xData = std::vector<double>{}; |
|
107 | 105 | auto valuesData = std::vector<double>{}; |
|
108 | 106 | |
|
109 | 107 | QString line{}; |
|
110 | 108 | |
|
111 | while (stream.readLineInto(&line)) { | |
|
112 | // Ignore comment lines | |
|
113 | if (!isCommentLine(line)) { | |
|
109 | // Skip comment lines | |
|
110 | while (stream.readLineInto(&line) && isCommentLine(line)) { | |
|
111 | } | |
|
112 | ||
|
113 | if (!stream.atEnd()) { | |
|
114 | do { | |
|
114 | 115 | auto lineData = line.split(RESULT_LINE_SEPARATOR, QString::SkipEmptyParts); |
|
115 |
if (lineData.size() == expectedNbValues |
|
|
116 | if (lineData.size() == expectedNbValues) { | |
|
116 | 117 | // X : the data is converted from date to double (in secs) |
|
117 | 118 | auto x = doubleDate(lineData.at(0)); |
|
118 | 119 | |
@@ -121,8 +122,8 readResults(QTextStream &stream, AmdaResultParser::ValueType valueType) | |||
|
121 | 122 | xData.push_back(x); |
|
122 | 123 | |
|
123 | 124 | // Values |
|
124 |
for (auto valueIndex = |
|
|
125 |
auto column = valueIndex |
|
|
125 | for (auto valueIndex = 1; valueIndex < expectedNbValues; ++valueIndex) { | |
|
126 | auto column = valueIndex; | |
|
126 | 127 | |
|
127 | 128 | bool valueOk; |
|
128 | 129 | auto value = lineData.at(column).toDouble(&valueOk); |
@@ -148,7 +149,7 readResults(QTextStream &stream, AmdaResultParser::ValueType valueType) | |||
|
148 | 149 | qCWarning(LOG_AmdaResultParser()) |
|
149 | 150 | << QObject::tr("Can't retrieve results from line %1: invalid line").arg(line); |
|
150 | 151 | } |
|
151 | } | |
|
152 | } while (stream.readLineInto(&line)); | |
|
152 | 153 | } |
|
153 | 154 | |
|
154 | 155 | return std::make_pair(std::move(xData), std::move(valuesData)); |
General Comments 0
You need to be logged in to leave comments.
Login now