From 3290a97f19bc95030ae05d70ff858f1a85776527 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Fri, 17 Jun 2022 01:01:16 -0400 Subject: [PATCH] Added in scaler support to SpectrumManager --- .../src/Navigator/Core/SpectrumManager.cpp | 32 +++++++++++++++++++ .../src/Navigator/Core/SpectrumManager.h | 7 ++++ 2 files changed, 39 insertions(+) diff --git a/Navigator/src/Navigator/Core/SpectrumManager.cpp b/Navigator/src/Navigator/Core/SpectrumManager.cpp index 745ceff..b3c8106 100644 --- a/Navigator/src/Navigator/Core/SpectrumManager.cpp +++ b/Navigator/src/Navigator/Core/SpectrumManager.cpp @@ -332,6 +332,38 @@ namespace Navigator { /*************Variable Functions End*************/ + void SpectrumManager::BindScaler(Scaler& scaler) + { + NAV_PROFILE_FUNCTION(); + std::scoped_lock guard(m_managerMutex); + auto iter = m_scalerMap.find(scaler.GetName()); + if (iter == m_scalerMap.end()) + { + m_scalerMap[scaler.GetName()].reset(new std::atomic(0)); + } + scaler.m_pdata = m_scalerMap[scaler.GetName()]; + } + + void SpectrumManager::ResetScalers() + { + NAV_PROFILE_FUNCTION(); + std::scoped_lock guard(m_managerMutex); + for (auto& scaler : m_scalerMap) + { + *(scaler.second) = 0; + } + } + + std::vector SpectrumManager::GetListOfScalers() + { + std::scoped_lock guard(m_managerMutex); + std::vector list; + list.reserve(m_scalerMap.size()); + for (auto& iter : m_scalerMap) + list.push_back(iter.first); + return list; + } + /*************Cut Functions Begin*************/ void SpectrumManager::RemoveCut(const std::string& name) diff --git a/Navigator/src/Navigator/Core/SpectrumManager.h b/Navigator/src/Navigator/Core/SpectrumManager.h index 44e4b98..1241176 100644 --- a/Navigator/src/Navigator/Core/SpectrumManager.h +++ b/Navigator/src/Navigator/Core/SpectrumManager.h @@ -67,6 +67,12 @@ namespace Navigator { std::vector GetListOfVariables(); /********************/ + /*Scaler Functions*/ + void BindScaler(Scaler& scaler); + void ResetScalers(); + std::vector GetListOfScalers(); + /******************/ + /*Cut Functions*/ inline void AddCut(const CutArgs& params, double min, double max) { @@ -105,6 +111,7 @@ namespace Navigator { std::unordered_map> m_cutMap; std::unordered_map> m_paramMap; std::unordered_map>> m_varMap; + std::unordered_map>> m_scalerMap; HistogramArgs m_nullHistoResult; //For handling bad query