Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
ea7ab9fa85 | |||
c281aeae19 | |||
0403f2bc64 | |||
![]() |
0969d626b8 | ||
![]() |
37cbc2d45f | ||
8c8ed10a90 | |||
![]() |
ecc1cd8005 | ||
![]() |
8746519d1a | ||
c9f8097c9b | |||
5ae6b3f5ba |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -20,3 +20,12 @@ cython/*.cpp
|
||||
*.parquet
|
||||
|
||||
src/*.cpp.cpp
|
||||
|
||||
pip/*.cpp
|
||||
pip/*.hpp
|
||||
pip/*.pyx
|
||||
pip/*.pxd
|
||||
pip/README.md
|
||||
pip/LICENSE
|
||||
pip/*egg-info
|
||||
pip/dist/
|
||||
|
79
README.md
79
README.md
@@ -10,16 +10,18 @@
|
||||
</p>
|
||||
|
||||
_IMCtermite_ provides access to the proprietary data format
|
||||
_IMC Bus Format_ with file extension _.raw_ introduced and developed by
|
||||
_IMC Bus Format_ with the file extension _.raw_ introduced and developed by
|
||||
[imc Test & Measurement GmbH](https://www.imc-tm.de/). This data format is
|
||||
employed i.a. by the measurement hardware
|
||||
[imc CRONOSflex](https://www.imc-tm.de/produkte/messtechnik-hardware/imc-cronosflex/ueberblick/)
|
||||
to dump and store data and the software packages
|
||||
[imc Studio](https://www.imc-tm.de/produkte/messtechnik-software/imc-studio/ueberblick/)
|
||||
and [imc FAMOS](https://www.imc-tm.de/produkte/messtechnik-software/imc-famos/)
|
||||
for measurement data control and analysis. The extracted measurement data can
|
||||
be stored in various open source file formats like _csv_, _json_, _parquet_ or
|
||||
_hdf5_.
|
||||
& [imc FAMOS](https://www.imc-tm.de/produkte/messtechnik-software/imc-famos/)
|
||||
for measurement data control and analysis. Thanks to the integrated Python module,
|
||||
the extracted measurement data can be stored in any open-source file format
|
||||
accessible by Python like i.a. _csv_, _json_ or _parquet_.
|
||||
|
||||
On the [Record Evolution Platform](https://www.record-evolution.de/en/home-en/), the library can be used both as a command line tool for interactive usage and as a Python module to integrate the _.raw_ format into any ETL workflow.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -28,16 +30,15 @@ _hdf5_.
|
||||
* [Usage and Examples](#Usage)
|
||||
* [References](#References)
|
||||
|
||||
## Fileformat
|
||||
## File format
|
||||
|
||||
A data file of _IMC Bus Format_ type with extension _.raw_ is a _mixed text/binary
|
||||
A data file of the _IMC Bus Format_ type with the extension _.raw_ is a _mixed text/binary
|
||||
file_ featuring a set of markers (keys) that indicate the start of various blocks
|
||||
of data providing meta information and the actual measurement data. Every single
|
||||
marker is introduced by character `"|" = 0x 7c` followed by two uppercase letters,
|
||||
which characterize the type of marker. Each block is further divided into several
|
||||
of data that provide meta information and the actual measurement data. Every single
|
||||
marker is introduced by the character `"|" = 0x 7c` followed by two uppercase letters that characterize the type of marker. Each block is further divided into several
|
||||
parameters separated by commata `"," = 0x 2c` and terminated by a semicolon
|
||||
`";" = 0x 3b`. For instance, the header - first 600 bytes - of a raw file may
|
||||
look like this (in UTF-8 encoding)
|
||||
look like this (in UTF-8 encoding):
|
||||
|
||||
```
|
||||
|CF,2,1,1;|CK,1,3,1,1;
|
||||
@@ -49,8 +50,8 @@ look like this (in UTF-8 encoding)
|
||||
|CS,1, 9619, 1,<2C>oD <09>nD6<44>nD)<29>nD<6E>
|
||||
```
|
||||
|
||||
where line breaks where introduced for readability. Most of the markers introduce
|
||||
blocks of text, while only the last one identified by `|CS` contains binary data.
|
||||
Line breaks are introduced for readability. Most of the markers introduce
|
||||
blocks of text, while only the last block identified by `|CS` contains binary data.
|
||||
The format supports the storage of _multiple data sets (channels)_ in a single
|
||||
file. The channels may be ordered in _multiplex_ mode (ordering w.r.t. time) or
|
||||
_block_ mode (ordering w.r.t. to channels).
|
||||
@@ -61,7 +62,7 @@ letters. There are _two types_ of markers distinguished by the first letter:
|
||||
1. _critical_ markers: introduced by `|C` featuring uppercase `C`
|
||||
1. _noncritical_ markers: introduced by `|N` featuring uppercase `N`
|
||||
|
||||
The second letter represents further details of the specific key. Note, that
|
||||
The second letter represents further details of the specific key. Note that
|
||||
while the _noncritical_ keys are optional, any _.raw_ file _cannot be_ correctly
|
||||
decoded if any of the _critical_ markers are misinterpreted, invalid or damaged.
|
||||
The second uppercase letter is followed by the first comma and the _version_
|
||||
@@ -70,9 +71,9 @@ representation) specifies the length of the entire block, i.e. the number of
|
||||
bytes between the following comma and the block-terminating semicolon. The further
|
||||
structure of a block is not defined and may feature different numbers of additional
|
||||
parameters. The format allows for any number of carriage returns (`CR = 0x0d`)
|
||||
and line feeds (`LF = 0x 0a`) between keys, i.e. the block terminating semicolon
|
||||
and line feeds (`LF = 0x 0a`) between keys, i.e. the block-terminating semicolon
|
||||
and the vertical bar (pipe) of the next key. The following _critical markers_
|
||||
are defined
|
||||
are defined:
|
||||
|
||||
|
||||
| marker | description |
|
||||
@@ -118,8 +119,8 @@ module.
|
||||
|
||||
### CLI tool
|
||||
|
||||
To build the CLI tool locally use the default target `make` resulting
|
||||
in the binary `imctermite`. To ensure system-wide availability the installation
|
||||
To build the CLI tool locally, use the default target `make` resulting
|
||||
in the binary `imctermite`. To ensure system-wide availability, the installation
|
||||
of the tool (in the default location `/usr/local/bin`) is done via
|
||||
|
||||
```
|
||||
@@ -130,27 +131,40 @@ which may require root permissions.
|
||||
|
||||
### Python
|
||||
|
||||
To integrate the library into a customized ETL toolchain several cython targets
|
||||
are available. For a local build that enables you to run the examples use:
|
||||
To integrate the library into a customized ETL toolchain, several cython targets
|
||||
are available. For a local build that enables you to run the examples, use:
|
||||
|
||||
```
|
||||
make cython-build
|
||||
```
|
||||
|
||||
However, in a production environment a proper installation of the module with
|
||||
However, in a production environment, a proper installation of the module with
|
||||
`make cython-install` is recommended for system-wide availability of the module.
|
||||
|
||||
#### Installation with pip
|
||||
|
||||
The package is also available in the [Python Package Index](https://pypi.org)
|
||||
at [IMCtermite](https://pypi.org/project/IMCtermite/).
|
||||
To install the latest version simply do
|
||||
|
||||
```Shell
|
||||
python3 -m pip install IMCtermite
|
||||
```
|
||||
|
||||
Note, that _python3_setuptools_ and _gcc version >= 10.2.0_ are required to
|
||||
successfully install and use it.
|
||||
|
||||
## Usage
|
||||
|
||||
### CLI
|
||||
|
||||
The usage of the `imctermite` binary looks like this
|
||||
The usage of the `imctermite` binary looks like this:
|
||||
|
||||
```
|
||||
imctermite <raw-file> [options]
|
||||
```
|
||||
|
||||
since you have to provide a single _raw_ files and any option to specify what
|
||||
You have to provide a single _raw_ file and any option to specify what
|
||||
to do with the data. All available options can be listed with `imctermite --help`:
|
||||
|
||||
```
|
||||
@@ -164,14 +178,14 @@ Options:
|
||||
```
|
||||
|
||||
For instance, to show a list of all channels included in `sample-data.raw`, you
|
||||
do `imctermite sample-data.raw --listchannels`. By default, no output files are
|
||||
written but only when an existing (!) directory is provided as argument to
|
||||
do `imctermite sample-data.raw --listchannels`. No output files are
|
||||
written by default. Output files are written only when an existing (!) directory is provided as argument to
|
||||
the `--output` option.
|
||||
|
||||
### Python
|
||||
|
||||
Given the `imctermite` module is available we can import it and declare an instance
|
||||
of it by passing a _raw_ file to the constructor
|
||||
Given the `imctermite` module is available, we can import it and declare an instance
|
||||
of it by passing a _raw_ file to the constructor:
|
||||
|
||||
```Python
|
||||
import imc_termite
|
||||
@@ -195,8 +209,13 @@ channels = imcraw.get_channels(False)
|
||||
print(channels)
|
||||
```
|
||||
|
||||
A more complete example including the methods for obtaining the channels including
|
||||
their data and or directly printing them to files can be found at
|
||||
[Usage](python/usage.py).
|
||||
A more complete [example](python/usage.py), including the methods for obtaining the
|
||||
channels, i.a. their data and/or directly printing them to files, can be found
|
||||
in the Python folder.
|
||||
|
||||
## References
|
||||
|
||||
- https://www.imc-tm.de/produkte/messtechnik-software/imc-famos/funktionen/im-und-export/
|
||||
- https://www.imc-tm.de/produkte/messtechnik-hardware/imc-cronosflex/ueberblick/
|
||||
- https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
|
||||
- https://github.com/Apollo3zehn/ImcFamosFile
|
||||
|
@@ -14,7 +14,7 @@ extensions = Extension(
|
||||
)
|
||||
|
||||
setup(
|
||||
version='0.1',
|
||||
version='1.2.2',
|
||||
description='IMCtermite cython extension',
|
||||
author='Record Evolution GmbH',
|
||||
author_email='mario.fink@record-evolution.de',
|
||||
|
72
makefile
72
makefile
@@ -1,5 +1,7 @@
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
# name of executable and CLI tool
|
||||
EXE = imctermite
|
||||
|
||||
@@ -17,9 +19,11 @@ CC = g++ -std=c++17
|
||||
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
||||
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
|
||||
|
||||
# determine git version/commit tag
|
||||
# determine git version/commit and release tag
|
||||
GTAG := $(shell git tag | tail -n1)
|
||||
GHSH := $(shell git rev-parse HEAD | head -c8)
|
||||
RTAG := v$(shell cat pip/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]")
|
||||
CTAG := v$(shell cat cython/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]")
|
||||
|
||||
# define install location
|
||||
INST := /usr/local/bin
|
||||
@@ -28,8 +32,8 @@ INST := /usr/local/bin
|
||||
# C++ and CLI tool
|
||||
|
||||
# build exectuable
|
||||
$(EXE) : main.o
|
||||
$(CC) $(OPT) $^ -o $@
|
||||
$(EXE) : check-vtag $(RTAG) main.o
|
||||
$(CC) $(OPT) main.o -o $@
|
||||
|
||||
# build main.cpp and include git version/commit tag
|
||||
main.o : src/main.cpp $(HPP)
|
||||
@@ -45,10 +49,22 @@ install : $(EXE)
|
||||
uninstall : $(INST)/$(EXE)
|
||||
rm $<
|
||||
|
||||
clean :
|
||||
cpp-clean :
|
||||
rm -vf $(EXE)
|
||||
rm -vf *.o
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# check version consistency of git tags and version string in package.json
|
||||
|
||||
$(GTAG) :
|
||||
@echo "consistent versions check successful: building $(GTAG)"
|
||||
|
||||
check-vtag:
|
||||
@echo "git tag version: "$(GTAG)
|
||||
@echo "git commit hash: "$(GHSH)
|
||||
@echo "release version: "$(RTAG)
|
||||
@echo "module version: "$(CTAG)
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Docker
|
||||
|
||||
@@ -61,48 +77,28 @@ docker-run:
|
||||
#-----------------------------------------------------------------------------#
|
||||
# python
|
||||
|
||||
cython-build : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $< build_ext --inplace
|
||||
cython-build : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $(CYT)setup.py build_ext --inplace
|
||||
cp -v imc_termite.cpython-*.so $(PYT)
|
||||
|
||||
cython-install : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $< install --record files_imctermite.txt
|
||||
cython-install : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $(CYT)setup.py install --record files_imctermite.txt
|
||||
|
||||
cython-clean :
|
||||
rm -vf imc_termite.cpython-*.so
|
||||
rm -vf $(PYT)imc_termite.cpython-*.so
|
||||
rm -rv build/
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Python (to be removed)
|
||||
# pip
|
||||
|
||||
# build python module
|
||||
py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
||||
output
|
||||
python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
||||
python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
||||
cp raw_eater.cpython-*.so $(PYT)
|
||||
cp raw_meat.cpython-*.so $(PYT)
|
||||
rm *.so
|
||||
|
||||
py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
||||
python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
||||
python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
||||
|
||||
py-clean :
|
||||
rm -f raw_eater.cpython-*.so
|
||||
rm -f $(PYT)raw_eater.cpython-*.so
|
||||
rm -f $(CYT)raw_eater.cpp
|
||||
rm -f raw_meat.cpython-*.so
|
||||
rm -f $(PYT)raw_meat.cpython-*.so
|
||||
rm -f $(CYT)raw_meat.cpp
|
||||
rm -rf build/
|
||||
rm -f *.txt
|
||||
rm -rf output/
|
||||
|
||||
# prepare directory for test output
|
||||
output :
|
||||
mkdir -pv output/
|
||||
pip-release: check-vtag $(RTAG) cython-build
|
||||
cd ./pip/ && make publish
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# clean
|
||||
|
||||
clean: cpp-clean cython-clean
|
||||
cd ./pip/ && make clean
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
4
pip/MANIFEST.in
Normal file
4
pip/MANIFEST.in
Normal file
@@ -0,0 +1,4 @@
|
||||
include *.hpp
|
||||
include *.cpp
|
||||
include *.pyx
|
||||
include *.pxd
|
4
pip/bkup.pyproject.toml
Normal file
4
pip/bkup.pyproject.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[build-system]
|
||||
requires = [
|
||||
"setuptools"
|
||||
]
|
26
pip/makefile
Normal file
26
pip/makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
publish: sdist upload
|
||||
|
||||
sdist: ../cython/py_imc_termite.pyx ../cython/imc_termite.pxd ../cython/py_imc_termite.cpp
|
||||
cp -v $? ./
|
||||
cp -v $(shell ls ../lib/imc_*.hpp) ./
|
||||
tail -n 212 ../README.md > ./README.md
|
||||
cp -v ../LICENSE ./
|
||||
python3 setup.py sdist
|
||||
|
||||
upload:
|
||||
python3 -m twine upload dist/$(shell ls -t dist/ | head -n1)
|
||||
|
||||
clean:
|
||||
rm -rvf dist/
|
||||
rm -rvf *.egg-info
|
||||
rm -rvf build/
|
||||
rm -rvf cython/
|
||||
rm -vf *.pyx *.pxd
|
||||
rm -vf *.cpp *.c *.hpp
|
||||
rm -vf README.md LICENSE
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
37
pip/setup.py
Normal file
37
pip/setup.py
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
from setuptools import setup, Extension
|
||||
import os
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setup(
|
||||
name="IMCtermite",
|
||||
version="1.2.2",
|
||||
author="Record Evolution GmbH",
|
||||
author_email="mario.fink@record-evolution.de",
|
||||
maintainer="Record Evolution GmbH",
|
||||
license="MIT",
|
||||
description="Enables extraction of measurement data from binary files with extension 'raw' used by proprietary software imcFAMOS/imcSTUDIO and facilitates its storage in open source file formats",
|
||||
keywords="IMC raw imcFAMOS imcSTUDIO imcCRONOS",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/RecordEvolution/IMCtermite.git",
|
||||
project_urls={
|
||||
"Bug Tracker": "https://github.com/RecordEvolution/IMCtermite/issues",
|
||||
},
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
ext_modules=[Extension("imc_termite",
|
||||
["py_imc_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'],
|
||||
)],
|
||||
)
|
Reference in New Issue
Block a user