neglect empty groups
This commit is contained in:
parent
4d31dcd32d
commit
e7730c2d02
@ -1,9 +1,11 @@
|
||||
|
||||
#include "tdm_ripper.hpp"
|
||||
|
||||
tdm_ripper::tdm_ripper(std::string tdmfile, std::string tdxfile):
|
||||
tdmfile_(tdmfile), tdxfile_(tdxfile), num_channels_(0), num_groups_(0),
|
||||
channel_id_(0), inc_id_(0), units_(0), channel_name_(0), group_id_(0), group_name_(0),
|
||||
tdm_ripper::tdm_ripper(std::string tdmfile, std::string tdxfile, bool neglect_empty_groups):
|
||||
tdmfile_(tdmfile), tdxfile_(tdxfile),
|
||||
neglect_empty_groups_(neglect_empty_groups), num_empty_groups_(0),
|
||||
num_channels_(0), num_groups_(0), channel_id_(0), inc_id_(0), units_(0),
|
||||
channel_name_(0), group_id_(0), group_name_(0),
|
||||
num_channels_group_(0), channels_group_(0), channel_ext_(0), minmax_(0),
|
||||
byteoffset_(0), length_(0), type_(0), external_id_(0)
|
||||
{
|
||||
@ -96,13 +98,17 @@ void tdm_ripper::parse_structure()
|
||||
for (pugi::xml_node anode: subtreedata.children())
|
||||
{
|
||||
if ( std::string(anode.name()).compare("tdm_channelgroup") == 0 )
|
||||
{
|
||||
int numchann = count_occ_string(anode.child_value("channels"),"id");
|
||||
if ( numchann > 0 || !neglect_empty_groups_ )
|
||||
{
|
||||
num_groups_++;
|
||||
group_id_.push_back(anode.attribute("id").value());
|
||||
group_name_.push_back(anode.child_value("name"));
|
||||
int numchann = count_occ_string(anode.child_value("channels"),"id");
|
||||
num_channels_group_.push_back(numchann);
|
||||
}
|
||||
if ( numchann == 0 ) num_empty_groups_++;
|
||||
}
|
||||
}
|
||||
|
||||
// obtain list of xpointers and ids to assign channels
|
||||
@ -201,18 +207,15 @@ void tdm_ripper::parse_structure()
|
||||
// std::string keyinit("usi23258");
|
||||
// std::cout<<"xml test "<<xml_double_sequence_[xml_values_[xml_local_columns_[keyinit]]]<<"\n\n";
|
||||
|
||||
// check consistency of number of channelgroups
|
||||
// check consistency of number of channel-groups
|
||||
int numgroups = count_occ_string(subtreedata.child("tdm_root").child_value("channelgroups"),"id");
|
||||
if ( 0*numgroups == 0 ) assert( numgroups == num_groups_ );
|
||||
assert( (neglect_empty_groups_ && numgroups == num_groups_+num_empty_groups_)
|
||||
|| (!neglect_empty_groups_ && numgroups == num_groups_) );
|
||||
|
||||
// check consistency of number of channels
|
||||
assert( num_channels_ == (int)channel_id_.size()
|
||||
&& num_channels_ == (int)channel_name_.size()
|
||||
&& num_channels_ == (int)channels_group_.size() );
|
||||
|
||||
std::cout<<std::setw(25)<<std::left<<"number of channels:"<<std::setw(10)<<num_channels_<<"\n";
|
||||
for ( int i = 0; i < num_groups_; i++ ) std::cout<<std::setw(25)<<std::left<<"group"<<std::setw(10)<<i+1<<std::setw(10)<<no_channels(i+1)<<"\n";
|
||||
std::cout<<std::right<<"\n\n";
|
||||
}
|
||||
|
||||
void tdm_ripper::list_channels(std::ostream& gout, int width, int maxshow)
|
||||
|
@ -23,6 +23,10 @@ class tdm_ripper
|
||||
// endianness (true = little, false = big)
|
||||
bool endianness_, machine_endianness_;
|
||||
|
||||
// evtl. neglect groups with no actual channels
|
||||
bool neglect_empty_groups_;
|
||||
int num_empty_groups_;
|
||||
|
||||
// number/names/ids of channels, channelgroups and channels's assignment to groups
|
||||
int num_channels_, num_groups_;
|
||||
std::vector<std::string> channel_id_, inc_id_, units_, channel_name_;
|
||||
@ -56,7 +60,7 @@ class tdm_ripper
|
||||
|
||||
public:
|
||||
|
||||
tdm_ripper(std::string tdmfile, std::string tdxfile = "");
|
||||
tdm_ripper(std::string tdmfile, std::string tdxfile = "", bool neglect_empty_groups = true);
|
||||
|
||||
void parse_structure();
|
||||
|
||||
|
4
main.cpp
4
main.cpp
@ -43,8 +43,8 @@ int main(int argc, char* argv[])
|
||||
// for ( auto el: channA ) std::cout<<el<<"\n";
|
||||
// std::cout<<"\n\n";
|
||||
|
||||
for ( int i = 3; i < 10; i++ )
|
||||
// for ( int i = 0; i < ripper.num_channels(); i++ )
|
||||
// for ( int i = 3; i < 10; i++ )
|
||||
for ( int i = 0; i < ripper.num_channels(); i++ )
|
||||
// for ( int i = 11880; i < ripper.num_channels(); i++ )
|
||||
{
|
||||
ripper.print_channel(i+1,("data/channel_"+std::to_string(i+1)+"_"
|
||||
|
Loading…
x
Reference in New Issue
Block a user