From 0f4eccf733789f8253f1f369fa315244ab7f2483 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Mon, 8 May 2023 20:32:56 +0200 Subject: [PATCH] AcquisitionOnlineCounters: More verbose error messages --- receiver/host/AcquisitionOnlineCounters.cpp | 47 +++++++++++++-------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/receiver/host/AcquisitionOnlineCounters.cpp b/receiver/host/AcquisitionOnlineCounters.cpp index 5378ec10..e2e973fb 100644 --- a/receiver/host/AcquisitionOnlineCounters.cpp +++ b/receiver/host/AcquisitionOnlineCounters.cpp @@ -24,7 +24,7 @@ void AcquisitionOnlineCounters::Reset(const DiffractionExperiment &experiment, u nmodules = experiment.GetModulesNum(data_stream); if (nmodules > max_modules) - throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Acqusition counter cannot support that many modules"); + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Acquisition counter cannot support that many modules"); for (int i = 0; i < max_modules; i++) head[i] = 0; @@ -39,10 +39,11 @@ void AcquisitionOnlineCounters::UpdateCounters(const Completion *c) { std::unique_lock ul(m); if (c->module >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, + "UpdateCounters Wrong module number: " + std::to_string(c->module)); if (c->frame_number >= expected_frames) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, - "Frame number is out of bounds"); + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, + "UpdateCounters Frame number is out of bounds"); else { if (head.at(c->module) < c->frame_number) head.at(c->module) = c->frame_number; @@ -73,9 +74,10 @@ void AcquisitionOnlineCounters::SetAcquisitionFinished() { uint64_t AcquisitionOnlineCounters::GetBufferHandle(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, - "Wrong frame number: " + std::to_string(frame)); + "GetBufferHandle Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetBufferHandle Wrong module number: " + std::to_string(module_number)); return handle_for_frame.at(frame * nmodules + module_number); } @@ -83,9 +85,10 @@ uint64_t AcquisitionOnlineCounters::GetBufferHandleAndClear(size_t frame, uint16 std::unique_lock ul(m); if (frame >= expected_frames) throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, - "Wrong frame number: " + std::to_string(frame)); + "GetBufferHandleAndClear Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetBufferHandleAndClear Wrong module number: " + std::to_string(module_number)); uint64_t ret_val = handle_for_frame.at(frame * nmodules + module_number); handle_for_frame.at(frame * nmodules + module_number) = HandleNotFound; return ret_val; @@ -93,7 +96,8 @@ uint64_t AcquisitionOnlineCounters::GetBufferHandleAndClear(size_t frame, uint16 uint64_t AcquisitionOnlineCounters::GetHead(uint16_t module_number) const { if (module_number >= max_modules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Module out of bounds"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetHead Wrong module number: " + std::to_string(module_number)); return head[module_number]; } @@ -127,38 +131,45 @@ bool AcquisitionOnlineCounters::IsAcquisitionFinished() const { bool AcquisitionOnlineCounters::IsFullModuleCollected(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, - "Wrong frame number: " + std::to_string(frame)); + "IsFullModuleCollected Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "IsFullModuleCollected Wrong module number: " + std::to_string(module_number)); return full_module_collected[frame * nmodules + module_number]; } uint64_t AcquisitionOnlineCounters::GetBunchID(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong frame number: " + std::to_string(frame)); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetBunchID Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetBunchID Wrong module number: " + std::to_string(module_number)); return bunch_id[frame * nmodules + module_number]; } uint32_t AcquisitionOnlineCounters::GetJFInfo(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong frame number: " + std::to_string(frame)); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetJFInfo Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetJFInfo Wrong module number: " + std::to_string(module_number)); return jf_info[frame * nmodules + module_number]; } uint64_t AcquisitionOnlineCounters::GetTimestamp(size_t frame, uint16_t module_number) const { if (frame >= expected_frames) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong frame number: " + std::to_string(frame)); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetTimestamp Wrong frame number: " + std::to_string(frame)); if (module_number >= nmodules) - throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "Wrong module number"); + throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, + "GetTimestamp Wrong module number: " + std::to_string(module_number)); return timestamp[frame * nmodules + module_number]; -} \ No newline at end of file +}