Compare commits
11 Commits
v1.2.5
...
69f5e5496b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
69f5e5496b | ||
![]() |
56f83b8132 | ||
![]() |
cda6673f85 | ||
![]() |
1d7a512fd4 | ||
658a73a284 | |||
71c9bb7a5c | |||
45efb06aa2 | |||
538b6f4659 | |||
![]() |
08e2589dfd | ||
![]() |
d098273816 | ||
![]() |
2f9c550323 |
10
README.md
10
README.md
@@ -171,14 +171,18 @@ 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.
|
||||
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
|
||||
|
||||
@@ -217,5 +221,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://apollo3zehn.github.io/ImcFamosFile/api/ImcFamosFile.FamosFileKeyType.html
|
||||
- https://pypi.org/help/#apitoken
|
||||
|
||||
|
@@ -15,7 +15,7 @@ extensions = Extension(
|
||||
|
||||
setup(
|
||||
name="imc_termite",
|
||||
version='1.2.4',
|
||||
version='1.2.8',
|
||||
description='IMCtermite cython extension',
|
||||
author='Record Evolution GmbH',
|
||||
author_email='mario.fink@record-evolution.de',
|
||||
|
@@ -63,7 +63,7 @@ namespace imc
|
||||
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();
|
||||
end_ = (unsigned long int)(buffer_->size());
|
||||
}
|
||||
|
||||
try {
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <sstream>
|
||||
#include "imc_datatype.hpp"
|
||||
#include "imc_conversion.hpp"
|
||||
#include <math.h>
|
||||
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace imc
|
||||
// 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_;
|
||||
std::string NTuuid_, NOuuid_, NLuuid_;
|
||||
|
||||
// reset all members
|
||||
void reset()
|
||||
@@ -38,6 +39,7 @@ namespace imc
|
||||
CSuuid_.clear();
|
||||
NTuuid_.clear();
|
||||
NOuuid_.clear();
|
||||
NLuuid_.clear();
|
||||
}
|
||||
|
||||
// get info
|
||||
@@ -58,7 +60,8 @@ namespace imc
|
||||
<<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<<"NOuuid:"<<NOuuid_<<"\n"
|
||||
<<std::setw(width)<<std::left<<"NLuuid:"<<NLuuid_<<"\n";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -79,32 +82,55 @@ namespace imc
|
||||
<<"\",\"CSuuid\":\""<<CSuuid_
|
||||
<<"\",\"NTuuid\":\""<<NTuuid_
|
||||
<<"\",\"NOuuid\":\""<<NOuuid_
|
||||
<<"\",\"NLuuid\":\""<<NLuuid_
|
||||
<<"\"}";
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
// adjust stream object
|
||||
void customize_stream(std::ostream& stout, int prec, bool fixed)
|
||||
{
|
||||
if ( fixed )
|
||||
{
|
||||
stout<<std::setprecision(prec)<<std::fixed;
|
||||
}
|
||||
else
|
||||
{
|
||||
stout<<std::setprecision(prec);
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
std::string joinvec(std::vector<dt> myvec, unsigned long int limit = 10, int prec = 10, bool fixed = true)
|
||||
{
|
||||
// include entire list for limit = - 1
|
||||
// include entire list for limit = 0
|
||||
limit = (limit == 0) ? myvec.size() : limit;
|
||||
|
||||
std::stringstream ss;
|
||||
ss<<"[";
|
||||
if ( myvec.size() <= limit )
|
||||
{
|
||||
for ( dt el: myvec ) ss<<std::setprecision(10)<<el<<",";
|
||||
for ( dt el: myvec )
|
||||
{
|
||||
customize_stream(ss,prec,fixed);
|
||||
ss<<el<<",";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long int heals = (unsigned long int)(limit/2.);
|
||||
for ( unsigned long int i = 0; i < heals; i++ ) ss<<myvec[i]<<",";
|
||||
for ( unsigned long int i = 0; i < heals; i++ )
|
||||
{
|
||||
customize_stream(ss,prec,fixed);
|
||||
ss<<myvec[i]<<",";
|
||||
}
|
||||
ss<<"...";
|
||||
for ( unsigned long int i = myvec.size()-heals; i < myvec.size(); i++ )
|
||||
{
|
||||
ss<<std::setprecision(10)<<myvec[i]<<",";
|
||||
customize_stream(ss,prec,fixed);
|
||||
ss<<myvec[i]<<",";
|
||||
}
|
||||
}
|
||||
std::string sumstr = ss.str();
|
||||
@@ -126,9 +152,11 @@ namespace imc
|
||||
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_;
|
||||
int xprec_;
|
||||
|
||||
// buffer and data
|
||||
int signbits_, num_bytes_;
|
||||
@@ -185,6 +213,9 @@ namespace imc
|
||||
xunit_ = blocks_->at(chnenv_.CDuuid_).get_parameter(prms[5]);
|
||||
// TODO
|
||||
// xname_ = std::string("time");
|
||||
|
||||
// find appropriate precision for "xdata_" by means of "xstepwidth_"
|
||||
xprec_ = (xstepwidth_ > 0 ) ? (int)ceil(fabs(log10(xstepwidth_))) : 10;
|
||||
}
|
||||
|
||||
// extract associated CP data
|
||||
@@ -233,6 +264,19 @@ namespace imc
|
||||
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();
|
||||
}
|
||||
@@ -252,7 +296,7 @@ namespace imc
|
||||
buffer_->begin()+buffstrt+buffer_size_+1 );
|
||||
|
||||
// determine number of values in buffer
|
||||
unsigned long int num_values = CSbuffer.size()/(signbits_/8);
|
||||
unsigned long int num_values = (unsigned long int)(CSbuffer.size()/(signbits_/8));
|
||||
if ( num_values*(signbits_/8) != CSbuffer.size() )
|
||||
{
|
||||
throw std::runtime_error("CSbuffer and significant bits of datatype don't match");
|
||||
@@ -330,6 +374,8 @@ namespace imc
|
||||
<<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"
|
||||
@@ -344,8 +390,8 @@ namespace imc
|
||||
<<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<<"ydata:"<<imc::joinvec<imc::datatype>(ydata_,6,9,true)<<"\n"
|
||||
<<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<double>(xdata_,6,xprec_,true)<<"\n";
|
||||
// <<std::setw(width)<<std::left<<"aff. blocks:"<<chnenv_.get_json()<<"\n";
|
||||
return ss.str();
|
||||
}
|
||||
@@ -359,6 +405,8 @@ namespace imc
|
||||
<<"\",\"comment\":\""<<comment_
|
||||
<<"\",\"origin\":\""<<origin_
|
||||
<<"\",\"description\":\""<<text_
|
||||
<<"\",\"language-code\":\""<<language_code_
|
||||
<<"\",\"codepage\":\""<<codepage_
|
||||
<<"\",\"yname\":\""<<yname_
|
||||
<<"\",\"yunit\":\""<<yunit_
|
||||
<<"\",\"significantbits\":\""<<signbits_
|
||||
@@ -371,8 +419,8 @@ namespace imc
|
||||
<<"\",\"comment\":\""<<group_comment_<<"\""<<"}";
|
||||
if ( include_data )
|
||||
{
|
||||
ss<<",\"ydata\":"<<imc::joinvec<imc::datatype>(ydata_,0)
|
||||
<<",\"xdata\":"<<imc::joinvec<double>(xdata_,0);
|
||||
ss<<",\"ydata\":"<<imc::joinvec<imc::datatype>(ydata_,0,9,true)
|
||||
<<",\"xdata\":"<<imc::joinvec<double>(xdata_,0,xprec_,true);
|
||||
}
|
||||
// ss<<"\",\"aff. blocks\":\""<<chnenv_.get_json()
|
||||
ss<<"}";
|
||||
@@ -381,7 +429,7 @@ namespace imc
|
||||
}
|
||||
|
||||
// print channel
|
||||
void print(std::string filename, const char sep = ',', int width = 25)
|
||||
void print(std::string filename, const char sep = ',', int width = 25, int yprec = 9)
|
||||
{
|
||||
std::ofstream fou(filename);
|
||||
|
||||
@@ -402,13 +450,16 @@ namespace imc
|
||||
{
|
||||
if ( sep == ' ' )
|
||||
{
|
||||
fou<<std::setprecision(9)<<std::fixed
|
||||
fou<<std::setprecision(xprec_)<<std::fixed
|
||||
<<std::setw(width)<<std::left<<xdata_[i]
|
||||
<<std::setprecision(yprec)<<std::fixed
|
||||
<<std::setw(width)<<std::left<<ydata_[i]<<"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fou<<xdata_[i]<<sep<<ydata_[i]<<"\n";
|
||||
fou<<std::setprecision(xprec_)<<std::fixed<<xdata_[i]
|
||||
<<sep
|
||||
<<std::setprecision(yprec)<<std::fixed<<ydata_[i]<<"\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//---------------------------------------------------------------------------//
|
||||
|
||||
#ifndef IMCCONVRSION
|
||||
#ifndef IMCCONVERSION
|
||||
#define IMCCONVERSION
|
||||
|
||||
#include <vector>
|
||||
|
@@ -48,7 +48,7 @@ namespace imc
|
||||
public:
|
||||
datatype(): ubyte_(0), sbyte_(0),
|
||||
ushort_(0), sshort_(0),
|
||||
ulint_(0.0), slint_(0.0),
|
||||
ulint_(0), slint_(0),
|
||||
sfloat_(0.0), sdouble_(0.0),
|
||||
sdigital_(0),
|
||||
dtidx_(0) { };
|
||||
@@ -61,10 +61,10 @@ namespace imc
|
||||
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),
|
||||
ulint_(0), slint_(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),
|
||||
ulint_(0), slint_(0), sfloat_(0.0), sdouble_(num),
|
||||
sdigital_(num), dtidx_(10) {};
|
||||
|
||||
// identify type
|
||||
|
@@ -87,7 +87,8 @@ namespace imc
|
||||
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,"NE","extraction rule for BUS channels",1),
|
||||
key(false,"NL","language info and code page",1)
|
||||
|
||||
};
|
||||
|
||||
|
@@ -500,22 +500,22 @@ namespace imc
|
||||
minute_ = std::stoi( get_parameter(buffer,¶meters[6]) );
|
||||
second_ = std::stod( get_parameter(buffer,¶meters[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,×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_)
|
||||
// + std::string(":") + std::to_string(minute_)
|
||||
// + std::string(":") + std::to_string(second_);
|
||||
//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,×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_)
|
||||
+ std::string(":") + std::to_string(minute_)
|
||||
+ std::string(":") + std::to_string(second_);
|
||||
}
|
||||
|
||||
// get info string
|
||||
|
@@ -123,20 +123,20 @@ namespace imc
|
||||
leng.push_back((char)*(it+pos));
|
||||
pos++;
|
||||
}
|
||||
unsigned long length = std::stoul(leng);
|
||||
unsigned long int 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,
|
||||
imc::block blk(itkey,(unsigned long int)(it-buffer_.begin()),
|
||||
(unsigned long int)(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() )
|
||||
if ( (unsigned long int)(it-buffer_.begin()+length) < (unsigned long int)(buffer_.size()) )
|
||||
{
|
||||
std::advance(it,length);
|
||||
}
|
||||
@@ -217,6 +217,7 @@ namespace imc
|
||||
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() )
|
||||
@@ -252,7 +253,7 @@ namespace imc
|
||||
// provide buffer size
|
||||
unsigned long int buffer_size()
|
||||
{
|
||||
return buffer_.size();
|
||||
return (unsigned long int)buffer_.size();
|
||||
}
|
||||
|
||||
// get blocks
|
||||
@@ -376,7 +377,7 @@ namespace imc
|
||||
std::filesystem::path pf = pd / filenam;
|
||||
|
||||
// and print the channel
|
||||
it->second.print(pf,sep);
|
||||
it->second.print(pf.u8string(),sep);
|
||||
}
|
||||
}
|
||||
|
||||
|
21
pip/setup.py
21
pip/setup.py
@@ -1,12 +1,24 @@
|
||||
|
||||
from setuptools import setup, Extension
|
||||
import sys
|
||||
|
||||
print("building on platform: "+sys.platform)
|
||||
|
||||
if sys.platform == "linux" or sys.platform == "darwin" :
|
||||
cmpargs = ['-std=c++17','-Wno-unused-variable']
|
||||
lnkargs = ['-std=c++17','-Wno-unused-variable']
|
||||
elif sys.platform == "win32" :
|
||||
cmpargs = ['/EHsc','/std:c++17']
|
||||
lnkargs = []
|
||||
else :
|
||||
raise RuntimeError("unknown platform")
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setup(
|
||||
name="IMCtermite",
|
||||
version="1.2.4",
|
||||
version="1.2.8",
|
||||
author="Record Evolution GmbH",
|
||||
author_email="mario.fink@record-evolution.de",
|
||||
maintainer="Record Evolution GmbH",
|
||||
@@ -30,7 +42,8 @@ setup(
|
||||
# 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'],
|
||||
)],
|
||||
extra_compile_args=cmpargs,
|
||||
extra_link_args=lnkargs,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@@ -133,7 +133,7 @@ void show_version()
|
||||
void show_usage()
|
||||
{
|
||||
std::cout<<"\n"
|
||||
<<"imctermite ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/IMCtermite.git)"
|
||||
<<"imctermite ["<<gittag<<"-g"<<githash<<"] (https://github.com/RecordEvolution/IMCtermite.git)"
|
||||
<<"\n\n"
|
||||
<<"Decode IMC raw files and dump data as *.csv"
|
||||
<<"\n\n"
|
||||
|
Reference in New Issue
Block a user