start group - channel - component - buffer association
This commit is contained in:
parent
9bac0f1063
commit
f4ecf48218
@ -142,6 +142,22 @@ namespace imc
|
|||||||
return parambuff;
|
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
|
// get info string
|
||||||
std::string get_info(bool include_object = true, int width = 20)
|
std::string get_info(bool include_object = true, int width = 20)
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ namespace imc
|
|||||||
{"CT", key(true,"CT","text definition",1)},
|
{"CT", key(true,"CT","text definition",1)},
|
||||||
{"CG", key(true,"CG","group of components",1)},
|
{"CG", key(true,"CG","group of components",1)},
|
||||||
{"CD", key(true,"CD","abscissa description",1)},
|
{"CD", key(true,"CD","abscissa description",1)},
|
||||||
{"CD", key(true,"CD","abscissa description",2)},
|
// {"CD2", key(true,"CD","abscissa description",2)},
|
||||||
{"CZ", key(true,"CZ","scaling of z-axis",1)},
|
{"CZ", key(true,"CZ","scaling of z-axis",1)},
|
||||||
{"CC", key(true,"CC","start of component",1)},
|
{"CC", key(true,"CC","start of component",1)},
|
||||||
{"CP", key(true,"CP","buffer, datatype and samples of component",1)},
|
{"CP", key(true,"CP","buffer, datatype and samples of component",1)},
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "imc_block.hpp"
|
#include "imc_block.hpp"
|
||||||
#include "imc_datatype.hpp"
|
#include "imc_datatype.hpp"
|
||||||
#include "imc_object.hpp"
|
#include "imc_object.hpp"
|
||||||
|
#include "imc_result.hpp"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
@ -233,9 +234,90 @@ namespace imc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// list all channels
|
// list all channels
|
||||||
std::vector<imc::block> list_channels()
|
std::vector<std::string> list_channels()
|
||||||
{
|
{
|
||||||
return this->list_blocks(imc::keys.at("CN"));
|
std::vector<std::string> channels;
|
||||||
|
for ( imc::block blk: this->rawblocks_ )
|
||||||
|
{
|
||||||
|
if ( blk.get_key() == imc::keys.at("CN") )
|
||||||
|
{
|
||||||
|
imc::parameter prm = blk.get_parameters()[6];
|
||||||
|
channels.push_back(blk.get_parameter(prm));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get specific channel data
|
||||||
|
// TODO generalize and simplify channel extraction!!
|
||||||
|
imc::channel_tab get_channel(std::string channel)
|
||||||
|
{
|
||||||
|
// declare single channel table
|
||||||
|
imc::channel_tab chtab;
|
||||||
|
|
||||||
|
// ordinate parameters
|
||||||
|
std::string yunit = std::string("");
|
||||||
|
unsigned long int num_samples = -1;
|
||||||
|
// imc::datatype dtype;
|
||||||
|
int numbits = -1;
|
||||||
|
double yoffset = -1.0, yfactor = -1.0;
|
||||||
|
|
||||||
|
// abscissa parameters
|
||||||
|
double dx = -1.0;
|
||||||
|
double xoffset = -1.0;
|
||||||
|
std::string xunit = std::string("");
|
||||||
|
|
||||||
|
// search block for required parameters
|
||||||
|
for ( imc::block blk: this->rawblocks_ )
|
||||||
|
{
|
||||||
|
if ( blk.get_key() == imc::keys.at("CR") )
|
||||||
|
{
|
||||||
|
yunit = blk.get_parameter(blk.get_parameters()[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( blk.get_key() == imc::keys.at("Cb") )
|
||||||
|
{
|
||||||
|
num_samples = std::stoul(blk.get_parameter(blk.get_parameters()[7]));
|
||||||
|
xoffset = std::stod(blk.get_parameter(blk.get_parameters()[11]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( blk.get_key() == imc::keys.at("CP") )
|
||||||
|
{
|
||||||
|
numbits = std::stoi(blk.get_parameter(blk.get_parameters()[5]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( blk.get_key() == imc::keys.at("CR") )
|
||||||
|
{
|
||||||
|
yfactor = std::stod(blk.get_parameter(blk.get_parameters()[3]));
|
||||||
|
yoffset = std::stod(blk.get_parameter(blk.get_parameters()[4]));
|
||||||
|
yunit = blk.get_parameter(blk.get_parameters()[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( blk.get_key() == imc::keys.at("CD") )
|
||||||
|
{
|
||||||
|
std::cout<<"got CD\n";
|
||||||
|
dx = std::stod(blk.get_parameter(blk.get_parameters()[2]));
|
||||||
|
xunit = blk.get_parameter(blk.get_parameters()[7]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout<<"yunit:"<<yunit<<"\n"
|
||||||
|
<<"yoffset:"<<yoffset<<"\n"
|
||||||
|
<<"yfactor:"<<yfactor<<"\n"
|
||||||
|
<<"numbits:"<<numbits<<"\n"
|
||||||
|
<<"num_samples:"<<num_samples<<"\n"
|
||||||
|
<<"dx:"<<dx<<"\n"
|
||||||
|
<<"xoffset:"<<xoffset<<"\n"
|
||||||
|
<<"xunit:"<<xunit<<"\n";
|
||||||
|
|
||||||
|
// generate abscissa data
|
||||||
|
|
||||||
|
|
||||||
|
// generate ordinate data
|
||||||
|
|
||||||
|
|
||||||
|
return chtab;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
30
lib/imc_result.hpp
Normal file
30
lib/imc_result.hpp
Normal 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
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
@ -193,8 +193,13 @@ int main(int argc, char* argv[])
|
|||||||
// for ( auto blk: CSblocks ) std::cout<<blk.get_info()<<"\n";
|
// for ( auto blk: CSblocks ) std::cout<<blk.get_info()<<"\n";
|
||||||
// std::vector<imc::block> groups = imcraw.list_groups();
|
// std::vector<imc::block> groups = imcraw.list_groups();
|
||||||
// for ( auto blk: groups ) std::cout<<blk.get_info()<<"\n";
|
// for ( auto blk: groups ) std::cout<<blk.get_info()<<"\n";
|
||||||
// std::vector<imc::block> channels = imcraw.list_channels();
|
|
||||||
// for ( auto blk: channels ) std::cout<<blk.get_info()<<"\n";
|
// std::vector<std::string> channels = imcraw.list_channels();
|
||||||
|
// for ( auto chn: channels )
|
||||||
|
// {
|
||||||
|
// std::cout<<chn<<"\n";
|
||||||
|
// imc::channel_tab chtab = imcraw.get_channel(chn);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user