Compare commits
No commits in common. "1d30a5f237053f17f9ffc9bf2012af41dc2f5a75" and "69f5e5496b4d6971ee3c6f7b14f10100f7bc7180" have entirely different histories.
1d30a5f237
...
69f5e5496b
@ -3,12 +3,10 @@
|
|||||||
#ifndef IMCCHANNEL
|
#ifndef IMCCHANNEL
|
||||||
#define IMCCHANNEL
|
#define IMCCHANNEL
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
#include "imc_datatype.hpp"
|
#include "imc_datatype.hpp"
|
||||||
#include "imc_conversion.hpp"
|
#include "imc_conversion.hpp"
|
||||||
#include <sstream>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <chrono>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
@ -154,8 +152,6 @@ namespace imc
|
|||||||
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::chrono::system_clock::time_point trigger_time_, absolute_trigger_time_;
|
|
||||||
double trigger_time_frac_secs_;
|
|
||||||
std::string language_code_, codepage_;
|
std::string language_code_, codepage_;
|
||||||
std::string yname_, yunit_;
|
std::string yname_, yunit_;
|
||||||
std::string xname_, xunit_;
|
std::string xname_, xunit_;
|
||||||
@ -166,7 +162,6 @@ namespace imc
|
|||||||
int signbits_, num_bytes_;
|
int signbits_, num_bytes_;
|
||||||
// unsigned long int byte_offset_;
|
// unsigned long int byte_offset_;
|
||||||
unsigned long int buffer_offset_, buffer_size_;
|
unsigned long int buffer_offset_, buffer_size_;
|
||||||
long int addtime_;
|
|
||||||
int datatp_;
|
int datatp_;
|
||||||
imc::datatype dattyp_;
|
imc::datatype dattyp_;
|
||||||
std::vector<imc::datatype> ydata_;
|
std::vector<imc::datatype> ydata_;
|
||||||
@ -240,7 +235,6 @@ namespace imc
|
|||||||
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]));
|
xoffset_ = std::stod(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[11]));
|
||||||
addtime_ = (long int)std::stod(blocks_->at(chnenv_.Cbuuid_).get_parameter(prms[12]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract associated CR data
|
// extract associated CR data
|
||||||
@ -283,35 +277,8 @@ namespace imc
|
|||||||
language_code_ = blocks_->at(chnenv_.NLuuid_).get_parameter(prms[3]);
|
language_code_ = blocks_->at(chnenv_.NLuuid_).get_parameter(prms[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// obtain NT data
|
|
||||||
// - https://en.cppreference.com/w/cpp/chrono/c/tm
|
|
||||||
// - https://en.cppreference.com/w/cpp/io/manip/put_time
|
|
||||||
if ( blocks_->count(chnenv_.NTuuid_) == 1 )
|
|
||||||
{
|
|
||||||
prms = blocks_->at(chnenv_.NTuuid_).get_parameters();
|
|
||||||
//std::tm tm{};
|
|
||||||
std::tm tms = std::tm();
|
|
||||||
tms.tm_mday = std::stoi(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[2]));
|
|
||||||
tms.tm_mon = std::stoi(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[3])) - 1;
|
|
||||||
tms.tm_year = std::stoi(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[4])) - 1900;
|
|
||||||
tms.tm_hour = std::stoi(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[5]));
|
|
||||||
tms.tm_min = std::stoi(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[6]));
|
|
||||||
double secs = std::stold(blocks_->at(chnenv_.NTuuid_).get_parameter(prms[7]));
|
|
||||||
double secs_int;
|
|
||||||
trigger_time_frac_secs_ = modf(secs,&secs_int);
|
|
||||||
tms.tm_sec = (int)secs_int;
|
|
||||||
|
|
||||||
// generate std::chrono::system_clock::time_point type
|
|
||||||
std::time_t ts = std::mktime(&tms);
|
|
||||||
trigger_time_ = std::chrono::system_clock::from_time_t(ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
||||||
// calculate absolute trigger-time
|
|
||||||
absolute_trigger_time_ = trigger_time_ + std::chrono::seconds(addtime_);
|
|
||||||
// + std::chrono::nanoseconds((long int)(trigger_time_frac_secs_*1.e9));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert buffer to actual datatype
|
// convert buffer to actual datatype
|
||||||
@ -401,18 +368,12 @@ namespace imc
|
|||||||
// get info string
|
// get info string
|
||||||
std::string get_info(int width = 20)
|
std::string get_info(int width = 20)
|
||||||
{
|
{
|
||||||
// prepare printable trigger-time
|
|
||||||
//std::time_t tt = std::chrono::system_clock::to_time_t(trigger_time_);
|
|
||||||
std::time_t att = std::chrono::system_clock::to_time_t(absolute_trigger_time_);
|
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<std::setw(width)<<std::left<<"uuid:"<<uuid_<<"\n"
|
ss<<std::setw(width)<<std::left<<"uuid:"<<uuid_<<"\n"
|
||||||
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
|
<<std::setw(width)<<std::left<<"name:"<<name_<<"\n"
|
||||||
<<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<<"trigger-time:"<<std::put_time(std::localtime(&tt),"%FT%T")<<"\n"
|
|
||||||
<<std::setw(width)<<std::left<<"trigger-time:"<<std::put_time(std::localtime(&att),"%FT%T")<<"\n"
|
|
||||||
<<std::setw(width)<<std::left<<"language-code:"<<language_code_<<"\n"
|
<<std::setw(width)<<std::left<<"language-code:"<<language_code_<<"\n"
|
||||||
<<std::setw(width)<<std::left<<"codepage:"<<codepage_<<"\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"
|
||||||
@ -421,7 +382,6 @@ namespace imc
|
|||||||
<<std::setw(width)<<std::left<<"significant bits:"<<signbits_<<"\n"
|
<<std::setw(width)<<std::left<<"significant bits:"<<signbits_<<"\n"
|
||||||
<<std::setw(width)<<std::left<<"buffer-offset:"<<buffer_offset_<<"\n"
|
<<std::setw(width)<<std::left<<"buffer-offset:"<<buffer_offset_<<"\n"
|
||||||
<<std::setw(width)<<std::left<<"buffer-size:"<<buffer_size_<<"\n"
|
<<std::setw(width)<<std::left<<"buffer-size:"<<buffer_size_<<"\n"
|
||||||
//<<std::setw(width)<<std::left<<"add-time:"<<addtime_<<"\n"
|
|
||||||
<<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"
|
||||||
@ -439,17 +399,12 @@ namespace imc
|
|||||||
// provide JSON string of metadata
|
// provide JSON string of metadata
|
||||||
std::string get_json(bool include_data = false)
|
std::string get_json(bool include_data = false)
|
||||||
{
|
{
|
||||||
// prepare printable trigger-time
|
|
||||||
//std::time_t tt = std::chrono::system_clock::to_time_t(trigger_time_);
|
|
||||||
std::time_t att = std::chrono::system_clock::to_time_t(absolute_trigger_time_);
|
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"{"<<"\"uuid\":\""<<uuid_
|
ss<<"{"<<"\"uuid\":\""<<uuid_
|
||||||
<<"\",\"name\":\""<<name_
|
<<"\",\"name\":\""<<name_
|
||||||
<<"\",\"comment\":\""<<comment_
|
<<"\",\"comment\":\""<<comment_
|
||||||
<<"\",\"origin\":\""<<origin_
|
<<"\",\"origin\":\""<<origin_
|
||||||
<<"\",\"description\":\""<<text_
|
<<"\",\"description\":\""<<text_
|
||||||
<<"\",\"trigger-time\":\""<<std::put_time(std::localtime(&att),"%FT%T")
|
|
||||||
<<"\",\"language-code\":\""<<language_code_
|
<<"\",\"language-code\":\""<<language_code_
|
||||||
<<"\",\"codepage\":\""<<codepage_
|
<<"\",\"codepage\":\""<<codepage_
|
||||||
<<"\",\"yname\":\""<<yname_
|
<<"\",\"yname\":\""<<yname_
|
||||||
|
@ -1,50 +1,12 @@
|
|||||||
##!/bin/bash/
|
##!/bin/bash/
|
||||||
|
|
||||||
fildir=$1
|
dir=$1
|
||||||
|
|
||||||
if [ -z "${fildir}" ]; then
|
#ls ${dir} | while read fn; do echo $fn; cat ${dir}$fn | grep -a "|[A-Z][A-Z]," -o | wc -l; done;
|
||||||
echo "CLI argument missing: provide file or directory" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
list-markers()
|
#ls ${dir} | while read fn; do echo $fn; cat ${dir}$fn | grep -a "|[A-Z][A-Z]," -o; done;
|
||||||
{
|
|
||||||
arg="$1"
|
|
||||||
if [ -z "${arg}" ]; then
|
|
||||||
echo "list-markers: missing file argument" >&2
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
if [ -d "${arg}" ]; then
|
|
||||||
echo "list-markers: file argument is a directory" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "\n${arg}\n"
|
#ls ${dir} | while read fn; do echo $fn; cat ${dir}$fn | xxd | head -n10 | tail -n3; done;
|
||||||
mrks=$(cat ${arg} | grep -a "|[A-Z][a-zA-Z]," -o)
|
|
||||||
mrksnum=$(echo "${mrks}" | wc -l)
|
|
||||||
echo -e "(${mrksnum})\n${mrks}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -f "${fildir}" ]; then
|
|
||||||
|
|
||||||
echo "analyzing single file ${fildir} ..."
|
|
||||||
list-markers "${fildir}"
|
|
||||||
|
|
||||||
elif [ -d "${fildir}" ]; then
|
|
||||||
|
|
||||||
echo "analyzing all *.raw files in directory ${fildir} ..."
|
|
||||||
lsfls=$(ls ${fildir}/*.raw | sed 's/\/\//\//g')
|
|
||||||
echo -e "\n${lsfls}"
|
|
||||||
|
|
||||||
for fl in ${lsfls}; do
|
|
||||||
list-markers "${fl}"
|
|
||||||
done
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
echo "does not exist: ${fildir}" >&2
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
ls ${dir} | while read fn; do echo $fn; cat ${dir}$fn | grep -a "|[A-Z][a-zA-Z]," -o | wc -l; done;
|
||||||
|
ls ${dir} | while read fn; do echo $fn; cat ${dir}$fn | grep -a "|[A-Z][a-zA-Z]," -o; done;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user