start channel access
This commit is contained in:
parent
616ceaf326
commit
9b0dd5e7d7
@ -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<<std::setw(width)<<std::left<<"id:"<<id_<<"\n"
|
||||
@ -62,7 +62,7 @@ struct tdm_datatype {
|
||||
int size_;
|
||||
std::string description_;
|
||||
|
||||
const std::string get_info(int width = 20)
|
||||
const std::string get_info(int width = 25)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
|
||||
@ -75,19 +75,19 @@ struct tdm_datatype {
|
||||
}
|
||||
};
|
||||
|
||||
const std::map<std::string,tdm_datatype> tdm_datatypes = {
|
||||
const std::vector<tdm_datatype> 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<std::string> channelgroups_;
|
||||
|
||||
const std::string get_info(int width = 20)
|
||||
const std::string get_info(int width = 25)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<std::setw(width)<<std::left<<"id:"<<id_<<"\n"
|
||||
@ -155,7 +155,7 @@ struct tdm_channelgroup {
|
||||
std::vector<std::string> channels_; // referenced by id
|
||||
std::vector<std::string> submatrices_;
|
||||
|
||||
const std::string get_info(int width = 20)
|
||||
const std::string get_info(int width = 25)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<std::setw(width)<<std::left<<"id:"<<id_<<"\n"
|
||||
@ -214,7 +214,7 @@ struct tdm_channel {
|
||||
// TODO
|
||||
waveform_channel wf_channel_;
|
||||
|
||||
const std::string get_info(int width = 20)
|
||||
const std::string get_info(int width = 25)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss<<std::setw(width)<<std::left<<"id:"<<id_<<"\n"
|
||||
@ -247,7 +247,7 @@ struct submatrix {
|
||||
std::vector<std::string> 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<<std::setw(width)<<std::left<<"id:"<<id_<<"\n"
|
||||
@ -291,6 +291,7 @@ struct localcolumn {
|
||||
std::vector<double> generation_parameters_; // { offset, factor }
|
||||
|
||||
std::string values_; // -> refers to usi:data -> _sequence
|
||||
std::string external_id_;
|
||||
|
||||
const std::string get_info(int width = 25)
|
||||
{
|
||||
|
@ -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: "<<localcolumns_.size()<<"\n\n";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
std::vector<double> tdm_reaper::get_channel(std::string &id)
|
||||
{
|
||||
// declare vector of channel data
|
||||
std::vector<double> chn;
|
||||
|
||||
// check for existence of required channel id (=key)
|
||||
if ( tdmchannels_.count(id) == 1 )
|
||||
{
|
||||
tdm_channel chn = tdmchannels_.at(id);
|
||||
std::cout<<chn.get_info()<<"\n";
|
||||
std::cout<<localcolumns_.at(chn.local_columns_[0]).get_info()<<"\n";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::invalid_argument(std::string("channel id does not exist: ") + id);
|
||||
}
|
||||
|
||||
return chn;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
@ -104,6 +104,30 @@ public:
|
||||
// process submatrices and localcolumns
|
||||
void process_submatrices(bool showlog);
|
||||
void process_localcolumns(bool showlog);
|
||||
|
||||
// get list of channelgroup ids
|
||||
std::vector<std::string> get_channelgroup_ids()
|
||||
{
|
||||
std::vector<std::string> channelgroup_ids;
|
||||
for (std::map<std::string,tdm_channelgroup>::iterator it=tdmchannelgroups_.begin();
|
||||
it!=tdmchannelgroups_.end(); ++it) channelgroup_ids.push_back(it->first);
|
||||
|
||||
return channelgroup_ids;
|
||||
}
|
||||
|
||||
// get list of channel ids
|
||||
std::vector<std::string> get_channel_ids()
|
||||
{
|
||||
std::vector<std::string> channel_ids;
|
||||
for (std::map<std::string,tdm_channel>::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<double> get_channel(std::string &id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
13
src/main.cpp
13
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<std::string> chgrids = jack.get_channelgroup_ids();
|
||||
for ( auto el: chgrids ) std::cout<<el<<",";
|
||||
std::cout<<"\n\n";
|
||||
|
||||
std::vector<std::string> chids = jack.get_channel_ids();
|
||||
for ( auto el: chids ) std::cout<<el<<",";
|
||||
std::cout<<"\n\n";
|
||||
|
||||
std::string id("usi23");
|
||||
std::vector<double> chi = jack.get_channel(id);
|
||||
|
||||
// print list of groups or channels to stdout
|
||||
// if ( listgroups ) jack.list_groups();
|
||||
// if ( listchannels ) jack.list_channels();
|
||||
|
Loading…
x
Reference in New Issue
Block a user