@@ -20,19 +20,28 const auto FILE_NOT_FOUND_MESSAGE = QStringLiteral("Not Found"); | |||||
20 | /// Separator between values in a result line |
|
20 | /// Separator between values in a result line | |
21 | const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; |
|
21 | const auto RESULT_LINE_SEPARATOR = QRegularExpression{QStringLiteral("\\s+")}; | |
22 |
|
22 | |||
23 | /// Regex to find the header of the data in the file. This header indicates the end of comments in |
|
23 | // AMDA V2 | |
24 | /// the file |
|
24 | // /// Regex to find the header of the data in the file. This header indicates the end of comments | |
25 | const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; |
|
25 | // in | |
|
26 | // /// the file | |||
|
27 | // const auto DATA_HEADER_REGEX = QRegularExpression{QStringLiteral("#\\s*DATA\\s*:")}; | |||
26 |
|
28 | |||
27 | /// Format for dates in result files |
|
29 | /// Format for dates in result files | |
28 | const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); |
|
30 | const auto DATE_FORMAT = QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz"); | |
29 |
|
31 | |||
30 | /// Regex to find unit in a line. Examples of valid lines: |
|
32 | // AMDA V2 | |
31 | /// ... PARAMETER_UNITS : nT ... |
|
33 | // /// Regex to find unit in a line. Examples of valid lines: | |
32 | /// ... PARAMETER_UNITS:nT ... |
|
34 | // /// ... PARAMETER_UNITS : nT ... | |
33 |
/// ... PARAMETER_UNITS: |
|
35 | // /// ... PARAMETER_UNITS:nT ... | |
34 |
/// ... PARAMETER_UNITS |
|
36 | // /// ... PARAMETER_UNITS: m² ... | |
35 | const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.+)")}; |
|
37 | // /// ... PARAMETER_UNITS : m/s ... | |
|
38 | // const auto UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_UNITS\\s*:\\s*(.+)")}; | |||
|
39 | ||||
|
40 | /// ... - Units : nT - ... | |||
|
41 | /// ... -Units:nT- ... | |||
|
42 | /// ... -Units: m²- ... | |||
|
43 | /// ... - Units : m/s - ... | |||
|
44 | const auto UNIT_REGEX = QRegularExpression{QStringLiteral("-\\s*Units\\s*:\\s*(.+?)\\s*-")}; | |||
36 |
|
45 | |||
37 | QDateTime dateTimeFromString(const QString &stringDate) noexcept |
|
46 | QDateTime dateTimeFromString(const QString &stringDate) noexcept | |
38 | { |
|
47 | { | |
@@ -90,7 +99,8 Unit readXAxisUnit(QTextStream &stream) | |||||
90 | QString line{}; |
|
99 | QString line{}; | |
91 |
|
100 | |||
92 | // Searches unit in the comment lines (as long as the reading has not reached the data header) |
|
101 | // Searches unit in the comment lines (as long as the reading has not reached the data header) | |
93 | while (stream.readLineInto(&line) && !line.contains(DATA_HEADER_REGEX)) { |
|
102 | // AMDA V2: while (stream.readLineInto(&line) && !line.contains(DATA_HEADER_REGEX)) { | |
|
103 | while (stream.readLineInto(&line) && isCommentLine(line)) { | |||
94 | auto match = UNIT_REGEX.match(line); |
|
104 | auto match = UNIT_REGEX.match(line); | |
95 | if (match.hasMatch()) { |
|
105 | if (match.hasMatch()) { | |
96 | return Unit{match.captured(1), true}; |
|
106 | return Unit{match.captured(1), true}; | |
@@ -203,6 +213,8 std::shared_ptr<IDataSeries> AmdaResultParser::readTxt(const QString &filePath, | |||||
203 | auto xAxisUnit = readXAxisUnit(stream); |
|
213 | auto xAxisUnit = readXAxisUnit(stream); | |
204 |
|
214 | |||
205 | // Reads results |
|
215 | // Reads results | |
|
216 | // AMDA V2: remove line | |||
|
217 | stream.seek(0); // returns to the beginning of the file | |||
206 | auto results = readResults(stream, valueType); |
|
218 | auto results = readResults(stream, valueType); | |
207 |
|
219 | |||
208 | // Creates data series |
|
220 | // Creates data series |
General Comments 0
You need to be logged in to leave comments.
Login now