start full revision
This commit is contained in:
parent
16a73d2d9f
commit
b519756aeb
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ tdmripper
|
||||
*.csv
|
||||
*.log
|
||||
*.txt
|
||||
tdmreaper
|
||||
|
@ -3,7 +3,7 @@
|
||||
<a href="https://github.com/RecordEvolution/tdm_ripper.git">
|
||||
<img
|
||||
alt="tdmreaper.svg"
|
||||
src="tdmreaper.svg"
|
||||
src="assets/tdmreaper.svg"
|
||||
width="400"
|
||||
/>
|
||||
</a>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
14
lib/makefile
14
lib/makefile
@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
CC = gcc -std=c++11 -stdlib=libc++
|
||||
CPPFLAGS = -O3 -Wall -Werror
|
||||
LIB = ../pugixml/
|
||||
|
||||
libtdmripper.a : tdm_ripper.o
|
||||
ar rcs $@ $^
|
||||
|
||||
tdm_ripper.o : tdm_ripper.cpp tdm_ripper.hpp
|
||||
$(CC) -c $(CPPFLAGS) -I $(LIB) $< -o $@
|
||||
|
||||
clean :
|
||||
rm -f *.o *.a
|
29
lib/tdm_reaper.cpp
Normal file
29
lib/tdm_reaper.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
#include "tdm_reaper.hpp"
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
tdm_ripper::tdm_ripper(std::string tdmfile, std::string tdxfile,
|
||||
bool suppress_status, bool neglect_empty_groups)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void tdm_ripper::print_channel(int idx, char const* name, int width)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tdm_ripper::list_groups(std::ostream& out, int g, int c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tdm_ripper::list_channels(std::ostream& out, int g, int c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
@ -1,3 +1,4 @@
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
#ifndef TDM_RIPPER
|
||||
#define TDM_RIPPER
|
||||
@ -13,22 +14,39 @@
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../pugixml/pugixml.hpp"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
// define datatypes
|
||||
|
||||
struct datatype {
|
||||
std::string name_;
|
||||
std::string channel_datatype_;
|
||||
int numeric_;
|
||||
std::string value_sequence_;
|
||||
int size_;
|
||||
std::string description;
|
||||
};
|
||||
|
||||
const std::map<std::string,datatype> tdm_datatypes = {
|
||||
{"eInt16Usi",{"eInt16Usi","DT_SHORT",2,"short_sequence",2,"signed 16 bit integer"}}
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
class tdm_ripper
|
||||
{
|
||||
// .tdm and .tdx filenames
|
||||
// .tdm and .tdx paths/filenames
|
||||
std::string tdmfile_;
|
||||
std::string tdxfile_;
|
||||
bool suppress_status_;
|
||||
|
||||
// set of .csv files
|
||||
std::vector<std::string> csvfile_;
|
||||
|
||||
// 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_;
|
||||
@ -38,6 +56,10 @@ class tdm_ripper
|
||||
std::vector<int> channels_group_;
|
||||
std::vector<int> channel_ext_;
|
||||
|
||||
// neglect empty groups
|
||||
bool neglect_empty_groups_;
|
||||
int num_empty_groups_;
|
||||
|
||||
// minimum/maximum value in particular channel (is provided in .tdm file as float)
|
||||
std::vector<std::pair<double,double>> minmax_;
|
||||
|
||||
@ -50,7 +72,7 @@ class tdm_ripper
|
||||
std::vector<std::string> type_;
|
||||
std::vector<std::string> external_id_;
|
||||
|
||||
// mapping of NI datatype to size (in bytes) of type
|
||||
// NI datatypes ( )
|
||||
std::map<std::string, int> datatypes_;
|
||||
|
||||
// xml parser
|
18
makefile
18
makefile
@ -1,7 +1,10 @@
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
# declare name of executable
|
||||
EXE = tdmripper
|
||||
EXE = tdmreaper
|
||||
|
||||
# source name
|
||||
SRC := tdm_reaper
|
||||
|
||||
# compiler and C++ standard
|
||||
CC = g++ -std=c++17
|
||||
@ -22,7 +25,7 @@ INST := /usr/local/bin
|
||||
# --------------------------------------------------------------------------- #
|
||||
# CLI tool
|
||||
|
||||
$(EXE) : main.o tdm_ripper.o
|
||||
$(EXE) : main.o $(SRC).o
|
||||
$(CC) $(OPT) $^ -o $@
|
||||
|
||||
install : $(EXE)
|
||||
@ -39,13 +42,7 @@ main.o : src/main.cpp
|
||||
$(CC) -c $(OPT) -I $(LIB) -I lib/ $<.cpp -o $@
|
||||
@rm $<.cpp
|
||||
|
||||
tdm_ripper.o : lib/tdm_ripper.cpp lib/tdm_ripper.hpp
|
||||
$(CC) -c $(OPT) -I $(LIB) $< -o $@
|
||||
|
||||
extall : extract_all.o tdm_ripper.o
|
||||
$(CC) $(OPT) $^ -o extract_all
|
||||
|
||||
extract_all.o : extract_all.cpp
|
||||
$(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp
|
||||
$(CC) -c $(OPT) -I $(LIB) $< -o $@
|
||||
|
||||
clean :
|
||||
@ -71,3 +68,6 @@ clean :
|
||||
# rm -f -r build
|
||||
# rm -f pytdm_ripper.cpp
|
||||
# rm -f *.so
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
106
src/main.cpp
106
src/main.cpp
@ -1,6 +1,6 @@
|
||||
// ------------------------------------------------------------------------- //
|
||||
|
||||
#include "tdm_ripper.hpp"
|
||||
#include "tdm_reaper.hpp"
|
||||
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
@ -13,7 +13,7 @@ const std::string githash("HASHSTRING");
|
||||
void show_usage()
|
||||
{
|
||||
std::cout<<"\n"
|
||||
<<"tdmripper ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/tdm_ripper.git)"
|
||||
<<"tdmreaper ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/tdm_ripper.git)"
|
||||
<<"\n\n"
|
||||
<<"Decode TDM/TDX files and dump data as *.csv"
|
||||
<<"\n\n"
|
||||
@ -181,57 +181,57 @@ int main(int argc, char* argv[])
|
||||
if ( listgroups ) jack.list_groups();
|
||||
if ( listchannels ) jack.list_channels();
|
||||
|
||||
// write data to filesystem
|
||||
if ( !listgroups && !listchannels )
|
||||
{
|
||||
// declare filesystem path
|
||||
std::filesystem::path pd = output;
|
||||
|
||||
// check for given directory
|
||||
if ( std::filesystem::is_directory(pd) )
|
||||
{
|
||||
// print (group,channel) data
|
||||
for ( int g = 0; g < jack.num_groups(); g++ )
|
||||
{
|
||||
// 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,"");
|
||||
|
||||
for ( int c = 0; c < jack.no_channels(g); c++ )
|
||||
{
|
||||
// get overall channel index/id
|
||||
int chidx = jack.obtain_channel_id(g,c);
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
// print meta data
|
||||
jack.print_meta((pd / "meta-data.log").c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr<<std::string("directory '") + output
|
||||
+ std::string("' does not exist") + std::string("\n");
|
||||
}
|
||||
}
|
||||
// // write data to filesystem
|
||||
// if ( !listgroups && !listchannels )
|
||||
// {
|
||||
// // declare filesystem path
|
||||
// std::filesystem::path pd = output;
|
||||
//
|
||||
// // check for given directory
|
||||
// if ( std::filesystem::is_directory(pd) )
|
||||
// {
|
||||
// // print (group,channel) data
|
||||
// for ( int g = 0; g < jack.num_groups(); g++ )
|
||||
// {
|
||||
// // 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,"");
|
||||
//
|
||||
// for ( int c = 0; c < jack.no_channels(g); c++ )
|
||||
// {
|
||||
// // get overall channel index/id
|
||||
// int chidx = jack.obtain_channel_id(g,c);
|
||||
//
|
||||
// // 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());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // print meta data
|
||||
// jack.print_meta((pd / "meta-data.log").c_str());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cerr<<std::string("directory '") + output
|
||||
// + std::string("' does not exist") + std::string("\n");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user