diff --git a/README.md b/README.md
index 52c1787..e8735a3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,13 @@
-# tdm_ripper
+
+
+
+
+
+
The _tdm_ripper_ is a C++ based library that decodes the _technical data management_
file format _TDM/TDX_ and is mainly employed for measurement data by
@@ -154,4 +163,5 @@ wrapper.
## References
+- https://www.ni.com/de-de/support/documentation/supplemental/10/ni-tdm-data-model.html
- https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/ni_test_data_exchange/
diff --git a/lib/tdm_ripper.hpp b/lib/tdm_ripper.hpp
index b8647bf..4e27576 100644
--- a/lib/tdm_ripper.hpp
+++ b/lib/tdm_ripper.hpp
@@ -203,7 +203,8 @@ public:
{
numsum += num_channels_group_[i];
}
- assert( (numsum + channelid) > 0 && (numsum + channelid) <= num_channels_ );
+ assert( (numsum + channelid) >= 0 );
+ assert( (numsum + channelid) <= num_channels_ );
return numsum+channelid;
}
diff --git a/src/main.cpp b/src/main.cpp
index bc46f31..d6bad3a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,7 +13,7 @@ const std::string githash("HASHSTRING");
void show_usage()
{
std::cout<<"\n"
- <<"tdmripper ["<("csvsep",argv[i+1]));
i += 1;
}
- else if ( std::string(argv[i]) == std::string("--prefix")
- || std::string(argv[i]) == std::string("-p") )
+ else if ( std::string(argv[i]) == std::string("--filenames")
+ || std::string(argv[i]) == std::string("-f") )
{
- prsdkeys.insert(std::pair("prefix",argv[i+1]));
+ prsdkeys.insert(std::pair("filenames",argv[i+1]));
i += 1;
}
else if ( std::string(argv[i]) == std::string("--listgroups")
@@ -167,8 +169,8 @@ int main(int argc, char* argv[])
: std::string("./");
std::string csvsep = cfgopts.count("csvsep") == 1 ? cfgopts.at("csvsep")
: std::string(",");
- std::string prefix = cfgopts.count("prefix") == 1 ? cfgopts.at("prefix")
- : std::string("");
+ std::string files = cfgopts.count("filenames") == 1 ? cfgopts.at("filenames")
+ : std::string("channel_%C_%G.csv");
bool listgroups = cfgopts.count("listgroups") == 1 ? true : false;
bool listchannels = cfgopts.count("listchannels") == 1 ? true : false;
@@ -185,24 +187,41 @@ int main(int argc, char* argv[])
std::filesystem::path pd = output;
if ( std::filesystem::is_directory(pd) )
{
- for ( int i = 0; i < jack.num_channels(); i++ )
+ for ( int g = 0; g < jack.num_groups(); g++ )
{
- // sanitize channel name
- std::regex reg("([^A-Za-z0-9])");
- std::string chname = std::regex_replace(jack.channel_name(i),reg,"");
+ // get and sanitize group name
+ std::string grpnm = jack.group_name(g);
+ std::regex regg("([^A-Za-z0-9])");
+ std::string grpname = std::regex_replace(grpnm,regg,"");
- // concat path and construct file name
- std::filesystem::path outfile = pd / ( std::string("channel_")
- + std::to_string(i+1) + std::string("_")
- + chname + std::string(".csv") );
+ for ( int c = 0; c < jack.no_channels(g); c++ )
+ {
+ // get overall channel index/id
+ int chidx = jack.obtain_channel_id(g,c);
- // write channel to filesystem
- jack.print_channel(i,outfile.c_str());
+ // get and sanitize channel name
+ std::string chnm = jack.channel_name(g,c);
+ std::regex regc("([^A-Za-z0-9])");
+ std::string chname = std::regex_replace(chnm,regc,"");
+
+ // construct file name according to filenaming rule
+ std::string filenm = files;
+ filenm = std::regex_replace(files,std::regex("\\%C"),std::to_string(c+1));
+ filenm = std::regex_replace(filenm,std::regex("\\%c"),chname);
+ filenm = std::regex_replace(filenm,std::regex("\\%G"),std::to_string(g+1));
+ filenm = std::regex_replace(filenm,std::regex("\\%g"),grpname);
+
+ // concat paths
+ std::filesystem::path outfile = pd / filenm;
+
+ // write channel to filesystem
+ jack.print_channel(chidx,outfile.c_str());
+ }
}
}
else
{
- std::cerr<
+