diff --git a/plugins/amda/include/AmdaResultParserDefs.h b/plugins/amda/include/AmdaResultParserDefs.h index 6c56028..410201a 100644 --- a/plugins/amda/include/AmdaResultParserDefs.h +++ b/plugins/amda/include/AmdaResultParserDefs.h @@ -46,6 +46,9 @@ extern const QString VALUES_UNIT_PROPERTY; /// ... - Units : m/s - ... extern const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX; +/// Regex to find end time of data in a line for a spectrogram +extern const QRegularExpression SPECTROGRAM_END_TIME_REGEX; + /// Regex to find fill value used in a line for a spectrogram extern const QRegularExpression SPECTROGRAM_FILL_VALUE_REGEX; @@ -61,6 +64,9 @@ extern const QRegularExpression SPECTROGRAM_MAX_SAMPLING_REGEX; /// Regex to find min x-axis sampling in a line for a spectrogram extern const QRegularExpression SPECTROGRAM_MIN_SAMPLING_REGEX; +/// Regex to find start time of data in a line for a spectrogram +extern const QRegularExpression SPECTROGRAM_START_TIME_REGEX; + /// Regex to find y-axis unit in a line for a spectrogram extern const QRegularExpression SPECTROGRAM_Y_AXIS_UNIT_REGEX; diff --git a/plugins/amda/src/AmdaResultParserDefs.cpp b/plugins/amda/src/AmdaResultParserDefs.cpp index 146b13f..37c2cf9 100644 --- a/plugins/amda/src/AmdaResultParserDefs.cpp +++ b/plugins/amda/src/AmdaResultParserDefs.cpp @@ -14,6 +14,9 @@ const QString VALUES_UNIT_PROPERTY = QStringLiteral("valuesUnit"); const QRegularExpression DEFAULT_X_AXIS_UNIT_REGEX = QRegularExpression{QStringLiteral("-\\s*Units\\s*:\\s*(.+?)\\s*-")}; +const QRegularExpression SPECTROGRAM_END_TIME_REGEX + = QRegularExpression{QStringLiteral("\\s*INTERVAL_STOP\\s*:\\s*(.*)")}; + const QRegularExpression SPECTROGRAM_FILL_VALUE_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_FILL_VALUE\\s*:\\s*(.*)")}; @@ -29,6 +32,9 @@ const QRegularExpression SPECTROGRAM_MAX_SAMPLING_REGEX const QRegularExpression SPECTROGRAM_MIN_SAMPLING_REGEX = QRegularExpression{QStringLiteral("\\s*DATASET_MIN_SAMPLING\\s*:\\s*(.*)")}; +const QRegularExpression SPECTROGRAM_START_TIME_REGEX + = QRegularExpression{QStringLiteral("\\s*INTERVAL_START\\s*:\\s*(.*)")}; + const QRegularExpression SPECTROGRAM_Y_AXIS_UNIT_REGEX = QRegularExpression{QStringLiteral("\\s*PARAMETER_TABLE_UNITS\\[0\\]\\s*:\\s*(.*)")}; diff --git a/plugins/amda/src/AmdaResultParserHelper.cpp b/plugins/amda/src/AmdaResultParserHelper.cpp index 882de94..5b3fa73 100644 --- a/plugins/amda/src/AmdaResultParserHelper.cpp +++ b/plugins/amda/src/AmdaResultParserHelper.cpp @@ -159,6 +159,18 @@ bool tryReadProperty(Properties &properties, const QString &key, const QString & } /** + * Reads a line from the AMDA file and tries to extract a data from it. Date is converted to double + * @sa tryReadProperty() + */ +bool tryReadDate(Properties &properties, const QString &key, const QString &line, + const QRegularExpression ®ex, bool timeUnit = false) +{ + return tryReadProperty(properties, key, line, regex, [timeUnit](const auto &match) { + return QVariant::fromValue(doubleDate(match.captured(1))); + }); +} + +/** * Reads a line from the AMDA file and tries to extract a double from it * @sa tryReadProperty() */ @@ -339,6 +351,15 @@ void SpectrogramParserHelper::readPropertyLine(const QString &line) [&] { return tryReadDoubles(m_Properties, MAX_BANDS_PROPERTY, line, SPECTROGRAM_MAX_BANDS_REGEX); + }, + // start time of data + [&] { + return tryReadDate(m_Properties, START_TIME_PROPERTY, line, + SPECTROGRAM_START_TIME_REGEX); + }, + // end time of data + [&] { + return tryReadDate(m_Properties, END_TIME_PROPERTY, line, SPECTROGRAM_END_TIME_REGEX); }}; for (auto function : functions) {