From ef0bb7550d4845bc4481783e22e885a90b62e2d6 Mon Sep 17 00:00:00 2001 From: Mario Fink Date: Sat, 11 Feb 2023 18:34:25 +0100 Subject: [PATCH] add multichannel support for multiple channels referring to same CS block, issue #15 --- lib/imc_raw.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/imc_raw.hpp b/lib/imc_raw.hpp index 83f524c..a122218 100644 --- a/lib/imc_raw.hpp +++ b/lib/imc_raw.hpp @@ -236,13 +236,27 @@ namespace imc // provide UUID for channel chnenv.uuid_ = chnenv.CNuuid_; + // for multichannel data there may be multiple channels referring to + // the same (final) CS block (in contrast to what the IMC software + // documentation seems to suggest) resulting in all channels missing + // a CS block except for the very last + if ( chnenv.CSuuid_.empty() ) { + for ( imc::block blkCS: rawblocks_ ) { + if ( blkCS.get_key().name_ == "CS" + && blkCS.get_begin() > (unsigned long int)stol(chnenv.uuid_) ) { + chnenv.CSuuid_ = blkCS.get_uuid(); + } + } + } + // create channel object and add it to the map of channels channels_.insert( std::pair (chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_,&buffer_)) ); // reset channel uuid - chnenv.CNuuid_.clear(); + chnenv.reset(); + //chnenv.CNuuid_.clear(); } } @@ -254,7 +268,6 @@ namespace imc } } - public: // provide buffer size