Skip to content

Commit

Permalink
Set principal clock by name
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Oct 4, 2024
1 parent 248c316 commit 13eb355
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions include/diagnostics/clock_regression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class ClockRegressionParallelEventVisitor:

calin::ix::diagnostics::clock_regression::ClockRegressionConfig config_;
int rebalance_ = 0;
std::string principal_clock_name_ = {};
int principal_clock_id_ = 0;
std::vector<ClockTest> camera_tests_;
std::vector<ModuleClockTest> module_tests_;
};
Expand Down
26 changes: 19 additions & 7 deletions src/diagnostics/clock_regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ bool ClockRegressionParallelEventVisitor::visit_telescope_run(
}

rebalance_ = config_.rebalance_nevent();
principal_clock_name_ = config_.principal_clock_name();
principal_clock_id_ = config_.principal_clock_id();

if(not principal_clock_name_.empty()) {
principal_clock_id_ = find_clock_id_by_name(principal_clock_name_,
run_config->camera_layout().camera_clock_name());
} else if(principal_clock_id_>=0
and principal_clock_id_<run_config->camera_layout().camera_clock_name_size()) {
principal_clock_name_ = run_config->camera_layout().camera_clock_name(principal_clock_id_);
}

camera_tests_.clear();
module_tests_.clear();
Expand Down Expand Up @@ -122,7 +132,8 @@ bool ClockRegressionParallelEventVisitor::visit_telescope_run(
if(not ct.config.clock_name().empty()) {
ct.config.set_clock_id(find_clock_id_by_name(ct.config.clock_name(),
run_config->camera_layout().camera_clock_name()));
} else if(ct.config.clock_id() < run_config->camera_layout().camera_clock_name_size()) {
} else if(ct.config.clock_id()>=0
and ct.config.clock_id()<run_config->camera_layout().camera_clock_name_size()) {
ct.config.set_clock_name(run_config->camera_layout().camera_clock_name(ct.config.clock_id()));
}
if(ct.config.clock_id()<0
Expand All @@ -139,12 +150,13 @@ bool ClockRegressionParallelEventVisitor::visit_telescope_run(
if(not mct.config.clock_name().empty()) {
mct.config.set_clock_id(find_clock_id_by_name(mct.config.clock_name(),
run_config->camera_layout().module_clock_name()));
} else if(mct.config.clock_id() < run_config->camera_layout().camera_clock_name_size()) {
mct.config.set_clock_name(run_config->camera_layout().camera_clock_name(mct.config.clock_id()));
} else if(mct.config.clock_id()>=0
and mct.config.clock_id()<run_config->camera_layout().module_clock_name_size()) {
mct.config.set_clock_name(run_config->camera_layout().module_clock_name(mct.config.clock_id()));
}
mct.modules.resize(run_config->configured_module_id_size());
if(mct.config.clock_id()<0
or mct.config.clock_id()>=run_config->camera_layout().camera_clock_name_size())
or mct.config.clock_id()>=run_config->camera_layout().module_clock_name_size())
continue;
// for(auto& ct : mct.modules) {
// ct.config = mct.config;
Expand Down Expand Up @@ -223,7 +235,7 @@ bool ClockRegressionParallelEventVisitor::visit_telescope_event(uint64_t seq_ind
}
}

const auto* principal_clock = find_clock(config_.principal_clock_id(),event->camera_clock());
const auto* principal_clock = find_clock(principal_clock_id_,event->camera_clock());
if(principal_clock == nullptr) {
return true;
}
Expand Down Expand Up @@ -393,8 +405,8 @@ ClockRegressionParallelEventVisitor::clock_regression(
results = new calin::ix::diagnostics::clock_regression::ClockRegressionResults();
}

results->set_principal_clock_name(config_.principal_clock_name());
results->set_principal_clock_id(config_.principal_clock_id());
results->set_principal_clock_name(principal_clock_name_);
results->set_principal_clock_id(principal_clock_id_);

for(const auto& ct : camera_tests_) {
transfer_clock_results(results->add_camera_clock(), ct);
Expand Down

0 comments on commit 13eb355

Please sign in to comment.