obtain meta information tags
This commit is contained in:
@@ -112,10 +112,24 @@ void tdm_ripper::parse_structure()
|
||||
pugi::xml_node subtreedata = xml_doc_.child("usi:tdm").child("usi:data");
|
||||
|
||||
// extract basic information about available groups
|
||||
int groupcount = 0;
|
||||
for (pugi::xml_node anode: subtreedata.children())
|
||||
{
|
||||
if ( std::string(anode.name()).compare("tdm_channelgroup") == 0 )
|
||||
{
|
||||
groupcount++;
|
||||
|
||||
// meta-info is pressumably contained in FIRST channel-group xml tree element
|
||||
// (eventually identify by name = TESTINFOS ??? )
|
||||
if ( groupcount == 1 )
|
||||
{
|
||||
for ( pugi::xml_node mnode: anode.child("instance_attributes").children() )
|
||||
{
|
||||
meta_info_.insert(std::pair<std::string,std::string>(mnode.attribute("name").value(),
|
||||
mnode.child_value("s")));
|
||||
}
|
||||
}
|
||||
|
||||
int numchann = count_occ_string(anode.child_value("channels"),"id");
|
||||
if ( numchann > 0 || !neglect_empty_groups_ )
|
||||
{
|
||||
@@ -183,6 +197,8 @@ void tdm_ripper::parse_structure()
|
||||
std::cout<<std::setw(25)<<std::left<<"xml_values_:"<<xml_values_.size()<<"\n";
|
||||
std::cout<<std::setw(25)<<std::left<<"xml_double_sequence_:"<<xml_double_sequence_.size()<<"\n";
|
||||
std::cout<<std::right<<"\n\n";
|
||||
|
||||
std::cout<<"meta-info snippets "<<meta_info_.size()<<"\n\n";
|
||||
}
|
||||
|
||||
// extract basic information about available channels
|
||||
@@ -212,29 +228,7 @@ void tdm_ripper::parse_structure()
|
||||
minmax_.push_back(minmaxchan);
|
||||
|
||||
// get correct assignment of channels to byteoffset, length and datatype
|
||||
// std::string locol = get_str_between(anode.child_value("local_columns"),"\"","\"");
|
||||
// std::string locolval;
|
||||
// locolval = local_columns_val_[locol];
|
||||
// for (pugi::xml_node anode: subtreedata.children())
|
||||
// {
|
||||
// if ( std::string(anode.name()).compare("localcolumn") == 0
|
||||
// && std::string(anode.attribute("id").value()).compare(locol) == 0 )
|
||||
// {
|
||||
// locolval = get_str_between(anode.child_value("values"),"\"","\"");
|
||||
// }
|
||||
// }
|
||||
|
||||
std::string locolvalext;
|
||||
// locolvalext = double_sequence_id_[locolval];
|
||||
// for (pugi::xml_node anode: subtreedata.children())
|
||||
// {
|
||||
// if ( std::string(anode.name()).compare("double_sequence") == 0
|
||||
// && std::string(anode.attribute("id").value()).compare(locolval) == 0 )
|
||||
// {
|
||||
// locolvalext = anode.child("values").attribute("external").value();
|
||||
// }
|
||||
// }
|
||||
|
||||
locolvalext = xml_double_sequence_[xml_values_[xml_local_columns_[anode.attribute("id").value()]]];
|
||||
|
||||
// save external id of channel and get corresponding channel index
|
||||
|
@@ -57,6 +57,9 @@ class tdm_ripper
|
||||
pugi::xml_document xml_doc_;
|
||||
pugi::xml_parse_result xml_result_;
|
||||
|
||||
// .tdm-file eventually contains some meta information about measurement
|
||||
std::map<std::string,std::string> meta_info_;
|
||||
|
||||
// binary data container
|
||||
std::vector<unsigned char> tdxbuf_;
|
||||
|
||||
@@ -250,18 +253,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// evtl. get group time_stamp of .tdm file given in unix format
|
||||
// get time-stamp of channel-group in .tdm file given in unix format
|
||||
static std::string unix_timestamp(std::string unixts)
|
||||
{
|
||||
// average year of Gregorian calender
|
||||
const double avgdaysofyear = 365.0 + 1./4 - 1./100 + 1./400
|
||||
- 8./24561; // gauge timestamp according to DIADEM result
|
||||
|
||||
// convert string to long int = number of second since 0000/01/01 00:00
|
||||
// convert string to long int = number of seconds since 0000/01/01 00:00
|
||||
long int ts = atol(unixts.c_str());
|
||||
assert( ts >= 0 );
|
||||
|
||||
// use STL to convert timestamp (epoch usually starts from 01.01.1970)
|
||||
// use STL to convert timestamp (epoch usually starts on 01.01.1970)
|
||||
std::time_t tstime = ts - 1970*avgdaysofyear*86400;
|
||||
|
||||
// get rid of linebreak character and return the result
|
||||
@@ -314,6 +317,12 @@ public:
|
||||
|
||||
void print_channel(int channelid, const char* filename, int width = 15);
|
||||
|
||||
// obtain any meta information about .tdm-file if available
|
||||
std::string get_meta(std::string attribute_name)
|
||||
{
|
||||
return meta_info_[attribute_name];
|
||||
}
|
||||
|
||||
// TODO add elements/methods to build .tdm and write .tdx files for your own data
|
||||
// by constructing xml document tree and write data to binary .tdx
|
||||
// void set_channels(std::vector<std::string> channels);
|
||||
|
Reference in New Issue
Block a user