Skip to content

Commit

Permalink
Revert "PERF: reduce the number of generated messages"
Browse files Browse the repository at this point in the history
This reverts commit a0b6691.
  • Loading branch information
luca-s committed May 26, 2023
1 parent b4b340b commit 509e277
Showing 1 changed file with 58 additions and 17 deletions.
75 changes: 58 additions & 17 deletions src/apps/cc/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ...");
Expand All @@ -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<DataModel::Notifier>(
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<DataModel::Notifier>(
"EventParameters", DataModel::OP_ADD, arrivalPick.pick.get())};

notifierMsg->attach(notifier.get());
}
// arrival
{
auto notifier{util::make_smart<DataModel::Notifier>(
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<DataModel::Notifier>(
detectionItem.origin->publicID(), DataModel::OP_ADD, mag.get())};

notifierMsg->attach(notifier.get());
}

// network magnitudes
for (auto &mag : detectionItem.networkMagnitudes) {
auto notifier{util::make_smart<DataModel::Notifier>(
"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<DataModel::Notifier>(
mag->publicID(), DataModel::OP_ADD,
mag->stationMagnitudeContribution(i))};
notifierMsg->attach(notifier.get());
}
}

if (!connection()->send(notifierMsg.get())) {
Expand All @@ -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
Expand Down

0 comments on commit 509e277

Please sign in to comment.