|
|
@@ -6,6 +6,7 @@
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include "imc_datatype.hpp"
|
|
|
|
#include "imc_datatype.hpp"
|
|
|
|
#include "imc_conversion.hpp"
|
|
|
|
#include "imc_conversion.hpp"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------//
|
|
|
|
//---------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
|
@@ -20,7 +21,7 @@ namespace imc
|
|
|
|
// collect affiliate blocks for a single channel
|
|
|
|
// collect affiliate blocks for a single channel
|
|
|
|
std::string CBuuid_, CGuuid_, CCuuid_, CNuuid_;
|
|
|
|
std::string CBuuid_, CGuuid_, CCuuid_, CNuuid_;
|
|
|
|
std::string CDuuid_, CTuuid_, Cbuuid_, CPuuid_, CRuuid_, CSuuid_;
|
|
|
|
std::string CDuuid_, CTuuid_, Cbuuid_, CPuuid_, CRuuid_, CSuuid_;
|
|
|
|
std::string NTuuid_, NOuuid_;
|
|
|
|
std::string NTuuid_, NOuuid_, NLuuid_;
|
|
|
|
|
|
|
|
|
|
|
|
// reset all members
|
|
|
|
// reset all members
|
|
|
|
void reset()
|
|
|
|
void reset()
|
|
|
@@ -38,6 +39,7 @@ namespace imc
|
|
|
|
CSuuid_.clear();
|
|
|
|
CSuuid_.clear();
|
|
|
|
NTuuid_.clear();
|
|
|
|
NTuuid_.clear();
|
|
|
|
NOuuid_.clear();
|
|
|
|
NOuuid_.clear();
|
|
|
|
|
|
|
|
NLuuid_.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// get info
|
|
|
|
// get info
|
|
|
@@ -58,7 +60,8 @@ namespace imc
|
|
|
|
<<std::setw(width)<<std::left<<"CSuuid:"<<CSuuid_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"CSuuid:"<<CSuuid_<<"\n"
|
|
|
|
//
|
|
|
|
//
|
|
|
|
<<std::setw(width)<<std::left<<"NTuuid:"<<NTuuid_<<"\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();
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -79,32 +82,55 @@ namespace imc
|
|
|
|
<<"\",\"CSuuid\":\""<<CSuuid_
|
|
|
|
<<"\",\"CSuuid\":\""<<CSuuid_
|
|
|
|
<<"\",\"NTuuid\":\""<<NTuuid_
|
|
|
|
<<"\",\"NTuuid\":\""<<NTuuid_
|
|
|
|
<<"\",\"NOuuid\":\""<<NOuuid_
|
|
|
|
<<"\",\"NOuuid\":\""<<NOuuid_
|
|
|
|
|
|
|
|
<<"\",\"NLuuid\":\""<<NLuuid_
|
|
|
|
<<"\"}";
|
|
|
|
<<"\"}";
|
|
|
|
return ss.str();
|
|
|
|
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
|
|
|
|
// given a list of numeric objects, join it into a string
|
|
|
|
template<typename dt>
|
|
|
|
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;
|
|
|
|
limit = (limit == 0) ? myvec.size() : limit;
|
|
|
|
|
|
|
|
|
|
|
|
std::stringstream ss;
|
|
|
|
std::stringstream ss;
|
|
|
|
ss<<"[";
|
|
|
|
ss<<"[";
|
|
|
|
if ( myvec.size() <= limit )
|
|
|
|
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
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned long int heals = (unsigned long int)(limit/2.);
|
|
|
|
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<<"...";
|
|
|
|
ss<<"...";
|
|
|
|
for ( unsigned long int i = myvec.size()-heals; i < myvec.size(); i++ )
|
|
|
|
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();
|
|
|
|
std::string sumstr = ss.str();
|
|
|
@@ -122,13 +148,15 @@ namespace imc
|
|
|
|
std::vector<unsigned char>* buffer_;
|
|
|
|
std::vector<unsigned char>* buffer_;
|
|
|
|
|
|
|
|
|
|
|
|
// collect meta-data of channels according to env,
|
|
|
|
// collect meta-data of channels according to env,
|
|
|
|
// just everything valueable in here
|
|
|
|
// just everything valueable in here
|
|
|
|
std::string uuid_;
|
|
|
|
std::string uuid_;
|
|
|
|
std::string name_, comment_;
|
|
|
|
std::string name_, comment_;
|
|
|
|
std::string origin_, origin_comment_, text_;
|
|
|
|
std::string origin_, origin_comment_, text_;
|
|
|
|
|
|
|
|
std::string language_code_, codepage_;
|
|
|
|
std::string yname_, yunit_;
|
|
|
|
std::string yname_, yunit_;
|
|
|
|
std::string xname_, xunit_;
|
|
|
|
std::string xname_, xunit_;
|
|
|
|
double xstepwidth_, xoffset_;
|
|
|
|
double xstepwidth_, xoffset_;
|
|
|
|
|
|
|
|
int xprec_;
|
|
|
|
|
|
|
|
|
|
|
|
// buffer and data
|
|
|
|
// buffer and data
|
|
|
|
int signbits_, num_bytes_;
|
|
|
|
int signbits_, num_bytes_;
|
|
|
@@ -185,6 +213,9 @@ namespace imc
|
|
|
|
xunit_ = blocks_->at(chnenv_.CDuuid_).get_parameter(prms[5]);
|
|
|
|
xunit_ = blocks_->at(chnenv_.CDuuid_).get_parameter(prms[5]);
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
// xname_ = std::string("time");
|
|
|
|
// xname_ = std::string("time");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// find appropriate precision for "xdata_" by means of "xstepwidth_"
|
|
|
|
|
|
|
|
xprec_ = (xstepwidth_ > 0 ) ? ceil(fabs(log10(xstepwidth_))) : 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// extract associated CP data
|
|
|
|
// extract associated CP data
|
|
|
@@ -233,6 +264,19 @@ namespace imc
|
|
|
|
origin_comment_ = blocks_->at(chnenv_.NOuuid_).get_parameter(prms[6]);
|
|
|
|
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
|
|
|
|
// start converting binary buffer to imc::datatype
|
|
|
|
if ( !chnenv_.CSuuid_.empty() ) convert_buffer();
|
|
|
|
if ( !chnenv_.CSuuid_.empty() ) convert_buffer();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -330,6 +374,8 @@ namespace imc
|
|
|
|
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"comment:"<<comment_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"origin:"<<origin_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"origin:"<<origin_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"description:"<<text_<<"\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<<"yname:"<<yname_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"yunit:"<<yunit_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"yunit:"<<yunit_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"datatype:"<<datatp_<<"\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<<"offset:"<<offset_<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"group:"<<"("<<group_index_<<","<<group_name_
|
|
|
|
<<std::setw(width)<<std::left<<"group:"<<"("<<group_index_<<","<<group_name_
|
|
|
|
<<","<<group_comment_<<")"<<"\n"
|
|
|
|
<<","<<group_comment_<<")"<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"ydata:"<<imc::joinvec<imc::datatype>(ydata_)<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"ydata:"<<imc::joinvec<imc::datatype>(ydata_,10,9,true)<<"\n"
|
|
|
|
<<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<double>(xdata_)<<"\n";
|
|
|
|
<<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<double>(xdata_,10,xprec_,true)<<"\n";
|
|
|
|
// <<std::setw(width)<<std::left<<"aff. blocks:"<<chnenv_.get_json()<<"\n";
|
|
|
|
// <<std::setw(width)<<std::left<<"aff. blocks:"<<chnenv_.get_json()<<"\n";
|
|
|
|
return ss.str();
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -359,6 +405,8 @@ namespace imc
|
|
|
|
<<"\",\"comment\":\""<<comment_
|
|
|
|
<<"\",\"comment\":\""<<comment_
|
|
|
|
<<"\",\"origin\":\""<<origin_
|
|
|
|
<<"\",\"origin\":\""<<origin_
|
|
|
|
<<"\",\"description\":\""<<text_
|
|
|
|
<<"\",\"description\":\""<<text_
|
|
|
|
|
|
|
|
<<"\",\"language-code\":\""<<language_code_
|
|
|
|
|
|
|
|
<<"\",\"codepage\":\""<<codepage_
|
|
|
|
<<"\",\"yname\":\""<<yname_
|
|
|
|
<<"\",\"yname\":\""<<yname_
|
|
|
|
<<"\",\"yunit\":\""<<yunit_
|
|
|
|
<<"\",\"yunit\":\""<<yunit_
|
|
|
|
<<"\",\"significantbits\":\""<<signbits_
|
|
|
|
<<"\",\"significantbits\":\""<<signbits_
|
|
|
@@ -371,8 +419,8 @@ namespace imc
|
|
|
|
<<"\",\"comment\":\""<<group_comment_<<"\""<<"}";
|
|
|
|
<<"\",\"comment\":\""<<group_comment_<<"\""<<"}";
|
|
|
|
if ( include_data )
|
|
|
|
if ( include_data )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ss<<",\"ydata\":"<<imc::joinvec<imc::datatype>(ydata_,0)
|
|
|
|
ss<<",\"ydata\":"<<imc::joinvec<imc::datatype>(ydata_,0,9,true)
|
|
|
|
<<",\"xdata\":"<<imc::joinvec<double>(xdata_,0);
|
|
|
|
<<",\"xdata\":"<<imc::joinvec<double>(xdata_,0,xprec_,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ss<<"\",\"aff. blocks\":\""<<chnenv_.get_json()
|
|
|
|
// ss<<"\",\"aff. blocks\":\""<<chnenv_.get_json()
|
|
|
|
ss<<"}";
|
|
|
|
ss<<"}";
|
|
|
@@ -381,7 +429,7 @@ namespace imc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// print channel
|
|
|
|
// 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);
|
|
|
|
std::ofstream fou(filename);
|
|
|
|
|
|
|
|
|
|
|
@@ -402,13 +450,16 @@ namespace imc
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( sep == ' ' )
|
|
|
|
if ( sep == ' ' )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fou<<std::setprecision(9)<<std::fixed
|
|
|
|
fou<<std::setprecision(xprec_)<<std::fixed
|
|
|
|
<<std::setw(width)<<std::left<<xdata_[i]
|
|
|
|
<<std::setw(width)<<std::left<<xdata_[i]
|
|
|
|
|
|
|
|
<<std::setprecision(yprec)<<std::fixed
|
|
|
|
<<std::setw(width)<<std::left<<ydata_[i]<<"\n";
|
|
|
|
<<std::setw(width)<<std::left<<ydata_[i]<<"\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|