Repository navigation
M2D-2: bounded canonical Quality/TimeQuality evidence for RCB reports #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
| #include "MmsReportController.hpp" | ||
| #include "MmsEngineeringEvidence.hpp" | ||
|
|
||
| #include "ariec61850/mms/data_codec.hpp" | ||
| #include "ariec61850/mms/dynamic_data_set.hpp" | ||
|
|
@@ -26,6 +27,8 @@ namespace mms = ar::iec61850::mms; | |
|
|
||
| namespace { | ||
| constexpr int kMaximumVisibleReports = 128; | ||
| constexpr int kMaximumTypedReportEvidence = 96; | ||
| constexpr int kMaximumVisibleReportMembers = 256; | ||
|
|
||
| QString boolText(const std::optional<bool> value) { | ||
| if (!value.has_value()) return QStringLiteral("—"); | ||
|
|
@@ -460,6 +463,7 @@ ReportUi buildSubscriptionUi( | |
| } | ||
| while (ui.events.size() > 256) ui.events.removeFirst(); | ||
|
|
||
| int typedEvidenceBudget = kMaximumTypedReportEvidence; | ||
| for (auto streamIt = subscription.streams.rbegin(); | ||
| streamIt != subscription.streams.rend(); ++streamIt) { | ||
| for (auto frameIt = streamIt->recent_frames.rbegin(); | ||
|
|
@@ -477,8 +481,46 @@ ReportUi buildSubscriptionUi( | |
| map.insert(QStringLiteral("decoderMode"), QString::fromStdString(frame.decoder_mode)); | ||
| map.insert(QStringLiteral("valueCount"), static_cast<int>(frame.values.size())); | ||
| QStringList values; | ||
| for (const auto& value : frame.values) values.push_back(reportValueText(value)); | ||
| QVariantList typedEvidence; | ||
| bool typedEvidenceTruncated = false; | ||
| int memberIndex = 0; | ||
| for (const auto& item : frame.values) { | ||
| values.push_back(reportValueText(item)); | ||
| if (item.value && memberIndex < kMaximumVisibleReportMembers) { | ||
| QString memberRef = QString::fromStdString(item.data_reference); | ||
| if (memberRef.isEmpty() && item.member) | ||
| memberRef = QString::fromStdString(item.member->user_reference); | ||
| if (memberRef.isEmpty() && item.member) | ||
| memberRef = QString::fromStdString(item.member->mms_reference); | ||
|
Comment on lines
+490
to
+494
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a report supplies a DataReference that disagrees with the directory member already mapped by inclusion index, this gives the untrusted wire string priority. A malformed endpoint can therefore make an unrelated 13-bit BIT STRING appear as IEC Quality merely by ending DataRef in AGENTS.md reference: AGENTS.md:L55-L66 Useful? React with 👍 / 👎. |
||
| if (typedEvidenceBudget > 0) { | ||
| const auto evidence = arstack::iedsim::decodeEngineeringEvidence( | ||
| memberRef, *item.value); | ||
| if (!evidence.isEmpty()) { | ||
| typedEvidence.push_back(QVariantMap{ | ||
| {QStringLiteral("index"), memberIndex}, | ||
| {QStringLiteral("evidence"), evidence}}); | ||
| --typedEvidenceBudget; | ||
| } | ||
| } else { | ||
| // Mark truncation only for real q/t typed members, not | ||
| // unrelated BIT STRING or UTC-valued attributes. | ||
| const auto kind = item.value->kind(); | ||
| const auto separator = std::max( | ||
| memberRef.lastIndexOf(QLatin1Char('$')), | ||
| memberRef.lastIndexOf(QLatin1Char('.'))); | ||
| const QString leaf = memberRef.mid(separator + 1); | ||
| if ((leaf == QStringLiteral("q") && | ||
| kind == mms::MmsDataKind::bit_string) || | ||
| (leaf == QStringLiteral("t") && | ||
| kind == mms::MmsDataKind::utc_time)) | ||
| typedEvidenceTruncated = true; | ||
| } | ||
| } | ||
| ++memberIndex; | ||
| } | ||
| map.insert(QStringLiteral("values"), values); | ||
| map.insert(QStringLiteral("valueEvidence"), typedEvidence); | ||
| map.insert(QStringLiteral("valueEvidenceTruncated"), typedEvidenceTruncated); | ||
| map.insert(QStringLiteral("valuesSummary"), values.mid(0, 3).join(QStringLiteral(" | "))); | ||
| map.insert(QStringLiteral("duplicateCount"), static_cast<qulonglong>(streamIt->state.duplicate_count)); | ||
| map.insert(QStringLiteral("gapCount"), static_cast<qulonglong>(streamIt->state.gap_count)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an RCB omits sequence-number, segmentation, and entry-id from OptFlds, successive reports all produce the same identity (
RptID|—|—|), so this handler never resets the selected row. The highlight then remains while the evidence silently changes to the same row in a newer frame; use a stable per-frame occurrence identifier rather than only optional wire fields.AGENTS.md reference: AGENTS.md:L74-L86
Useful? React with 👍 / 👎.