print channels
This commit is contained in:
parent
665b93be3f
commit
a6ab3daf87
@ -544,7 +544,6 @@ void tdm_reaper::summarize_member(block blk, std::string& summary, format& forma
|
|||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
|
|
||||||
// extract channel by id
|
// extract channel by id
|
||||||
// template<typename tdmtype>
|
|
||||||
std::vector<tdmdatatype> tdm_reaper::get_channel(std::string& id)
|
std::vector<tdmdatatype> tdm_reaper::get_channel(std::string& id)
|
||||||
{
|
{
|
||||||
// check for existence of required channel id (=key)
|
// check for existence of required channel id (=key)
|
||||||
@ -625,14 +624,39 @@ std::vector<tdmdatatype> tdm_reaper::get_channel(std::string& id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdm_reaper::print_channel(std::string &id, const char* filename)
|
// -------------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
void tdm_reaper::print_channel(std::string &id, const char* filename, bool include_meta)
|
||||||
{
|
{
|
||||||
std::ofstream fou(filename);
|
// declare file stream
|
||||||
|
std::ofstream fou;
|
||||||
|
try {
|
||||||
|
fou.open(filename);
|
||||||
|
} catch ( const std::exception& e) {
|
||||||
|
throw std::runtime_error( std::string("failed to open file to dump channel")
|
||||||
|
+ e.what() );
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<double> chn; // = this->get_channel(id);
|
// get channel object
|
||||||
|
tdm_channel chn = this->tdmchannels_.at(id);
|
||||||
|
if ( include_meta )
|
||||||
|
{
|
||||||
|
int width = 20;
|
||||||
|
fou<<std::setw(width)<<std::left<<"# channel-id:"<<chn.id_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# name:"<<chn.name_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# description:"<<chn.description_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# unit_string:"<<chn.unit_string_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# datatype:"<<chn.datatype_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# minimum:"<<chn.minimum_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# maximum:"<<chn.maximum_<<"\n";
|
||||||
|
fou<<std::setw(width)<<std::left<<"# group:"<<chn.group_<<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
for ( auto el: chn ) fou<<el<<"\n";
|
// obtain channel data
|
||||||
|
std::vector<tdmdatatype> chndata = this->get_channel(id);
|
||||||
|
for ( auto el: chndata ) fou<<el<<"\n";
|
||||||
|
|
||||||
|
// close file
|
||||||
fou.close();
|
fou.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +157,11 @@ public:
|
|||||||
// get block/submatrix/localcolumn overview
|
// get block/submatrix/localcolumn overview
|
||||||
template<typename tdmelement>
|
template<typename tdmelement>
|
||||||
std::string get_overview(format formatter);
|
std::string get_overview(format formatter);
|
||||||
|
private:
|
||||||
void summarize_member(submatrix sbm, std::string& summary, format& formatter);
|
void summarize_member(submatrix sbm, std::string& summary, format& formatter);
|
||||||
void summarize_member(localcolumn lcc, std::string& summary, format& formatter);
|
void summarize_member(localcolumn lcc, std::string& summary, format& formatter);
|
||||||
void summarize_member(block blk, std::string& summary, format& formatter);
|
void summarize_member(block blk, std::string& summary, format& formatter);
|
||||||
|
public:
|
||||||
|
|
||||||
// get list of channelgroup ids
|
// get list of channelgroup ids
|
||||||
std::vector<std::string> get_channelgroup_ids()
|
std::vector<std::string> get_channelgroup_ids()
|
||||||
@ -184,7 +186,9 @@ public:
|
|||||||
// extract channel by id
|
// extract channel by id
|
||||||
std::vector<tdmdatatype> get_channel(std::string& id);
|
std::vector<tdmdatatype> get_channel(std::string& id);
|
||||||
|
|
||||||
void print_channel(std::string &id, const char* filename);
|
// dump a single channel/entire group (identified by id) to file
|
||||||
|
void print_channel(std::string &id, const char* filename, bool include_meta = true);
|
||||||
|
void print_group(std::string &id, const char* filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
29
src/main.cpp
29
src/main.cpp
@ -201,29 +201,20 @@ int main(int argc, char* argv[])
|
|||||||
std::cout<<jack.get_overview<localcolumn>(formatter)<<"\n";
|
std::cout<<jack.get_overview<localcolumn>(formatter)<<"\n";
|
||||||
std::cout<<jack.get_overview<block>(formatter)<<"\n";
|
std::cout<<jack.get_overview<block>(formatter)<<"\n";
|
||||||
|
|
||||||
std::string chid("usi14");
|
|
||||||
std::vector<tdmdatatype> chdata = jack.get_channel(chid);
|
|
||||||
|
|
||||||
std::cout<<"channel size: "<<chdata.size()<<"\n";
|
|
||||||
for ( tdmdatatype el: chdata )
|
|
||||||
{
|
|
||||||
std::cout<<el<<":"<<el.dtype()<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// std::vector<std::string> chgrids = jack.get_channelgroup_ids();
|
// std::vector<std::string> chgrids = jack.get_channelgroup_ids();
|
||||||
// for ( auto el: chgrids ) std::cout<<el<<",";
|
// for ( auto id: chgrids )
|
||||||
// std::cout<<"\n";
|
|
||||||
// std::vector<std::string> chids = jack.get_channel_ids();
|
|
||||||
// for ( auto el: chids ) std::cout<<el<<",";
|
|
||||||
// std::cout<<"\n\n";
|
|
||||||
|
|
||||||
|
|
||||||
// for ( auto el: chids )
|
|
||||||
// {
|
// {
|
||||||
// std::string chfile = std::string("channel_") +el +std::string(".csv");
|
//
|
||||||
// jack.print_channel(el,chfile.c_str());
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
std::vector<std::string> chids = jack.get_channel_ids();
|
||||||
|
for ( auto id: chids )
|
||||||
|
{
|
||||||
|
std::string filenam = std::string("channel_") + id + std::string(".dat");
|
||||||
|
// std::vector<tdmdatatype> chdata = jack.get_channel(id);
|
||||||
|
jack.print_channel(id,filenam.c_str(),true);
|
||||||
|
}
|
||||||
|
|
||||||
// print list of groups or channels to stdout
|
// print list of groups or channels to stdout
|
||||||
// if ( listgroups ) jack.list_groups();
|
// if ( listgroups ) jack.list_groups();
|
||||||
// if ( listchannels ) jack.list_channels();
|
// if ( listchannels ) jack.list_channels();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user