From 61d2b17d82f901150b91c4f8684a7e8fa7ccd1f2 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Mon, 25 Nov 2024 12:45:05 +0100 Subject: [PATCH] Complete checks for usage of an afe --- schema/appmodel/PDS.schema.xml | 11 +++++++---- src/DaphneApplication.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/schema/appmodel/PDS.schema.xml b/schema/appmodel/PDS.schema.xml index 96407f3..13b3d2c 100644 --- a/schema/appmodel/PDS.schema.xml +++ b/schema/appmodel/PDS.schema.xml @@ -80,7 +80,7 @@ - + @@ -147,6 +147,12 @@ + + + + + + @@ -162,9 +168,6 @@ - - - diff --git a/src/DaphneApplication.cpp b/src/DaphneApplication.cpp index b21e7fc..5a22e19 100644 --- a/src/DaphneApplication.cpp +++ b/src/DaphneApplication.cpp @@ -166,6 +166,17 @@ uint16_t DaphneConf::get_board_slot(const std::string & ip) const { return it->at("slot").get(); } +bool +DaphneV2BoardConf::is_channel_used(size_t ch) const { + + for ( auto ch_p : get_active_channels() ) { + if ( ch_p->get_channel_id() == ch ) { + return true; + } + } + + return false; +} const DaphneV2Channel & DaphneV2BoardConf::get_channel(size_t ch) const { @@ -179,9 +190,23 @@ DaphneV2BoardConf::get_channel(size_t ch) const { return *get_default_channel(); } +bool +DaphneV2BoardConf::is_afe_used(size_t afe) const { + + auto begin = afe*8; + auto end = (afe+1)*8; + for ( size_t i = begin; i < end; ++i) { + if( is_channel_used(i) ) return true; + } + + return false; +} + const DaphneV2AFE & DaphneV2BoardConf::get_afe(size_t ch) const { + if ( ! is_afe_used(ch) ) return *get_default_afe(); + for ( auto afe_p : get_active_afes() ) { if ( afe_p->get_afe_id() == ch ) { return *afe_p;