Compare commits

..

85 Commits

Author SHA1 Message Date
45efb06aa2 add support for NL key, issue #6 2021-06-29 12:38:55 +02:00
538b6f4659 README.md: add famosfilekey reference 2021-06-29 11:45:50 +02:00
Mario Fink
08e2589dfd README: fix typo 2021-06-28 16:38:23 +02:00
Mario Fink
d098273816 README.md: udpate to new CLI options 2021-06-28 16:37:16 +02:00
Mario Fink
2f9c550323 bump pip/cython version 1.2.5 2021-06-28 16:33:25 +02:00
Mario Fink
234876c5a9 * cython/*_imc_termite.*: introduce both print_channel/print_channels
methods featuring csv delimiter option
* imc_raw.hpp: add print_channel()
* python/{example.py,usage.py}: adjust to existing sample file names,
  add print_channel() example
* src/main.cpp: add --delimiter option, additional CLI option checks
2021-06-28 16:26:07 +02:00
Mario Fink
bafc018566 CLI version: add option for delimiter token of csv output 2021-06-28 12:51:09 +02:00
fdd107fbb3 README.md: fix typo 2021-05-06 18:11:40 +02:00
cd4ce55e7e badge starts 2021-05-06 16:01:07 +02:00
27683cbbd6 license badge 2021-05-06 15:59:43 +02:00
25a51215a0 adjust README.md header 2021-05-06 15:50:38 +02:00
36c02089aa clean up README.md header 2021-05-06 15:47:31 +02:00
cd75689d32 lgtm code stats 2021-05-06 11:46:43 +02:00
57c7f6021b makefile: cppcheck target 2021-05-05 15:58:10 +02:00
83922c343f * imc_channel, imc_raw: optimize with pass by reference
* imc_object: asc_time, localtime: make threadsafe
* imc_datatype: satisfy 'rule of two'
* python: remove all unused imports
2021-05-05 13:28:11 +02:00
72378877ec add some pipy release documentation 2021-05-02 19:57:13 +02:00
e7094d0125 * py_imc_termite.pyx: remove json loads parse_float option
* imc_raw.hpp: catch empty/invalid file to avoid seg fault
2021-05-02 19:34:08 +02:00
16a77ecf1e bump version 1.2.4 for pip/cython 2021-04-30 11:10:41 +02:00
798fc22d7a imc_conversion.hpp: more comprehensive error message, imc_datatype: imc_Ulongint,imc_Slongint typedef for x86_64 vs. arm 2021-04-27 12:42:24 +02:00
2b2e69f0e5 * add support for datatype 11 = 2-byte-word digital
* usage.py: raise proper exception
* usage_adv.py: use different example file
2021-04-27 11:38:43 +02:00
Mario Fink
8708d2d008 * cython/py_imc_termite.pyx: json loads take care of floats, fix column assignment
* imc_channel.hpp: fix floating precision for get_channel()
* extend/include advanced usage in examples
2021-04-26 19:41:56 +02:00
9feadb50c1 py_imc_termite.pyx: fix special character encoding 2021-04-16 09:37:58 +02:00
dbeb1b862a py_imc_termite.pyx: print_table: encoding, xdata 2021-04-15 23:51:44 +02:00
bda799832c fix Dockerfile, cython: print_table to print all channels in single table 2021-04-15 20:17:02 +02:00
97c2195f98 ignore hexshow.hpp, version 1.2.3 2021-03-05 09:19:06 +01:00
ea7ab9fa85 gitignore: add pip files, pip: add proper README 2021-03-04 18:48:59 +01:00
c281aeae19 clean: include build directory 2021-03-04 11:48:06 +01:00
0403f2bc64 add pip package build/upload, check version tags 2021-03-04 11:47:15 +01:00
Mario Fink
0969d626b8 Merge pull request #5 from ZornitsaD/patch-2
Update README.md
2021-02-18 11:38:42 +01:00
ZornitsaD
37cbc2d45f Update README.md 2021-02-18 10:50:25 +01:00
8c8ed10a90 README.md: some minor tweak 2021-02-17 10:23:53 +01:00
Mario Fink
ecc1cd8005 Merge pull request #4 from ZornitsaD/patch-1
Update README.md
2021-02-16 12:39:45 +01:00
ZornitsaD
8746519d1a Update README.md
Hi Mario, I've had a look at the file and made some minor adjustments (punctuation mostly). Marko has asked us to mention the platform in the README files of the open-source projects with a brief explanation of where TDMtermite comes from and how we use it in the platform. I have to say, however, that I'm a bit out of my depth here.
2021-02-16 12:33:36 +01:00
c9f8097c9b README: fix link 2021-02-12 13:32:05 +01:00
5ae6b3f5ba add references 2021-02-12 13:29:53 +01:00
4c082451fa finalize README.md + example + cython interface 2021-02-12 13:22:15 +01:00
133279258f README: installation + usage 2021-02-12 12:14:51 +01:00
dd78b37290 cython setup imc_termite pytho module 2021-02-12 11:30:16 +01:00
3d9305a1be prepare imc_channel + imc_raw for cython interface 2021-02-12 09:52:52 +01:00
40a922893d CLI: fix options vs. argc handling 2021-02-12 09:29:55 +01:00
78c1ec4596 add Dockerfile 2021-02-11 20:11:52 +01:00
3948bfeac6 fix/improve printing and CLI 2021-02-11 19:54:09 +01:00
6b41dbe00a add printing methods 2021-02-11 19:39:11 +01:00
0107e367c4 finished conversion + CLI 2021-02-11 19:21:26 +01:00
3afa7fe345 channel: add origin NO 2021-02-11 17:21:39 +01:00
a03930515e finished metadata extraction 2021-02-11 17:17:09 +01:00
6f9133c638 start extraction 2021-02-11 16:03:49 +01:00
acd55194a5 imc_raw + imc_channels: channel extraction from blocks and environment 2021-02-11 15:49:11 +01:00
1596ca15b5 generate channel_envs 2021-02-11 13:38:07 +01:00
4b510ea91b remove redundant stuff related to imc_object 2021-02-11 12:52:53 +01:00
bed43d6785 * remove usage of imc::object
* introduce imc_channel with collection of affiliate blocks
* imc::keys as list instead of map with custom check/get methods
* imc_raw: start generation of affiliate blocks
2021-02-11 12:48:49 +01:00
fb16935829 makefile: force removal of object files to suppress error 2021-02-11 08:48:32 +01:00
c649961abb makefile: use PYT variable 2021-02-11 08:45:15 +01:00
42583eb51f makefile: restore python targets + readjust cython setup 2021-02-11 08:42:10 +01:00
26ff196676 remove redundant docu 2021-02-10 20:09:20 +01:00
2697e0b578 rename directories 2021-02-10 20:04:47 +01:00
f4ecf48218 start group - channel - component - buffer association 2021-02-10 20:01:11 +01:00
9bac0f1063 * list specific blocks
* key comparison operator
* imc::object: fix timestamp, fix analog vs. digital index
* imc_raw: convert datatype
2021-02-10 18:17:54 +01:00
eb13088257 rename samples and datasets/files 2021-02-10 16:09:33 +01:00
cfca5310ef remove old (makefile + main.cpp) 2021-02-10 15:38:43 +01:00
0eb034196d imc::object: all objects parsed 2021-02-10 15:37:24 +01:00
fe3befc5f2 start parsing imc::objects 2021-02-10 13:08:32 +01:00
eb2c49549a integrate imc::object into parsing workflow 2021-02-10 11:08:08 +01:00
4f3e816dbf wrapper for imc::object, include imc::object in imc::block 2021-02-09 20:57:44 +01:00
a808a001a9 imc::objects: preliminary complete 2021-02-09 19:31:27 +01:00
e952764e4f reduce computational complexity 2021-02-09 18:11:06 +01:00
79c1b19e33 check block consistency, reset block.end for length that exceeds buffer size (e.g. final CS) 2021-02-09 16:40:11 +01:00
c918746d29 add examples from IMC documentation 2021-02-09 15:06:55 +01:00
ee7f70d36f add imc_meta.hpp 2021-02-08 18:09:02 +01:00
09737a93fb imcdatatype: simplify class name 2021-02-08 17:27:17 +01:00
cb8365a897 implement imcdatatype 2021-02-08 17:21:37 +01:00
cf7d51e2fb imc::block: fix parameters parsing 2021-02-08 16:48:22 +01:00
cf6f91a324 extract all block/parameters data 2021-02-08 16:22:28 +01:00
3c91583ede adjust to new revision, main.cpp fix help message typo 2021-02-08 10:27:20 +01:00
584243f466 full imc raw format revision 2021-02-05 19:45:33 +01:00
09011b50ba tidy up parquet from lib 2021-02-05 12:30:01 +01:00
b869c1df3f clean up docu 2021-02-05 11:00:29 +01:00
e6be107950 update name/labeling 2021-02-05 10:14:48 +01:00
21039b5225 use single docu file for format 2021-02-05 09:16:10 +01:00
Mario Fink
700a1bed82 add technical docu 2021-02-04 17:20:25 +01:00
Mario Fink
5d0b330d9e update description 2021-02-04 14:06:00 +01:00
4ca398fa8c README: fix some formatting 2021-02-04 12:06:35 +01:00
debb4c4ec0 docu revision 2021-02-04 12:02:35 +01:00
42f1ebc0b8 update README.md 2021-02-03 16:50:15 +01:00
Mario Fink
acec174b8d Create LICENSE 2021-02-03 16:41:11 +01:00
150 changed files with 3369 additions and 6607 deletions

14
.gitignore vendored
View File

@@ -1,6 +1,7 @@
eatraw
eatdev
imctermite
nohup.out
@@ -9,7 +10,7 @@ nohup.out
raw_eater.cpp
raw_meat.cpp
cyt/*.cpp
cython/*.cpp
/build
*.log
@@ -17,3 +18,14 @@ cyt/*.cpp
*.o
*.csv
*.parquet
src/*.cpp.cpp
pip/*.cpp
pip/*.hpp
pip/*.pyx
pip/*.pxd
pip/README.md
pip/LICENSE
pip/*egg-info
pip/dist/

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM debian:bullseye-20210111
USER root
RUN apt-get update && apt-get install -y \
build-essential git vim \
python3 python3-pip
RUN python3 -m pip install cython
RUN g++ -v
COPY ./ /IMCtermite/
# install CLI tool
RUN cd /IMCtermite && ls -lh && make install && ls -lh /usr/local/bin/imctermite
# install Python module
RUN cd /IMCtermite && ls -lh && make cython-install
CMD ["sleep","infinity"]

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Record Evolution
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

317
README.md
View File

@@ -1,124 +1,225 @@
# raw_eater
[![Total alerts](https://img.shields.io/lgtm/alerts/g/RecordEvolution/IMCtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/alerts/)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/RecordEvolution/IMCtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/context:cpp)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/RecordEvolution/IMCtermite.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/context:python)
[![LICENSE](https://img.shields.io/github/license/RecordEvolution/IMCtermite)](https://img.shields.io/github/license/RecordEvolution/IMCtermite)
[![STARS](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)
The _raw_eater_ package is used to parse files with extension `*.raw`, which
are usually binary files produced by the labsoftware _Famos_ to dump measurement
time series.
# IMCtermite
## .raw-file format structure
_IMCtermite_ provides access to the proprietary data format
_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/)
& [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_.
The binary `*.raw` file features a series of markers that indicate the starting
point of various blocks of information. Every markers is introduced by character
"|" = `0x 7c` followed by two uppercase letters, which characterize the type of
marker. The following markers are defined:
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.
1. CF (0x 43 46)
1. CK (0x 43 4b)
1. NO (0x 4e 4f)
1. CG (0x 43 47)
1. CD (0x 43 44)
1. NT (0x 4e 54)
1. CC (0x 43 43)
1. CP (0x 43 50)
1. CR (0x 43 52)
1. CN (0x 43 4e)
1. Cb (0x 43 62)
1. CS (0x 43 53)
## Overview
Each of these markers are followed by multiple commata (0x 2c) separated parameters
and are terminated by a semicolon `;` = 0x 3b, except for the sequence following
the data marker CS, that may have any number of 0x3b occurencies, while still
terminated by a semicolon at the very end of the file (since CS is the last marker
section in the file). The markers have the following meaning:
* [File format](#Fileformat)
* [Build and Installation](#Installation)
* [Usage and Examples](#Usage)
* [References](#References)
- *CF* (3 parameters)
`|CF,2,1,1;`
specifies file format, key length and processor
- *CK* (4 parameters)
`|CK,1,3,1,1;`
start of group of keys
- *NO* (6 parameters)
`|NO,1,85,0,77,imc STUDIO 5.0 R3 (10.09.2015)@imc DEVICES 2.8R7 (26.8.2015)@imcDev__15190567,0,;`
origin of the file, provides some info about the software package/device
and its version
- *CB* (6 parameters)
group definition
- *CT* (8 parameters)
text definition
- *CG* (5 parameters)
`|CG,1,5,1,1,1;`
definition of a data field
|CG,1,KeyLang,AnzahlKomponenten,Feldtyp,Dimension;
- *CD* (mostly 11 parameters)
since we're dealing with measured entities from the lab this markers contains
info about the measurement frequency, i.e. sample rate. For instance
`|CD,2, 63, 5.0000000000000001E-03,1,1,s,0,0,0, 0.0000000000000000E+00,1;`
indicates a measured entity every 0.005 seconds, i.e. a sample rate = 200Hz
- *NT* (7 parameters)
`|NT,1,16,1,1,1980,0,0,0.0;`
|NT,1,KeyLang,Tag,Monat,Jahr,Stunden,Minuten,Sekunden;
triggerzeit
- *CC* (mostly 4 parameters)
`|CC,1,3,1,1;`
Start einer Komponente (component)
- *CP* (9 parameters)
`|CP,1,16,1,4,7,32,0,0,1,0;`
Pack-Information zu dieser Komponente
CP,1,KeyLang,BufferReferenz,Bytes,Zahlenformat,SignBits,Maske,Offset,DirekteFolgeAnzahl,AbstandBytes;
Bytes = 1...8
Zahlenformat : 1 = unsigned byte
2 = signed byte
3 = unsigned short
4 = signed short
5 = unsigned long
6 = signed long
7 = float
8 = double
9 = imc Devices
10 = timestamp ascii
11 =
12 =
13 =
## File format
- *CR* (7 parameters)
Wertebereich der Komponente, nur bei analogen, nicht bei digitalen Daten.
|CR,1,KeyLang,Transformieren,Faktor,Offset,Kalibriert,EinheitLang, Einheit;
provides the _physical unit_ of the measured entity, maybe shows the
minimum and maximum value during the measurment, e.g.
`|CR,1,60,0, 1.0000000000000000E+00, 0.0000000000000000E+00,1,4,mbar;`
Transformieren : 0 = nein
1 = ja, mit faktor und offset transformieren (für ganzzahlige Rohdaten)
Faktor,Offset: physikalischer Wert = Faktor * Rohdatenwerten + Offset
- *CN* (mostly 9 parameters)
gives the _name_ of the measured entity
|CN,1,KeyLang,IndexGruppe,0,IndexBit,NameLang,Name,KommLang,Kommentar;
`|CN,1,27,0,0,0,15,pressure_Vacuum,0,;`
- *Cb* (mostly 14 paramters) (optional?)
this one probably gives the minimum/maximum measured values!!
`|Cb,1,117,1,0,1,1,0,341288,0,341288,1,0.0000000000000000E+00,1.1781711390000000E+09,;`
- *CS* (mostly 4 parameters)
this markers announces the actual measurement data in binary format,
provide the number of values and the actual data,
e.g. `|CS,1, 341299, 1, ...data... ;`
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 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):
### Open Issues and question?
```
|CF,2,1,1;|CK,1,3,1,1;
|NO,1,86,0,78,imc STUDIO 5.0 R10 (04.08.2017)@imc DEVICES 2.9R7 (25.7.2017)@imcDev__15190567,0,;
|CG,1,5,1,1,1; |CD,2, 63, 5.0000000000000001E-03,1,1,s,0,0,0, 0.0000000000000000E+00,1;
|NT,1,16,1,1,1980,0,0,0.0; |CC,1,3,1,1;|CP,1,16,1,4,7,32,0,0,1,0;
|CR,1,60,0, 1.0000000000000000E+00, 0.0000000000000000E+00,1,4,mbar;|CN,1,27,0,0,0,15,pressure_Vacuum,0,;
|Cb,1, 117,1,0, 1, 1, 0, 9608, 0, 9608,1, 2.0440300000000000E+03, 1.2416717060000000E+09,;
|CS,1, 9619, 1,<2C>oD <09>nD6<44>nD)<29>nD<6E>
```
- which parameter indicate(s) little vs. big endian?
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).
## .parquet-file writer
The markers (keys) are introduced by `"|" = 0x 7c` followed by two uppercase
letters. There are _two types_ of markers distinguished by the first letter:
The extracted and converted data originating from the *.raw file format may be efficiently grouped and
written as .parquet files
[parquet file writer example](https://github.com/apache/parquet-cpp/blob/master/examples/low-level-api/reader-writer.cc)
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
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_
of the key starting from 1. After the next comma, an _(long) integer_ (in text
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 the vertical bar (pipe) of the next key. The following _critical markers_
are defined:
| marker | description |
|--------|-----------------------------------------------------------------------------------------------------|
| CF | format version and processor |
| CK | start of group of keys, no. parameters = 3, indicates (in)correct closure of the measurement series |
| CB | defines a group of channels |
| CT | text definition including group association index |
| CG | introduces group of components corresponding to CC keys |
| CD1,2 | old/new version of abscissa description |
| CZ | scaling of z-axis for segments |
| CC | start of a component |
| CP | information about buffer, datatype and samples of component |
| Cb | buffer description |
| CR | permissible range of values in component |
| CN | name and comment of channel |
| CS | raw binary data |
| CI | single numerical value (including unit) |
| Ca | add reference key |
Among the _noncritical_ markers, there are
| marker | description |
|--------|--------------------------------------------|
| NO | origin of data |
| NT | timestamp of trigger |
| ND | (color) display properties |
| NU | user defined key |
| Np | property of a channel |
| NE | extraction rule for channels from BUS data |
The format loosely defines some rules for the ordering of the markers in the
file stream. The rules for critical keys include: _CK_ has to follow up on _CF_,
_CK_ may be followed by any number of _CG_ blocks, each _CG_ has to be followed
by (any number of) component sequences comprised of the series _CC_ , _CP_,
(_CR_), (_ND_) and terminated by either _CS_ or the start of a new group,
component, text field or buffer.
## Installation
The _IMCtermite_ library may be employed both as a _CLI_ tool and a _python_
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
of the tool (in the default location `/usr/local/bin`) is done via
```
make install
````
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:
```
make cython-build
```
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:
```
imctermite <raw-file> [options]
```
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`:
```
Options:
-c, --listchannels list channels
-b, --listblocks list IMC key-blocks
-d, --output output directory to print channels
-s, --delimiter csv delimiter/separator char for output
-h, --help show this help message
-v, --version display version
```
For instance, to show a list of all channels included in `sample-data.raw`, you
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. By default, every output file
is written using a `,` delimiter. You may provide any custom separator with the
option `--delimiter`. For example, in order to use `|`, the binary is called with
options `imctermite sample-data.raw -b -c -s '|'`.
### 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:
```Python
import imc_termite
imcraw = imc_termite.imctermite(b"sample/sampleA.raw")
```
An example of how to create an instance and obtain the list of channels is:
```Python
import imc_termite
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = imc_termite.imctermite(b"samples/sampleA.raw")
except RuntimeError as e :
print("failed to load/parse raw-file: " + str(e))
# obtain list of channels as list of dictionaries (without data)
channels = imcraw.get_channels(False)
print(channels)
```
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://ch.mathworks.com/matlabcentral/fileexchange/30187-sequnce-to-read-famos-data-into-matlab-workspace
- https://community.ptc.com/t5/PTC-Mathcad/FAMOS-IMC-raw-data-in-MathCAD/td-p/130378
- http://marmatek.com/wp-content/uploads/2014/04/imc_STUDIO_Manual.pdf
### Parquet
- https://github.com/apache/parquet-cpp
- https://github.com/apache/parquet-cpp/tree/master/examples
- 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
- https://apollo3zehn.github.io/ImcFamosFile/api/ImcFamosFile.FamosFileKeyType.html
- https://pypi.org/help/#apitoken

111
assets/imctermite.svg Normal file
View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="78.080002"
width="325.72"
id="svg3945"
version="1.1"
viewBox="0 0 325.72 78.08"
sodipodi:docname="imctermite.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2048"
inkscape:window-height="1088"
id="namedview18"
showgrid="false"
inkscape:zoom="2.5577614"
inkscape:cx="138.13369"
inkscape:cy="-27.086877"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="svg3945"
inkscape:document-rotation="0" />
<metadata
id="metadata3951">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>flasher</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3949" />
<title
id="title3916">flasher</title>
<g
id="logog"
transform="translate(0,0.99981694)">
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 32.86,2 -13,7.5 v 0 h -0.05 v 0 l -0.48,0.28 c -4.27,2.46 -5.68,11.38 -6.06,14.75 L 36.2,11.33 c 0.39,-0.19 7.6,-3.69 13.57,-3.69 h 0.14 L 40.13,2 a 8.15,8.15 0 0 0 -7.27,0"
id="path138"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 5.68,17.69 A 8.2,8.2 0 0 0 2,24 v 15.78 c 0,4.9 7,10.48 9.75,12.46 V 25.77 c 0,-0.44 0.6,-8.55 3.65,-13.72 z"
id="path142"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 12.1,54.12 v 0 C 11.74,53.88 5,49.41 2,44.24 v 11.14 a 8.2,8.2 0 0 0 3.64,6.3 l 13.5,7.79 c 4.28,2.46 12.7,-0.77 15.81,-2.12 z"
id="path146"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 36.79,68 c -0.4,0.19 -7.71,3.75 -13.71,3.69 l 9.78,5.64 a 8.15,8.15 0 0 0 7.27,0 l 13.51,-7.8 c 4.27,-2.46 5.68,-11.39 6.06,-14.75 z"
id="path150"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 61.2,27.13 V 53.6 c 0,0.44 -0.6,8.55 -3.65,13.72 l 9.77,-5.64 A 8.2,8.2 0 0 0 71,55.38 V 39.59 c 0,-4.94 -7,-10.5 -9.75,-12.46"
id="path154"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 67.31,17.69 53.81,9.9 C 49.53,7.44 41.11,10.67 38,12 l 22.85,13.23 v 0 a 43.43,43.43 0 0 1 5.7,4.51 24,24 0 0 1 4.45,5.35 V 24 a 8.2,8.2 0 0 0 -3.64,-6.3"
id="path158"
inkscape:connector-curvature="0" />
</g>
<g
id="re"
transform="translate(0,0.99981694)" />
<text
id="text3955"
y="55.47554"
x="74.101189"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#364d5c;fill-opacity:1;stroke:none"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:44px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#364d5c;fill-opacity:1"
y="55.47554"
x="74.101189"
id="tspan3953"><tspan
id="tspan24"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold'">IMC</tspan><tspan
id="tspan3845"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif">termite</tspan> </tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

112
assets/raweater.svg Normal file
View File

@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="78.080002"
width="290.72"
id="svg3945"
version="1.1"
viewBox="0 0 290.72 78.08"
sodipodi:docname="raweater.svg"
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1360"
inkscape:window-height="704"
id="namedview18"
showgrid="false"
inkscape:zoom="0.90430522"
inkscape:cx="191.86"
inkscape:cy="38.540001"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg3945" />
<metadata
id="metadata3951">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>flasher</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3949" />
<title
id="title3916">flasher</title>
<g
id="logog"
transform="translate(0,0.99981694)">
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 32.86,2 -13,7.5 v 0 h -0.05 v 0 l -0.48,0.28 c -4.27,2.46 -5.68,11.38 -6.06,14.75 L 36.2,11.33 c 0.39,-0.19 7.6,-3.69 13.57,-3.69 h 0.14 L 40.13,2 a 8.15,8.15 0 0 0 -7.27,0"
id="path138"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 5.68,17.69 A 8.2,8.2 0 0 0 2,24 v 15.78 c 0,4.9 7,10.48 9.75,12.46 V 25.77 c 0,-0.44 0.6,-8.55 3.65,-13.72 z"
id="path142"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 12.1,54.12 v 0 C 11.74,53.88 5,49.41 2,44.24 v 11.14 a 8.2,8.2 0 0 0 3.64,6.3 l 13.5,7.79 c 4.28,2.46 12.7,-0.77 15.81,-2.12 z"
id="path146"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="m 36.79,68 c -0.4,0.19 -7.71,3.75 -13.71,3.69 l 9.78,5.64 a 8.15,8.15 0 0 0 7.27,0 l 13.51,-7.8 c 4.27,-2.46 5.68,-11.39 6.06,-14.75 z"
id="path150"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 61.2,27.13 V 53.6 c 0,0.44 -0.6,8.55 -3.65,13.72 l 9.77,-5.64 A 8.2,8.2 0 0 0 71,55.38 V 39.59 c 0,-4.94 -7,-10.5 -9.75,-12.46"
id="path154"
inkscape:connector-curvature="0" />
<path
style="fill:#364d5c"
transform="translate(-2.04,-1.15)"
d="M 67.31,17.69 53.81,9.9 C 49.53,7.44 41.11,10.67 38,12 l 22.85,13.23 v 0 a 43.43,43.43 0 0 1 5.7,4.51 24,24 0 0 1 4.45,5.35 V 24 a 8.2,8.2 0 0 0 -3.64,-6.3"
id="path158"
inkscape:connector-curvature="0" />
</g>
<g
id="re"
transform="translate(0,0.99981694)" />
<text
id="text3955"
y="55.47554"
x="74.101189"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#364d5c;fill-opacity:1;stroke:none"
xml:space="preserve"><tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:44px;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#364d5c;fill-opacity:1"
y="55.47554"
x="74.101189"
id="tspan3953"><tspan
id="tspan24"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold'">R</tspan><tspan
id="tspan3845"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif">aw<tspan
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold'"
id="tspan22">E</tspan>ater</tspan> </tspan></text>
</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

20
cython/imc_termite.pxd Normal file
View File

@@ -0,0 +1,20 @@
# cython: language_level = 3
# use some C++ STL libraries
from libcpp.string cimport string
from libcpp.vector cimport vector
from libcpp cimport bool
cdef extern from "imc_raw.hpp" namespace "imc":
cdef cppclass imc_termite "imc::raw":
# constructor(s)
imc_termite() except +
imc_termite(string rawfile) except +
# provide raw file
void set_file(string rawfile) except +
# get JSON list of channels
vector[string] get_channels(bool json, bool data) except +
# print single channel/all channels
void print_channel(string channeluuid, string outputdir, char delimiter) except +
void print_channels(string outputdir, char delimiter) except +
void print_table(string outputfile) except +

44
cython/py_imc_termite.pyx Normal file
View File

@@ -0,0 +1,44 @@
# distutils: language = c++
from imc_termite cimport imc_termite
import json as jn
import decimal
# import numpy as np
cdef class imctermite:
# C++ instance of class => stack allocated (requires nullary constructor!)
cdef imc_termite cpp_imc
# constructor
def __cinit__(self, string rawfile):
self.cpp_imc = imc_termite(rawfile)
# provide raw file
def submit_file(self,string rawfile):
self.cpp_imc.set_file(rawfile)
# get JSON list of channels
def get_channels(self, bool data):
chnlst = self.cpp_imc.get_channels(True,data)
chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst]
return chnlstjn
# print single channel/all channels
def print_channel(self, string channeluuid, string outputfile, char delimiter):
self.cpp_imc.print_channel(channeluuid,outputfile,delimiter)
def print_channels(self, string outputdir, char delimiter):
self.cpp_imc.print_channels(outputdir,delimiter)
# print table including channels
def print_table(self, string outputfile):
chnlst = self.cpp_imc.get_channels(True,True)
chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst]
with open(outputfile.decode(),'w') as fout:
for chn in chnlstjn:
fout.write('#' +str(chn['xname']).rjust(19)+str(chn['yname']).rjust(20)+'\n')
fout.write('#'+str(chn['xunit']).rjust(19)+str(chn['yunit']).rjust(20)+'\n')
for n in range(0,len(chn['ydata'])):
fout.write(str(chn['xdata'][n]).rjust(20)+
str(chn['ydata'][n]).rjust(20)+'\n')

24
cython/setup.py Normal file
View File

@@ -0,0 +1,24 @@
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
extensions = Extension(
name="imc_termite",
sources=["cython/py_imc_termite.pyx"],
# libraries=[""],
# library_dirs=["lib"],
include_dirs=["lib"],
language='c++',
extra_compile_args=['-std=c++17','-Wno-unused-variable'],
extra_link_args=['-std=c++17'],
)
setup(
name="imc_termite",
version='1.2.6',
description='IMCtermite cython extension',
author='Record Evolution GmbH',
author_email='mario.fink@record-evolution.de',
url='https://github.com/RecordEvolution/IMCtermite.git',
ext_modules=cythonize(extensions,force=True)
)

View File

@@ -4,7 +4,7 @@ from Cython.Build import cythonize
extensions = Extension(
name="raw_eater",
sources=["cyt/raw_eater.pyx"],
sources=["cython/raw_eater.pyx"],
# libraries=[""],
library_dirs=["src"],
include_dirs=["src"],

View File

@@ -4,7 +4,7 @@ from Cython.Build import cythonize
extensions = Extension(
name="raw_meat",
sources=["cyt/raw_meat.pyx"],
sources=["cython/raw_meat.pyx"],
# libraries=[""],
library_dirs=["src"],
include_dirs=["src"],

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,217 +0,0 @@
function [dataOut]=FAMOSimport(filename)
% Usage: data=FAMOSimport(filename);
%
% FAMOSimport() opens (MARC generated) FAMOS files and imports all signals.
%
% *************************************************************************
%
%
% Preset output to empty;
dataOut=[];
%% Check for valid input file
if exist('filename','var')~=1 ...
|| isempty(filename)
[filename, pathname] = uigetfile( ...
{'*.dat','FAMOS measurement files'; ...
'*.*','All files'},'Select FAMOS measurement file ...');
if isequal(filename,0)
disp('FAMOS-measurement file import cancelled.');
return;
end
filename=fullfile(pathname, filename);
clear pathname;
end
if exist(filename,'file')~=2
disp('Given file could not be found. Aborting import.');
return;
end
%% Load input file
fid=fopen(filename,'r','l');
data=fread(fid,inf,'uint8=>char','l')';
fclose(fid);
clear fid
%% Parse header information
dataOut.FileName=filename;
dataOut.TYPE='AFT MARC (FAMOS)';
header=strfind(data(1:200),[char(13) char(10) '|NO,']);
subIdx=strfind(data(header(1):header(1)+50),',');
dataOut.Device=strtrim(data(header(1)+subIdx(5):header(1)+subIdx(6)-2));
%% Parse measurement entries information
units=strfind(data,[char(13) char(10) '|CR,'])';
dataOut.Unit=cell(size(units));
dataOut.Factor=zeros(size(dataOut.Unit),'double');
dataOut.Offset=zeros(size(dataOut.Unit),'double');
for i=1:length(units)
subIdx=sort([strfind(data(units(i):units(i)+255),',') ...
strfind(data(units(i):units(i)+255),';')]);
dataOut.Factor(i)=str2double( ...
data(units(i)+subIdx(4):units(i)+subIdx(5)-2));
dataOut.Offset(i)=str2double( ...
data(units(i)+subIdx(5):units(i)+subIdx(6)-2));
dataOut.Unit{i}=data(units(i)+subIdx(8):units(i)+subIdx(9)-2);
end
clear units subIdx;
%Extract measurement variables names and corresponding time column
varName=strfind(data,[char(13) char(10) '|CN,'])';
dataOut.TimeIndex=zeros(size(varName),'uint32');
dataOut.Label=cellstr(char(zeros(size(dataOut.TimeIndex))));
dataOut.Data=zeros(size(dataOut.TimeIndex),'double');
for i=1:length(varName)
subIdx=strfind(data(varName(i):varName(i)+255),',');
dataOut.Label{i}=data(varName(i)+subIdx(7):varName(i)+subIdx(8)-2);
end
for i=1:length(varName)
subIdx=sort([strfind(data(varName(i):varName(i)+255),',') ...
strfind(data(varName(i):varName(i)+255),';')]);
TimeVarName=data(varName(i)+subIdx(9):varName(i)+subIdx(10)-2);
if i==1 || ~strcmp(dataOut.TimeIndex(i-1),TimeVarName)
idx=strmatch(TimeVarName,dataOut.Label,'exact');
if ~isempty(idx)
dataOut.TimeIndex(i)=idx(1);
else
warning('FAMOSconnect:invalidTimeLabel', ...
['Signal ''%s'' (%d) refers to non-existing ' ...
'time signal label ''%s''.'], ...
dataOut.Label{i},i,TimeVarName);
end
else
dataOut.TimeIndex(i)=dataOut.TimeIndex(i-1);
end
end
clear varName TimeVarName subIdx;
%Extract measurement value data type and bitlength
dataType=strfind(data,[char(13) char(10) '|CP,1,'])';
dataOut.DataType=cell(size(dataType));
dataOut.DataBits=zeros(size(dataOut.DataType),'uint8');
for i=1:length(dataType)
subIdx=strfind(data(dataType(i):dataType(i)+50),',');
switch (data(dataType(i)+subIdx(5):dataType(i)+subIdx(6)-2))
case '1' % uint8
dataOut.DataType{i}='uint8';
case '2' % int8
dataOut.DataType{i}='int8';
case {'3','9','11'} % uint16
dataOut.DataType{i}='uint16';
case '4' % int16
dataOut.DataType{i}='int16';
case '5' % uint32
dataOut.DataType{i}='uint32';
case '6' % int32
dataOut.DataType{i}='int32';
case '7' % float
dataOut.DataType{i}='single';
case {'8','10','13'} % double
dataOut.DataType{i}='double';
otherwise
dataOut.DataType{i}='UNKNOWN';
end
dataOut.DataBits(i)=str2double( ...
data(dataType(i)+subIdx(6):dataType(i)+subIdx(7)-2));
end
clear dataType subIdx;
%Extract measurement value data block and item number
dataInfo=strfind(data,[char(13) char(10) '|Cb,1,'])';
dataOut.DataBlock=zeros(size(dataInfo),'uint16');
dataOut.DataItem=zeros(size(dataOut.DataBlock),'uint16');
for i=1:length(dataInfo)
subIdx=strfind(data(dataInfo(i):dataInfo(i)+50),',');
dataOut.DataItem(i)=str2double( ...
data(dataInfo(i)+subIdx(5):dataInfo(i)+subIdx(6)-2));
dataOut.DataBlock(i)=str2double( ...
data(dataInfo(i)+subIdx(6):dataInfo(i)+subIdx(7)-2));
end
clear dataInfo subIdx;
%Extract measurement value binary data length and offset
dataBlock=strfind(data,[char(13) char(10) '|CS,'])';
dataOut.DataBlocks=length(dataBlock);
dataOut.DataBlocksLength=zeros(size(dataBlock),'uint32');
dataOut.DataBlocksItemLength=zeros(size(dataBlock),'uint32');
dataOut.DataBlocksOffset=zeros(size(dataBlock),'uint32');
for i=1:length(dataBlock)
subIdx=strfind(data(dataBlock(i):dataBlock(i)+50),',');
dataOut.DataBlocksOffset(i)=dataBlock(i)+subIdx(4)-1;
dataOut.DataBlocksLength(i)=str2double( ...
data(dataBlock(i)+subIdx(2):dataBlock(i)+subIdx(3)-2)) ...
-(subIdx(4)-subIdx(3)); %Fix offset
dataOut.DataBlocksItemLength(i)=dataOut.DataBlocksLength(i) ...
/(sum(dataOut.DataBits(dataOut.DataBlock==i)/8));
end
clear dataBlock subIdx;
%% Sort entries - note: DataItem-value continues over blocks.
[~, dataOrder]=sort(dataOut.DataItem);
dataOutField=fieldnames(dataOut);
for i=1:length(dataOutField)
if length(dataOut.(dataOutField{i}))==length(dataOut.DataItem) ...
&& ~strcmp(dataOutField{i},'DataBlocksLength')
dataOut.(dataOutField{i})=dataOut.(dataOutField{i})(dataOrder);
end
end
clear dataOrder dataOutField;
%% Extract measurement data, format: shots-aligned (not variables aligned)
data=cast(data,'uint8');
dataOut.Data=cell(length(dataOut.DataItem),1);
dataBlockId=1;
dataOffset=dataOut.DataBlocksOffset(dataBlockId);
dataVarIdx1=uint32(1: ...
dataOut.DataBlocksLength(dataBlockId) ...
/dataOut.DataBlocksItemLength(dataBlockId): ...
dataOut.DataBlocksLength(dataBlockId));
dataVarIdx2=reshape([dataVarIdx1; dataVarIdx1+1],1,[]);
dataVarIdx4=reshape([dataVarIdx1; dataVarIdx1+1; ...
dataVarIdx1+2; dataVarIdx1+3],1,[]);
for i=1:length(dataOut.Label)
if dataOut.DataBlock(i)>dataBlockId
dataBlockId=dataOut.DataBlock(i);
dataOffset=dataOut.DataBlocksOffset(dataBlockId);
dataVarIdx1=uint32(1: ...
dataOut.DataBlocksLength(dataBlockId) ...
/dataOut.DataBlocksItemLength(dataBlockId): ...
dataOut.DataBlocksLength(dataBlockId));
dataVarIdx2=reshape([dataVarIdx1; dataVarIdx1+1],1,[]);
dataVarIdx4=reshape([dataVarIdx1; dataVarIdx1+1; ...
dataVarIdx1+2; dataVarIdx1+3],1,[]);
end
switch dataOut.DataBits(i)
case 8
dataVal=cast(typecast(data(dataVarIdx1+dataOffset),...
dataOut.DataType{i}),'double');
dataOffset=dataOffset+1;
case 16
dataVal=cast(typecast(data(dataVarIdx2+dataOffset),...
dataOut.DataType{i}),'double');
dataOffset=dataOffset+2;
case 32
dataVal=cast(typecast(data(dataVarIdx4+dataOffset),...
dataOut.DataType{i}),'double');
dataOffset=dataOffset+4;
otherwise
fprintf(2,['Unsupported data width in item %d:' ...
'%d Bits - Skipping.\n'], ...
dataOut.DataItem(i),dataOut.DataBits(i));
dataOffset=dataOut.DataBits(i)/8;
continue;
end
dataVal=dataVal*dataOut.Factor(i)+dataOut.Offset(i);
dataOut.Data{i}=dataVal';
end
clear dataOffset dataBlockId dataVarIdx1 dataVarIdx2 dataVarIdx4 dataVal;
clear i data;

View File

@@ -1,222 +0,0 @@
function Channel=importfamos(FullRawData)
%__________________________________________________________________________
% The sequnce importfamos.m was produced to convert imc raw data(*.raw;
% *.dat) to matlab data. Here, struct is used to manage the channel
% information.
%
% For more information of FAMOS file format, please see the
% manufacturer's website: http://www.imc-berlin.de
%
% Corresponding to Data Structure in Matlab, the channels are stored
% as struct struct: Channel + name (channel name)
% + comment
% + data (channel Value)
% + length
% + yUnit
% + t0
% + dt(sampling period)
% + xUnit
% Version history:
% Version 1.0 (2011.1.19); Current version only can deal with analog rawdata
% from imc devices. The digital and group function is ongoning and will be
% released in version 2.
% Version 1.1 (2013.12.31): In order to solve non-manually save data,
% regular pattern is introduced into sloving data structure without CR and
% LF.
% (only support data(Channel) from imc devices)
%
%%-------------------------------------------------------------------------
% Author: Liang
% Danke.Liang@gmail.com
% Started on Dec.14, 2010
%__________________________________________________________________________
if nargin == 0;
[RawData,FamosPath] = uigetfile({'*.raw';'*.dat'},'Select Famos Raw data');
FullRawData=strcat(FamosPath,RawData);
end
fid = fopen(FullRawData,'r');
if fid==-1,
disp('failed to read rawdata')
return
end
disp(['Info: Read data @' datestr(now) ' from' ])
disp([ ' ' FullRawData '...'])
Textall=fscanf(fid,'%c');
CSstring='\|CS,\d,\D*\d+,\D*\d+,';
CSend=regexp(Textall,CSstring,'end');
InfoSegment=Textall(1,1:CSend);
Cbstr='\|Cb.*?;';
CGstr='\|CG,.*?;';
CDstr='\|CD,.*?;';
NTstr='\|NT,.*?;';
CPstr='\|CP,.*?;';
CRstr='\|CR,.*?;';
CNstr='\|CN,.*?;';
ArrCG=char(regexp(InfoSegment,CGstr,'match'));
ChannelNum=size(ArrCG,1);
ArrCN=char(regexp(InfoSegment,CNstr,'match'));
ArrCD=char(regexp(InfoSegment,CDstr,'match'));
ArrNT=char(regexp(InfoSegment,NTstr,'match'));
ArrCP=char(regexp(InfoSegment,CPstr,'match'));
ArrCb=char(regexp(InfoSegment,Cbstr,'match'));
ArrCR=char(regexp(InfoSegment,CRstr,'match'));
%% CN
ChannelName=cell(ChannelNum,1);
ChannelComment=cell(ChannelNum,1);
%% CD,NT
CDsample=zeros(ChannelNum,1);
CDUnit=cell(ChannelNum,1);
TriggerTime=cell(ChannelNum,1);
%% CP
KeyBufferRef=zeros(ChannelNum,1);
KeyBytes=zeros(ChannelNum,1);
KeyNumberFormat=cell(ChannelNum,1);
KeySignBits=zeros(ChannelNum,1);
%% Cb
KeyBufferRefIndex=zeros(ChannelNum,1);
KeyBufferRefCb=zeros(ChannelNum,1);
KeyOffsetBufferInSamplesKey=zeros(ChannelNum,1);
KeyBufferFilledBytes=zeros(ChannelNum,1);
%% CR
KeyTransformation=zeros(ChannelNum,1);
KeyCRfactor=zeros(ChannelNum,1);
KeyCRoffset=zeros(ChannelNum,1);
KeyUnit=cell(ChannelNum,1);
%% Define Return object
Channel=struct('name','','comment','','data',[],'length',0,'yUnit','','t0','','dt','','xUnit','');
BinaryStart=CSend;
ChannelID=1;
while ChannelID <= ChannelNum
temptext=char(ArrCD(ChannelID,:));
[CDsample(ChannelID,1), CDUnit{ChannelID,1}]=ProcessCD(temptext);
[ChannelName{ChannelID,1},ChannelComment{ChannelID,1}]=ProcessCN(ArrCN(ChannelID,:));
Channel(ChannelID).name=ChannelName{ChannelID,1};
disp(strcat('Channel_',num2str(ChannelID),':',Channel(ChannelID).name))
Channel(ChannelID).comment=ChannelComment{ChannelID,1};
Channel(ChannelID).dt=strcat(num2str(CDsample(ChannelID,1)),CDUnit{ChannelID,1});
Channel(ChannelID).xUnit=CDUnit{ChannelID,1};
TriggerTime{ChannelID,1}=ProcessNT(ArrNT(ChannelID,:));
Channel(ChannelID).t0=TriggerTime{ChannelID,1};
[KeyBufferRef(ChannelID,1),KeyBytes(ChannelID,1),KeyNumberFormat{ChannelID,1},KeySignBits(ChannelID,1)]=ProcessCP(ArrCP(ChannelID,:));
[KeyBufferRefIndex(ChannelID,1),KeyBufferRefCb(ChannelID,1),KeyOffsetBufferInSamplesKey(ChannelID,1),KeyBufferFilledBytes(ChannelID,1)]=ProcessCblittle(ArrCb(ChannelID,:));
[KeyTransformation(ChannelID,1),KeyCRfactor(ChannelID,1),KeyCRoffset(ChannelID,1),KeyUnit{ChannelID,1}]=ProcessCR(ArrCR(ChannelID,:));
Channel(ChannelID).yUnit=KeyUnit{ChannelID,1};
BinaryRead= BinaryStart+KeyOffsetBufferInSamplesKey(ChannelID,1);
ChannelLength=KeyBufferFilledBytes(ChannelID,1)*8/KeySignBits(ChannelID,1);
Channel(ChannelID).data=ReadChannel(fid,BinaryRead,ChannelLength,KeyNumberFormat{ChannelID,1},KeyCRfactor(ChannelID,1),KeyCRoffset(ChannelID,1));
Channel(ChannelID).length=ChannelLength;
ChannelID=ChannelID+1;
end
fclose(fid);
end
%%
function [KeyDx, KeyUnit]= ProcessCD(TxtString)
% disp('Info: Processing key CD...');
CommaLocation=find(TxtString==',');
Txtemp=TxtString(CommaLocation(3)+1:CommaLocation(4)-1);
KeyDx=str2double(Txtemp);
KeyUnit=TxtString(CommaLocation(6)+1:CommaLocation(7)-1);
% disp('Info: Finished Process key CD!');
end
function TimeStart = ProcessNT(TxtString)
CommaLocation=find(TxtString==',');
Txtemp=TxtString(CommaLocation(3)+1:CommaLocation(4)-1);
KeyDay=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(4)+1:CommaLocation(5)-1);
KeyMonth=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(5)+1:CommaLocation(6)-1);
KeyYear=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(6)+1:CommaLocation(7)-1);
KeyHours=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(7)+1:CommaLocation(8)-1);
KeyMinutes=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(8)+1:length(TxtString));
KeySeconds=str2num(Txtemp);
TimeStart=datestr(datenum([KeyYear, KeyMonth,KeyDay,KeyHours,KeyMinutes,KeySeconds]),'yyyy-mm-dd HH:MM:SS');
% disp('Info: Finished Processing key NT!');
end
function [KeyBufferRef,KeyBytes,KeyNumerFormat,KeySignBits]= ProcessCP(TxtString)
% disp('Info: Processing key CP...');
CommaLocation=find(TxtString==',');
Txtemp=TxtString(CommaLocation(3)+1:CommaLocation(4)-1);
KeyBufferRef=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(4)+1:CommaLocation(5)-1);
KeyBytes=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(5)+1:CommaLocation(6)-1);
NumberFormat=str2num(Txtemp);
switch (NumberFormat)
case 1
KeyNumerFormat='*uint';
case 2
KeyNumerFormat='*int';
case 3
KeyNumerFormat='*ushort';
case 4
KeyNumerFormat='*short';
case 5
KeyNumerFormat='*ulong';
case 6
KeyNumerFormat='*long';
case 7
KeyNumerFormat='*float';
case 8
KeyNumerFormat='*float32';
case 9
KeyNumerFormat='*'; % imc Device Transitional Recording
case 10
KeyNumerFormat='*TimeStampASII' ;% TimeStamp is famos type
case 11
KeyNumberFormat='*bit16'; %2-byte-word digital
case 13
KeyNumberFormat='*bit48';
end
Txtemp=TxtString(CommaLocation(6)+1:CommaLocation(7)-1);
KeySignBits=str2num(Txtemp);
end
function [KeyBufferRefIndex,KeyBufferRefCb,KeyOffsetBufferInSamplesKey,KeyBufferFilledBytes] = ProcessCblittle(TxtString)
% disp('Info: Processing key Cb...');
CommaLocation=find(TxtString==',');
Txtemp=TxtString(CommaLocation(3)+1:CommaLocation(4)-1);
KeyBufferRefIndex=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(5)+1:CommaLocation(6)-1);
KeyBufferRefCb=str2double(Txtemp);
Txtemp=TxtString(CommaLocation(7)+1:CommaLocation(8)-1);
KeyOffsetBufferInSamplesKey=str2double(Txtemp);
Txtemp=TxtString(CommaLocation(10)+1:CommaLocation(11)-1);
KeyBufferFilledBytes=str2double(Txtemp);
%disp('Info: Finished Processing key Cb!');
end
function [KeyTransformation,KeyCRfactor,KeyCRoffset,KeyUnit]= ProcessCR(TxtString)
% disp('Info: Processing key CR...')
%
CommaLocation=find(TxtString==',');
Txtemp=TxtString(CommaLocation(3)+1:CommaLocation(4)-1);
KeyTransformation=str2num(Txtemp);
Txtemp=TxtString(CommaLocation(4)+1:CommaLocation(5)-1);
KeyCRfactor=str2double(Txtemp);
Txtemp=TxtString(CommaLocation(5)+1:CommaLocation(6)-1);
KeyCRoffset=str2double(Txtemp);
Txtemp=TxtString(CommaLocation(7)+1:CommaLocation(8)-1);
KeyUnitLength=str2double(Txtemp);
KeyUnit=TxtString(CommaLocation(8)+1:CommaLocation(8)+KeyUnitLength);
% disp('Info: Finished Processing key CR!');
end
function [ChannelName,ChannelComment]= ProcessCN(TxtString)
CommaLocation=find(TxtString==',');
ChannelName=TxtString(CommaLocation(7)+1:CommaLocation(8)-1);
ChannelCommLength=TxtString(CommaLocation(8)+1:CommaLocation(9)-1);
if ChannelCommLength=='0';
ChannelComment='';
else
temp=str2double(ChannelCommLength);
ChannelComment=TxtString(CommaLocation(9)+1:CommaLocation(9)+temp);
end
end
function tempChannel=ReadChannel(FileID, ReadStart,ChannelLength, Datatype,factor,offset)
fseek(FileID,ReadStart,'bof');
tempChannel=double(fread(FileID,ChannelLength,Datatype))*factor+offset;
%disp('Info: a Channle was imported.... ');
end

View File

@@ -4,6 +4,7 @@
#define HEXSHOW
#include <sstream>
#include <assert.h>
//---------------------------------------------------------------------------//

178
lib/imc_block.hpp Normal file
View File

@@ -0,0 +1,178 @@
//---------------------------------------------------------------------------//
#ifndef IMCBLOCK
#define IMCBLOCK
#include <iomanip>
#include <map>
#include <string>
#include <sstream>
#include <vector>
#include "imc_parameter.hpp"
#include "imc_object.hpp"
//---------------------------------------------------------------------------//
namespace imc
{
// define "magic bytes" announcing start/end of blocks and separation of parameters within
const unsigned char ch_bgn_ = 0x7c, ch_end_ = 0x3b, ch_sep_ = 0x2c;
// define properties of a raw file block
class block
{
// associated IMC key
key thekey_;
// unique identifier for using block in hash maps (e.g. byte-position of block = begin_)
std::string uuid_;
// offset (in byte) of first (=ch_bgn_) and last byte (=ch_end_) of block
// w.r.t. to entire raw file
unsigned long int begin_, end_;
// name and buffer of associated raw file
std::string raw_file_;
const std::vector<unsigned char>* buffer_;
// offset of first/last byte of parameters in block (separated by ch_sep_)
// w.r.t. to first byte of block (=0)
std::vector<imc::parameter> parameters_;
public:
// constructor
block(key thekey, unsigned long int begin, unsigned long int end,
std::string raw_file, const std::vector<unsigned char>* buffer):
thekey_(thekey), uuid_(std::to_string(begin))
{
if ( !imc::check_key(thekey) ) throw std::logic_error("unknown key");
begin_ = begin;
end_ = end;
if ( end_ <= begin_ )
{
throw std::logic_error("block: offset of first byte larger than last byte's offset");
}
raw_file_ = raw_file;
buffer_ = buffer;
// make sure "end_" does not exceed buffer size due to invalid "length" parameter of block
if ( end_ > buffer_->size() )
{
std::cout<<"WARNING: invalid length parameter in "<<thekey_.name_<<"-block "
<<"(block-end:"<<end_<<",buffer-size:"<<buffer_->size()<<")"
<<" => resetting block-end to buffer-size\n";
end_ = buffer_->size();
}
try {
parse_parameters();
} catch (const std::exception& e) {
throw std::runtime_error(
std::string("block: failed to parse parameters/objects: ") + e.what()
);
}
}
private:
// identify/parse parameters in block
void parse_parameters()
{
// parse entire block and check for separator tokens
// (consider only first four of any CS block)
int count = 0;
for ( unsigned long int b = begin_;
b < end_ && ( ! (thekey_.name_== "CS") || count < 4 ); b++ )
{
if ( buffer_->at(b) == imc::ch_sep_ )
{
// define range of parameter with first byte = ch_sep_
parameters_.push_back(imc::parameter(b,b));
count++;
}
}
// set offset of parameters's last byte
for ( unsigned long int p = 0; p < parameters_.size()-1; p++ )
{
parameters_[p].end( parameters_[p+1].begin() - 1 );
}
parameters_.back().end( this->end_ - 1 );
}
public:
// access members
imc::key get_key() { return thekey_; }
std::string get_uuid() { return uuid_; }
unsigned long int get_begin() { return begin_; }
unsigned long int get_end() { return end_; }
// get list of parameters
std::vector<parameter>& get_parameters()
{
return parameters_;
}
// get data of single parameter
std::vector<unsigned char> extract_parameter(parameter& param)
{
// check parameter w.r.t. to block
if ( param.begin() < begin_ || param.end() > end_ )
{
throw std::logic_error("inconsistent parameter offsets");
}
std::vector<unsigned char> parambuff(buffer_->begin()+begin_+param.begin(),
buffer_->begin()+begin_+param.end());
return parambuff;
}
// get single parameter as string
std::string get_parameter(parameter& param)
{
// check parameter w.r.t. to block
if ( param.begin() < begin_ || param.end() > end_ )
{
throw std::logic_error("inconsistent parameter offsets");
}
std::string prm("");
for ( unsigned long int i = param.begin()+1; i <= param.end(); i++ )
{
prm.push_back( (char)((*buffer_)[i]) );
}
return prm;
}
// get info string
std::string get_info(int width = 20)
{
// summarize parameters in single string
std::string prsstr("{");
for ( auto par: parameters_ ) prsstr += par.get_info() + std::string(",");
if ( prsstr.size() > 1 ) prsstr.pop_back();
prsstr += std::string("}");
// construct block info string
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"block:"<<thekey_.name_
<<" version "<<thekey_.version_
<<" ("<<thekey_.description_<<")"<<"\n"
<<std::setw(width)<<std::left<<"uuid:"<<uuid_<<"\n"
<<std::setw(width)<<std::left<<"begin:"<<begin_<<"\n"
<<std::setw(width)<<std::left<<"end:"<<end_<<"\n"
<<std::setw(width)<<std::left<<"rawfile:"<<raw_file_<<"\n"
<<std::setw(width)<<std::left<<"buffersize:"<<buffer_->size()<<"\n"
<<std::setw(width)<<std::left<<"parameters:"<<prsstr<<"\n";
return ss.str();
}
};
}
#endif
//---------------------------------------------------------------------------//

444
lib/imc_channel.hpp Normal file
View File

@@ -0,0 +1,444 @@
//---------------------------------------------------------------------------//
#ifndef IMCCHANNEL
#define IMCCHANNEL
#include <sstream>
#include "imc_datatype.hpp"
#include "imc_conversion.hpp"
//---------------------------------------------------------------------------//
namespace imc
{
// collect uuid's of blocks required for full channel reconstruction
struct channel_env
{
// define unique identifer for channel_env
std::string uuid_;
// collect affiliate blocks for a single channel
std::string CBuuid_, CGuuid_, CCuuid_, CNuuid_;
std::string CDuuid_, CTuuid_, Cbuuid_, CPuuid_, CRuuid_, CSuuid_;
std::string NTuuid_, NOuuid_, NLuuid_;
// reset all members
void reset()
{
uuid_.clear();
CBuuid_.clear();
CGuuid_.clear();
CCuuid_.clear();
CNuuid_.clear();
CDuuid_.clear();
CTuuid_.clear();
Cbuuid_.clear();
CPuuid_.clear();
CRuuid_.clear();
CSuuid_.clear();
NTuuid_.clear();
NOuuid_.clear();
NLuuid_.clear();
}
// get info
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"uuid:"<<uuid_<<"\n"
<<std::setw(width)<<std::left<<"CBuuid:"<<CBuuid_<<"\n"
<<std::setw(width)<<std::left<<"CGuuid:"<<CGuuid_<<"\n"
<<std::setw(width)<<std::left<<"CCuuid:"<<CCuuid_<<"\n"
<<std::setw(width)<<std::left<<"CNuuid:"<<CNuuid_<<"\n"
//
<<std::setw(width)<<std::left<<"CDuuid:"<<CDuuid_<<"\n"
<<std::setw(width)<<std::left<<"CTuuid:"<<CTuuid_<<"\n"
<<std::setw(width)<<std::left<<"Cbuuid:"<<Cbuuid_<<"\n"
<<std::setw(width)<<std::left<<"CPuuid:"<<CPuuid_<<"\n"
<<std::setw(width)<<std::left<<"CRuuid:"<<CRuuid_<<"\n"
<<std::setw(width)<<std::left<<"CSuuid:"<<CSuuid_<<"\n"
//
<<std::setw(width)<<std::left<<"NTuuid:"<<NTuuid_<<"\n"
<<std::setw(width)<<std::left<<"NOuuid:"<<NOuuid_<<"\n"
<<std::setw(width)<<std::left<<"NLuuid:"<<NLuuid_<<"\n";
return ss.str();
}
// get JSON info string
std::string get_json()
{
std::stringstream ss;
ss<<"{"<<"\"uuid\":\""<<uuid_
<<"\",\"CBuuid\":\""<<CBuuid_
<<"\",\"CGuuid\":\""<<CGuuid_
<<"\",\"CCuuid\":\""<<CCuuid_
<<"\",\"CNuuid\":\""<<CNuuid_
<<"\",\"CDuuid\":\""<<CDuuid_
<<"\",\"CTuuid\":\""<<CTuuid_
<<"\",\"Cbuuid\":\""<<Cbuuid_
<<"\",\"CPuuid\":\""<<CPuuid_
<<"\",\"CRuuid\":\""<<CRuuid_
<<"\",\"CSuuid\":\""<<CSuuid_
<<"\",\"NTuuid\":\""<<NTuuid_
<<"\",\"NOuuid\":\""<<NOuuid_
<<"\",\"NLuuid\":\""<<NLuuid_
<<"\"}";
return ss.str();
}
};
// given a list of numeric objects, join it into a string
template<typename dt>
std::string joinvec(std::vector<dt> myvec, unsigned long int limit = 10)
{
// include entire list for limit = - 1
limit = (limit == 0) ? myvec.size() : limit;
std::stringstream ss;
ss<<"[";
if ( myvec.size() <= limit )
{
for ( dt el: myvec ) ss<<std::setprecision(10)<<el<<",";
}
else
{
unsigned long int heals = (unsigned long int)(limit/2.);
for ( unsigned long int i = 0; i < heals; i++ ) ss<<myvec[i]<<",";
ss<<"...";
for ( unsigned long int i = myvec.size()-heals; i < myvec.size(); i++ )
{
ss<<std::setprecision(10)<<myvec[i]<<",";
}
}
std::string sumstr = ss.str();
if ( sumstr.size() > 1 ) sumstr.pop_back();
sumstr += std::string("]");
return sumstr;
}
// channel
struct channel
{
// associated environment of blocks and map of blocks
channel_env chnenv_;
std::map<std::string,imc::block>* blocks_;
std::vector<unsigned char>* buffer_;
// collect meta-data of channels according to env,
// just everything valueable in here
std::string uuid_;
std::string name_, comment_;
std::string origin_, origin_comment_, text_;
std::string language_code_, codepage_;
std::string yname_, yunit_;
std::string xname_, xunit_;
double xstepwidth_, xoffset_;
// buffer and data
int signbits_, num_bytes_;
// unsigned long int byte_offset_;
unsigned long int buffer_offset_, buffer_size_;
int datatp_;
imc::datatype dattyp_;
std::vector<imc::datatype> ydata_;
std::vector<double> xdata_;
// range, factor and offset
double factor_, offset_;
// group reference the channel belongs to
int group_index_;
std::string group_uuid_, group_name_, group_comment_;
// constructor takes channel's block environment
channel(channel_env &chnenv, std::map<std::string,imc::block>* blocks,
std::vector<unsigned char>* buffer):
chnenv_(chnenv), blocks_(blocks), buffer_(buffer),
factor_(1.), offset_(0.),
group_index_(-1)
{
// declare list of block parameters
std::vector<imc::parameter> prms;
// use uuid from CN block
uuid_ = chnenv_.CNuuid_;
// extract associated CB data
if ( blocks_->count(chnenv_.CBuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CBuuid_).get_parameters();
group_index_ = std::stoi(blocks_->at(chnenv_.CBuuid_).get_parameter(prms[2]));
group_name_ = blocks_->at(chnenv_.CBuuid_).get_parameter(prms[4]);
group_comment_ = blocks_->at(chnenv_.CBuuid_).get_parameter(prms[6]);
}
// extract associated CT data
if ( blocks_->count(chnenv_.CTuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CTuuid_).get_parameters();
text_ = blocks_->at(chnenv_.CTuuid_).get_parameter(prms[4]) + std::string(" - ")
+ blocks_->at(chnenv_.CTuuid_).get_parameter(prms[6]) + std::string(" - ")
+ blocks_->at(chnenv_.CTuuid_).get_parameter(prms[8]);
}
// extract associated CD data
if ( blocks_->count(chnenv_.CDuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CDuuid_).get_parameters();
xstepwidth_ = std::stod(blocks_->at(chnenv_.CDuuid_).get_parameter(prms[2]));
xunit_ = blocks_->at(chnenv_.CDuuid_).get_parameter(prms[5]);
// TODO
// xname_ = std::string("time");
}
// extract associated CP data
if ( blocks_->count(chnenv_.CPuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CPuuid_).get_parameters();
num_bytes_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[3]));
datatp_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[4]));
signbits_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[5]));
// byte_offset_ = std::stoul(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[7]));
}
// extract associated Cb data
if ( blocks_->count(chnenv_.Cbuuid_) == 1 )
{
prms = blocks_->at(chnenv_.Cbuuid_).get_parameters();
buffer_offset_ = std::stoul(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[6]));
buffer_size_ = std::stoul(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[7]));
xoffset_ = std::stod(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[11]));
}
// extract associated CR data
if ( blocks_->count(chnenv_.CRuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CRuuid_).get_parameters();
factor_ = std::stod(blocks_->at(chnenv_.CRuuid_).get_parameter(prms[3]));
offset_ = std::stod(blocks_->at(chnenv_.CRuuid_).get_parameter(prms[4]));
yunit_ = blocks_->at(chnenv_.CRuuid_).get_parameter(prms[7]);
}
// extract associated CN data
if ( blocks_->count(chnenv_.CNuuid_) == 1 )
{
prms = blocks_->at(chnenv_.CNuuid_).get_parameters();
name_ = blocks_->at(chnenv_.CNuuid_).get_parameter(prms[6]);
yname_ = name_;
comment_ = blocks_->at(chnenv_.CNuuid_).get_parameter(prms[8]);
// group_index_ = std::stoi(blocks_->at(chnenv_.CNuuid_).get_parameter(prms[2]));
}
// extract associated NO data
if ( blocks_->count(chnenv_.NOuuid_) == 1 )
{
prms = blocks_->at(chnenv_.NOuuid_).get_parameters();
origin_ = blocks_->at(chnenv_.NOuuid_).get_parameter(prms[4]);
origin_comment_ = blocks_->at(chnenv_.NOuuid_).get_parameter(prms[6]);
}
// extract associated NL data
// codepage:
// - http://www.iana.org/assignments/character-sets/character-sets.xhtml
// - https://de.wikipedia.org/wiki/Zeichensatztabelle
// language-code:
// - https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c?redirectedfrom=MSDN
if ( blocks_->count(chnenv_.NLuuid_) == 1 )
{
prms = blocks_->at(chnenv_.NLuuid_).get_parameters();
codepage_ = blocks_->at(chnenv_.NLuuid_).get_parameter(prms[2]);
language_code_ = blocks_->at(chnenv_.NLuuid_).get_parameter(prms[3]);
}
// start converting binary buffer to imc::datatype
if ( !chnenv_.CSuuid_.empty() ) convert_buffer();
}
// convert buffer to actual datatype
void convert_buffer()
{
// TODO no clue how/if/when to handle buffer offset/mask/subsequent_bytes
// etc. and whatever that shit is!
std::vector<imc::parameter> prms = blocks_->at(chnenv_.CSuuid_).get_parameters();
if ( prms.size() < 4)
{
throw std::runtime_error("CS block is invalid and features to few parameters");
}
unsigned long int buffstrt = prms[3].begin();
std::vector<unsigned char> CSbuffer( buffer_->begin()+buffstrt+1,
buffer_->begin()+buffstrt+buffer_size_+1 );
// determine number of values in buffer
unsigned long int num_values = CSbuffer.size()/(signbits_/8);
if ( num_values*(signbits_/8) != CSbuffer.size() )
{
throw std::runtime_error("CSbuffer and significant bits of datatype don't match");
}
// adjust size of ydata
ydata_.resize(num_values);
// distinguish numeric datatypes included in "imc_datatype"
if ( datatp_ == 1 )
{
imc::convert_data_to_type<imc_Ubyte>(CSbuffer,ydata_);
}
else if ( datatp_ == 2 )
{
imc::convert_data_to_type<imc_Sbyte>(CSbuffer,ydata_);
}
else if ( datatp_ == 3 )
{
imc::convert_data_to_type<imc_Ushort>(CSbuffer,ydata_);
}
else if ( datatp_ == 4 )
{
imc::convert_data_to_type<imc_Sshort>(CSbuffer,ydata_);
}
else if ( datatp_ == 5 )
{
imc::convert_data_to_type<imc_Ulongint>(CSbuffer,ydata_);
}
else if ( datatp_ == 6 )
{
imc::convert_data_to_type<imc_Slongint>(CSbuffer,ydata_);
}
else if ( datatp_ == 7 )
{
imc::convert_data_to_type<imc_float>(CSbuffer,ydata_);
}
else if ( datatp_ == 8 )
{
imc::convert_data_to_type<imc_double>(CSbuffer,ydata_);
}
// ...
else if ( datatp_ == 11 )
{
imc::convert_data_to_type<imc_digital>(CSbuffer,ydata_);
}
else
{
throw std::runtime_error(std::string("unsupported/unknown datatype") + std::to_string(datatp_));
}
// fill xdata_
for ( unsigned long int i = 0; i < num_values; i++ )
{
xdata_.push_back(xoffset_+i*xstepwidth_);
}
// employ data transformation
if ( factor_ != 1.0 || offset_ != 0.0 )
{
for ( imc::datatype& el: ydata_ )
{
// std::cout<<"value:"<<el.as_double()<<"\n";
el = imc::datatype(el.as_double()*factor_ + offset_);
}
}
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"uuid:"<<uuid_<<"\n"
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n"
<<std::setw(width)<<std::left<<"origin:"<<origin_<<"\n"
<<std::setw(width)<<std::left<<"description:"<<text_<<"\n"
<<std::setw(width)<<std::left<<"language-code:"<<language_code_<<"\n"
<<std::setw(width)<<std::left<<"codepage:"<<codepage_<<"\n"
<<std::setw(width)<<std::left<<"yname:"<<yname_<<"\n"
<<std::setw(width)<<std::left<<"yunit:"<<yunit_<<"\n"
<<std::setw(width)<<std::left<<"datatype:"<<datatp_<<"\n"
<<std::setw(width)<<std::left<<"significant bits:"<<signbits_<<"\n"
<<std::setw(width)<<std::left<<"buffer-offset:"<<buffer_offset_<<"\n"
<<std::setw(width)<<std::left<<"buffer-size:"<<buffer_size_<<"\n"
<<std::setw(width)<<std::left<<"xname:"<<xname_<<"\n"
<<std::setw(width)<<std::left<<"xunit:"<<xunit_<<"\n"
<<std::setw(width)<<std::left<<"xstepwidth:"<<xstepwidth_<<"\n"
<<std::setw(width)<<std::left<<"xoffset:"<<xoffset_<<"\n"
<<std::setw(width)<<std::left<<"factor:"<<factor_<<"\n"
<<std::setw(width)<<std::left<<"offset:"<<offset_<<"\n"
<<std::setw(width)<<std::left<<"group:"<<"("<<group_index_<<","<<group_name_
<<","<<group_comment_<<")"<<"\n"
<<std::setw(width)<<std::left<<"ydata:"<<imc::joinvec<imc::datatype>(ydata_)<<"\n"
<<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<double>(xdata_)<<"\n";
// <<std::setw(width)<<std::left<<"aff. blocks:"<<chnenv_.get_json()<<"\n";
return ss.str();
}
// provide JSON string of metadata
std::string get_json(bool include_data = false)
{
std::stringstream ss;
ss<<"{"<<"\"uuid\":\""<<uuid_
<<"\",\"name\":\""<<name_
<<"\",\"comment\":\""<<comment_
<<"\",\"origin\":\""<<origin_
<<"\",\"description\":\""<<text_
<<"\",\"language-code\":\""<<language_code_
<<"\",\"codepage\":\""<<codepage_
<<"\",\"yname\":\""<<yname_
<<"\",\"yunit\":\""<<yunit_
<<"\",\"significantbits\":\""<<signbits_
<<"\",\"xname\":\""<<xname_
<<"\",\"xunit\":\""<<xunit_
<<"\",\"xstepwidth\":\""<<xstepwidth_
<<"\",\"xoffset\":\""<<xoffset_
<<"\",\"group\":{"<<"\"index\":\""<<group_index_
<<"\",\"name\":\""<<group_name_
<<"\",\"comment\":\""<<group_comment_<<"\""<<"}";
if ( include_data )
{
ss<<",\"ydata\":"<<imc::joinvec<imc::datatype>(ydata_,0)
<<",\"xdata\":"<<imc::joinvec<double>(xdata_,0);
}
// ss<<"\",\"aff. blocks\":\""<<chnenv_.get_json()
ss<<"}";
return ss.str();
}
// print channel
void print(std::string filename, const char sep = ',', int width = 25)
{
std::ofstream fou(filename);
// header
if ( sep == ' ' )
{
fou<<std::setw(width)<<std::left<<xname_
<<std::setw(width)<<std::left<<yname_<<"\n"
<<std::setw(width)<<std::left<<xunit_
<<std::setw(width)<<std::left<<yunit_<<"\n";
}
else
{
fou<<xname_<<sep<<yname_<<"\n"<<xunit_<<sep<<yunit_<<"\n";
}
for ( unsigned long int i = 0; i < xdata_.size(); i++ )
{
if ( sep == ' ' )
{
fou<<std::setprecision(9)<<std::fixed
<<std::setw(width)<<std::left<<xdata_[i]
<<std::setw(width)<<std::left<<ydata_[i]<<"\n";
}
else
{
fou<<xdata_[i]<<sep<<ydata_[i]<<"\n";
}
}
fou.close();
}
};
}
#endif
//---------------------------------------------------------------------------//

51
lib/imc_conversion.hpp Normal file
View File

@@ -0,0 +1,51 @@
//---------------------------------------------------------------------------//
#ifndef IMCCONVRSION
#define IMCCONVERSION
#include <vector>
//---------------------------------------------------------------------------//
namespace imc
{
// convert raw data in buffer into specific datatype
template<typename datatype>
void convert_data_to_type(std::vector<unsigned char>& subbuffer,
std::vector<imc::datatype>& channel)
{
// check number of elements of type "datatype" in buffer
if ( subbuffer.size() != channel.size()*sizeof(datatype) )
{
throw std::runtime_error( std::string("size mismatch between subbuffer (")
+ std::to_string(subbuffer.size())
+ std::string(") and datatype (")
+ std::to_string(channel.size()) + std::string("*")
+ std::to_string(sizeof(datatype)) + std::string(")") );
}
// extract every single number of type "datatype" from buffer
for ( unsigned long int i = 0; i < channel.size(); i++ )
{
// declare number of required type and point it to first byte in buffer
// representing the number
datatype df;
uint8_t* dfcast = reinterpret_cast<uint8_t*>(&df);
for ( unsigned long int j = 0; j < sizeof(datatype); j++ )
{
dfcast[j] = (int)subbuffer[i*sizeof(datatype)+j];
}
// save number in channel
channel[i] = df;
}
// for ( auto el: channel ) std::cout<<el<<"\n";
}
}
#endif
//---------------------------------------------------------------------------//

202
lib/imc_datatype.hpp Normal file
View File

@@ -0,0 +1,202 @@
//---------------------------------------------------------------------------//
#ifndef IMCDATATYPE
#define IMCDATATYPE
//---------------------------------------------------------------------------//
namespace imc
{
// map datatype to machine's datatypes
typedef unsigned char imc_Ubyte;
typedef signed char imc_Sbyte;
//
typedef unsigned short imc_Ushort;
typedef signed short imc_Sshort;
//
// e.g. ARM Cortex-A72 armv7l gcc version 10.2.0 (Ubuntu 10.2.0-13ubuntu1)
// #ifdef __arm__
typedef unsigned long int imc_Ulongint;
typedef signed long int imc_Slongint;
// e.g. Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz x86_64 gcc version 10.2.0 (Ubuntu 10.2.0-13ubuntu1)
// #ifdef i386 __i386 __i386__
// typedef unsigned int imc_Ulongint;
// typedef signed int imc_Slongint;
//
typedef float imc_float;
typedef double imc_double;
//
// TODO not all remaining types are supported yet
// typedef <whatever that is ->... > "imc Devices Transitional Recording"
// typedf <sometimestamptype> "Timestamp Ascii"
typedef char16_t imc_digital;
// typedef < > imc_sixbyte "6byte unsigned long"
class datatype
{
protected:
imc_Ubyte ubyte_; // 0
imc_Sbyte sbyte_; // 1
imc_Ushort ushort_; // 2
imc_Sshort sshort_; // 3
imc_Ulongint ulint_; // 4
imc_Slongint slint_; // 5
imc_float sfloat_; // 6
imc_double sdouble_; // 7
imc_digital sdigital_; // 10
short int dtidx_; // \in \{0,...,7,10\}
public:
datatype(): ubyte_(0), sbyte_(0),
ushort_(0), sshort_(0),
ulint_(0.0), slint_(0.0),
sfloat_(0.0), sdouble_(0.0),
sdigital_(0),
dtidx_(0) { };
// every supported datatype gets its own constructor
datatype(imc_Ubyte num): ubyte_(num), dtidx_(0) {};
datatype(imc_Sbyte num): sbyte_(num), dtidx_(1) {};
datatype(imc_Ushort num): ushort_(num), dtidx_(2) {};
datatype(imc_Sshort num): sshort_(num), dtidx_(3) {};
datatype(imc_Ulongint num): ulint_(num), dtidx_(4) {};
datatype(imc_Slongint num): slint_(num), dtidx_(5) {};
datatype(imc_float num): sfloat_(num), dtidx_(6) {};
datatype(imc_double num): ubyte_(0), sbyte_(0), ushort_(0), sshort_(0),
ulint_(0.0), slint_(0.0), sfloat_(0.0), sdouble_(num),
sdigital_(0), dtidx_(7) {};
datatype(imc_digital num): ubyte_(0), sbyte_(0), ushort_(0), sshort_(0),
ulint_(0.0), slint_(0.0), sfloat_(0.0), sdouble_(num),
sdigital_(num), dtidx_(10) {};
// identify type
short int& dtype() { return dtidx_; }
// copy constructor
datatype(const datatype &num)
{
this->ubyte_ = num.ubyte_;
this->sbyte_ = num.sbyte_;
this->ushort_ = num.ushort_;
this->sshort_ = num.sshort_;
this->ulint_ = num.ulint_;
this->slint_ = num.slint_;
this->sfloat_ = num.sfloat_;
this->sdouble_ = num.sdouble_;
this->sdigital_ = num.sdigital_;
this->dtidx_ = num.dtidx_;
}
// overall assignment operator
datatype& operator=(const datatype &num)
{
if ( this != &num )
{
this->ubyte_ = num.ubyte_;
this->sbyte_ = num.sbyte_;
this->ushort_ = num.ushort_;
this->sshort_ = num.sshort_;
this->ulint_ = num.ulint_;
this->slint_ = num.slint_;
this->sfloat_ = num.sfloat_;
this->sdouble_ = num.sdouble_;
this->sdigital_ = num.sdigital_;
this->dtidx_ = num.dtidx_;
}
return *this;
}
// implement assignment operator for individual datatypes
datatype& operator=(const imc_Ubyte &num)
{
this->ubyte_ = num;
this->dtidx_ = 0;
return *this;
}
datatype& operator=(const imc_Sbyte &num)
{
this->sbyte_ = num;
this->dtidx_ = 1;
return *this;
}
datatype& operator=(const imc_Ushort &num)
{
this->ushort_ = num;
this->dtidx_ = 2;
return *this;
}
datatype& operator=(const imc_Sshort &num)
{
this->sshort_ = num;
this->dtidx_ = 3;
return *this;
}
datatype& operator=(const imc_Ulongint &num)
{
this->ulint_ = num;
this->dtidx_ = 4;
return *this;
}
datatype& operator=(const imc_Slongint &num)
{
this->slint_ = num;
this->dtidx_ = 5;
return *this;
}
datatype& operator=(const imc_float &num)
{
this->sfloat_ = num;
this->dtidx_ = 6;
return *this;
}
datatype& operator=(const imc_double &num)
{
this->sdouble_ = num;
this->dtidx_ = 7;
return *this;
}
datatype& operator=(const imc_digital &num)
{
this->sdigital_ = num;
this->dtidx_ = 10;
return *this;
}
// obtain number as double
double as_double()
{
double num = 0.0;
if ( dtidx_ == 0 ) num = (double)ubyte_;
else if ( dtidx_ == 1 ) num = (double)sbyte_;
else if ( dtidx_ == 2 ) num = (double)ushort_;
else if ( dtidx_ == 3 ) num = (double)sshort_;
else if ( dtidx_ == 4 ) num = (double)ulint_;
else if ( dtidx_ == 5 ) num = (double)slint_;
else if ( dtidx_ == 6 ) num = (double)sfloat_;
else if ( dtidx_ == 7 ) num = (double)sdouble_;
else if ( dtidx_ == 10 ) num = static_cast<double>(sdigital_);
return num;
}
// define custom stream operator to print the correct type
friend std::ostream& operator<<(std::ostream& out, const datatype& num)
{
if ( num.dtidx_ == 0 ) out<<num.ubyte_;
else if ( num.dtidx_ == 1 ) out<<num.sbyte_;
else if ( num.dtidx_ == 2 ) out<<num.ushort_;
else if ( num.dtidx_ == 3 ) out<<num.sshort_;
else if ( num.dtidx_ == 4 ) out<<num.ulint_;
else if ( num.dtidx_ == 5 ) out<<num.slint_;
else if ( num.dtidx_ == 6 ) out<<num.sfloat_;
else if ( num.dtidx_ == 7 ) out<<num.sdouble_;
else if ( num.dtidx_ == 10 ) out<<static_cast<double>(num.sdigital_);
return out;
}
};
}
#endif
//---------------------------------------------------------------------------//

135
lib/imc_key.hpp Normal file
View File

@@ -0,0 +1,135 @@
//---------------------------------------------------------------------------//
#ifndef IMCKEY
#define IMCKEY
#include <iomanip>
#include <map>
#include <string>
#include <sstream>
#include <vector>
//---------------------------------------------------------------------------//
namespace imc
{
// define "magic bytes" announcing critical (=C) non-critical keys (=N)
const unsigned char key_crit_ = 0x43, key_non_crit_ = 0x4e;
// define properties of marker/key
struct key
{
// (non)critical key
bool critical_;
// name of key (two uppercase letters)
std::string name_;
// short description
std::string description_;
// version of marker
int version_;
// constructor
key(bool critical, std::string name,
std::string description = std::string(""), int version = -1)
{
critical_ = critical;
if ( name.size() != 2 ) throw std::logic_error("invalid key name");
name_ = name;
description_ = description;
version_ = version;
}
// comparison operator
bool operator==(const key& akey)
{
return ( this->critical_ == akey.critical_
&& this->name_ == akey.name_
&& this->description_ == akey.description_
&& this->version_ == akey.version_ );
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"critical:"<<(critical_?"yes":"no")<<"\n"
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
<<std::setw(width)<<std::left<<"description:"<<description_<<"\n"
<<std::setw(width)<<std::left<<"version:"<<version_<<"\n";
return ss.str();
}
};
const std::vector<key> keys = {
// critical keys
key(true,"CF","format version and processor",2),
key(true,"CK","start of group of keys",1),
key(true,"CB","group of channels",1),
key(true,"CT","text definition",1),
key(true,"CG","group of components",1),
key(true,"CD","abscissa description",1),
key(true,"CD","abscissa description",2),
key(true,"CZ","scaling of z-axis",1),
key(true,"CC","start of component",1),
key(true,"CP","buffer, datatype and samples of component",1),
key(true,"Cb","buffer description",1),
key(true,"CR","permissible range of values in component",1),
key(true,"CN","name and comment of channel",1),
key(true,"CS","raw binary data",1),
key(true,"CI","single numerical value",1),
key(true,"Ca","add reference key",1),
// noncritical keys
key(false,"NO","origin of data",1),
key(false,"NT","timestamp of trigger",1),
key(false,"ND","(color) display properties",1),
key(false,"NU","user defined key",1),
key(false,"Np","property of channel",1),
key(false,"NE","extraction rule for BUS channels",1),
key(false,"NL","language info and code page",1)
};
// check for existence of specific key
bool check_key(key& mykey)
{
for ( key ky: keys ) if ( mykey == ky ) return true;
return false;
}
// get key (with respect to name and evtl. version)
key get_key(bool critical, std::string name, int version = -1)
{
// check validity of required key name
if ( name.size() > 2 || name.size() < 1 )
{
throw std::runtime_error(std::string("invalid key name: ") + name);
}
// declare new key with available data
key mykey(critical,name,std::string(""),version);
// try to find matching key in list of predefined keys
for ( key ky: keys )
{
if ( critical == ky.critical_ && name == ky.name_
&& ( version == ky.version_ || version == -1 ) )
{
mykey = ky;
// provide first match
return mykey;
}
}
return mykey;
}
}
#endif
//---------------------------------------------------------------------------//

700
lib/imc_object.hpp Normal file
View File

@@ -0,0 +1,700 @@
//---------------------------------------------------------------------------//
#ifndef IMCOBJECT
#define IMCOBJECT
#include <time.h>
#include "imc_key.hpp"
//---------------------------------------------------------------------------//
namespace imc
{
// obtain specific parameters as string
std::string get_parameter(const std::vector<unsigned char>* buffer, const imc::parameter* param)
{
std::string prm("");
for ( unsigned long int i = param->begin()+1; i <= param->end(); i++ )
{
prm.push_back((char)(*buffer)[i]);
}
return prm;
}
// format and processor (corresponds to key CF)
struct format
{
int fileformat_;
int processor_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 3 ) throw std::runtime_error("invalid number of parameters in CF");
fileformat_ = std::stoi(get_parameter(buffer,&parameters[0]));
processor_ = std::stoi(get_parameter(buffer,&parameters[2]));
}
format(): fileformat_(-1), processor_(-1) {}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"format:"<<fileformat_<<"\n"
<<std::setw(width)<<std::left<<"processor:"<<processor_<<"\n";
return ss.str();
}
};
// start of group of keys (corresponds to key CK)
struct keygroup
{
int version_;
int length_;
bool closed_; // corresponds to true = 1 and false = 0 in file
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 2 ) throw std::runtime_error("invalid number of parameters in CK");
version_ = std::stoi(get_parameter(buffer,&parameters[0]));
length_ = std::stoi(get_parameter(buffer,&parameters[1]));
closed_ = ( get_parameter(buffer,&parameters[3])==std::string("1") );
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"version:"<<version_<<"\n"
<<std::setw(width)<<std::left<<"length:"<<length_<<"\n"
<<std::setw(width)<<std::left<<"closed:"<<(closed_?"yes":"no")<<"\n";
return ss.str();
}
};
// group definition (corresponds to key CB)
struct groupobj
{
unsigned long int group_index_;
std::string name_;
std::string comment_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 7 ) throw std::runtime_error("invalid number of parameters in CB");
group_index_ = std::stoul(get_parameter(buffer,&parameters[2]));
name_ = get_parameter(buffer,&parameters[4]);
comment_ = get_parameter(buffer,&parameters[6]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"group-index:"<<group_index_<<"\n"
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n";
return ss.str();
}
};
// text definition (corresponds to key CT)
struct text
{
unsigned long int group_index_; // corresponding to group-index in CB block
std::string name_;
std::string text_;
std::string comment_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 9 ) throw std::runtime_error("invalid number of parameters in CT");
group_index_ = std::stoul(get_parameter(buffer,&parameters[2]));
name_ = get_parameter(buffer,&parameters[4]);
text_ = get_parameter(buffer,&parameters[6]);
comment_ = get_parameter(buffer,&parameters[8]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"group-index:"<<group_index_<<"\n"
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
<<std::setw(width)<<std::left<<"text:"<<text_<<"\n"
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n";
return ss.str();
}
};
enum fieldtype {
realnumber = 1, // 1
xmonotony, // 2
xy, // 3
complexrealimag, // 4
complexabsphase, // 5
complexdbphase // 6
};
// definition of data field (corresponds to key CG)
struct datafield
{
unsigned long int number_components_;
fieldtype fldtype_;
int dimension_; // corresponding to fieldtype \in {1,}
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 5 ) throw std::runtime_error("invalid number of parameters in CG");
number_components_ = std::stoul(get_parameter(buffer,&parameters[2]));
fldtype_ = (fieldtype)std::stoi(get_parameter(buffer,&parameters[3]));
dimension_ = std::stoi(get_parameter(buffer,&parameters[4]));
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"#components:"<<number_components_<<"\n"
<<std::setw(width)<<std::left<<"fieldtype:"<<fldtype_<<"\n"
<<std::setw(width)<<std::left<<"dimension:"<<dimension_<<"\n";
return ss.str();
}
};
// definition of abscissa (corresponds to key CD1)
struct abscissa
{
double dx_;
bool calibration_;
std::string unit_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 6 ) throw std::runtime_error("invalid number of parameters in CD1");
dx_ = std::stod(get_parameter(buffer,&parameters[2]));
calibration_ = ( get_parameter(buffer,&parameters[3]) == std::string("1") );
unit_ = get_parameter(buffer,&parameters[5]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"dx:"<<dx_<<"\n"
<<std::setw(width)<<std::left<<"calibration:"<<(calibration_?"yes":"no")<<"\n"
<<std::setw(width)<<std::left<<"unit:"<<unit_<<"\n";
return ss.str();
}
};
// definition of abscissa (corresponds to key CD2)
struct abscissa2
{
double dx_;
bool calibration_;
std::string unit_;
bool reduction_;
bool ismultievent_;
bool sortbuffer_;
double x0_;
int pretriggerapp_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 11 ) throw std::runtime_error("invalid number of parameters in CD2");
dx_ = std::stod(get_parameter(buffer,&parameters[2]));
calibration_ = ( get_parameter(buffer,&parameters[3]) == std::string("1") );
unit_ = get_parameter(buffer,&parameters[5]);
reduction_ = ( get_parameter(buffer,&parameters[6]) == std::string("1") );
ismultievent_ = ( get_parameter(buffer,&parameters[7]) == std::string("1") );
sortbuffer_ = ( get_parameter(buffer,&parameters[8]) == std::string("1") );
x0_ = std::stod(get_parameter(buffer,&parameters[9]));
pretriggerapp_ = std::stoi( get_parameter(buffer,&parameters[10]) );
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"dx:"<<dx_<<"\n"
<<std::setw(width)<<std::left<<"calibration:"<<(calibration_?"yes":"no")<<"\n"
<<std::setw(width)<<std::left<<"unit:"<<unit_<<"\n"
<<std::setw(width)<<std::left<<"reduction:"<<reduction_<<"\n"
<<std::setw(width)<<std::left<<"ismultievent:"<<ismultievent_<<"\n"
<<std::setw(width)<<std::left<<"sortbuffer:"<<sortbuffer_<<"\n"
<<std::setw(width)<<std::left<<"x0:"<<x0_<<"\n"
<<std::setw(width)<<std::left<<"pretriggerapp:"<<pretriggerapp_<<"\n";
return ss.str();
}
};
// start of component (corresponds to key CC)
struct component
{
int component_index_;
bool analog_digital_; // 1 => false (analog), 2 => true (digital)
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 4 ) throw std::runtime_error("invalid number of parameters in CD2");
component_index_ = std::stoi(get_parameter(buffer,&parameters[2]));
analog_digital_ = ( std::stoi(get_parameter(buffer,&parameters[3])) == 2 );
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"index:"<<component_index_<<"\n"
<<std::setw(width)<<std::left<<"analog/digital:"<<(analog_digital_?"digital":"analog")<<"\n";
return ss.str();
}
};
enum numtype {
unsigned_byte = 1,
signed_byte,
unsigned_short,
signed_short,
unsigned_long,
signed_long,
ffloat,
ddouble,
imc_devices_transitional_recording,
timestamp_ascii,
two_byte_word_digital,
six_byte_unsigned_long
};
// packaging information of component (corresponds to key CP)
struct packaging
{
unsigned long int buffer_reference_;
int bytes_;
numtype numeric_type_;
int signbits_;
int mask_;
unsigned long int offset_;
unsigned long int number_subsequent_samples_;
unsigned long int distance_bytes_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 10 ) throw std::runtime_error("invalid number of parameters in CP");
buffer_reference_ = std::stoi(get_parameter(buffer,&parameters[2]));
numeric_type_ = (numtype)std::stoi(get_parameter(buffer,&parameters[3]));
bytes_ = std::stoi(get_parameter(buffer,&parameters[4]));
signbits_ = std::stoi(get_parameter(buffer,&parameters[5]));
mask_ = std::stoi(get_parameter(buffer,&parameters[6]));
offset_ = std::stoul(get_parameter(buffer,&parameters[7]));
number_subsequent_samples_ = std::stoul(get_parameter(buffer,&parameters[8]));
distance_bytes_ = std::stoul(get_parameter(buffer,&parameters[9]));
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"buffer-reference:"<<buffer_reference_<<"\n"
<<std::setw(width)<<std::left<<"datatype:"<<numeric_type_<<"\n"
<<std::setw(width)<<std::left<<"significant bits:"<<signbits_<<"\n"
<<std::setw(width)<<std::left<<"mask:"<<mask_<<"\n"
<<std::setw(width)<<std::left<<"offset:"<<offset_<<"\n"
<<std::setw(width)<<std::left<<"#subseq.-samples:"<<number_subsequent_samples_<<"\n"
<<std::setw(width)<<std::left<<"distance in bytes:"<<distance_bytes_<<"\n";
return ss.str();
}
};
// buffer description (corresponds to key Cb)
struct buffer
{
unsigned long int number_buffers_;
unsigned long int bytes_userinfo_;
// for every single buffer
unsigned long int buffer_reference_; // corresponds to buffer_reference_ in key CP
unsigned long int sample_index_; // corresponds to index of CS key
unsigned long int offset_buffer_; // number of bytes from beginning of CS key
unsigned long int number_bytes_; // number of bytes in buffer
unsigned long int offset_first_sample_;
unsigned long int number_filled_bytes_;
double x0_;
double add_time_; // start of trigger time = NT + add_time
// bool user_info_;
// bool new_event_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 13 ) throw std::runtime_error("invalid number of parameters in CD2");
number_buffers_ = std::stoul(get_parameter(buffer,&parameters[2]));
bytes_userinfo_ = std::stoul(get_parameter(buffer,&parameters[3]));
buffer_reference_ = std::stoul(get_parameter(buffer,&parameters[4]));
sample_index_ = std::stoul(get_parameter(buffer,&parameters[5]));
offset_buffer_ = std::stoul(get_parameter(buffer,&parameters[6]));
number_bytes_ = std::stoul(get_parameter(buffer,&parameters[7]));
offset_first_sample_ = std::stoul(get_parameter(buffer,&parameters[8]));
number_filled_bytes_ = std::stoul(get_parameter(buffer,&parameters[9]));
x0_ = std::stod(get_parameter(buffer,&parameters[11]));
add_time_ = std::stod(get_parameter(buffer,&parameters[12]));
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"#buffers:"<<number_buffers_<<"\n"
<<std::setw(width)<<std::left<<"bytes user info:"<<bytes_userinfo_<<"\n"
<<std::setw(width)<<std::left<<"buffer reference:"<<buffer_reference_<<"\n"
<<std::setw(width)<<std::left<<"sample index:"<<sample_index_<<"\n"
<<std::setw(width)<<std::left<<"offset buffer:"<<offset_buffer_<<"\n"
<<std::setw(width)<<std::left<<"buffer size:"<<number_bytes_<<"\n"
<<std::setw(width)<<std::left<<"offset sample:"<<offset_first_sample_<<"\n"
<<std::setw(width)<<std::left<<"#filled bytes:"<<number_filled_bytes_<<"\n"
<<std::setw(width)<<std::left<<"time offset:"<<x0_<<"\n"
<<std::setw(width)<<std::left<<"add time:"<<add_time_<<"\n";
return ss.str();
}
};
// range of values of component (corresponds to key CR)
struct range
{
bool transform_; // 1 = true: yes, requires offset + factor, 0 = false: no
double factor_, offset_; // value = raw value * factor + offset
bool calibration_; // 1 = true: calibration, 0 = false: no calibration
std::string unit_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 8 ) throw std::runtime_error("invalid number of parameters in CD2");
transform_ = (get_parameter(buffer,&parameters[2]) == std::string("1"));
factor_ = std::stod(get_parameter(buffer,&parameters[3]));
offset_ = std::stod(get_parameter(buffer,&parameters[4]));
calibration_ = (get_parameter(buffer,&parameters[5]) == std::string("1"));
unit_ = get_parameter(buffer,&parameters[7]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"transform:"<<(transform_?"yes":"no")<<"\n"
<<std::setw(width)<<std::left<<"factor:"<<factor_<<"\n"
<<std::setw(width)<<std::left<<"offset:"<<offset_<<"\n"
<<std::setw(width)<<std::left<<"calibration:"<<(calibration_?"yes":"no")<<"\n"
<<std::setw(width)<<std::left<<"unit:"<<unit_<<"\n";
return ss.str();
}
};
// channel (corresponds to key CN)
struct channelobj
{
unsigned long int group_index_; // corresponds to group-index in CB key
bool index_bit_; // true = 1: digital, false = 0: analog
std::string name_;
std::string comment_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 9 ) throw std::runtime_error("invalid number of parameters in CD2");
group_index_ = std::stoul(get_parameter(buffer,&parameters[2]));
index_bit_ = (get_parameter(buffer,&parameters[4]) == std::string("1"));
name_ = get_parameter(buffer,&parameters[6]);
comment_ = get_parameter(buffer,&parameters[8]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"group-index:"<<group_index_<<"\n"
<<std::setw(width)<<std::left<<"index-bit:"<<index_bit_<<"\n"
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n";
return ss.str();
}
};
// rawdata (corresponds to key CS)
struct data
{
unsigned long int index_; // starting from 1 in first CS block in file
// std::vector<unsigned char> rawdata_;
// unsigned long int begin_buffer_, end_buffer_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 4 ) throw std::runtime_error("invalid number of parameters in CD2");
index_ = std::stoul(get_parameter(buffer,&parameters[2]));
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"index:"<<index_<<"\n";
// <<std::setw(width)<<std::left<<"(begin,end) buffer:"
// <<"("<<begin_buffer_<<","<<end_buffer_<<")"<<"\n";
return ss.str();
}
};
// origin of data (corresponds to key NO)
struct origin_data
{
bool origin_; // corresponds to true = 1 ("verrechnet") and false = 0 ("Original")
std::string generator_;
std::string comment_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 7 ) throw std::runtime_error("invalid number of parameters in CD2");
origin_ = ( get_parameter(buffer,&parameters[2]) == std::string("1") );
generator_ = get_parameter(buffer,&parameters[4]);
comment_ = get_parameter(buffer,&parameters[6]);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"origin:"<<(origin_?"verrechnet":"Original")<<"\n"
<<std::setw(width)<<std::left<<"generator:"<<generator_<<"\n"
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n";
return ss.str();
}
};
// trigger timestamp (corresponds to key NT1)
struct triggertime
{
int day_, month_, year_;
int hour_, minute_;
double second_;
std::string timestamp_;
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 8 ) throw std::runtime_error("invalid number of parameters in CD2");
day_ = std::stoi( get_parameter(buffer,&parameters[2]) );
month_ = std::stoi( get_parameter(buffer,&parameters[3]) );
year_ = std::stoi( get_parameter(buffer,&parameters[4]) );
hour_ = std::stoi( get_parameter(buffer,&parameters[5]) );
minute_ = std::stoi( get_parameter(buffer,&parameters[6]) );
second_ = std::stod( get_parameter(buffer,&parameters[7]) );
time_t rawtime;
struct tm ts;
time(&rawtime);
localtime_r(&rawtime,&ts);
ts.tm_mday = day_;
ts.tm_mon = month_-1;
ts.tm_year = year_-1900;
ts.tm_hour = hour_;
ts.tm_min = minute_;
ts.tm_sec = (int)second_;
asctime_r(&ts,&timestamp_[0]);
// timestamp_ = std::to_string(year_) + std::string("-") + std::to_string(month_)
// + std::string("-") + std::to_string(day_)
// + std::string("T") + std::to_string(hour_)
// + std::string(":") + std::to_string(minute_)
// + std::string(":") + std::to_string(second_);
}
// get info string
std::string get_info(int width = 20)
{
std::stringstream ss;
ss<<std::setw(width)<<std::left<<"timestamp:"<<timestamp_<<"\n";
return ss.str();
}
};
}
namespace imc {
// create wrapper for imc_object types
// (not particularly memory-efficient but it simplifies the remaining stuff
// considerably and the structs are pretty small anyway!)
class rawobject
{
format fmt_; // 0
keygroup kyg_; // 1
groupobj grp_; // 2
text txt_; // 3
datafield dtf_; // 4
abscissa abs_; // 5
component cmt_; // 6
packaging pkg_; // 7
buffer bfr_; // 8
range rng_; // 9
channelobj chn_; // 10
data dat_; // 11
origin_data org_; // 12
triggertime trt_; // 13
abscissa2 abs2_; // 14
int objidx_;
public:
rawobject(): objidx_(-1) { }
void parse(imc::key key, const std::vector<unsigned char>* buffer,
const std::vector<parameter>& parameters)
{
if ( key.name_ == std::string("CF") )
{
fmt_.parse(buffer,parameters);
objidx_ = 0;
}
else if ( key.name_ == std::string("CK") )
{
kyg_.parse(buffer,parameters);
objidx_ = 1;
}
else if ( key.name_ == std::string("CB") )
{
grp_.parse(buffer,parameters);
objidx_ = 2;
}
else if ( key.name_ == std::string("CT") )
{
txt_.parse(buffer,parameters);
objidx_ = 3;
}
else if ( key.name_ == std::string("CG") )
{
dtf_.parse(buffer,parameters);
objidx_ = 4;
}
else if ( key.name_ == std::string("CD") && key.version_ == 1 )
{
abs_.parse(buffer,parameters);
objidx_ = 5;
}
else if ( key.name_ == std::string("CC") )
{
cmt_.parse(buffer,parameters);
objidx_ = 6;
}
else if ( key.name_ == std::string("CP") )
{
pkg_.parse(buffer,parameters);
objidx_ = 7;
}
else if ( key.name_ == std::string("Cb") )
{
bfr_.parse(buffer,parameters);
objidx_ = 8;
}
else if ( key.name_ == std::string("CR") )
{
rng_.parse(buffer,parameters);
objidx_ = 9;
}
else if ( key.name_ == std::string("CN") )
{
chn_.parse(buffer,parameters);
objidx_ = 10;
}
else if ( key.name_ == std::string("CS") )
{
dat_.parse(buffer,parameters);
objidx_ = 11;
}
else if ( key.name_ == std::string("NO") )
{
org_.parse(buffer,parameters);
objidx_ = 12;
}
else if ( key.name_ == std::string("NT") && key.version_ == 1 )
{
trt_.parse(buffer,parameters);
objidx_ = 13;
}
else if ( key.name_ == std::string("CD") && key.version_ == 2 )
{
abs2_.parse(buffer,parameters);
objidx_ = 14;
}
else
{
if ( key.name_.at(0) == 'C' )
{
throw std::logic_error(
std::string("unsupported block associated to critical key ")
+ key.name_ + std::to_string(key.version_)
);
}
else
{
std::cout<<"WARNING: unsupported block associated to noncritical key "
<<key.name_<<key.version_<<"\n";
}
}
}
// provide info string
std::string get_info(int width = 20)
{
switch (objidx_) {
case 0:
return fmt_.get_info();
case 1:
return kyg_.get_info();
case 2:
return grp_.get_info();
case 3:
return txt_.get_info();
case 4:
return dtf_.get_info();
case 5:
return abs_.get_info();
case 6:
return cmt_.get_info();
case 7:
return pkg_.get_info();
case 8:
return bfr_.get_info();
case 9:
return rng_.get_info();
case 10:
return chn_.get_info();
case 11:
return dat_.get_info();
case 12:
return org_.get_info();
case 13:
return trt_.get_info();
case 14:
return abs2_.get_info();
default:
return std::string("");
}
}
};
}
#endif
//---------------------------------------------------------------------------//

73
lib/imc_parameter.hpp Normal file
View File

@@ -0,0 +1,73 @@
//---------------------------------------------------------------------------//
#ifndef IMCPARAMETER
#define IMCPARAMETER
#include <iomanip>
#include <map>
#include <string>
#include <sstream>
#include <vector>
//---------------------------------------------------------------------------//
namespace imc
{
// single parameter (in a block) is determined by offset of its first/last byte
class parameter
{
// offset of first/last byte of parameter
unsigned long int begin_, end_;
public:
parameter(unsigned long int begin, unsigned long int end):
begin_(begin), end_(end)
{
if ( end_ < begin_ )
{
throw std::logic_error("parameter: offset of first byte larger than last byte's offset");
}
}
// set members
void begin(unsigned long int begin)
{
if ( end_ < begin )
{
throw std::logic_error("parameter: offset of first byte larger than last byte's offset");
}
begin_ = begin;
}
void end(unsigned long int end)
{
if ( end < begin_ )
{
throw std::logic_error("parameter: offset of first byte larger than last byte's offset");
}
end_ = end;
}
// access members
const unsigned long int& begin() const { return begin_; }
const unsigned long int& end() const { return end_; }
// comparison operator
bool operator==(const parameter& param)
{
return ( this->begin_ == param.begin_ && this->end_ == param.end_ );
}
// get info
std::string get_info() const
{
return ( std::string("[") + std::to_string(begin_) + std::string(",")
+ std::to_string(end_) + std::string("]") );
}
};
}
#endif
//---------------------------------------------------------------------------//

390
lib/imc_raw.hpp Normal file
View File

@@ -0,0 +1,390 @@
//---------------------------------------------------------------------------//
#ifndef IMCRAW
#define IMCRAW
#include <fstream>
#include <filesystem>
#include <iostream>
// #include "hexshow.hpp"
#include "imc_key.hpp"
#include "imc_block.hpp"
#include "imc_datatype.hpp"
#include "imc_object.hpp"
#include "imc_result.hpp"
#include "imc_channel.hpp"
//---------------------------------------------------------------------------//
namespace imc
{
class raw
{
// (path of) raw-file and its basename
std::string raw_file_, file_name_;
// buffer of raw-file
std::vector<unsigned char> buffer_;
// list and map of imc-blocks
std::vector<imc::block> rawblocks_;
std::map<std::string,imc::block> mapblocks_;
// check computational complexity for parsing blocks
unsigned long int cplxcnt_;
// list groups and channels (including their affiliate blocks)
std::map<std::string,imc::channel> channels_;
public:
// constructor
raw() { };
raw(std::string raw_file): raw_file_(raw_file) { set_file(raw_file); };
// provide new raw-file
void set_file(std::string raw_file)
{
raw_file_ = raw_file;
this->fill_buffer();
this->parse_blocks();
this->generate_block_map();
this->generate_channel_env();
}
private:
// open file and stream data into buffer
void fill_buffer()
{
// open file and put data in buffer
try {
std::ifstream fin(raw_file_.c_str(),std::ifstream::binary);
if ( !fin.good() ) throw std::runtime_error("failed to open file");
std::vector<unsigned char> buffer((std::istreambuf_iterator<char>(fin)),
(std::istreambuf_iterator<char>()));
buffer_ = buffer;
fin.close();
} catch ( const std::exception& e ) {
throw std::runtime_error(
std::string("failed to open raw-file and stream data in buffer: ") + e.what()
);
}
}
// parse all raw blocks in buffer
void parse_blocks()
{
// reset counter to identify computational complexity
cplxcnt_ = 0;
// start parsing raw-blocks in buffer
for ( std::vector<unsigned char>::iterator it=buffer_.begin();
it!=buffer_.end(); ++it )
{
cplxcnt_++;
// check for "magic byte"
if ( *it == ch_bgn_ )
{
// check for (non)critical key
if ( *(it+1) == imc::key_crit_ || *(it+1) == imc::key_non_crit_ )
{
// compose (entire) key
std::string newkey = { (char)*(it+1), (char)*(it+2) };
imc::key itkey(*(it+1) == imc::key_crit_,newkey);
// expecting ch_sep_ after key
if ( *(it+3) == ch_sep_ )
{
// extract key version
std::string vers("");
unsigned long int pos = 4;
while ( *(it+pos) != ch_sep_ )
{
vers.push_back((char)*(it+pos));
pos++;
}
int version = std::stoi(vers);
// try to retrieve full key
itkey.version_ = version;
itkey = imc::get_key(itkey.critical_,itkey.name_,itkey.version_);
// check for known keys (including version)
if ( imc::check_key(itkey) )
{
// get block length
std::string leng("");
pos++;
while ( *(it+pos) != ch_sep_ )
{
leng.push_back((char)*(it+pos));
pos++;
}
unsigned long length = std::stoul(leng);
// declare and initialize corresponding key and block
// imc::key bkey( *(it+1)==imc::key_crit_ , newkey,
// imc::keys.at(newkey).description_, version );
imc::block blk(itkey,it-buffer_.begin(),
it-buffer_.begin()+pos+1+length,
raw_file_, &buffer_);
// add block to list
rawblocks_.push_back(blk);
// skip the remaining block according to its length
if ( it-buffer_.begin()+length < buffer_.size() )
{
std::advance(it,length);
}
}
else
{
// all critical must be known !! while a noncritical may be ignored
if ( *(it+1) == imc::key_crit_ )
{
throw std::runtime_error(
std::string("unknown critical key: ") + newkey + std::to_string(version)
);
}
else
{
std::cout<<"WARNING: unknown noncritical key '"
<<newkey<<version<<"' will be ignored\n";
}
}
}
else
{
throw std::runtime_error(
std::string("invalid block or corrupt buffer at byte: ")
+ std::to_string(it+3-buffer_.begin())
);
}
}
}
}
this->check_consistency();
}
// check consistency of blocks
void check_consistency()
{
for ( unsigned long int b = 0; b < this->rawblocks_.size()-1 && this->rawblocks_.size() > 0; b++ )
{
if ( this->rawblocks_[b].get_end() >= this->rawblocks_[b+1].get_begin() )
{
throw std::runtime_error(
std::string("inconsistent subsequent blocks:\n")
+ std::to_string(b) + std::string("-th block:\n") + this->rawblocks_[b].get_info()
+ std::string("\n")
+ std::to_string(b+1) + std::string("-th block:\n") + this->rawblocks_[b+1].get_info() );
}
}
}
// generate map of blocks using their uuid
void generate_block_map()
{
for ( imc::block blk: rawblocks_ )
{
mapblocks_.insert( std::pair<std::string,imc::block>(blk.get_uuid(),blk) );
}
}
// generate channel "environments"
void generate_channel_env()
{
// declare single channel environment
imc::channel_env chnenv;
chnenv.reset();
// collect affiliate blocks for every channel WITH CHANNEL and AFFILIATE
// BLOCK CORRESPONDENCE GOVERNED BY BLOCK ORDER IN BUFFER!!
for ( imc::block blk: rawblocks_ )
{
if ( blk.get_key().name_ == "CN" ) chnenv.CNuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CD" ) chnenv.CDuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CT" ) chnenv.CTuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "Cb" ) chnenv.Cbuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CP" ) chnenv.CPuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CR" ) chnenv.CRuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CS" ) chnenv.CSuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "NT" ) chnenv.NTuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "NO" ) chnenv.NOuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "NL" ) chnenv.NLuuid_ = blk.get_uuid();
// check for currently associated channel
if ( !chnenv.CNuuid_.empty() )
{
// any component/channel is closed by any of {CS, CC, CG, CB}
if ( blk.get_key().name_ == "CS" || blk.get_key().name_ == "CC"
|| blk.get_key().name_ == "CG" || blk.get_key().name_ == "CB" )
{
// provide UUID for channel
chnenv.uuid_ = chnenv.CNuuid_;
// create channel object and add it to the map of channels
channels_.insert( std::pair<std::string,imc::channel>
(chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_,&buffer_))
);
// reset channel uuid
chnenv.CNuuid_.clear();
}
}
// in contrast to component closed by CS block the blocks CB, CG, CC
// already belong to NEXT component
if ( blk.get_key().name_ == "CB" ) chnenv.CBuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CG" ) chnenv.CGuuid_ = blk.get_uuid();
else if ( blk.get_key().name_ == "CC" ) chnenv.CCuuid_ = blk.get_uuid();
}
}
public:
// provide buffer size
unsigned long int buffer_size()
{
return buffer_.size();
}
// get blocks
std::vector<imc::block>& blocks()
{
return rawblocks_;
}
// get computational complexity
unsigned long int& computational_complexity()
{
return cplxcnt_;
}
// get list of channels with metadata
std::vector<std::string> get_channels(bool json = false, bool include_data = false)
{
std::vector<std::string> chns;
for ( std::map<std::string,imc::channel>::iterator it = channels_.begin();
it != channels_.end(); ++it)
{
if ( !json )
{
chns.push_back(it->second.get_info());
}
else
{
chns.push_back(it->second.get_json(include_data));
}
}
return chns;
}
// get particular channel including data by its uuid
imc::channel get_channel(std::string uuid)
{
if ( channels_.count(uuid) )
{
return channels_.at(uuid);
}
else
{
throw std::runtime_error(std::string("channel does not exist:") + uuid);
}
}
// list a particular type of block
std::vector<imc::block> list_blocks(const imc::key &mykey)
{
std::vector<imc::block> myblocks;
for ( imc::block blk: this->rawblocks_ )
{
if ( blk.get_key() == mykey ) myblocks.push_back(blk);
}
return myblocks;
}
// list all groups (associated to blocks "CB")
std::vector<imc::block> list_groups()
{
return this->list_blocks(imc::get_key(true,"CB"));
}
// list all channels
std::vector<std::string> list_channels()
{
std::vector<std::string> channels;
for ( imc::block blk: this->rawblocks_ )
{
if ( blk.get_key() == imc::get_key(true,"CN") )
{
imc::parameter prm = blk.get_parameters()[6];
channels.push_back(blk.get_parameter(prm));
}
}
return channels;
}
// print single specific channel
void print_channel(std::string channeluuid, std::string outputfile, const char sep)
{
// check for given parent directory of output file
std::filesystem::path pdf = outputfile;
if ( !std::filesystem::is_directory(pdf.parent_path()) )
{
throw std::runtime_error(std::string("required directory does not exist: ")
+ pdf.parent_path().u8string() );
}
// find channel with given name
if ( channels_.count(channeluuid) == 1 )
{
channels_.at(channeluuid).print(outputfile,sep);
}
else
{
throw std::runtime_error(std::string("channel does not exist:")
+ channeluuid);
}
}
// print all channels into given directory
void print_channels(std::string output, const char sep)
{
// check for given directory
std::filesystem::path pd = output;
if ( !std::filesystem::is_directory(pd) )
{
throw std::runtime_error(std::string("given directory does not exist: ")
+ output);
}
for ( std::map<std::string,imc::channel>::iterator it = channels_.begin();
it != channels_.end(); ++it)
{
// construct filename
std::string chid = std::string("channel_") + it->first;
std::string filenam = it->second.name_.empty() ? chid + std::string(".csv")
: it->second.name_ + std::string(".csv");
std::filesystem::path pf = pd / filenam;
// and print the channel
it->second.print(pf,sep);
}
}
};
}
#endif
//---------------------------------------------------------------------------//

30
lib/imc_result.hpp Normal file
View File

@@ -0,0 +1,30 @@
//---------------------------------------------------------------------------//
#ifndef IMCRESULT
#define IMCRESULT
#include "imc_datatype.hpp"
//---------------------------------------------------------------------------//
namespace imc
{
struct channel_tab
{
std::string name_;
// abscissa
std::vector<double> xaxis_;
std::string xunit_;
// ordinate
// std::vector<imc::datatype> yaxis_;
std::vector<double> yaxis_;
std::string yunit_;
};
}
#endif
//---------------------------------------------------------------------------//

View File

@@ -1,506 +0,0 @@
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/numeric_cast_utils.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/api/reader.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/comparison_op.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/io/buffered.cc
/home/mario/Desktop/arrow/cpp/src/arrow/extension_type.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/ubsan.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/is_subranged.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_time.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/yes_no.hpp
/home/mario/Desktop/arrow/cpp/src/generated/parquet_types.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_primitive.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/variant.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/multiplies.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/detail/is_function_cxx_11.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/status.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/void_fwd.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/concatenate.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessor/enum.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/strtod.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/config.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_nested.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/less.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_decimal.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/cached-powers.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/string.cc
/home/mario/Desktop/arrow/cpp/src/parquet/exception.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_binary.cc
/home/mario/Desktop/arrow/cpp/src/parquet/encoding.cc
/home/mario/Desktop/arrow/cpp/src/arrow/type_traits.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/transport/TTransportException.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/lambda_fwd.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/adl_barrier.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_nested.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/kernel.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/future.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/formatting.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/include_preprocessed.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/fast-dtoa.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessor/def_params_tail.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/macros.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_vector.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_void.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/intrinsics.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/workaround.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/bignum.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/tuple/rem.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/control/iif.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/logical/bitand.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/kernels/codegen_internal.cc
/home/mario/Desktop/arrow/cpp/src/parquet/column_writer.cc
/home/mario/Desktop/arrow/cpp/src/parquet/encryption.cc
/home/mario/Desktop/arrow/cpp/src/parquet/encoding.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/value_parsing.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/double_conversion.h
/home/mario/Desktop/arrow/cpp/src/arrow/io/file.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/compiler.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_aggregate.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/logical/compl.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_block_counter.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/thread_pool.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/utf8.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_rvalue_reference.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/facilities/identity.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/na_fwd.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/numeric_cast_traits.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/msvc_typename.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/utility/enable_if.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/internal_file_encryptor.cc
/home/mario/Desktop/arrow/cpp/src/arrow/datum.cc
/home/mario/Desktop/arrow/cpp/src/arrow/result.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/arithmetic/inc.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/logical/and.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_function.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/na.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/string.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_scalar.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TDebugProtocol.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_array.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/windows_compatibility.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/converter_policies.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/schema_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/int_util.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/core/enable_if.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/cstdint.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/remove_cv.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/checked_delete.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_base.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/make_unique.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_aggregate.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/sign_mixture.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/type_traits.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/double-conversion.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/declval.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/status.cc
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/xxhash/xxhash.c
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/has_apply.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/time.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/spaced.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/datetime/date.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/bignum.h
/home/mario/Desktop/arrow/cpp/src/arrow/extension_type.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_same.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/utf8cpp/core.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/detail/select_platform_config.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_dict.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/control/while.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/formatting.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/detail/is_binary.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/adl.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/debug/error.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_binary.h
/home/mario/Desktop/arrow/cpp/src/arrow/io/buffered.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/facilities/overload.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/diff.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/variadic/size.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/integral_constant.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/empty.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_complete.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/align_util.h
/home/mario/Desktop/arrow/cpp/src/arrow/table.h
/home/mario/Desktop/arrow/cpp/src/arrow/memory_pool.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/void.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/overload_resolution.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/ctps.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/ieee.h
/home/mario/Desktop/arrow/cpp/src/parquet/internal_file_encryptor.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/future.cc
/home/mario/Desktop/arrow/cpp/src/arrow/builder.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/range.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/fixed-dtoa.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/eti.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/msvc_eti_base.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/type_wrapper.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/metadata.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/value_parsing.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/forwarding.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/gcc.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/and.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_binary.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/array/size.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/repetition/repeat.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/times.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_reader.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_builders.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/udt_builtin_mixture.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/checked_cast.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_primitive.cc
/home/mario/Desktop/arrow/cpp/src/parquet/thrift_internal.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/config.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/transport/TTransport.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/static_cast.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/key_value_metadata.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/eval_if.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/arithmetic/sub.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/data.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/arithmetic/dec.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_generate.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/hash_util.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/string_builder.cc
/home/mario/Desktop/arrow/cpp/src/arrow/visitor.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/strptime.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_ops.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/byte_stream_split.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/detail/select_compiler_config.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/string_builder.h
/home/mario/Desktop/arrow/cpp/src/parquet/encryption.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/validate.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/vector.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TVirtualProtocol.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TCompactProtocol.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/data.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/tag.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessor/params.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/bounds.hpp
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/transport/PlatformSocket.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/throw_exception.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/stl_allocator.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/na_spec.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/thread_pool.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/cpu_info.h
/home/mario/Desktop/arrow/cpp/src/arrow/buffer.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/smart_ptr/detail/sp_noexcept.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/device.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/xxhash/xxh3.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/validate.h
/home/mario/Desktop/arrow/cpp/src/parquet/api/schema.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/visibility.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/detail/yes_no_type.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/utf8cpp/checked.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/numeric_op.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/platform.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/basic_decimal.cc
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/thrift-config.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/tuple/elem.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/smart_ptr/detail/sp_nullptr_t.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_nested.cc
/home/mario/Desktop/arrow/cpp/src/parquet/schema.cc
/home/mario/Desktop/arrow/cpp/src/arrow/compute/util_internal.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TCompactProtocol.tcc
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_base.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/internal_file_decryptor.h
/home/mario/Desktop/arrow/cpp/src/arrow/sparse_tensor.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/cast.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/scalar.h
/home/mario/Desktop/arrow/cpp/src/arrow/io/util_internal.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/logical/bool.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/stdlib/libstdcpp3.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/control/expr_iif.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/parquet_version.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_reference.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/int_fwd.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_abstract.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_adaptive.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/bpacking.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_decimal.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/use_preprocessed.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/io_util.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/integral_wrapper.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/scoped_array.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/io/interfaces.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/add_reference.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/converter.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessed/gcc/times.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/xxhash/xxhash.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/registry.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/fold_right.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessed/gcc/equal_to.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/identity.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/io/caching.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/optional.h
/home/mario/Desktop/arrow/cpp/src/parquet/schema.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_convertible.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/detail/check.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/cached-powers.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_arithmetic.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_lvalue_reference.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/detail/select_stdlib_config.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/variadic/elem.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/workaround.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/double-conversion.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/bool.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/identity.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_vector.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/detail/suffix.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/control/if.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/column_reader.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_binary.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/no_tr1/cmath.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/strtod.cc
/home/mario/Desktop/arrow/cpp/src/arrow/tensor.h
/home/mario/Desktop/arrow/cpp/src/arrow/compare.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/udt_builtin_mixture_enum.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/memory.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/add_lvalue_reference.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/integral.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/record_batch.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/diff.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_decimal.cc
/home/mario/Desktop/arrow/cpp/src/arrow/array/util.cc
/home/mario/Desktop/arrow/cpp/src/parquet/properties.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/bounds.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/detail/posix_features.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/basic_decimal.h
/home/mario/Desktop/arrow/cpp/src/parquet/types.h
/home/mario/Desktop/arrow/cpp/src/parquet/column_writer.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/not.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/file_writer.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_floating_point.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/file_reader.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/arithmetic_op.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/result.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/sort.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_union.cc
/home/mario/Desktop/arrow/cpp/src/arrow/tensor/converter.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_dict.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/compression.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/preprocessor.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/column_scanner.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/repetition/enum_trailing_params.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/nested_type_wknd.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_util.cc
/home/mario/Desktop/arrow/cpp/src/parquet/metadata.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/adt.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/chunked_array.cc
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TBinaryProtocol.tcc
/home/mario/Desktop/arrow/cpp/src/parquet/level_conversion.h
/home/mario/Desktop/arrow/cpp/src/parquet/properties.cc
/home/mario/Desktop/arrow/cpp/src/arrow/datum.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/has_xxx.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/detail/auto_rec.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_ops.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/core/checked_delete.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/exec.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/io_util.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/datetime/tz.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/limits/arity.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/memory_pool.cc
/home/mario/Desktop/arrow/cpp/src/arrow/array/util.h
/home/mario/Desktop/arrow/cpp/src/parquet/types.cc
/home/mario/Desktop/arrow/cpp/src/arrow/chunked_array.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/version.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/exec_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_util.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/smart_ptr/detail/operator_bool.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_stream_utils.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/int_util.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/converter.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/fold_left.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/deprecated_io.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/optional.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/repeat.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/file_writer.cc
/home/mario/Desktop/arrow/cpp/src/parquet/encryption_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/io/interfaces.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/lambda_arity_param.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/kernel.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/lambda.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/io/concurrency.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/atomic_shared_ptr.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_builders.cc
/home/mario/Desktop/arrow/cpp/src/arrow/type.cc
/home/mario/Desktop/arrow/cpp/src/arrow/pretty_print.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/comma_if.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessed/gcc/less.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/sign_mixture_enum.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/logging.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/integral_c.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/windows_compatibility.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/detail/workaround.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/static_assert.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/key_value_metadata.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/tuple/eat.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/column_reader.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/compression_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bpacking_default.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/equal_to.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/is_msvc_eti_arg.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/value_wknd.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/int_float_mixture_enum.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/config/config.hpp
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/transport/TVirtualTransport.h
/home/mario/Desktop/arrow/cpp/src/parquet/column_scanner.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/compression.cc
/home/mario/Desktop/arrow/cpp/src/arrow/io/memory.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/control/detail/while.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/punctuation/comma_if.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/array/elem.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/printer.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/fast-dtoa.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/smart_ptr/scoped_array.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/static_constant.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/template_arity_fwd.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/sparse_tensor.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/conversion_traits.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/msvc_never_true.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_union.h
/home/mario/Desktop/arrow/cpp/src/arrow/buffer.cc
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/transport/TBufferTransports.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/integral_c_tag.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/has_tag.hpp
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/stdcxx.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TProtocolException.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/facilities/expand.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/has_apply.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/table.cc
/home/mario/Desktop/arrow/cpp/src/arrow/io/caching.cc
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/xxhash.h
/home/mario/Desktop/arrow/cpp/src/parquet/api/writer.h
/home/mario/Desktop/arrow/cpp/src/parquet/api/io.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/cast_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_base.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/int.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/numeric_cast.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/simd.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/user.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/rle_encoding.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/bitmap_writer.h
/home/mario/Desktop/arrow/cpp/src/parquet/level_conversion.cc
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TBinaryProtocol.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_decimal.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/apply_wrap.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/detail/config.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/intel.hpp
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/Thrift.h
/home/mario/Desktop/arrow/cpp/src/arrow/pretty_print.h
/home/mario/Desktop/arrow/cpp/src/parquet/statistics.cc
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/diy-fp.cc
/home/mario/Desktop/arrow/cpp/src/arrow/array/dict_internal.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/time.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/function.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/utf8.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/cpu_info.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/array/data.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/platform/linux.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/string_view.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/dtp.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/kernels/codegen_internal.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/TBase.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/TApplicationException.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/utils.h
/home/mario/Desktop/arrow/cpp/src/arrow/io/memory.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/lambda_support.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/hashing.h
/home/mario/Desktop/arrow/cpp/src/arrow/record_batch.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/ttp.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/io/file.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/integral_c_fwd.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/type_fwd.h
/home/mario/Desktop/arrow/cpp/src/arrow/scalar.cc
/home/mario/Desktop/arrow/cpp/src/arrow/type.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/decimal.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/function.cc
/home/mario/Desktop/arrow/cpp/src/arrow/device.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/arithmetic/add.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/is_integral.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/type_fwd.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/string_view.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/has_xxx.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/bignum-dtoa.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/nttp_decl.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/inc.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/int_float_mixture.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/functional.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/cast.h
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/fixed-dtoa.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/variant.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/add_rvalue_reference.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/registry_internal.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/meta.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/iterator.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_primitive.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/if.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_block_counter.cc
/home/mario/Desktop/arrow/cpp/src/arrow/array/concatenate.cc
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_dict.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/arity.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/largest_int.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/tuple/detail/is_single_return.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/datetime.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/windows_fixup.h
/home/mario/Desktop/arrow/cpp/src/parquet/internal_file_decryptor.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/iterator.cc
/home/mario/Desktop/arrow/cpp/src/arrow/buffer_builder.h
/home/mario/Desktop/arrow/cpp/src/arrow/tensor.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/detail/fold_left.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/decimal.cc
/home/mario/Desktop/arrow/cpp/src/arrow/visitor.cc
/home/mario/Desktop/arrow/cpp/src/arrow/compute/registry.h
/home/mario/Desktop/arrow/cpp/src/arrow/util/memory.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/compare.h
/home/mario/Desktop/arrow/cpp/src/arrow/compare.cc
/home/mario/Desktop/arrow/cpp/src/arrow/util/logging.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/exec.h
/home/mario/Desktop/arrow/cpp/src/parquet/column_page.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/arrays.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/detail/fold_right.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/nttp.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/numeric_cast_traits.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_base.h
/home/mario/Desktop/arrow/cpp/src/arrow/visitor_inline.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/cat.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/type_traits/remove_reference.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/diy-fp.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_primitive.cc
/home/mario/Desktop/arrow/cpp/src/arrow/type_fwd.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/repetition/enum_params.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/current_function.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/assert.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/file_reader.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/list/reverse.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/compute/cast.cc
/home/mario/Desktop/arrow/cpp/src/arrow/io/type_fwd.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/protocol/TProtocol.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/exception/exception.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/deprecated_io.cc
/home/mario/Desktop/arrow/cpp/src/parquet/encryption_internal.cc
/home/mario/Desktop/arrow/cpp/src/parquet/platform.h
/home/mario/Desktop/arrow/cpp/src/arrow/compute/api_scalar.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/config/compiler/gcc.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_run_reader.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessed/gcc/and.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/vendored/double-conversion/bignum-dtoa.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_adaptive.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/config/msvc.hpp
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/TLogging.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/builder_nested.h
/home/mario/Desktop/arrow/cpp/src/arrow/array/array_dict.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/numeric/conversion/detail/conversion_traits.hpp
/home/mario/Desktop/arrow/cpp/src/arrow/util/bit_run_reader.h
/home/mario/Desktop/arrow/cpp/thrift_ep-install/include/thrift/TOutput.h
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/limits.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/stringize.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/bool_fwd.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/facilities/empty.hpp
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/mpl/aux_/preprocessor/default_params.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/printer.cc
/home/mario/Desktop/arrow/cpp/src/arrow/builder.cc
/home/mario/Desktop/arrow/cpp/boost_ep-prefix/src/boost_ep/boost/preprocessor/punctuation/comma.hpp
/home/mario/Desktop/arrow/cpp/src/parquet/statistics.h

File diff suppressed because it is too large Load Diff

156
makefile
View File

@@ -1,92 +1,110 @@
#-----------------------------------------------------------------------------#
# choose shell
SHELL := /bin/bash
RAW = ../raw/
# name of executable and CLI tool
EXE = imctermite
# directory names
SRC = src/
LIB = lib/
CYT = cyt/
CYT = cython/
PYT = python/
# name of executable
EXE = eatraw
# list headers
HPP = $(wildcard $(LIB)/*.hpp)
# compiler and its options
CCC = g++ -std=c++11
# choose compiler and its options
CC = g++ -std=c++17
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
OPT = -O3 -Wall -Werror
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
# 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
#-----------------------------------------------------------------------------#
# C++
# C++ and CLI tool
# build executable
$(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp output
$(CCC) $(OPT) $< -o $@
# build exectuable
$(EXE) : check-vtag $(RTAG) main.o
$(CC) $(OPT) main.o -o $@
# development version
eatdev : $(SRC)main_dev.cpp $(LIB)raweat.hpp
$(CCC) $(OPT) $< -o $@
# build main.cpp and include git version/commit tag
main.o : src/main.cpp $(HPP)
@cp $< $<.cpp
@sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp
@sed -i 's/HASHSTRING/$(GHSH)/g' $<.cpp
$(CC) -c $(OPT) -I $(LIB) $<.cpp -o $@
@rm $<.cpp
# build target for conversion set of .raw files
eatall : $(SRC)eatall.cpp $(LIB)raweat.hpp
$(CCC) $(OPT) $< -o $@
# remove executable
clean :
rm -f $(EXE)
rm -f eatall
rm -f eatdev
rm -rf output/
# check existence of name of executable globally
chexe:=$(shell command -v $(EXE))
# install executable if name does not exist yet
install : $(EXE)
ifeq ($(chexe),)
cp $(EXE) /usr/local/bin/
else
@echo "executable with name already exists! choose different name!"
@exit 1
endif
cp $< $(INST)/
# uninstall
uninstall :
rm /usr/local/bin/$(EXE)
uninstall : $(INST)/$(EXE)
rm $<
cpp-clean :
rm -vf $(EXE)
rm -vf *.o
#-----------------------------------------------------------------------------#
# Python
# linter and code check
# 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/
check-code:
cppcheck --enable=all -I lib/ src/main.cpp
#-----------------------------------------------------------------------------#
# 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
docker-build :
docker build ./ --tag imctermite:0.1
docker-run:
docker run -it --rm imctermite:0.1 /bin/bash
#-----------------------------------------------------------------------------#
# python
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 : 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 -rvf build/
#-----------------------------------------------------------------------------#
# pip
pip-release: check-vtag $(RTAG) cython-build
cd ./pip/ && make publish
#-----------------------------------------------------------------------------#
# clean
clean: cpp-clean cython-clean
cd ./pip/ && make clean
#-----------------------------------------------------------------------------#

View File

@@ -1,6 +1,5 @@
#-----------------------------------------------------------------------------#
import glob
from pathlib import Path
# find source files

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"
]

29
pip/makefile Normal file
View File

@@ -0,0 +1,29 @@
# --------------------------------------------------------------------------- #
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
# authentication:
# - username: __token__
# - password: <token value including pypi-prefix>
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
# --------------------------------------------------------------------------- #

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="IMCtermite",
version="1.2.6",
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'],
)],
)

View File

@@ -5,19 +5,18 @@ import raw_eater
import raw_meat
import pyarrow as pa
import pyarrow.parquet as pq
import glob
from pathlib import Path
fileobj1 = Path("smp/Rangerover_Evoque_F-RR534_2019-05-07/").rglob("*.raw")
fileobj1 = Path("samples/datasetA/").rglob("*.raw")
rawlist1 = [str(fl) for fl in fileobj1]
fileobj2 = Path("smp/Mercedes_E-Klasse-2019-08-08/").rglob("*.raw")
fileobj2 = Path("samples/datasetB/").rglob("*.raw")
rawlist2 = [str(fl) for fl in fileobj2]
rawlist = rawlist1 #[rawlist1[0],rawlist1[4],rawlist2[0],rawlist2[6]]
for fil in rawlist2 :
rawlist.append(fil)
rawlist.append("smp/pressure_Vacuum.asc")
rawlist.append("./README.md")
print("")
print(rawlist)

38
python/usage.py Normal file
View File

@@ -0,0 +1,38 @@
import imc_termite
import json
import os
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = imc_termite.imctermite(b"samples/exampleB.raw")
except RuntimeError as e :
raise Exception("failed to load/parse raw-file: " + str(e))
# obtain list of channels as list of dictionaries (without data)
channels = imcraw.get_channels(False)
print(json.dumps(channels,indent=4, sort_keys=False))
# obtain data of first channel (with data)
channelsdata = imcraw.get_channels(True)
if len(channelsdata) > 0 :
chnydata = channelsdata[0]['ydata']
chnxdata = channelsdata[0]['xdata']
print(len(chnydata))
print(len(chnxdata))
# print the channels into a specific directory
imcraw.print_channels(b"./data",ord(','))
# print all channels separately
idx = 0
for chn in channels :
print(str(idx)+" : "+chn['name']+" : "+chn['uuid'])
filname = os.path.join("./data",str(idx) + "_" + chn['name']+".csv")
print(filname)
imcraw.print_channel(chn['uuid'].encode(),filname.encode(),ord(','))
idx = idx + 1
# print all channels in single file
# imcraw.print_table(b"./data/allchannels.csv")

30
python/usage_adv.py Normal file
View File

@@ -0,0 +1,30 @@
import imc_termite
import json
import os
# list files in sample directory
# fileobj1 = Path("samples/").rglob("*.raw")
# rawlist1 = [str(fl) for fl in fileobj1]
rawlist1 = ["samples/datasetB/datasetB_29.raw"]
print(rawlist1)
for fl in rawlist1:
print("converting " + str(fl) + " : " + str(os.path.basename(fl)) )
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = imc_termite.imctermite(fl.encode())
except RuntimeError as e :
raise Exception("failed to load/parse raw-file: " + str(e))
# obtain list of channels as list of dictionaries (without data)
channels = imcraw.get_channels(False)
print(json.dumps(channels,indent=4, sort_keys=False))
# print the channels into a specific directory
imcraw.print_channels(b"./")
# print all channels in single file
imcraw.print_table(("./"+str(os.path.basename(fl).split('.')[0])+"_allchannels.csv").encode())

Some files were not shown because too many files have changed in this diff Show More