From 509e2770acb1392be5c94d57fb8b3b1ebe104077 Mon Sep 17 00:00:00 2001 From: Luca Scarabello Date: Fri, 26 May 2023 10:18:22 +0200 Subject: [PATCH] Revert "PERF: reduce the number of generated messages" This reverts commit a0b66912d8f71b7d76b23ac1cb9cff7f315e889d. --- src/apps/cc/app.cpp | 75 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/src/apps/cc/app.cpp b/src/apps/cc/app.cpp index e984b1d5..87507080 100644 --- a/src/apps/cc/app.cpp +++ b/src/apps/cc/app.cpp @@ -975,21 +975,6 @@ void Application::publishDetection( void Application::publishDetection(const DetectionItem &detectionItem) { logObject(_outputOrigins, Core::Time::GMT()); - // finalize origin by adding Arrivals and Magnitudes - - // Arrivals - for (auto &arrivalPick : detectionItem.arrivalPicks) { - detectionItem.origin->add(arrivalPick.arrival.get()); - } - // station magnitudes - for (auto &mag : detectionItem.magnitudes) { - detectionItem.origin->add(mag.get()); - } - // network magnitudes - for (auto &mag : detectionItem.networkMagnitudes) { - detectionItem.origin->add(mag.get()); - } - if (connection() && !_config.noPublish) { SCDETECT_LOG_DEBUG_TAGGED(detectionItem.detectorId, "Sending event parameters (detection) ..."); @@ -1001,11 +986,55 @@ void Application::publishDetection(const DetectionItem &detectionItem) { "EventParameters", DataModel::OP_ADD, detectionItem.origin.get())}; notifierMsg->attach(notifier.get()); - // pick + // comments + for (std::size_t i{0}; i < detectionItem.origin->commentCount(); ++i) { + auto notifier{util::make_smart( + detectionItem.origin->publicID(), DataModel::OP_ADD, + detectionItem.origin->comment(i))}; + + notifierMsg->attach(notifier.get()); + } + for (auto &arrivalPick : detectionItem.arrivalPicks) { + // pick + { + auto notifier{util::make_smart( + "EventParameters", DataModel::OP_ADD, arrivalPick.pick.get())}; + + notifierMsg->attach(notifier.get()); + } + // arrival + { + auto notifier{util::make_smart( + detectionItem.origin->publicID(), DataModel::OP_ADD, + arrivalPick.arrival.get())}; + + notifierMsg->attach(notifier.get()); + } + } + + // station magnitudes + for (auto &mag : detectionItem.magnitudes) { + auto notifier{util::make_smart( + detectionItem.origin->publicID(), DataModel::OP_ADD, mag.get())}; + + notifierMsg->attach(notifier.get()); + } + + // network magnitudes + for (auto &mag : detectionItem.networkMagnitudes) { auto notifier{util::make_smart( - "EventParameters", DataModel::OP_ADD, arrivalPick.pick.get())}; + detectionItem.origin->publicID(), DataModel::OP_ADD, mag.get())}; + notifierMsg->attach(notifier.get()); + // station magnitude contributions + for (std::size_t i{0}; i < mag->stationMagnitudeContributionCount(); + ++i) { + auto notifier{util::make_smart( + mag->publicID(), DataModel::OP_ADD, + mag->stationMagnitudeContribution(i))}; + notifierMsg->attach(notifier.get()); + } } if (!connection()->send(notifierMsg.get())) { @@ -1019,8 +1048,20 @@ void Application::publishDetection(const DetectionItem &detectionItem) { _ep->add(detectionItem.origin.get()); for (auto &arrivalPick : detectionItem.arrivalPicks) { + detectionItem.origin->add(arrivalPick.arrival.get()); + _ep->add(arrivalPick.pick.get()); } + + // station magnitudes + for (auto &mag : detectionItem.magnitudes) { + detectionItem.origin->add(mag.get()); + } + + // network magnitudes + for (auto &mag : detectionItem.networkMagnitudes) { + detectionItem.origin->add(mag.get()); + } } // amplitudes