From 3e4ee699ad63779502ca011b7f931bc66f9e78c4 Mon Sep 17 00:00:00 2001 From: Mario Fink Date: Fri, 5 Feb 2021 10:01:03 +0100 Subject: [PATCH] change repository/library/tool name --- .gitignore | 1 + README.md | 44 ++++---- assets/tdmtermite.svg | 100 ++++++++++++++++++ .../{py_tdm_reaper.pyx => py_tdm_termite.pyx} | 8 +- cython/setup.py | 8 +- cython/{tdm_reaper.pxd => tdm_termite.pxd} | 10 +- lib/{tdm_reaper.cpp => tdm_termite.cpp} | 56 +++++----- lib/{tdm_reaper.hpp => tdm_termite.hpp} | 12 +-- makefile | 14 +-- python/custom.py | 6 +- python/minimal.py | 6 +- python/usage.py | 6 +- src/main.cpp | 14 +-- 13 files changed, 193 insertions(+), 92 deletions(-) create mode 100644 assets/tdmtermite.svg rename cython/{py_tdm_reaper.pyx => py_tdm_termite.pyx} (92%) rename cython/{tdm_reaper.pxd => tdm_termite.pxd} (82%) rename lib/{tdm_reaper.cpp => tdm_termite.cpp} (94%) rename lib/{tdm_reaper.hpp => tdm_termite.hpp} (97%) diff --git a/.gitignore b/.gitignore index fef44c6..5dea18d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ tdmripper *.log tdmreaper cython/*.cpp +tdmtermite diff --git a/README.md b/README.md index 4bf698c..90436d3 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@

tdmreaper.svg

-The _tdm_reaper_ is a C++ based library that decodes (encodes) the proprietary +_TDMtermite_ is a C++ based library that decodes (encodes) the proprietary file format _TDM/TDX_ for measurement data, which relies upon the _technical data management_ data model. The TDM format was introduced by [National Instruments](https://www.ni.com) and is employed by @@ -134,7 +134,7 @@ The library can be used both as a _CLI_ based tool and as a _Python_ module. ### CLI tool -To install the CLI tool _tdmreaper_ do +To install the CLI tool _tdmtermite_ do ```Shell make install @@ -151,7 +151,7 @@ available, which may be installed via `python3 -m pip install cython` . Furthermore, the [Numpy](https://numpy.org) package is recommended to be able to pass arrays of data from the C++ kernel to Python. The _makefile_ provides the target `make cython-requirements` to install all required Python modules. -Finally, to build the Python extension _tdm_reaper_ either locally or install +Finally, to build the Python extension _tdm_termite_ either locally or install it the targets `make cython-build` and `make cython-install` are provided. Hence, to install the Python module on the system simply do @@ -160,19 +160,19 @@ make cython-requirements make cython-install ``` -that makes the module available to be imported as `import tdm_reaper` . +that makes the module available to be imported as `import tdm_termite` . ## Usage ### CLI tool The usage of the CLI tool is sufficiently clarified by its help message displayed -by `tdmreaper --help`. For instance, to extract the data decoded in the pair of +by `tdmtermite --help`. For instance, to extract the data decoded in the pair of files `samples/SineData.tdm` and `samples/SineData.tdx` into the directory `/home/jack/data/`: ```Shell -tdmreaper samples/SineData.tdm samples/SineData.tdx --output /home/jack/data +tdmtermite samples/SineData.tdm samples/SineData.tdx --output /home/jack/data ``` The tool can also be used to list the available objects in the TDM dataset, which @@ -180,7 +180,7 @@ are i.a. _channels_, _channelgroups_ and TDX _blocks_. For instance, to list all channels and channelgroups (without writing any file output): ```Shell -tdmreaper samples/SineData.tdm samples/SineData.tdx --listgroups --listchannels +tdmtermite samples/SineData.tdm samples/SineData.tdx --listgroups --listchannels ``` The user may also submit a _filenaming rule_ to control the names of the files the @@ -189,7 +189,7 @@ and `%c` representing the group id, group name, channel index and channel name are defined. The default filenaming option is ```Shell -tdmreaper samples/SineData.tdm samples/SineData.tdx --output /home/jack/data --filenames channelgroup_%G.csv +tdmtermite samples/SineData.tdm samples/SineData.tdx --output /home/jack/data --filenames channelgroup_%G.csv ``` which makes the tool write _all channels_ grouped into files according to their @@ -199,7 +199,7 @@ to extract only a single channel(group) by providing a particular channel(-group id in the filenaming flag. For example, ```Shell -tdmreaper samples/SineData.tdm samples/SineData.tdx --output /home/jack/data -f channel_usi16_%c.csv --includemeta +tdmtermite samples/SineData.tdm samples/SineData.tdx --output /home/jack/data -f channel_usi16_%c.csv --includemeta ``` will write the single channel with id `usi16` to the file @@ -207,25 +207,25 @@ will write the single channel with id `usi16` to the file ### Python -To be able to use the Python module _tdm_reaper_ it first has to be build locally +To be able to use the Python module _tdm_termite_ it first has to be build locally or installed on the system. In the Python interpreter simply do: ```Python -import tdm_reaper +import tdm_termite ``` to import the module. The TDM files are provided by creating an instance of -the _tdm_reaper_ class: +the _tdm_termite_ class: ```Python -# create 'tdm_reaper' instance object +# create 'tdm_termite' instance object try : - jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') + jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') except RuntimeError as e: print("failed to load/decode TDM files: " + str(e)) ``` -After initializing the _tdm_reaper_ object it can be used to extract any of the +After initializing the _tdm_termite_ object it can be used to extract any of the available data. For instance, to list the included channelgroups and channels: ```Python @@ -241,12 +241,12 @@ As a use case, we have look at listing the ids of all channelgroups and printing their data to separate files: ```Python -import tdm_reaper +import tdm_termite import re -# create 'tdm_reaper' instance object +# create 'tdm_termite' instance object try : - jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') + jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') except RuntimeError as e : print("failed to load/decode TDM files: " + str(e)) @@ -280,8 +280,8 @@ to simply extract all data of the TDM datatset and dump it to files in a given (existing!) directory, do ```Python -import tdm_reaper -jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') +import tdm_termite +jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') jack.write_all(b"./my_tdm_data_directory/") ``` diff --git a/assets/tdmtermite.svg b/assets/tdmtermite.svg new file mode 100644 index 0000000..a1bfb0f --- /dev/null +++ b/assets/tdmtermite.svg @@ -0,0 +1,100 @@ + + + + + + + image/svg+xml + + flasher + + + + + flasher + + + + + + + + + + TDMtermite + diff --git a/cython/py_tdm_reaper.pyx b/cython/py_tdm_termite.pyx similarity index 92% rename from cython/py_tdm_reaper.pyx rename to cython/py_tdm_termite.pyx index 3866db3..09da2bb 100644 --- a/cython/py_tdm_reaper.pyx +++ b/cython/py_tdm_termite.pyx @@ -1,17 +1,17 @@ # distutils: language = c++ -from tdm_reaper cimport tdm_reaper +from tdm_termite cimport tdm_termite import json as jn # import numpy as np -cdef class tdmreaper: +cdef class tdmtermite: # C++ instance of class => stack allocated (requires nullary constructor!) - cdef tdm_reaper cpp_tdm + cdef tdm_termite cpp_tdm # constructor def __cinit__(self, string tdmfile, string tdxfile): - self.cpp_tdm = tdm_reaper(tdmfile,tdxfile) + self.cpp_tdm = tdm_termite(tdmfile,tdxfile) # provide TDM files def submit_files(self,string tdmfile, string tdxfile): diff --git a/cython/setup.py b/cython/setup.py index f005526..5679b10 100644 --- a/cython/setup.py +++ b/cython/setup.py @@ -3,8 +3,8 @@ from distutils.extension import Extension from Cython.Build import cythonize extensions = Extension( - name="tdm_reaper", - sources=["cython/py_tdm_reaper.pyx"], + name="tdm_termite", + sources=["cython/py_tdm_termite.pyx"], # libraries=[""], # library_dirs=["lib"], include_dirs=["lib","pugixml"], @@ -15,10 +15,10 @@ extensions = Extension( setup( version='0.1', - description='TDMReaper cython extension', + description='TDMtermite cython extension', author='Record Evolution GmbH', author_email='mario.fink@record-evolution.de', url='https://github.com/RecordEvolution/tdm_ripper.git', - name="tdm_reaper", + name="tdm_termite", ext_modules=cythonize(extensions) ) diff --git a/cython/tdm_reaper.pxd b/cython/tdm_termite.pxd similarity index 82% rename from cython/tdm_reaper.pxd rename to cython/tdm_termite.pxd index 7ff4352..6fe58f9 100644 --- a/cython/tdm_reaper.pxd +++ b/cython/tdm_termite.pxd @@ -5,14 +5,14 @@ from libcpp.string cimport string from libcpp.vector cimport vector from libcpp cimport bool -cdef extern from "tdm_reaper.cpp": +cdef extern from "tdm_termite.cpp": pass -cdef extern from "tdm_reaper.hpp": - cdef cppclass tdm_reaper: +cdef extern from "tdm_termite.hpp": + cdef cppclass tdm_termite: # constructor(s) - tdm_reaper() except + - tdm_reaper(string tdmfile, string tdxfile) except + + tdm_termite() except + + tdm_termite(string tdmfile, string tdxfile) except + # provide TDM files void submit_files(string tdmfile, string tdxfile) except+ # get list of channel(-group) ids diff --git a/lib/tdm_reaper.cpp b/lib/tdm_termite.cpp similarity index 94% rename from lib/tdm_reaper.cpp rename to lib/tdm_termite.cpp index 8078c2d..c66587d 100644 --- a/lib/tdm_reaper.cpp +++ b/lib/tdm_termite.cpp @@ -1,22 +1,22 @@ // -------------------------------------------------------------------------- // -#include "tdm_reaper.hpp" +#include "tdm_termite.hpp" // -------------------------------------------------------------------------- // -tdm_reaper::tdm_reaper() +tdm_termite::tdm_termite() { } -tdm_reaper::tdm_reaper(std::string tdmfile, std::string tdxfile, bool showlog): +tdm_termite::tdm_termite(std::string tdmfile, std::string tdxfile, bool showlog): tdmfile_(tdmfile), tdxfile_(tdxfile) { // start processing tdm data model this->process_tdm(showlog); } -void tdm_reaper::submit_files(std::string tdmfile, std::string tdxfile, bool showlog) +void tdm_termite::submit_files(std::string tdmfile, std::string tdxfile, bool showlog) { // save files tdmfile_ = tdmfile; @@ -34,7 +34,7 @@ void tdm_reaper::submit_files(std::string tdmfile, std::string tdxfile, bool sho this->process_tdm(showlog); } -void tdm_reaper::process_tdm(bool showlog) +void tdm_termite::process_tdm(bool showlog) { // check both tdm, tdx files std::filesystem::path ptdm(tdmfile_), ptdx(tdxfile_); @@ -124,7 +124,7 @@ void tdm_reaper::process_tdm(bool showlog) } } -void tdm_reaper::process_include(bool showlog, pugi::xml_document& xml_doc) +void tdm_termite::process_include(bool showlog, pugi::xml_document& xml_doc) { // get XML node pugi::xml_node tdmincl = xml_doc.child("usi:tdm").child("usi:include"); @@ -178,7 +178,7 @@ void tdm_reaper::process_include(bool showlog, pugi::xml_document& xml_doc) if ( showlog ) std::cout<<"number of blocks: "< pugi::xml_node tdmdata = xml_doc.child("usi:tdm").child("usi:data"); @@ -236,7 +236,7 @@ void tdm_reaper::process_channelgroups(bool showlog, pugi::xml_document& xml_doc if ( showlog ) std::cout<<"number of channelgroups: "< pugi::xml_node tdmdata = xml_doc.child("usi:tdm").child("usi:data"); @@ -280,7 +280,7 @@ void tdm_reaper::process_channels(bool showlog, pugi::xml_document& xml_doc) if ( showlog ) std::cout<<"number of channels: "< pugi::xml_node tdmdata = xml_doc.child("usi:tdm").child("usi:data"); @@ -319,7 +319,7 @@ void tdm_reaper::process_submatrices(bool showlog, pugi::xml_document& xml_doc) if ( showlog ) std::cout<<"number of submatrices: "< pugi::xml_node tdmdata = xml_doc.child("usi:tdm").child("usi:data"); @@ -435,7 +435,7 @@ void tdm_reaper::process_localcolumns(bool showlog, pugi::xml_document& xml_doc) // -------------------------------------------------------------------------- // -std::string tdm_reaper::get_channel_overview(format chformatter) +std::string tdm_termite::get_channel_overview(format chformatter) { // summarize all output in single string std::string channels_summary; @@ -474,7 +474,7 @@ std::string tdm_reaper::get_channel_overview(format chformatter) } template -std::string tdm_reaper::get_overview(format formatter) +std::string tdm_termite::get_overview(format formatter) { // summarize all output in single string std::string summary; @@ -500,12 +500,12 @@ std::string tdm_reaper::get_overview(format formatter) return summary; } -template std::string tdm_reaper::get_overview(format formatter); -template std::string tdm_reaper::get_overview(format formatter); -template std::string tdm_reaper::get_overview(format formatter); -template std::string tdm_reaper::get_overview(format formatter); +template std::string tdm_termite::get_overview(format formatter); +template std::string tdm_termite::get_overview(format formatter); +template std::string tdm_termite::get_overview(format formatter); +template std::string tdm_termite::get_overview(format formatter); -void tdm_reaper::summarize_member(tdm_channelgroup chp, std::string& summary, format& formatter) +void tdm_termite::summarize_member(tdm_channelgroup chp, std::string& summary, format& formatter) { for ( std::map::iterator it=this->tdmchannelgroups_.begin(); it!=this->tdmchannelgroups_.end(); ++it) @@ -515,7 +515,7 @@ void tdm_reaper::summarize_member(tdm_channelgroup chp, std::string& summary, fo } } -void tdm_reaper::summarize_member(submatrix sbm, std::string& summary, format& formatter) +void tdm_termite::summarize_member(submatrix sbm, std::string& summary, format& formatter) { for ( std::map::iterator it=this->submatrices_.begin(); it!=this->submatrices_.end(); ++it) @@ -525,7 +525,7 @@ void tdm_reaper::summarize_member(submatrix sbm, std::string& summary, format& f } } -void tdm_reaper::summarize_member(localcolumn lcc, std::string& summary, format& formatter) +void tdm_termite::summarize_member(localcolumn lcc, std::string& summary, format& formatter) { for ( std::map::iterator it=this->localcolumns_.begin(); it!=this->localcolumns_.end(); ++it) @@ -535,7 +535,7 @@ void tdm_reaper::summarize_member(localcolumn lcc, std::string& summary, format& } } -void tdm_reaper::summarize_member(block blk, std::string& summary, format& formatter) +void tdm_termite::summarize_member(block blk, std::string& summary, format& formatter) { for ( std::map::iterator it=this->tdx_blocks_.begin(); it!=this->tdx_blocks_.end(); ++it) @@ -548,7 +548,7 @@ void tdm_reaper::summarize_member(block blk, std::string& summary, format& forma // -------------------------------------------------------------------------- // // extract channel by id -std::vector tdm_reaper::get_channel(std::string& id) +std::vector tdm_termite::get_channel(std::string& id) { // check for existence of required channel id (=key) if ( tdmchannels_.count(id) == 1 ) @@ -653,7 +653,7 @@ std::vector tdm_reaper::get_channel(std::string& id) // -------------------------------------------------------------------------- // -void tdm_reaper::print_channel(std::string &id, const char* filename, bool include_meta) +void tdm_termite::print_channel(std::string &id, const char* filename, bool include_meta) { // check required path this->check_filename_path(filename); @@ -698,7 +698,7 @@ void tdm_reaper::print_channel(std::string &id, const char* filename, bool inclu } } -void tdm_reaper::print_group(std::string &id, const char* filename, bool include_meta, +void tdm_termite::print_group(std::string &id, const char* filename, bool include_meta, char sep, std::string column_header) { // check required path @@ -834,7 +834,7 @@ void tdm_reaper::print_group(std::string &id, const char* filename, bool include } } -void tdm_reaper::check_filename_path(const char* filename) +void tdm_termite::check_filename_path(const char* filename) { // declare filesystem path instance from filename std::filesystem::path pt(filename); @@ -850,7 +850,7 @@ void tdm_reaper::check_filename_path(const char* filename) // -------------------------------------------------------------------------- // -void tdm_reaper::check_local_datatypes() +void tdm_termite::check_local_datatypes() { std::cout<<"\nmachine's C++ datatypes:\n"; std::cout< -void tdm_reaper::convert_data_to_type(std::vector &buffer, +void tdm_termite::convert_data_to_type(std::vector &buffer, std::vector &channel) { // check number of elements of type "datatype" in buffer diff --git a/lib/tdm_reaper.hpp b/lib/tdm_termite.hpp similarity index 97% rename from lib/tdm_reaper.hpp rename to lib/tdm_termite.hpp index 9e219ac..f035ebe 100644 --- a/lib/tdm_reaper.hpp +++ b/lib/tdm_termite.hpp @@ -1,7 +1,7 @@ // ------------------------------------------------------------------------- // -#ifndef TDM_REAPER -#define TDM_REAPER +#ifndef TDM_TERMITE +#define TDM_TERMITE #include #include @@ -24,7 +24,7 @@ // -------------------------------------------------------------------------- // -class tdm_reaper +class tdm_termite { // .tdm and .tdx paths/filenames std::string tdmfile_; @@ -115,11 +115,11 @@ class tdm_reaper public: // encoding - // tdm_reaper(std::vector csvfile); + // tdm_termite(std::vector csvfile); // decoding - tdm_reaper(); - tdm_reaper(std::string tdmfile, std::string tdxfile = std::string(""), + tdm_termite(); + tdm_termite(std::string tdmfile, std::string tdxfile = std::string(""), bool showlog = false); // provide (tdm,tdx) files diff --git a/makefile b/makefile index b66dfe8..a0dd525 100644 --- a/makefile +++ b/makefile @@ -1,10 +1,10 @@ # --------------------------------------------------------------------------- # # declare name of executable -EXE = tdmreaper +EXE = tdmtermite # sources and headers -SRC := tdm_reaper +SRC := tdm_termite HPP = $(wildcard lib/*.hpp) # compiler and C++ standard @@ -77,16 +77,16 @@ cython-help : cython/setup.py cython-list : cython/setup.py python3 $< --name --description --author --author-email --url -cython-build : cython/setup.py cython/tdm_reaper.pxd cython/py_tdm_reaper.pyx $(HPP) lib/tdm_reaper.cpp +cython-build : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp python3 $< build_ext --inplace - cp -v tdm_reaper.cpython-*.so python/ + cp -v tdm_termite.cpython-*.so python/ -cython-install : cython/setup.py cython/tdm_reaper.pxd cython/py_tdm_reaper.pyx $(HPP) lib/tdm_reaper.cpp +cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp python3 $< install clean-cython : - rm -vf cython/py_tdm_reaper.cpp - rm -vf tdm_reaper.cpython-*.so python/tdm_reaper.cpython-*.so + rm -vf cython/py_tdm_termite.cpp + rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so rm -rf build # --------------------------------------------------------------------------- # diff --git a/python/custom.py b/python/custom.py index faa86b7..9a349eb 100644 --- a/python/custom.py +++ b/python/custom.py @@ -1,11 +1,11 @@ -import tdm_reaper +import tdm_termite import json import re -# create 'tdm_reaper' instance object +# create 'tdm_termite' instance object try : - jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') + jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') except RuntimeError as e : print("failed to load/decode TDM files: " + str(e)) diff --git a/python/minimal.py b/python/minimal.py index 8a86d3c..4be5648 100644 --- a/python/minimal.py +++ b/python/minimal.py @@ -1,9 +1,9 @@ -import tdm_reaper +import tdm_termite -# create 'tdm_reaper' instance object +# create 'tdm_termite' instance object try : - jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') + jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') # list ids of channelgroups grpids = jack.get_channelgroup_ids() # iterate through groups diff --git a/python/usage.py b/python/usage.py index 465297e..09639fe 100644 --- a/python/usage.py +++ b/python/usage.py @@ -1,12 +1,12 @@ -import tdm_reaper +import tdm_termite # import numpy as np import json import re -# create 'tdm_reaper' instance object +# create 'tdm_termite' instance object try : - jack = tdm_reaper.tdmreaper(b'samples/SineData.tdm',b'samples/SineData.tdx') + jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx') except RuntimeError as e : print("failed to load/decode TDM files: " + str(e)) diff --git a/src/main.cpp b/src/main.cpp index 17cbc9c..0b31a31 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ // ------------------------------------------------------------------------- // -#include "tdm_reaper.hpp" +#include "tdm_termite.hpp" #include #include @@ -15,12 +15,12 @@ const std::string githash("HASHSTRING"); void show_usage() { std::cout<<"\n" - <<"tdmreaper ["< [options]" + <<" tdmtermite [options]" <<"\n\n" <<"Options:" <<"\n\n" @@ -55,7 +55,7 @@ void show_usage() typedef std::map optkeys; const std::string argmsg = std::string("both .tdm and .tdx file must be provided!"); -const std::string arguse = std::string("see $ tdmreaper --help for usage"); +const std::string arguse = std::string("see $ tdmtermite --help for usage"); optkeys parse_args(int argc, char* argv[], bool showargs = false) { @@ -78,7 +78,7 @@ optkeys parse_args(int argc, char* argv[], bool showargs = false) else if ( std::string(argv[1]) == std::string("--version") || std::string(argv[1]) == std::string("-v") ) { - std::cout<<"tdmreaper "<