Compare commits
21 Commits
v1.2.2
...
fdd107fbb3
Author | SHA1 | Date | |
---|---|---|---|
fdd107fbb3 | |||
cd4ce55e7e | |||
27683cbbd6 | |||
25a51215a0 | |||
36c02089aa | |||
cd75689d32 | |||
57c7f6021b | |||
83922c343f | |||
72378877ec | |||
e7094d0125 | |||
16a77ecf1e | |||
798fc22d7a | |||
2b2e69f0e5 | |||
![]() |
8708d2d008 | ||
9feadb50c1 | |||
dbeb1b862a | |||
bda799832c | |||
97c2195f98 | |||
ea7ab9fa85 | |||
c281aeae19 | |||
0403f2bc64 |
9
.gitignore
vendored
9
.gitignore
vendored
@@ -20,3 +20,12 @@ cython/*.cpp
|
||||
*.parquet
|
||||
|
||||
src/*.cpp.cpp
|
||||
|
||||
pip/*.cpp
|
||||
pip/*.hpp
|
||||
pip/*.pyx
|
||||
pip/*.pxd
|
||||
pip/README.md
|
||||
pip/LICENSE
|
||||
pip/*egg-info
|
||||
pip/dist/
|
||||
|
@@ -4,8 +4,9 @@ FROM debian:bullseye-20210111
|
||||
USER root
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential git \
|
||||
build-essential git vim \
|
||||
python3 python3-pip
|
||||
RUN python3 -m pip install cython
|
||||
|
||||
RUN g++ -v
|
||||
|
||||
@@ -15,6 +16,6 @@ COPY ./ /IMCtermite/
|
||||
RUN cd /IMCtermite && ls -lh && make install && ls -lh /usr/local/bin/imctermite
|
||||
|
||||
# install Python module
|
||||
# RUN cd /tdm_ripper && ls -lh && make cython-requirements && make cython-install
|
||||
RUN cd /IMCtermite && ls -lh && make cython-install
|
||||
|
||||
CMD ["sleep","inifity"]
|
||||
CMD ["sleep","infinity"]
|
||||
|
31
README.md
31
README.md
@@ -1,13 +1,11 @@
|
||||
|
||||
<p align="center">
|
||||
<a href="https://record-evolution.de/reswarm">
|
||||
<img
|
||||
alt="imctermite.svg"
|
||||
src="assets/imctermite.svg"
|
||||
width="400"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
[](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/alerts/)
|
||||
[](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/context:cpp)
|
||||
[](https://lgtm.com/projects/g/RecordEvolution/IMCtermite/context:python)
|
||||
[](https://img.shields.io/github/license/RecordEvolution/IMCtermite)
|
||||
[](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)
|
||||
|
||||
# IMCtermite
|
||||
|
||||
_IMCtermite_ provides access to the proprietary data format
|
||||
_IMC Bus Format_ with the file extension _.raw_ introduced and developed by
|
||||
@@ -141,6 +139,19 @@ 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
|
||||
@@ -206,3 +217,5 @@ in the Python folder.
|
||||
- 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://pypi.org/help/#apitoken
|
||||
|
||||
|
@@ -16,3 +16,4 @@ cdef extern from "imc_raw.hpp" namespace "imc":
|
||||
vector[string] get_channels(bool json, bool data) except +
|
||||
# print all channels
|
||||
void print_channels(string outputdir) except +
|
||||
void print_table(string outputfile) except +
|
||||
|
@@ -3,6 +3,7 @@
|
||||
from imc_termite cimport imc_termite
|
||||
|
||||
import json as jn
|
||||
import decimal
|
||||
# import numpy as np
|
||||
|
||||
cdef class imctermite:
|
||||
@@ -21,9 +22,21 @@ cdef class imctermite:
|
||||
# get JSON list of channels
|
||||
def get_channels(self, bool data):
|
||||
chnlst = self.cpp_imc.get_channels(True,data)
|
||||
chnlstjn = [jn.loads(chn.decode()) for chn in chnlst]
|
||||
chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst]
|
||||
return chnlstjn
|
||||
|
||||
# print a channels
|
||||
# print channels
|
||||
def print_channels(self, string outputdir):
|
||||
self.cpp_imc.print_channels(outputdir)
|
||||
|
||||
# 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')
|
||||
|
@@ -14,11 +14,11 @@ extensions = Extension(
|
||||
)
|
||||
|
||||
setup(
|
||||
version='0.1',
|
||||
name="imc_termite",
|
||||
version='1.2.4',
|
||||
description='IMCtermite cython extension',
|
||||
author='Record Evolution GmbH',
|
||||
author_email='mario.fink@record-evolution.de',
|
||||
url='https://github.com/RecordEvolution/IMCtermite.git',
|
||||
name="imc_termite",
|
||||
ext_modules=cythonize(extensions,force=True)
|
||||
)
|
||||
|
@@ -95,7 +95,7 @@ namespace imc
|
||||
ss<<"[";
|
||||
if ( myvec.size() <= limit )
|
||||
{
|
||||
for ( dt el: myvec ) ss<<el<<",";
|
||||
for ( dt el: myvec ) ss<<std::setprecision(10)<<el<<",";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,7 +104,7 @@ namespace imc
|
||||
ss<<"...";
|
||||
for ( unsigned long int i = myvec.size()-heals; i < myvec.size(); i++ )
|
||||
{
|
||||
ss<<myvec[i]<<",";
|
||||
ss<<std::setprecision(10)<<myvec[i]<<",";
|
||||
}
|
||||
}
|
||||
std::string sumstr = ss.str();
|
||||
@@ -147,9 +147,11 @@ namespace imc
|
||||
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,
|
||||
channel(channel_env &chnenv, std::map<std::string,imc::block>* blocks,
|
||||
std::vector<unsigned char>* buffer):
|
||||
chnenv_(chnenv), blocks_(blocks), buffer_(buffer), group_index_(-1)
|
||||
chnenv_(chnenv), blocks_(blocks), buffer_(buffer),
|
||||
factor_(1.), offset_(0.),
|
||||
group_index_(-1)
|
||||
{
|
||||
// declare list of block parameters
|
||||
std::vector<imc::parameter> prms;
|
||||
@@ -292,6 +294,11 @@ namespace imc
|
||||
{
|
||||
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_));
|
||||
|
@@ -17,7 +17,11 @@ namespace imc
|
||||
// check number of elements of type "datatype" in buffer
|
||||
if ( subbuffer.size() != channel.size()*sizeof(datatype) )
|
||||
{
|
||||
throw std::runtime_error("size mismatch between subbuffer and 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
|
||||
@@ -36,6 +40,8 @@ namespace imc
|
||||
// save number in channel
|
||||
channel[i] = df;
|
||||
}
|
||||
|
||||
// for ( auto el: channel ) std::cout<<el<<"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,13 +10,27 @@ 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 remaining types are not yet supported
|
||||
//
|
||||
// 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
|
||||
{
|
||||
@@ -29,12 +43,14 @@ namespace imc
|
||||
imc_Slongint slint_; // 5
|
||||
imc_float sfloat_; // 6
|
||||
imc_double sdouble_; // 7
|
||||
short int dtidx_; // \in \{0,...,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) {};
|
||||
@@ -46,11 +62,29 @@ namespace imc
|
||||
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),
|
||||
dtidx_(7) {};
|
||||
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)
|
||||
{
|
||||
@@ -64,6 +98,7 @@ namespace imc
|
||||
this->slint_ = num.slint_;
|
||||
this->sfloat_ = num.sfloat_;
|
||||
this->sdouble_ = num.sdouble_;
|
||||
this->sdigital_ = num.sdigital_;
|
||||
this->dtidx_ = num.dtidx_;
|
||||
}
|
||||
|
||||
@@ -119,6 +154,12 @@ namespace imc
|
||||
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()
|
||||
@@ -132,6 +173,7 @@ namespace imc
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -146,6 +188,7 @@ namespace imc
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -501,16 +501,16 @@ namespace imc
|
||||
second_ = std::stod( get_parameter(buffer,¶meters[7]) );
|
||||
|
||||
time_t rawtime;
|
||||
struct tm* ts;
|
||||
struct tm ts;
|
||||
time(&rawtime);
|
||||
ts = localtime(&rawtime);
|
||||
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_;
|
||||
timestamp_ = asctime(ts);
|
||||
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,×tamp_[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_)
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
||||
#include "hexshow.hpp"
|
||||
// #include "hexshow.hpp"
|
||||
#include "imc_key.hpp"
|
||||
#include "imc_block.hpp"
|
||||
#include "imc_datatype.hpp"
|
||||
@@ -174,7 +174,7 @@ namespace imc
|
||||
// check consistency of blocks
|
||||
void check_consistency()
|
||||
{
|
||||
for ( unsigned long int b = 0; b < this->rawblocks_.size()-1; b++ )
|
||||
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() )
|
||||
{
|
||||
@@ -300,7 +300,7 @@ namespace imc
|
||||
}
|
||||
|
||||
// list a particular type of block
|
||||
std::vector<imc::block> list_blocks(imc::key mykey)
|
||||
std::vector<imc::block> list_blocks(const imc::key &mykey)
|
||||
{
|
||||
std::vector<imc::block> myblocks;
|
||||
for ( imc::block blk: this->rawblocks_ )
|
||||
|
78
makefile
78
makefile
@@ -1,5 +1,7 @@
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
SHELL := /bin/bash
|
||||
|
||||
# name of executable and CLI tool
|
||||
EXE = imctermite
|
||||
|
||||
@@ -17,9 +19,11 @@ CC = g++ -std=c++17
|
||||
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
||||
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
|
||||
|
||||
# determine git version/commit tag
|
||||
# determine git version/commit and release tag
|
||||
GTAG := $(shell git tag | tail -n1)
|
||||
GHSH := $(shell git rev-parse HEAD | head -c8)
|
||||
RTAG := v$(shell cat pip/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]")
|
||||
CTAG := v$(shell cat cython/setup.py | grep version | grep -oP "([0-9]\.){2}[0-9]")
|
||||
|
||||
# define install location
|
||||
INST := /usr/local/bin
|
||||
@@ -28,8 +32,8 @@ INST := /usr/local/bin
|
||||
# C++ and CLI tool
|
||||
|
||||
# build exectuable
|
||||
$(EXE) : main.o
|
||||
$(CC) $(OPT) $^ -o $@
|
||||
$(EXE) : check-vtag $(RTAG) main.o
|
||||
$(CC) $(OPT) main.o -o $@
|
||||
|
||||
# build main.cpp and include git version/commit tag
|
||||
main.o : src/main.cpp $(HPP)
|
||||
@@ -45,10 +49,28 @@ install : $(EXE)
|
||||
uninstall : $(INST)/$(EXE)
|
||||
rm $<
|
||||
|
||||
clean :
|
||||
cpp-clean :
|
||||
rm -vf $(EXE)
|
||||
rm -vf *.o
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# linter and code check
|
||||
|
||||
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
|
||||
|
||||
@@ -61,48 +83,28 @@ docker-run:
|
||||
#-----------------------------------------------------------------------------#
|
||||
# python
|
||||
|
||||
cython-build : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $< build_ext --inplace
|
||||
cython-build : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $(CYT)setup.py build_ext --inplace
|
||||
cp -v imc_termite.cpython-*.so $(PYT)
|
||||
|
||||
cython-install : $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $< install --record files_imctermite.txt
|
||||
cython-install : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)py_imc_termite.pyx $(HPP)
|
||||
python3 $(CYT)setup.py install --record files_imctermite.txt
|
||||
|
||||
cython-clean :
|
||||
rm -vf imc_termite.cpython-*.so
|
||||
rm -vf $(PYT)imc_termite.cpython-*.so
|
||||
rm -rv build/
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# Python (to be removed)
|
||||
# pip
|
||||
|
||||
# build python module
|
||||
py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
||||
output
|
||||
python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
||||
python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
||||
cp raw_eater.cpython-*.so $(PYT)
|
||||
cp raw_meat.cpython-*.so $(PYT)
|
||||
rm *.so
|
||||
|
||||
py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
||||
python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
||||
python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
||||
|
||||
py-clean :
|
||||
rm -f raw_eater.cpython-*.so
|
||||
rm -f $(PYT)raw_eater.cpython-*.so
|
||||
rm -f $(CYT)raw_eater.cpp
|
||||
rm -f raw_meat.cpython-*.so
|
||||
rm -f $(PYT)raw_meat.cpython-*.so
|
||||
rm -f $(CYT)raw_meat.cpp
|
||||
rm -rf build/
|
||||
rm -f *.txt
|
||||
rm -rf output/
|
||||
|
||||
# prepare directory for test output
|
||||
output :
|
||||
mkdir -pv output/
|
||||
pip-release: check-vtag $(RTAG) cython-build
|
||||
cd ./pip/ && make publish
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
# clean
|
||||
|
||||
clean: cpp-clean cython-clean
|
||||
cd ./pip/ && make clean
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
import glob
|
||||
from pathlib import Path
|
||||
|
||||
# find source files
|
||||
|
4
pip/MANIFEST.in
Normal file
4
pip/MANIFEST.in
Normal file
@@ -0,0 +1,4 @@
|
||||
include *.hpp
|
||||
include *.cpp
|
||||
include *.pyx
|
||||
include *.pxd
|
4
pip/bkup.pyproject.toml
Normal file
4
pip/bkup.pyproject.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[build-system]
|
||||
requires = [
|
||||
"setuptools"
|
||||
]
|
29
pip/makefile
Normal file
29
pip/makefile
Normal 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
36
pip/setup.py
Normal 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.4",
|
||||
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'],
|
||||
)],
|
||||
)
|
@@ -5,7 +5,6 @@ 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")
|
||||
|
@@ -6,7 +6,7 @@ import json
|
||||
try :
|
||||
imcraw = imc_termite.imctermite(b"samples/sampleA.raw")
|
||||
except RuntimeError as e :
|
||||
print("failed to load/parse raw-file: " + str(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)
|
||||
@@ -23,3 +23,6 @@ print(len(chnxdata))
|
||||
|
||||
# print the channels into a specific directory
|
||||
imcraw.print_channels(b"./")
|
||||
|
||||
# print all channels in single file
|
||||
imcraw.print_table(b"./allchannels.csv")
|
||||
|
30
python/usage_adv.py
Normal file
30
python/usage_adv.py
Normal 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())
|
@@ -178,6 +178,13 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
// catch invalid or empty ".raw" file
|
||||
if ( imcraw.blocks().size() == 0 )
|
||||
{
|
||||
std::cerr<<"this appears to be an empty/invalid '.raw' file since no blocks were found"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// list blocks
|
||||
if ( cfgopts.count("listblocks") == 1 )
|
||||
{
|
||||
|
Reference in New Issue
Block a user