finished conversion + CLI

This commit is contained in:
Mario Fink 2021-02-11 19:21:26 +01:00
parent 3afa7fe345
commit 0107e367c4
5 changed files with 233 additions and 109 deletions

View File

@ -5,6 +5,7 @@
#include <sstream> #include <sstream>
#include "imc_datatype.hpp" #include "imc_datatype.hpp"
#include "imc_conversion.hpp"
//---------------------------------------------------------------------------// //---------------------------------------------------------------------------//
@ -114,7 +115,8 @@ namespace imc
{ {
// associated environment of blocks and map of blocks // associated environment of blocks and map of blocks
channel_env chnenv_; channel_env chnenv_;
const std::map<std::string,imc::block>* blocks_; std::map<std::string,imc::block>* blocks_;
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
@ -123,7 +125,7 @@ namespace imc
std::string origin_, origin_comment_, text_; std::string origin_, origin_comment_, text_;
std::string yname_, yunit_; std::string yname_, yunit_;
std::string xname_, xunit_; std::string xname_, xunit_;
double xstepwidth_; double xstepwidth_, xoffset_;
// buffer and data // buffer and data
int signbits_, num_bytes_; int signbits_, num_bytes_;
@ -132,7 +134,7 @@ namespace imc
int datatp_; int datatp_;
imc::datatype dattyp_; imc::datatype dattyp_;
std::vector<imc::datatype> ydata_; std::vector<imc::datatype> ydata_;
std::vector<imc::datatype> xdata_; std::vector<double> xdata_;
// range, factor and offset // range, factor and offset
double factor_, offset_; double factor_, offset_;
@ -142,8 +144,9 @@ namespace imc
std::string group_uuid_, group_name_, group_comment_; std::string group_uuid_, group_name_, group_comment_;
// constructor takes channel's block environment // 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,
chnenv_(chnenv), blocks_(blocks), group_index_(-1) std::vector<unsigned char>* buffer):
chnenv_(chnenv), blocks_(blocks), buffer_(buffer), group_index_(-1)
{ {
// declare list of block parameters // declare list of block parameters
std::vector<imc::parameter> prms; std::vector<imc::parameter> prms;
@ -152,76 +155,159 @@ namespace imc
uuid_ = chnenv_.CNuuid_; uuid_ = chnenv_.CNuuid_;
// extract associated CB data // extract associated CB data
if ( blocks->count(chnenv_.CBuuid_) == 1 ) if ( blocks_->count(chnenv_.CBuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CBuuid_).get_parameters(); prms = blocks_->at(chnenv_.CBuuid_).get_parameters();
group_index_ = std::stoi(blocks->at(chnenv_.CBuuid_).get_parameter(prms[2])); group_index_ = std::stoi(blocks_->at(chnenv_.CBuuid_).get_parameter(prms[2]));
group_name_ = blocks->at(chnenv_.CBuuid_).get_parameter(prms[4]); group_name_ = blocks_->at(chnenv_.CBuuid_).get_parameter(prms[4]);
group_comment_ = blocks->at(chnenv_.CBuuid_).get_parameter(prms[6]); group_comment_ = blocks_->at(chnenv_.CBuuid_).get_parameter(prms[6]);
} }
// extract associated CT data // extract associated CT data
if ( blocks->count(chnenv_.CTuuid_) == 1 ) if ( blocks_->count(chnenv_.CTuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CTuuid_).get_parameters(); prms = blocks_->at(chnenv_.CTuuid_).get_parameters();
text_ = blocks->at(chnenv_.CTuuid_).get_parameter(prms[4]) + std::string(" - ") 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[6]) + std::string(" - ")
+ blocks->at(chnenv_.CTuuid_).get_parameter(prms[8]); + blocks_->at(chnenv_.CTuuid_).get_parameter(prms[8]);
} }
// extract associated CD data // extract associated CD data
if ( blocks->count(chnenv_.CDuuid_) == 1 ) if ( blocks_->count(chnenv_.CDuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CDuuid_).get_parameters(); prms = blocks_->at(chnenv_.CDuuid_).get_parameters();
xstepwidth_ = std::stod(blocks->at(chnenv_.CDuuid_).get_parameter(prms[2])); xstepwidth_ = std::stod(blocks_->at(chnenv_.CDuuid_).get_parameter(prms[2]));
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");
} }
// extract associated CP data // extract associated CP data
if ( blocks->count(chnenv_.CPuuid_) == 1 ) if ( blocks_->count(chnenv_.CPuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CPuuid_).get_parameters(); prms = blocks_->at(chnenv_.CPuuid_).get_parameters();
datatp_ = std::stoi(blocks->at(chnenv_.CPuuid_).get_parameter(prms[3])); num_bytes_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[3]));
num_bytes_ = std::stoi(blocks->at(chnenv_.CPuuid_).get_parameter(prms[4])); datatp_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[4]));
signbits_ = std::stoi(blocks->at(chnenv_.CPuuid_).get_parameter(prms[5])); signbits_ = std::stoi(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[5]));
// byte_offset_ = std::stoul(blocks->at(chnenv_.CPuuid_).get_parameter(prms[7])); // byte_offset_ = std::stoul(blocks_->at(chnenv_.CPuuid_).get_parameter(prms[7]));
} }
// extract associated Cb data // extract associated Cb data
if ( blocks->count(chnenv_.Cbuuid_) == 1 ) if ( blocks_->count(chnenv_.Cbuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.Cbuuid_).get_parameters(); prms = blocks_->at(chnenv_.Cbuuid_).get_parameters();
buffer_offset_ = std::stoul(blocks->at(chnenv_.Cbuuid_).get_parameter(prms[6])); buffer_offset_ = std::stoul(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[6]));
buffer_size_ = std::stoul(blocks->at(chnenv_.Cbuuid_).get_parameter(prms[7])); 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 // extract associated CR data
if ( blocks->count(chnenv_.CRuuid_) == 1 ) if ( blocks_->count(chnenv_.CRuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CRuuid_).get_parameters(); prms = blocks_->at(chnenv_.CRuuid_).get_parameters();
factor_ = std::stod(blocks->at(chnenv_.CRuuid_).get_parameter(prms[3])); factor_ = std::stod(blocks_->at(chnenv_.CRuuid_).get_parameter(prms[3]));
offset_ = std::stod(blocks->at(chnenv_.CRuuid_).get_parameter(prms[4])); offset_ = std::stod(blocks_->at(chnenv_.CRuuid_).get_parameter(prms[4]));
yunit_ = blocks->at(chnenv_.CRuuid_).get_parameter(prms[7]); yunit_ = blocks_->at(chnenv_.CRuuid_).get_parameter(prms[7]);
} }
// extract associated CN data // extract associated CN data
if ( blocks->count(chnenv_.CNuuid_) == 1 ) if ( blocks_->count(chnenv_.CNuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.CNuuid_).get_parameters(); prms = blocks_->at(chnenv_.CNuuid_).get_parameters();
name_ = blocks->at(chnenv_.CNuuid_).get_parameter(prms[6]); name_ = blocks_->at(chnenv_.CNuuid_).get_parameter(prms[6]);
yname_ = name_; yname_ = name_;
comment_ = blocks->at(chnenv_.CNuuid_).get_parameter(prms[8]); comment_ = blocks_->at(chnenv_.CNuuid_).get_parameter(prms[8]);
// group_index_ = std::stoi(blocks->at(chnenv_.CNuuid_).get_parameter(prms[2])); // group_index_ = std::stoi(blocks_->at(chnenv_.CNuuid_).get_parameter(prms[2]));
} }
// extract associated NO data // extract associated NO data
if ( blocks->count(chnenv_.NOuuid_) == 1 ) if ( blocks_->count(chnenv_.NOuuid_) == 1 )
{ {
prms = blocks->at(chnenv_.NOuuid_).get_parameters(); prms = blocks_->at(chnenv_.NOuuid_).get_parameters();
origin_ = blocks->at(chnenv_.NOuuid_).get_parameter(prms[4]); origin_ = blocks_->at(chnenv_.NOuuid_).get_parameter(prms[4]);
origin_comment_ = blocks->at(chnenv_.NOuuid_).get_parameter(prms[6]); origin_comment_ = blocks_->at(chnenv_.NOuuid_).get_parameter(prms[6]);
}
// 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
{
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_);
}
} }
} }
@ -243,13 +329,14 @@ namespace imc
<<std::setw(width)<<std::left<<"xname:"<<xname_<<"\n" <<std::setw(width)<<std::left<<"xname:"<<xname_<<"\n"
<<std::setw(width)<<std::left<<"xunit:"<<xunit_<<"\n" <<std::setw(width)<<std::left<<"xunit:"<<xunit_<<"\n"
<<std::setw(width)<<std::left<<"xstepwidth:"<<xstepwidth_<<"\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<<"factor:"<<factor_<<"\n"
<<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_)<<"\n"
<<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<imc::datatype>(xdata_)<<"\n" <<std::setw(width)<<std::left<<"xdata:"<<imc::joinvec<double>(xdata_)<<"\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();
} }
@ -268,11 +355,12 @@ namespace imc
<<"\",\"xname\":\""<<xname_ <<"\",\"xname\":\""<<xname_
<<"\",\"xunit\":\""<<xunit_ <<"\",\"xunit\":\""<<xunit_
<<"\",\"xstepwidth\":\""<<xstepwidth_ <<"\",\"xstepwidth\":\""<<xstepwidth_
<<"\",\"xoffset\":\""<<xoffset_
<<"\",\"group\":{"<<"\"index\":\""<<group_index_ <<"\",\"group\":{"<<"\"index\":\""<<group_index_
<<"\",\"name\":\""<<group_name_ <<"\",\"name\":\""<<group_name_
<<"\",\"comment\":\""<<group_comment_<<"\""<<"}" <<"\",\"comment\":\""<<group_comment_<<"\""<<"}"
<<"\",\"ydata\":\""<<imc::joinvec<imc::datatype>(ydata_) <<"\",\"ydata\":\""<<imc::joinvec<imc::datatype>(ydata_)
<<"\",\"xdata\":\""<<imc::joinvec<imc::datatype>(xdata_) <<"\",\"xdata\":\""<<imc::joinvec<double>(xdata_)
<<"\",\"aff. blocks\":\""<<chnenv_.get_json() <<"\",\"aff. blocks\":\""<<chnenv_.get_json()
<<"\"}"; <<"\"}";
return ss.str(); return ss.str();

45
lib/imc_conversion.hpp Normal file
View File

@ -0,0 +1,45 @@
//---------------------------------------------------------------------------//
#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("size mismatch between subbuffer and datatype");
}
// 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;
}
}
}
#endif
//---------------------------------------------------------------------------//

View File

@ -32,10 +32,10 @@ namespace imc
short int dtidx_; // \in \{0,...,7\} short int dtidx_; // \in \{0,...,7\}
public: public:
datatype(): ubyte_(0), sbyte_(0), datatype(): ubyte_(0), sbyte_(0),
ushort_(0), sshort_(0), ushort_(0), sshort_(0),
ulint_(0.0), slint_(0.0), ulint_(0.0), slint_(0.0),
sfloat_(0.0), sdouble_(0.0), sfloat_(0.0), sdouble_(0.0),
dtidx_(0) { }; dtidx_(0) { };
// every supported datatype gets its own constructor // every supported datatype gets its own constructor
datatype(imc_Ubyte num): ubyte_(num), dtidx_(0) {}; datatype(imc_Ubyte num): ubyte_(num), dtidx_(0) {};
datatype(imc_Sbyte num): sbyte_(num), dtidx_(1) {}; datatype(imc_Sbyte num): sbyte_(num), dtidx_(1) {};
@ -44,7 +44,9 @@ namespace imc
datatype(imc_Ulongint num): ulint_(num), dtidx_(4) {}; datatype(imc_Ulongint num): ulint_(num), dtidx_(4) {};
datatype(imc_Slongint num): slint_(num), dtidx_(5) {}; datatype(imc_Slongint num): slint_(num), dtidx_(5) {};
datatype(imc_float num): sfloat_(num), dtidx_(6) {}; datatype(imc_float num): sfloat_(num), dtidx_(6) {};
datatype(imc_double num): sdouble_(num), dtidx_(7) {}; 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) {};
// identify type // identify type
short int& dtype() { return dtidx_; } short int& dtype() { return dtidx_; }
@ -142,8 +144,8 @@ namespace imc
else if ( num.dtidx_ == 3 ) out<<num.sshort_; else if ( num.dtidx_ == 3 ) out<<num.sshort_;
else if ( num.dtidx_ == 4 ) out<<num.ulint_; else if ( num.dtidx_ == 4 ) out<<num.ulint_;
else if ( num.dtidx_ == 5 ) out<<num.slint_; else if ( num.dtidx_ == 5 ) out<<num.slint_;
else if ( num.dtidx_ == 5 ) out<<num.sfloat_; else if ( num.dtidx_ == 6 ) out<<num.sfloat_;
else if ( num.dtidx_ == 6 ) out<<num.sdouble_; else if ( num.dtidx_ == 7 ) out<<num.sdouble_;
return out; return out;
} }

View File

@ -229,7 +229,7 @@ namespace imc
// create channel object and add it to the map of channels // create channel object and add it to the map of channels
channels_.insert( std::pair<std::string,imc::channel> channels_.insert( std::pair<std::string,imc::channel>
(chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_)) (chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_,&buffer_))
); );
// reset channel uuid // reset channel uuid
@ -245,35 +245,6 @@ namespace imc
} }
} }
// parse channel's raw data
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("size mismatch between subbuffer and datatype");
}
// 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;
}
}
public: public:

View File

@ -36,11 +36,11 @@ optkeys parse_args(int argc, char* argv[], bool list_args = false)
{ {
prsdkeys.insert(std::pair<std::string,std::string>("showmeta",argv[i])); prsdkeys.insert(std::pair<std::string,std::string>("showmeta",argv[i]));
} }
else if ( std::string(argv[i]) == std::string("--listgroups") // else if ( std::string(argv[i]) == std::string("--listgroups")
|| std::string(argv[i]) == std::string("-g") ) // || std::string(argv[i]) == std::string("-g") )
{ // {
prsdkeys.insert(std::pair<std::string,std::string>("listgroups",argv[i])); // prsdkeys.insert(std::pair<std::string,std::string>("listgroups",argv[i]));
} // }
else if ( std::string(argv[i]) == std::string("--listchannels") else if ( std::string(argv[i]) == std::string("--listchannels")
|| std::string(argv[i]) == std::string("-c") ) || std::string(argv[i]) == std::string("-c") )
{ {
@ -51,17 +51,17 @@ optkeys parse_args(int argc, char* argv[], bool list_args = false)
{ {
prsdkeys.insert(std::pair<std::string,std::string>("listblocks",argv[i])); prsdkeys.insert(std::pair<std::string,std::string>("listblocks",argv[i]));
} }
else if ( std::string(argv[i]) == std::string("--filename") else if ( std::string(argv[i]) == std::string("--output")
|| std::string(argv[i]) == std::string("-f") ) || std::string(argv[i]) == std::string("-d") )
{ {
if ( i+1 == argc || argv[i+1][0] == '-' ) if ( i+1 == argc || argv[i+1][0] == '-' )
{ {
std::cerr<<"invalid or missing --filename argument\n"; std::cerr<<"invalid or missing --output argument\n";
prsdkeys.insert(std::pair<std::string,std::string>("invalid","filename")); prsdkeys.insert(std::pair<std::string,std::string>("invalid","output"));
} }
else else
{ {
prsdkeys.insert(std::pair<std::string,std::string>("filename",argv[i+1])); prsdkeys.insert(std::pair<std::string,std::string>("output",argv[i+1]));
i = i + 1; i = i + 1;
} }
} }
@ -116,10 +116,10 @@ void show_usage()
<<"Options:" <<"Options:"
<<"\n\n" <<"\n\n"
<<" -m, --showmeta show meta information about IMC dataset\n" <<" -m, --showmeta show meta information about IMC dataset\n"
<<" -g, --listgroups list channelgroups\n" // <<" -g, --listgroups list channelgroups\n"
<<" -c, --listchannels list channels\n" <<" -c, --listchannels list channels\n"
<<" -b, --listblocks list IMC key-blocks\n" <<" -b, --listblocks list IMC key-blocks\n"
<<" -f, --filename filename for csv output\n" <<" -d, --output output directory\n"
<<" -h, --help show this help message \n" <<" -h, --help show this help message \n"
<<" -v, --version display version\n" <<" -v, --version display version\n"
<<"\n"; <<"\n";
@ -146,13 +146,20 @@ int main(int argc, char* argv[])
else else
{ {
// check for at least one file argument // check for at least one file argument
if ( cfgopts.size() == (unsigned int)argc-1 ) if ( argc == 1 )
{ {
std::cerr<<"no .raw file given => check --help for usage\n"; std::cerr<<"no .raw file given => check --help for usage\n";
return 1; return 1;
} }
std::string rawfile(argv[1]); std::string rawfile(argv[1]);
// one further argument to do something useful with the file
if ( argc == 2 )
{
std::cerr<<"provide any option => check --help for usage\n";
return 1;
}
// check existence of file // check existence of file
std::filesystem::path rawpath = rawfile; std::filesystem::path rawpath = rawfile;
if ( !std::filesystem::exists(rawpath) ) if ( !std::filesystem::exists(rawpath) )
@ -170,20 +177,31 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
// // list blocks // list blocks
// for ( imc::block blk: imcraw.blocks() ) if ( cfgopts.count("listblocks") == 1 )
// { {
// std::cout<<blk.get_key().get_info()<<"\n"; for ( imc::block blk: imcraw.blocks() )
// std::cout<<blk.get_info()<<"\n"; {
// } // std::cout<<blk.get_key().get_info()<<"\n";
std::cout<<"number of blocks: "<<imcraw.blocks().size()<<"\n"; std::cout<<blk.get_info()<<"\n";
std::cout<<"computational complexity: "<<imcraw.computational_complexity() }
<<"/"<<imcraw.buffer_size()<<"\n\n"; std::cout<<"number of blocks: "<<imcraw.blocks().size()<<"\n";
// std::cout<<"computational complexity: "<<imcraw.computational_complexity()
// <<"/"<<imcraw.buffer_size()<<"\n\n";
}
// list channels // list channels
std::cout<<"list of channels:\n"; if ( cfgopts.count("listchannels") == 1 )
std::vector<std::string> channels = imcraw.get_channels(); {
for ( auto el: channels ) std::cout<<el<<"\n"; std::vector<std::string> channels = imcraw.get_channels();
for ( auto el: channels ) std::cout<<el<<"\n";
}
// print channel(s) to certain directory
if ( cfgopts.count("directory") == 1 )
{
std::cout<<cfgopts.at("directory")<<"\n";
}
} }