28 Commits
v0.5 ... v1.0.1

Author SHA1 Message Date
3c72747def README.md: some reference 2021-05-06 17:51:45 +02:00
62159bb68b README.md: header 2021-05-06 17:37:29 +02:00
d9573443fd proper header in README 2021-05-06 11:44:18 +02:00
9d593dbf24 fix lgtm badge display 2021-05-06 11:41:57 +02:00
138acc3a00 include lgtm code stats 2021-05-06 11:39:29 +02:00
e46e3f866b * tdm_datatype: satisfy "rule of two"
* tdm_termite: summarize_member: pass by reference
* setup.py: remove unused imports
2021-05-05 12:48:25 +02:00
8d1577806b pip/setup.py: fix syntax typo, gitignore: add pip build files 2021-05-04 18:35:12 +02:00
0d6fd6545f * tdm_termite: fix copy/assignment for cython-build
* setup.py: version 1.0.0
2021-05-04 18:29:02 +02:00
caae8be862 makefile: fix order of targets, gitignore: add tdmtest 2021-05-03 19:15:22 +02:00
9ebac41973 add tdm test for memory profiling 2021-05-03 19:01:06 +02:00
c4f2a5ff5d keep ifstream object for tdx file instead of reading entire file in buffer 2021-05-03 18:20:15 +02:00
Mario Fink
3443d2dafa Dockerfile: fix typo in CMD 2021-03-16 23:10:05 +01:00
Mario Fink
66402b280c setup.py: fix IndexError: list index out of range for empty tag list 2021-03-16 19:59:31 +01:00
Mario Fink
76f4ee589d README: fix typo 2021-03-03 19:14:07 +01:00
Mario Fink
d957289124 add pip installation in README 2021-03-03 19:10:20 +01:00
Mario Fink
086da08873 pip simply makefile 2021-03-03 18:56:55 +01:00
Mario Fink
1be064b4f7 public release 0.5.0 for Python Package Index 2021-03-03 18:55:36 +01:00
Mario Fink
62239e2aeb clean up pip/ 2021-03-03 18:25:17 +01:00
Mario Fink
2ce5db0e85 PyPI sdist setup 2021-03-03 17:59:31 +01:00
Mario Fink
0d94c7064a fix 3rdparty path for cython 2021-03-03 09:37:00 +01:00
74c8027a10 move pugixml to 3rdparty 2021-03-03 09:30:58 +01:00
Mario Fink
145392108b PyPI setup 2021-03-02 17:13:33 +01:00
Mario Fink
c10fd1c488 Dockerfile + makefile, #6 2021-03-02 11:12:22 +01:00
ZornitsaD
31471106bc Update README.md 2021-02-18 10:43:31 +01:00
6a55fd68a5 correction in README.md 2021-02-17 09:54:06 +01:00
ZornitsaD
5180d2f168 Update README.md
some minor tweaks
2021-02-16 15:15:21 +01:00
12437fc2ec cython: setup.py: correct git URL 2021-02-12 10:38:18 +01:00
818963555d README typo 2021-02-05 13:41:20 +01:00
20 changed files with 556 additions and 106 deletions

11
.gitignore vendored
View File

@@ -12,3 +12,14 @@ tdmripper
tdmreaper tdmreaper
cython/*.cpp cython/*.cpp
tdmtermite tdmtermite
dist/
*.egg-info/
output/
monitor-process.sh
tdmtest
pip/*.hpp
pip/*.md
pip/*.cpp
pip/*.pyx
pip/*.pxd
pip/LICENSE

View File

@@ -1,20 +1,30 @@
FROM debian:bullseye-20210111 FROM debian:bullseye
USER root # install requirements
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
RUN apt-get update && apt-get install -y \ build-essential \
build-essential git \ g++ make git \
python3 python3-pip python3 python3-pip
RUN g++ -v # check compiler and current user
RUN g++ -v && whoami
COPY ./ /tdm_ripper/ # use /home as working directory
WORKDIR /home
# get the public TDMtermite repository
RUN git clone https://github.com/RecordEvolution/TDMtermite.git
# install CLI tool # install CLI tool
RUN cd /tdm_ripper && ls -lh && make install && ls -lh /usr/local/bin/tdmreaper RUN cd ./TDMtermite && ls -lh && make install && ls -lh /usr/local/bin/tdmtermite
# install Python module # install Python module
RUN cd /tdm_ripper && ls -lh && make cython-requirements && make cython-install RUN cd ./TDMtermite && ls -lh && make cython-requirements && make cython-list && make cython-install
# create directory for data exchange
#RUN [ "/bin/bash", "-c", "mkdir -pv data/{input,output}" ]
RUN mkdir -pv data
CMD ["sleep","infinity"]
CMD ["sleep","inifity"]

146
README.md
View File

@@ -1,21 +1,21 @@
<p align="center"> [![Total alerts](https://img.shields.io/lgtm/alerts/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/TDMtermite/alerts/)
<a href="https://github.com/RecordEvolution/tdm_ripper.git"> [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/TDMtermite/context:cpp)
<img [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/TDMtermite/context:python)
alt="tdmtermite.svg" [![LICENSE](https://img.shields.io/github/license/RecordEvolution/TDMtermite)](https://img.shields.io/github/license/RecordEvolution/TDMtermite)
src="assets/tdmtermite.svg" [![STARS](https://img.shields.io/github/stars/RecordEvolution/TDMtermite)](https://img.shields.io/github/stars/RecordEvolution/TDMtermite)
width="400"
/>
</a>
</p>
_TDMtermite_ is a C++ based library that decodes (encodes) the proprietary # TDMtermite
file format _TDM/TDX_ for measurement data, which relies upon the
_technical data management_ data model. The TDM format was introduced by _TDMtermite_ is a C++ based library that decodes the proprietary
[National Instruments](https://www.ni.com) and is employed by file format _TDM/TDX_ for measurement data. First introduced by
[National Instruments](https://www.ni.com), the TDM format relies on the
_technical data management_ data model and is employed by
[LabVIEW](https://www.ni.com/de-de/shop/labview.html), LabWindows™/CVI™, [LabVIEW](https://www.ni.com/de-de/shop/labview.html), LabWindows™/CVI™,
Measurement Studio, SignalExpress, and [DIAdem](https://www.ni.com/de-de/shop/data-acquisition-and-control/application-software-for-data-acquisition-and-control-category/what-is-diadem.html). Measurement Studio, SignalExpress, and [DIAdem](https://www.ni.com/de-de/shop/data-acquisition-and-control/application-software-for-data-acquisition-and-control-category/what-is-diadem.html).
The [Record Evolution Platform](https://www.record-evolution.de/en/home-en/) uses TDMtermite to integrate measurement data into ETL processes. The TDMtermite library is available both as a command line tool and as a Python module. The Python module of TDMtermite enables data scientists to conveniently include TDM formats in their existing data pipelines by providing access to both raw data and metadata in terms of native Python objects.
## Overview ## Overview
* [TDM file format](#Dataformat) * [TDM file format](#Dataformat)
@@ -25,18 +25,18 @@ Measurement Studio, SignalExpress, and [DIAdem](https://www.ni.com/de-de/shop/da
## Dataformat ## Dataformat
Datasets encoded in the TDM/TDX format come along in pairs comprised of a Datasets encoded in the TDM/TDX format come in pairs comprised of a
.tdm (header) and a .tdx (data) file. While the .tdm file is a human-readable .tdm (header) file and a .tdx (data) file. While the .tdm file is a human-readable
file providing meta information about the data set, the .tdx is a binary file providing meta information about the dataset, the .tdx file is a binary file
containing the actual data. The .tdm based on the _technical data management_ containing the actual data. The .tdm based on the _technical data management_
model is an XML file and basically describes what data the .tdx contains and how model is an XML file. It describes what data the .tdx file contains and how
to read it. The to read it. The
[TDM data model](https://www.ni.com/de-de/support/documentation/supplemental/10/ni-tdm-data-model.html) [TDM data model](https://www.ni.com/de-de/support/documentation/supplemental/10/ni-tdm-data-model.html)
structures the data hierarchically with respect to _file_, (channel) _groups_ and structures the data hierarchically with respect to _file_, _(channel)_ _groups_ and
_channels_. The file level XML may contain any number of (channel) groups each _channels_. The file-level XML may contain any number of (channel) groups, each
of which is made up of an arbitrary number of channels. Thus, the XML tree in of which is made up of an arbitrary number of channels. Thus, the XML tree in
the [TDM header file](https://zone.ni.com/reference/de-XX/help/370858P-0113/tdmdatamodel/tdmdatamodel/tdm_headerfile/) the [TDM header file](https://zone.ni.com/reference/de-XX/help/370858P-0113/tdmdatamodel/tdmdatamodel/tdm_headerfile/)
looks basically like this: looks like this:
```xml ```xml
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
@@ -67,14 +67,14 @@ looks basically like this:
</usi:tdm> </usi:tdm>
``` ```
and is comprised of _four_ main XML elements: `usi:documentation`, `usi:model`, The XML tree is comprised of _four_ main XML elements: `usi:documentation`, `usi:model`,
`usi:include` and `usi:data`. The element `usi:include` references the data file `usi:include` and `usi:data`. The element `usi:include` references the data file
`example.tdx` and reveals one of _two_ possible orderings of the mass data (.tdx): `example.tdx` and reveals one of _two_ possible orderings of the mass data (.tdx):
1. either _channel wise_ (`<block>`) - all values of a specific channel follow subsequently - 1. either _channel-wise_ (`<block>`) - all values of a specific channel follow subsequently
1. or _block wise_ (`<block_bm>`) - all values of a specific measurement time follow subsequently - 1. or _block-wise_ (`<block_bm>`) - all values of a specific measurement time follow subsequently.
ordering. The supported _numerical data types_ are The supported _numerical data types_ are:
| datatype | channel datatype | numeric | value sequence | size | description | | datatype | channel datatype | numeric | value sequence | size | description |
|-------------|------------------|---------|-----------------|-------|-------------------------| |-------------|------------------|---------|-----------------|-------|-------------------------|
@@ -87,10 +87,10 @@ ordering. The supported _numerical data types_ are
| eFloat64Usi | DT_DOUBLE | 7 | double_sequence | 8byte | 64 Bit double | | eFloat64Usi | DT_DOUBLE | 7 | double_sequence | 8byte | 64 Bit double |
| eStringUsi | DT_STRING | 1 | string_sequence | | text | | eStringUsi | DT_STRING | 1 | string_sequence | | text |
The XML element `<usi:data>` is basically comprised of _five_ different types of The XML element `<usi:data>` is comprised of _five_ different types of
elements that are `<tdm_root>`, `<tdm_channelgroup>`, `<tdm_channel>`, `<localcolumn>` elements that are `<tdm_root>`, `<tdm_channelgroup>`, `<tdm_channel>`, `<localcolumn>`
and `<submatrix>`. The root element `<tdm_root>` describes the general properties and `<submatrix>`. The root element `<tdm_root>` describes the general properties
of the dataset and lists the _id's_ of all channel groups that belong to of the dataset and lists the _ids_ of all channel groups that belong to
the dataset. The element `<tdm_channelgroup>` divides the _channels_ into groups the dataset. The element `<tdm_channelgroup>` divides the _channels_ into groups
and has a unique _id_ that is referenced by its root element. The `<channels>` and has a unique _id_ that is referenced by its root element. The `<channels>`
element in `<tdm_channelgroup>` lists the unique ids of all channels that belong element in `<tdm_channelgroup>` lists the unique ids of all channels that belong
@@ -110,7 +110,7 @@ actual data including its datatype. The remaining element types are
</localcolumn> </localcolumn>
``` ```
with a unique id, the `<measurement_quantity>` refering to one specific channel, with a unique id, the `<measurement_quantity>` referring to one specific channel,
the `<submatrix>` and its id respectively, the type of representation in the `<submatrix>` and its id respectively, the type of representation in
`<sequence_representation>` - being one of _explicit_, _implicit linear_ or `<sequence_representation>` - being one of _explicit_, _implicit linear_ or
_rawlinear_ - and the `<values>` element, which refers to one _value sequence_, _rawlinear_ - and the `<values>` element, which refers to one _value sequence_,
@@ -125,49 +125,61 @@ and the element `<submatrix>`
</submatrix> </submatrix>
``` ```
that references the channel group in `<measurement>` it belongs to and provides that references the channel group in `<measurement>` to which it belongs and provides
the _number of rows_ in the channels listed in `<local_columns>`. the _number of rows_ in the channels listed in `<local_columns>`.
## Installation ## Installation
The library can be used both as a _CLI_ based tool and as a _Python_ module. The library can be used both as a _CLI_-based tool and as a _Python_ module.
### CLI tool ### CLI tool
To install the CLI tool _tdmtermite_ do To install the CLI tool _TDMtermite_, do
```Shell ```Shell
make install make install
``` ```
which uses `/usr/local/bin` as installation directory. On _macOSX_ please first which uses `/usr/local/bin` as an installation directory. On _macOSX_, please first
build the binary locally with `make` and install it in your preferred location. build the binary locally with `make` and install it in your preferred location.
### Python ### Python
In order to build a _Python module_ from the _C++_ code base the In order to build a _Python module_ from the _C++_ code base, the
[Cython](https://cython.readthedocs.io/en/latest/index.html) package must be [Cython](https://cython.readthedocs.io/en/latest/index.html) package must be
available, which may be installed via `python3 -m pip install cython` . available. It may be installed via `python3 -m pip install cython` .
Furthermore, the [Numpy](https://numpy.org) package is recommended to be able The [Numpy](https://numpy.org) package is recommended
to pass arrays of data from the C++ kernel to Python. The _makefile_ provides 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. the target `make cython-requirements` to install all required Python modules.
Finally, to build the Python extension _tdm_termite_ either locally or install Finally, to build the Python extension _tdm_termite_ locally or install
it the targets `make cython-build` and `make cython-install` are provided. it, the targets `make cython-build` and `make cython-install` are provided.
Hence, to install the Python module on the system simply do To install the Python module on the system, simply do
```Shell ```Shell
make cython-requirements make cython-requirements
make cython-install make cython-install
``` ```
that makes the module available to be imported as `import tdm_termite` . That makes the module available for import as a `import tdm_termite` .
#### Installation with pip
The package is also available via the [Python Package Index](https://pypi.org) at
[TDMtermite](https://pypi.org/project/TDMtermite/). To install the latest version simply do
```Shell
python3 -m pip install TDMtermite
```
Note, that _python3_setuptools_ and _gcc version >= 10.2.0_ are required to
successfully install and use it.
## Usage ## Usage
### CLI tool ### CLI tool
The usage of the CLI tool is sufficiently clarified by its help message displayed The usage of the CLI tool is sufficiently clarified by its help message displayed
by `tdmtermite --help`. For instance, to extract the data decoded in the pair of by `tdmtermite --help`. To extract the data decoded in the pair of
files `samples/SineData.tdm` and `samples/SineData.tdx` into the directory files `samples/SineData.tdm` and `samples/SineData.tdx` into the directory
`/home/jack/data/`: `/home/jack/data/`:
@@ -176,7 +188,7 @@ 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 The tool can also be used to list the available objects in the TDM dataset, which
are i.a. _channels_, _channelgroups_ and TDX _blocks_. For instance, to list are i.a. _channels_, _channelgroups_ and TDX _blocks_. To list
all channels and channelgroups (without writing any file output): all channels and channelgroups (without writing any file output):
```Shell ```Shell
@@ -184,37 +196,37 @@ 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 The user may also submit a _filenaming rule_ to control the names of the files the
channel(-group)s are written to. To this end, the _magic flags_ `%G` `%g`, `%C` channel(group)s are written to. To this end, the _magic flags_ `%G` `%g`, `%C`
and `%c` representing the group id, group name, channel index and channel name and `%c` representing the group id, group name, channel index and channel name
are defined. The default filenaming option is are defined. The default filenaming option is:
```Shell ```Shell
tdmtermite 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 This makes the tool write _all channels_ grouped into files according to their
group association, while all channelgroup filenames obey the pattern `channelgroup_%G.csv` group association, while all channelgroup filenames obey the pattern `channelgroup_%G.csv`,
with `%G` being replaced by the group id. The filenaming rule also enables the user with `%G` being replaced by the group id. The filenaming rule also enables the user
to extract only a single channel(group) by providing a particular channel(-group) to extract only a single channel(group) by providing a particular channel(group)
id in the filenaming flag. For example, id in the filenaming flag. For example,
```Shell ```Shell
tdmtermite 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 This will write the single channel with the id `usi16` to the file
`/home/jack/data/channel_usi16_A4.csv` including its meta-data as a file header. `/home/jack/data/channel_usi16_A4.csv`, including its meta-data as a file header.
### Python ### Python
To be able to use the Python module _tdm_termite_ it first has to be build locally To be able to use the Python module _tdm_termite_, it first has to be built locally
or installed on the system. In the Python interpreter simply do: or installed on the system. In the Python interpreter, simply do:
```Python ```Python
import tdm_termite import tdm_termite
``` ```
to import the module. The TDM files are provided by creating an instance of This will import the module. The TDM files are provided by creating an instance of
the _tdm_termite_ class: the _tdm_termite_ class:
```Python ```Python
@@ -225,7 +237,7 @@ except RuntimeError as e:
print("failed to load/decode TDM files: " + str(e)) print("failed to load/decode TDM files: " + str(e))
``` ```
After initializing the _tdm_termite_ 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: available data. For instance, to list the included channelgroups and channels:
```Python ```Python
@@ -237,7 +249,7 @@ grpids = jack.get_channelgroup_ids()
chnids = jack.get_channel_ids() chnids = jack.get_channel_ids()
``` ```
As a use case, we have look at listing the ids of all channelgroups and printing As a use case, we have a look at listing the ids of all channelgroups and printing
their data to separate files: their data to separate files:
```Python ```Python
@@ -274,7 +286,7 @@ for grp in grpids :
print("failed to print channelgroup: " + str(grp) + " : " + str(e)) print("failed to print channelgroup: " + str(grp) + " : " + str(e))
``` ```
For a full example including more details see the [extensive example](python/usage.py) For details, see this [extensive example](python/usage.py)
and the absolute minimal example [minimal usage](python/minimal.py). In order and the absolute minimal example [minimal usage](python/minimal.py). In order
to simply extract all data of the TDM datatset and dump it to files in a given to simply extract all data of the TDM datatset and dump it to files in a given
(existing!) directory, do (existing!) directory, do
@@ -285,8 +297,8 @@ jack = tdm_termite.tdmtermite(b'samples/SineData.tdm',b'samples/SineData.tdx')
jack.write_all(b"./my_tdm_data_directory/") jack.write_all(b"./my_tdm_data_directory/")
``` ```
The interface allows to construct customized file/column headers from any The interface allows you to construct customized file/column headers from any
meta-data and provide these headers for usage in file output (see the meta-data and provide these headers for usage in file output (see this
[example](python/custom.py)). [example](python/custom.py)).
## References ## References
@@ -308,6 +320,30 @@ meta-data and provide these headers for usage in file output (see the
### Implementation ### Implementation
- https://en.cppreference.com/w/
- https://pugixml.org/ - https://pugixml.org/
- https://github.com/zeux/pugixml - https://github.com/zeux/pugixml
- https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html - https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
### Packaging
#### Documentation
- https://packaging.python.org/tutorials/packaging-projects/
- https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html
- https://test.pypi.org/account/register/
- https://github.com/pypa/auditwheel
- https://github.com/pypa/python-manylinux-demo
- https://github.com/pypa/manylinux
#### C/C++ Extensions
- https://docs.python.org/3/extending/building.html
#### Articles
- https://martinsosic.com/development/2016/02/08/wrapping-c-library-as-python-module.html
- https://malramsay.com/post/perils-of-packaging/
- https://github.com/neuronsimulator/nrn/issues/329
- https://levelup.gitconnected.com/how-to-deploy-a-cython-package-to-pypi-8217a6581f09
- https://medium.com/swlh/distributing-python-packages-protected-with-cython-40fc29d84caf

55
assets/index.html Normal file
View File

@@ -0,0 +1,55 @@
<html>
<head>
<title>TDMtermite</title>
<style>
</style>
</head>
<body>
<p align="center">
<a href="https://github.com/RecordEvolution/TDMtermite.git">
<img alt="tdmtermite.svg"
src="assets/tdmtermite.svg"
width="400"
/>
</a>
</p>
<div style="width: 100%; display: block; margin-left: 28%; margin-right: 28%;">
<div style="width: 100%; overflow: hidden;">
<div style="margin: 5px; float: left;">
<a href="https://lgtm.com/projects/g/RecordEvolution/TDMtermite/alerts/">
<img alt="Total alerts"
src="https://img.shields.io/lgtm/alerts/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18"/>
</a>
</div>
<div style="margin: 5px; float: left;">
<a href="https://lgtm.com/projects/g/RecordEvolution/TDMtermite/context:cpp">
<img alt="Language grade: C/C++"
src="https://img.shields.io/lgtm/grade/cpp/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18"/>
</a>
</div>
<div style="margin: 5px; float: left;">
<a href="https://lgtm.com/projects/g/RecordEvolution/TDMtermite/context:python">
<img alt="Language grade: Python"
src="https://img.shields.io/lgtm/grade/python/g/RecordEvolution/TDMtermite.svg?logo=lgtm&logoWidth=18"/>
</a>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,24 +1,35 @@
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from Cython.Build import cythonize from Cython.Build import cythonize
import os
extensions = Extension( extensions = Extension(
name="tdm_termite", name="tdm_termite",
sources=["cython/py_tdm_termite.pyx"], sources=["cython/py_tdm_termite.pyx"],
# libraries=[""], # libraries=[""],
# library_dirs=["lib"], # library_dirs=["lib"],
include_dirs=["lib","pugixml"], include_dirs=["lib","3rdparty/pugixml"],
language='c++', language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'], extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'], extra_link_args=['-std=c++17'],
) )
os.system("git tag > gittags.log")
with open ("gittags.log","r") as gt:
taglst = gt.readlines()
os.remove("gittags.log")
if len(taglst) > 0 :
version = taglst[-1].replace('\n','').replace('v','')
else:
version = 'unkown'
print("building version: "+version)
setup( setup(
version='0.1', version=version,
description='TDMtermite cython extension', description='TDMtermite cython extension',
author='Record Evolution GmbH', author='Record Evolution GmbH',
author_email='mario.fink@record-evolution.de', author_email='mario.fink@record-evolution.de',
url='https://github.com/RecordEvolution/tdm_ripper.git', url='https://github.com/RecordEvolution/TDMtermite.git',
name="tdm_termite", name="tdm_termite",
ext_modules=cythonize(extensions) ext_modules=cythonize(extensions)
) )

View File

@@ -17,6 +17,7 @@ typedef double eFloat64Usi;
class tdmdatatype class tdmdatatype
{ {
protected: protected:
eInt16Usi sint16_; // 0 eInt16Usi sint16_; // 0
eInt32Usi sint32_; // 1 eInt32Usi sint32_; // 1
@@ -26,6 +27,7 @@ protected:
eFloat32Usi float32_; // 5 eFloat32Usi float32_; // 5
eFloat64Usi float64_; // 6 eFloat64Usi float64_; // 6
short int dtidx_; // \in \{0,...,6\} short int dtidx_; // \in \{0,...,6\}
public: public:
tdmdatatype(): sint16_(0), sint32_(0), tdmdatatype(): sint16_(0), sint32_(0),
uint8_(0), uint16_(0), uint32_(0), uint8_(0), uint16_(0), uint32_(0),
@@ -43,6 +45,19 @@ public:
// identify type // identify type
short int& dtype() { return dtidx_; } short int& dtype() { return dtidx_; }
// copy constructor
tdmdatatype(const tdmdatatype &num)
{
this->sint16_ = num.sint16_;
this->sint32_ = num.sint32_;
this->uint8_ = num.uint8_;
this->uint16_ = num.uint16_;
this->uint32_ = num.uint32_;
this->float32_ = num.float32_;
this->float64_ = num.float64_;
this->dtidx_ = num.dtidx_;
}
// overall assignment operator // overall assignment operator
tdmdatatype& operator=(const tdmdatatype &num) tdmdatatype& operator=(const tdmdatatype &num)
{ {
@@ -55,6 +70,7 @@ public:
this->uint32_ = num.uint32_; this->uint32_ = num.uint32_;
this->float32_ = num.float32_; this->float32_ = num.float32_;
this->float64_ = num.float64_; this->float64_ = num.float64_;
this->dtidx_ = num.dtidx_;
} }
return *this; return *this;

View File

@@ -6,16 +6,73 @@
tdm_termite::tdm_termite() tdm_termite::tdm_termite()
{ {
tdx_ifstream_ = new std::ifstream;
} }
tdm_termite::tdm_termite(std::string tdmfile, std::string tdxfile, bool showlog): tdm_termite::tdm_termite(std::string tdmfile, std::string tdxfile, bool showlog):
tdmfile_(tdmfile), tdxfile_(tdxfile) tdmfile_(tdmfile), tdxfile_(tdxfile)
{ {
tdx_ifstream_ = new std::ifstream;
// start processing tdm data model // start processing tdm data model
this->process_tdm(showlog); this->process_tdm(showlog);
} }
tdm_termite::~tdm_termite()
{
// close tdx-file stream and free memory
if ( tdx_ifstream_->is_open() ) tdx_ifstream_->close();
delete tdx_ifstream_;
}
tdm_termite::tdm_termite(const tdm_termite& other):
tdmfile_(other.tdmfile_), tdxfile_(other.tdxfile_), csvfile_(other.csvfile_),
endianness_(other.endianness_), machine_endianness_(other.machine_endianness_),
meta_data_(other.meta_data_), tdmdt_name_(other.tdmdt_name_),
tdmdt_chan_(other.tdmdt_chan_),
tdx_blocks_(other.tdx_blocks_), tdmroot_(other.tdmroot_),
tdmchannelgroups_(other.tdmchannelgroups_), tdmchannels_(other.tdmchannels_),
tdmchannels_data_(other.tdmchannels_data_), submatrices_(other.submatrices_),
localcolumns_(other.localcolumns_), tdxbuffer_(other.tdxbuffer_)
{
tdx_ifstream_ = new std::ifstream;
if ( other.tdx_ifstream_->is_open() )
{
tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
tdx_ifstream_->seekg(other.tdx_ifstream_->tellg());
}
}
tdm_termite& tdm_termite::operator=(const tdm_termite& other)
{
if ( this != &other )
{
tdmfile_ = other.tdmfile_;
tdxfile_ = other.tdxfile_;
csvfile_ = other.csvfile_;
endianness_ = other.endianness_;
machine_endianness_ = other.machine_endianness_;
meta_data_ = other.meta_data_;
tdmdt_name_ = other.tdmdt_name_;
tdmdt_chan_= other.tdmdt_chan_;
tdx_blocks_ = other.tdx_blocks_;
tdmroot_ = other.tdmroot_;
tdmchannelgroups_ = other.tdmchannelgroups_;
tdmchannels_ = other.tdmchannels_;
tdmchannels_data_ = other.tdmchannels_data_;
submatrices_ = other.submatrices_;
localcolumns_ = other.localcolumns_;
tdxbuffer_ = other.tdxbuffer_;
if ( other.tdx_ifstream_->is_open() )
{
tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
tdx_ifstream_->seekg(other.tdx_ifstream_->tellg());
}
}
return *this;
}
void tdm_termite::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 // save files
@@ -106,20 +163,26 @@ void tdm_termite::process_tdm(bool showlog)
this->process_localcolumns(showlog,xml_doc); this->process_localcolumns(showlog,xml_doc);
// open .tdx and stream all binary data into buffer // open .tdx and stream all binary data into buffer
// try {
// std::ifstream fin(tdxfile_.c_str(),std::ifstream::binary);
// // if ( !fin.good() ) std::cerr<<"failed to open .tdx-file\n";
//
// std::vector<unsigned char> tdxbuf((std::istreambuf_iterator<char>(fin)),
// (std::istreambuf_iterator<char>()));
// tdxbuffer_ = tdxbuf;
//
// if ( showlog ) std::cout<<"size of .tdx buffer (bytes): "<<tdxbuffer_.size()<<"\n\n";
//
// // close .tdx file
// fin.close();
// } catch (const std::exception& e ) {
// throw std::runtime_error( std::string("failed to open .tdx and stream data to buffer: ")
// + e.what() );
// }
try { try {
std::ifstream fin(tdxfile_.c_str(),std::ifstream::binary); tdx_ifstream_->open(tdxfile_.c_str(),std::ifstream::binary);
// if ( !fin.good() ) std::cerr<<"failed to open .tdx-file\n"; } catch (const std::exception& e) {
throw std::runtime_error( std::string("failed to open .tdx file in ifstream: ")
std::vector<unsigned char> tdxbuf((std::istreambuf_iterator<char>(fin)),
(std::istreambuf_iterator<char>()));
tdxbuffer_ = tdxbuf;
if ( showlog ) std::cout<<"size of .tdx buffer (bytes): "<<tdxbuffer_.size()<<"\n\n";
// close .tdx file
fin.close();
} catch (const std::exception& e ) {
throw std::runtime_error( std::string("failed to open .tdx and stream data to buffer: ")
+ e.what() ); + e.what() );
} }
} }
@@ -505,7 +568,7 @@ template std::string tdm_termite::get_overview<submatrix>(format formatter);
template std::string tdm_termite::get_overview<localcolumn>(format formatter); template std::string tdm_termite::get_overview<localcolumn>(format formatter);
template std::string tdm_termite::get_overview<block>(format formatter); template std::string tdm_termite::get_overview<block>(format formatter);
void tdm_termite::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<std::string,tdm_channelgroup>::iterator it=this->tdmchannelgroups_.begin(); for ( std::map<std::string,tdm_channelgroup>::iterator it=this->tdmchannelgroups_.begin();
it!=this->tdmchannelgroups_.end(); ++it) it!=this->tdmchannelgroups_.end(); ++it)
@@ -515,7 +578,7 @@ void tdm_termite::summarize_member(tdm_channelgroup chp, std::string& summary, f
} }
} }
void tdm_termite::summarize_member(submatrix sbm, std::string& summary, format& formatter) void tdm_termite::summarize_member(submatrix &sbm, std::string& summary, format& formatter)
{ {
for ( std::map<std::string,submatrix>::iterator it=this->submatrices_.begin(); for ( std::map<std::string,submatrix>::iterator it=this->submatrices_.begin();
it!=this->submatrices_.end(); ++it) it!=this->submatrices_.end(); ++it)
@@ -525,7 +588,7 @@ void tdm_termite::summarize_member(submatrix sbm, std::string& summary, format&
} }
} }
void tdm_termite::summarize_member(localcolumn lcc, std::string& summary, format& formatter) void tdm_termite::summarize_member(localcolumn &lcc, std::string& summary, format& formatter)
{ {
for ( std::map<std::string,localcolumn>::iterator it=this->localcolumns_.begin(); for ( std::map<std::string,localcolumn>::iterator it=this->localcolumns_.begin();
it!=this->localcolumns_.end(); ++it) it!=this->localcolumns_.end(); ++it)
@@ -535,7 +598,7 @@ void tdm_termite::summarize_member(localcolumn lcc, std::string& summary, format
} }
} }
void tdm_termite::summarize_member(block blk, std::string& summary, format& formatter) void tdm_termite::summarize_member(block &blk, std::string& summary, format& formatter)
{ {
for ( std::map<std::string,block>::iterator it=this->tdx_blocks_.begin(); for ( std::map<std::string,block>::iterator it=this->tdx_blocks_.begin();
it!=this->tdx_blocks_.end(); ++it) it!=this->tdx_blocks_.end(); ++it)
@@ -584,10 +647,20 @@ std::vector<tdmdatatype> tdm_termite::get_channel(std::string& id)
// declare buffer covering the required range of "tdxbuffer_" // declare buffer covering the required range of "tdxbuffer_"
// (consider both channel-wise and block-wise ordering) // (consider both channel-wise and block-wise ordering)
unsigned long int strtidx = blk.block_offset_*blk.block_size_ unsigned long int strtidx = blk.block_offset_*blk.block_size_
+ blk.byte_offset_, + blk.byte_offset_;
fnshidx = strtidx + blk.length_*dtyp.size_; // fnshidx = strtidx + blk.length_*dtyp.size_;
std::vector<unsigned char> tdxblk( tdxbuffer_.begin()+strtidx, // std::vector<unsigned char> tdxblk( tdxbuffer_.begin()+strtidx,
tdxbuffer_.begin()+fnshidx ); // tdxbuffer_.begin()+fnshidx );
char* blkbuf = new char[blk.length_*dtyp.size_];
try {
tdx_ifstream_->seekg(strtidx);
tdx_ifstream_->read(blkbuf,blk.length_*dtyp.size_);
} catch (const std::exception& e) {
throw std::runtime_error( std::string("failed to read block from tdx_ifstream_: ")
+ e.what() );
}
std::vector<unsigned char> tdxblk(blkbuf,blkbuf+blk.length_*dtyp.size_);
delete []blkbuf;
// distinguish numeric datatypes included in "tdmdatatype" // distinguish numeric datatypes included in "tdmdatatype"
if ( blk.value_type_ == std::string("eInt16Usi") ) if ( blk.value_type_ == std::string("eInt16Usi") )

View File

@@ -60,8 +60,9 @@ class tdm_termite
std::map<std::string,submatrix> submatrices_; std::map<std::string,submatrix> submatrices_;
std::map<std::string,localcolumn> localcolumns_; std::map<std::string,localcolumn> localcolumns_;
// binary data container // binary data container/file stream
std::vector<unsigned char> tdxbuffer_; std::vector<unsigned char> tdxbuffer_;
std::ifstream *tdx_ifstream_;
// extract list of identifiers from e.g. "#xpointer(id("usi12") id("usi13"))" // extract list of identifiers from e.g. "#xpointer(id("usi12") id("usi13"))"
std::vector<std::string> extract_ids(std::string idstring) std::vector<std::string> extract_ids(std::string idstring)
@@ -121,6 +122,9 @@ public:
tdm_termite(); tdm_termite();
tdm_termite(std::string tdmfile, std::string tdxfile = std::string(""), tdm_termite(std::string tdmfile, std::string tdxfile = std::string(""),
bool showlog = false); bool showlog = false);
~tdm_termite();
tdm_termite(const tdm_termite& other);
tdm_termite& operator=(const tdm_termite& other);
// provide (tdm,tdx) files // provide (tdm,tdx) files
void submit_files(std::string tdmfile, std::string tdxfile = std::string(""), void submit_files(std::string tdmfile, std::string tdxfile = std::string(""),
@@ -180,10 +184,10 @@ public:
template<typename tdmelement> template<typename tdmelement>
std::string get_overview(format formatter); std::string get_overview(format formatter);
private: private:
void summarize_member(tdm_channelgroup chp, std::string& summary, format& formatter); void summarize_member(tdm_channelgroup &chp, std::string& summary, format& formatter);
void summarize_member(submatrix sbm, std::string& summary, format& formatter); void summarize_member(submatrix &sbm, std::string& summary, format& formatter);
void summarize_member(localcolumn lcc, std::string& summary, format& formatter); void summarize_member(localcolumn &lcc, std::string& summary, format& formatter);
void summarize_member(block blk, std::string& summary, format& formatter); void summarize_member(block &blk, std::string& summary, format& formatter);
public: public:
// get list of channelgroup ids // get list of channelgroup ids

View File

@@ -1,5 +1,7 @@
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
SHELL := /bin/bash
# declare name of executable # declare name of executable
EXE = tdmtermite EXE = tdmtermite
@@ -13,8 +15,9 @@ CC = g++ -std=c++17
# compiler options and optimization flags # compiler options and optimization flags
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
# include library path # include 3rd party libraries paths
LIB = pugixml/ LIBB := 3rdparty/
LIB := $(foreach dir,$(shell ls $(LIBB)),-I $(LIBB)$(dir))
# determine git version/commit tag # determine git version/commit tag
GTAG := $(shell git tag | tail -n1) GTAG := $(shell git tag | tail -n1)
@@ -23,8 +26,9 @@ GHSH := $(shell git rev-parse HEAD | head -c8)
# define install location # define install location
INST := /usr/local/bin INST := /usr/local/bin
# platform # platform and current working directory
OST := $(shell uname) OST := $(shell uname)
CWD := $(shell pwd)
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# CLI tool # CLI tool
@@ -49,14 +53,20 @@ main.o : src/main.cpp lib/$(SRC).hpp $(HPP)
sed -i '' 's/TAGSTRING/$(GTAG)/g' $<.cpp; \ sed -i '' 's/TAGSTRING/$(GTAG)/g' $<.cpp; \
sed -i '' 's/HASHSTRING/$(GHSH)/g' $<.cpp; \ sed -i '' 's/HASHSTRING/$(GHSH)/g' $<.cpp; \
fi fi
$(CC) -c $(OPT) -I $(LIB) -I lib/ $<.cpp -o $@ $(CC) -c $(OPT) $(LIB) -I lib/ $<.cpp -o $@
@rm $<.cpp @rm $<.cpp
$(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP) $(SRC).o : lib/$(SRC).cpp lib/$(SRC).hpp $(HPP)
$(CC) -c $(OPT) -I $(LIB) $< -o $@ $(CC) -c $(OPT) $(LIB) $< -o $@
clean-cpp : tdmtest : tdmtest.o
rm -f $(EXE) *.o src/main.cpp.cpp $(CC) $(OPT) $^ -o $@
tdmtest.o : src/test.cpp lib/$(SRC).hpp $(HPP)
$(CC) -c $(OPT) $(LIB) -I lib/ $< -o $@
cpp-clean :
rm -f $(EXE) *.o src/main.cpp.cpp tdmtest
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# check process # check process
@@ -84,13 +94,37 @@ cython-build : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx
cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp cython-install : cython/setup.py cython/tdm_termite.pxd cython/py_tdm_termite.pyx $(HPP) lib/tdm_termite.cpp
python3 $< install python3 $< install
clean-cython : cython-clean :
rm -vf cython/py_tdm_termite.cpp rm -vf cython/py_tdm_termite.c* cython/tdm_termite.c*
rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so rm -vf tdm_termite.cpython-*.so python/tdm_termite.cpython-*.so
rm -rf build rm -rf build
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# docker
clean : clean-cpp clean-cython docker-build:
docker build . --tag tdmtermite:latest
docker-run:
mkdir -pv data/{input,output}
docker run -it --rm --volume $(CWD)/data:/home/data tdmtermite:latest /bin/bash
docker-clean:
rm -rv data
docker image remove tdmtermite
# --------------------------------------------------------------------------- #
# pip
pip-publish: cython-build
cd pip/ && make pip-publish
pip-test:
cd pip/ && make pip-test
# --------------------------------------------------------------------------- #
clean : cpp-clean cython-clean
cd pip/ && make pip-clean
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #

15
pip/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM debian:bullseye
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && apt-get upgrade -y && apt-get install -y \
python3 \
python3-pip \
python3-setuptools
# RUN python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution==0.6.7 && \
# python3 -m pip install --upgrade TDMtermite-RecordEvolution
RUN python3 -m pip install TDMtermite
# CMD ["sleep","3600"]
CMD ["python3","-m","pip","freeze"]

25
pip/Dockerfile-manylinux Normal file
View File

@@ -0,0 +1,25 @@
FROM quay.io/pypa/manylinux2010_x86_64
RUN yum -y install \
git \
python34-devel \
gcc-c++ \
python34-tkinter \
make \
python34-pip \
RUN sudo yum -y install rh-python36-python-devel.x86_64 rh-python35-python-devel.x86_64 python27-python-devel.x86_64
ENV PATH /opt/rh/python27/root/usr/bin:/opt/rh/rh-python35/root/usr/bin/:/opt/rh/rh-python36/root/usr/bin/:$PATH
RUN python3.6 -m pip install --user --upgrade cython wheel twine auditwheel
WORKDIR /home/${USERNAME}/neuron-yale
RUN git checkout setuppy \
&& python3.6 setup.py bdist_wheel
# repair wheel? see : https://malramsay.com/post/perils_of_packaging/
RUN python3.6 -m pip install --user --upgrade auditwheel
RUN LD_LIBRARY_PATH=`pwd`/_install/lib auditwheel repair dist/NEURON-7.8-cp36-cp36m-linux_x86_64.whl

4
pip/MANIFEST.in Normal file
View File

@@ -0,0 +1,4 @@
include *.hpp
include *.cpp
include *.pyx
include *.pxd

4
pip/bkup.pyproject.toml Normal file
View File

@@ -0,0 +1,4 @@
[build-system]
requires = [
"setuptools"
]

62
pip/makefile Normal file
View File

@@ -0,0 +1,62 @@
# --------------------------------------------------------------------------- #
pip-publish: pip-sdist pip-upload
pip-sdist: ../cython/py_tdm_termite.pyx ../cython/tdm_termite.pxd ../cython/py_tdm_termite.cpp
cp -v ../cython/py_tdm_termite.pyx ../cython/tdm_termite.pxd ./
cp -v ../cython/py_tdm_termite.cpp ./
cp -v ../lib/*.hpp ../lib/*.cpp ./
cp -v ../3rdparty/pugixml/* ./
cat ../README.md | head -n316 | tail -n306 > ./README.md
cp -v ../LICENSE ./
# cython py_tdm_termite.pyx -o py_tdm_termite.cpp
python3 setup.py sdist
pip-setup:
apt-get install -y python3-setuptools \
python3-pip \
python3-venv
python3 -m pip install --upgrade build
python3 -m pip install twine wheel auditwheel cython
python3 -m pip install --user --upgrade twine
pip-build:
#python3 -m build
# python3 setup.py sdist bdist_wheel
python3 setup.py bdist_wheel
# actually it seems we have to use CentOS container
# docker run -i -t -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /bin/bash
# see https://github.com/neuronsimulator/nrn/issues/329 for setup of the container
pip-audit:
auditwheel repair $(shell find dist/ -name "*-cp38-cp38-linux_x86_64.whl")
# username: __token__
# password: API-token including "pypi-"
# !! RUN AS ROOT!! (only for bdist_wheel + auditwheel)
pip-upload-test:
python3 -m twine upload --repository testpypi dist/$(shell ls -t dist/ | head -n1)
pip-upload:
python3 -m twine upload dist/$(shell ls -t dist/ | head -n1)
pip-test-install:
python3 -m pip install --index-url https://test.pypi.org/simple --no-deps TDMtermite-RecordEvolution
# python3 -m pip install -i https://test.pypi.org/simple/ TDMtermite-RecordEvolution==0.5
pip-test:
docker build . --tag tdmtermite-piptest
docker run -it --rm tdmtermite-piptest
pip-clean:
rm -rvf dist/
rm -rvf *.egg-info
rm -rvf build/
rm -rvf cython/
rm -rvf wheelhouse/
rm -vf *.pyx *.pxd
rm -vf *.cpp *.c *.hpp
rm -vf README.md LICENSE
# --------------------------------------------------------------------------- #

21
pip/setup.cfg Normal file
View File

@@ -0,0 +1,21 @@
[metadata]
name = TDMtermite-RecordEvolution
version = 0.5
author = Record Evolution GmbH
author_email = mario.fink@record-evolution.de
maintainer = Record Evolution GmbH
license = MIT
description = Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/RecordEvolution/TDMtermite.git
project_urls =
Bug Tracker = https://github.com/RecordEvolution/TDMtermite/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
packages = find:
python_requires = >=3.6

36
pip/setup.py Normal file
View File

@@ -0,0 +1,36 @@
from setuptools import setup, Extension
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name="TDMtermite",
version="1.0.0", #version,
author="Record Evolution GmbH",
author_email="mario.fink@record-evolution.de",
maintainer="Record Evolution GmbH",
license="MIT",
description="Extract and read data from National Instruments LabVIEW tdx/tdm files and export them as csv files",
keywords="TDM/TDX NationalInstruments LabVIEW decode",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/RecordEvolution/TDMtermite.git",
project_urls={
"Bug Tracker": "https://github.com/RecordEvolution/TDMtermite/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
ext_modules=[Extension("tdm_termite",
["py_tdm_termite.cpp"],
# libraries_dirs=["cython/"],
# include_dirs=["3rdparty/pugixml/","lib/"],
# depends=["../lib/tdm_termite.hpp"]
language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'],
)],
)

33
src/test.cpp Normal file
View File

@@ -0,0 +1,33 @@
// ------------------------------------------------------------------------- //
#include "tdm_termite.hpp"
#include <filesystem>
#include <regex>
#include <thread>
#include <chrono>
// ------------------------------------------------------------------------- //
int main(int argc, char* argv[])
{
std::string tdmfile(argv[1]);
std::string tdxfile(argv[2]);
std::cout<<tdmfile<<"\n"<<tdxfile<<"\n";
pugi::xml_document xml_doc;
pugi::xml_parse_result xml_result;
// load XML document from stream
std::ifstream fin(tdmfile.c_str());
xml_result = xml_doc.load(fin);
fin.close();
std::cout<<"\nloading "<<tdmfile<<": "<<xml_result.description()<<"\n";
std::cout<<"encoding: "<<(pugi::xml_encoding)xml_result.encoding<<"\n\n";
std::this_thread::sleep_for(std::chrono::milliseconds(4000));
return 0;
}