37 #define DATRW_TSOFTDATA_CC_VERSION \ 38 "DATRW_TSOFTDATA_CC V1.2" 41 #include <datrwxx/tsoftdata.h> 62 const char*
NSP=
"NSP";
69 Mline(line), Mhastag(false), Mhascontent(false)
76 const string::size_type len=line.length();
78 string::size_type i=1;
79 string::size_type j=line.find_first_of(
tagend, i);
80 Mtag=line.substr(i,j-i);
85 j=line.find_first_not_of (
" ", i);
101 Mlocation(
NSP), Minstrument(
NSP), Mdatatype(
NSP), Munits(
NSP)
111 Tvos::const_iterator I=vos.begin();
112 if (I != vos.end()) {
Mlocation = *I; ++I; }
114 if (I != vos.end()) {
Mdatatype = *I; ++I; }
125 int year,month,day,hour,minute ,second;
126 std::istringstream iss(
Mline);
127 iss >> year >> month >> day >> hour >> minute >> second;
129 "read beyond end of data line when reading date and time" << line);
130 DATRW_assert(iss.good(),
"empty data line or read beyond end of file");
131 Mtime=libtime::TAbsoluteTime(year,month,day,hour,minute,second);
148 "index out of range");
169 std::cout <<
" date: " << this->
date().timestring() << std::endl;
170 std::cout <<
" interval: " << this->
interval().timestring() << std::endl;
171 std::cout <<
" nsamples: " << this->
nsamples() << std::endl;
173 libtime::TAbsoluteTime retval=this->
date();
184 Mdate=libtime::TAbsoluteTime();
193 Tvod::const_iterator I=
Msamples.begin();
194 for (aff::Tsubscript i=
series.f();
229 const double& invalue,
230 const double& undetval,
231 const libtime::TRelativeTime&
dt,
236 double value=invalue;
237 libtime::TAbsoluteTime time=intime;
248 std::cout <<
" yes, take this sample" << std::endl;
268 "WARNING (Channeldata::push_sample): TSOFT reading\n" 269 "User requested to bridge data entries labelled with time: " 271 <<
"This time label is present in the first entry of the" 273 <<
"First input lines cannot be bridged.");
298 const double& theundetval,
299 const libtime::TRelativeTime&
dt,
305 std::cout <<
"the line: " << line << std::endl;
306 std::cout <<
" time: " << thedata.
time().timestring() << std::endl;
307 std::cout <<
" dt: " <<
dt.timestring() << std::endl;
308 std::cout <<
" undetval: " << theundetval << std::endl;
311 for (
int ich=0; ich<thedata.
nsamples(); ++ich)
313 double thesample=thedata.
sample(ich);
317 std::cout <<
" sample: " << thesample << std::endl;
331 for (
unsigned int ich=0; ich<
Mchannels.size(); ++ich)
342 const std::string& delimiters)
345 const string::size_type len = line.length();
346 string::size_type i = 0;
351 i = line.find_first_not_of (
" ", i);
352 if (i == string::npos)
356 string::size_type j = line.find_first_of (delimiters, i);
359 if (j == string::npos) {
360 result.push_back (line.substr(i));
363 result.push_back (line.substr(i, j-i));
381 string::size_type ib=line.find_first_not_of(
" ", 0);
382 if (ib==string::npos)
388 string::size_type il=line.find_last_not_of(
" \r", line.length());
389 string::size_type n=il>=ib ? il-ib+1 : 0;
390 if (n==0) { ib = 0; }
395 if ((ib!=0) || (n!=line.length())) { line=line.substr(ib,n); }
406 std::ostringstream oss;
408 retval.push_back(oss.str());
411 retval.push_back(oss.str());
414 retval.push_back(oss.str());
417 retval.push_back(oss.str());
425 std::string inputline;
426 getline(is, inputline);
void append(const double &v)
append sample
config parameters for data extractionThese parameters control the way gaps in the input data are hand...
void push_sample(const libtime::TAbsoluteTime &time, const double &value, const double &undetval, const libtime::TRelativeTime &dt, const ReaderConfig &rc, const bool &debug=false)
push a sample
libtime::TAbsoluteTime timeofnextsample(const bool &debug=false) const
return time of next sample after last samples
ReaderConfig Mreaderconfig
reader configuration
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
std::list< std::string > Tlos
list of strings.
std::string Mcontent
the content part of the line
Tvod Msamples
vector of data values
Tvocd Mchannels
data sequences
Channeldata()
constructor to initialize
const char * tagdata
TSOFT data tag.
std::string Mline
the data line
trace of contiguous data.
const std::string & thedatatype() const
return datatype
libtime::TRelativeTime Minterval
sampling interval
bool Mhascontent
true if this line has a content
libtime::TAbsoluteTime time() const
return time
const std::string & theunits() const
return units
std::vector< std::string > Tvos
vector of strings.
libtime::TRelativeTime dt()
return sampling interval of HPMO data acquisition (i.e. 5 sec)
std::string Minstrument
instrument field in channel name
const char * tagbegin
first character of TSOFT tag
Line(const std::string &line)
constructor: swallow line
void series(const Tdseries &s)
set series
double sample(const int &i) const
return specific sample
Dataline(const std::string &line)
swallow a line
int nsamples() const
return number of samples in line
const char * tagtimeformat
TSOFT timeformat tag.
bool Mhastag
true if this line contains a tag
aff::Series< double > Tdseries
int nsamples() const
return number of samples
const Datatrace & trace(const unsigned int &i) const
return data trace
Tdseries series() const
return samples in a series container
exception class declaration for libdatrwxx (prototypes)
std::string Mline
the actual line
libtime::TAbsoluteTime Mdate
time of first sample
void trimws(std::string &line)
helper function trimws
void interval(const libtime::TRelativeTime i)
set sampling interval
libtime::TRelativeTime interval() const
return sampling interval
libtime::TAbsoluteTime date() const
return time of first sample
std::string Mtag
the tag part of the line
const char * tagunits
TSOFT units tag.
libtime::TAbsoluteTime Mtime
time
const char * tagincrement
TSOFT increment tag.
const std::string & theinstrument() const
return instrument
Root namespace of library.
const char * tagend
last character of TSOFT tag
void initialize()
initialize data sequence
Channelinfo()
standard constructor
Tlos channelinfofree(const Channelinfo &ci)
prepare free comment block from channel info
void setchannelinfo(const std::string &line)
set channel info
Tvos stringtovec(const std::string &line, const std::string &delimiters)
helper function stringtok
std::string Mlocation
location field in channel name
const std::string & thelocation() const
return location
const char * NSP
value not specified
void flushcollector()
function to flush collector to vector of sequences
void date(const libtime::TAbsoluteTime d)
set time of first sample
Datasequence Mcollector
vector of samples to collect from file
const char * tagfileid
TSOFT fileid tag.
void push_data(const std::string &line, const double &undetval, const libtime::TRelativeTime &dt, const bool &debug=false)
push a data line
void flushchannels()
flush all channels
void date(const libtime::TAbsoluteTime d)
set time of first sample
const char * tagchannels
TSOFT channels tag.
std::string Mdatatype
data type field in channel name
Channeldata & channel(const unsigned int &i, const bool &debug=false)
return data for specific channel
libtime::TAbsoluteTime bridgetime
void interval(const libtime::TRelativeTime i)
set sampling interval
#define DATRW_report_assert(C, M)
Check an assertion and report only.
std::string getDOSline(std::istream &is)
helper function getDOSline
const char * tagundetval
TSOFT undetval tag.