From 9b0dd5e7d7b262b68397a0865d32819a26c12170 Mon Sep 17 00:00:00 2001 From: Mario Fink Date: Wed, 20 Jan 2021 14:15:27 +0100 Subject: [PATCH] start channel access --- lib/tdm_datamodel.hpp | 31 ++++++++++++++++--------------- lib/tdm_reaper.cpp | 24 +++++++++++++++++++++++- lib/tdm_reaper.hpp | 24 ++++++++++++++++++++++++ src/main.cpp | 13 ++++++++++++- 4 files changed, 75 insertions(+), 17 deletions(-) diff --git a/lib/tdm_datamodel.hpp b/lib/tdm_datamodel.hpp index d0c77c8..6ad172f 100644 --- a/lib/tdm_datamodel.hpp +++ b/lib/tdm_datamodel.hpp @@ -35,7 +35,7 @@ struct block { value_type_ = std::string(""); } - const std::string get_info(int width = 20) + const std::string get_info(int width = 25) { std::stringstream ss; ss< tdm_datatypes = { +const std::vector tdm_datatypes = { - {"eInt16Usi",{"eInt16Usi","DT_SHORT",2,"short_sequence",2,"signed 16 bit integer"}}, - {"eInt32Usi",{"eInt32Usi","DT_LONG",6,"long_sequence",4,"signed 32 bit integer"}}, + {"eInt16Usi","DT_SHORT",2,"short_sequence",2,"signed 16 bit integer"}, + {"eInt32Usi","DT_LONG",6,"long_sequence",4,"signed 32 bit integer"}, - {"eUInt8Usi",{"eUInt8Usi","DT_BYTE",5,"byte_sequence",1,"unsigned 8 bit integer"}}, - {"eUInt16Usi",{"eUInt16Usi","DT_SHORT",2,"short_sequence",2,"unsigned 16 bit integer"}}, - {"eUInt32Usi",{"eUInt32Usi","DT_LONG",6,"long_sequence",4,"unsigned 32 bit integer"}}, + {"eUInt8Usi","DT_BYTE",5,"byte_sequence",1,"unsigned 8 bit integer"}, + {"eUInt16Usi","DT_SHORT",2,"short_sequence",2,"unsigned 16 bit integer"}, + {"eUInt32Usi","DT_LONG",6,"long_sequence",4,"unsigned 32 bit integer"}, - {"eFloat32Usi",{"eFloat32Usi","DT_FLOAT",3,"float_sequence",4,"32 bit float"}}, - {"eFloat64Usi",{"eFloat64Usi","DT_DOUBLE",7,"double_sequence",8,"64 bit double"}}, + {"eFloat32Usi","DT_FLOAT",3,"float_sequence",4,"32 bit float"}, + {"eFloat64Usi","DT_DOUBLE",7,"double_sequence",8,"64 bit double"}, - {"eStringUsi",{"eStringUsi","DT_STRING",1,"string_sequence",0,"text"}} + {"eStringUsi","DT_STRING",1,"string_sequence",0,"text"} }; @@ -124,7 +124,7 @@ struct tdm_root { std::vector channelgroups_; - const std::string get_info(int width = 20) + const std::string get_info(int width = 25) { std::stringstream ss; ss< channels_; // referenced by id std::vector submatrices_; - const std::string get_info(int width = 20) + const std::string get_info(int width = 25) { std::stringstream ss; ss< local_columns_; // -> list of type "localcolumn" unsigned long int number_of_rows_; // -> number of values in channels - const std::string get_info(int width = 20) + const std::string get_info(int width = 25) { std::stringstream ss; ss< generation_parameters_; // { offset, factor } std::string values_; // -> refers to usi:data -> _sequence + std::string external_id_; const std::string get_info(int width = 25) { diff --git a/lib/tdm_reaper.cpp b/lib/tdm_reaper.cpp index 88d037a..96508e9 100644 --- a/lib/tdm_reaper.cpp +++ b/lib/tdm_reaper.cpp @@ -269,7 +269,7 @@ void tdm_reaper::process_submatrices(bool showlog) } submat.local_columns_ = this->extract_ids(subm.child_value("local_columns")); std::string numrows = subm.child_value("number_of_rows"); - numrows = numrows.empty() ? std::string("0") : numrows; + numrows = numrows.empty() ? std::string("0") : numrows; submat.number_of_rows_ = std::stoul(numrows); // add submatrix to map @@ -344,5 +344,27 @@ void tdm_reaper::process_localcolumns(bool showlog) if ( showlog ) std::cout<<"number of localcolumns: "< tdm_reaper::get_channel(std::string &id) +{ + // declare vector of channel data + std::vector chn; + + // check for existence of required channel id (=key) + if ( tdmchannels_.count(id) == 1 ) + { + tdm_channel chn = tdmchannels_.at(id); + std::cout< get_channelgroup_ids() + { + std::vector channelgroup_ids; + for (std::map::iterator it=tdmchannelgroups_.begin(); + it!=tdmchannelgroups_.end(); ++it) channelgroup_ids.push_back(it->first); + + return channelgroup_ids; + } + + // get list of channel ids + std::vector get_channel_ids() + { + std::vector channel_ids; + for (std::map::iterator it=tdmchannels_.begin(); + it!=tdmchannels_.end(); ++it) channel_ids.push_back(it->first); + + return channel_ids; + } + + // extract channel by id + // (TODO introduce template T to reference specific datatype instead of double in general) + std::vector get_channel(std::string &id); }; #endif diff --git a/src/main.cpp b/src/main.cpp index 685b665..4cfef38 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,12 +179,23 @@ int main(int argc, char* argv[]) // declare and initialize tdm_ripper instance tdm_reaper jack; try { - jack.submit_files(cfgopts.at("tdm"),cfgopts.at("tdx"),true); + jack.submit_files(cfgopts.at("tdm"),cfgopts.at("tdx"),false); } catch (const std::exception& e) { throw std::runtime_error( std::string("failed to load and parse tdm/tdx files: ") + e.what() ); } + std::vector chgrids = jack.get_channelgroup_ids(); + for ( auto el: chgrids ) std::cout< chids = jack.get_channel_ids(); + for ( auto el: chids ) std::cout< chi = jack.get_channel(id); + // print list of groups or channels to stdout // if ( listgroups ) jack.list_groups(); // if ( listchannels ) jack.list_channels();