26 fDataFormat(
"uint32_t"),
29 fCharBufferLength(1024),
46 delete [] fCharBuffer; fCharBuffer =
nullptr;
58 if (fDataFormat==
"float") { fFormatId = 0; fDataUnitSize =
sizeof(float); }
else
59 if (fDataFormat==
"int32_t") { fFormatId = 1; fDataUnitSize = 4; }
else
60 if (fDataFormat==
"int") { fFormatId = 1; fDataUnitSize = 4; }
else
61 if (fDataFormat==
"uint32_t") { fFormatId = 2; fDataUnitSize = 4; }
else
62 if (fDataFormat==
"unsigned") { fFormatId = 2; fDataUnitSize = 4; }
else {
63 EOUT(
"Unsupported data format %s", fDataFormat.c_str());
67 if (fCharBufferLength < 1024) fCharBufferLength = 1024;
68 fCharBuffer =
new char[fCharBufferLength];
70 return OpenNextFile();
77 if (!TakeNextFileName())
return false;
79 fFile.open(CurrentFileName().c_str());
81 int cnt = fNumHeaderLines;
82 while (cnt-- > 0) fFile.getline(fCharBuffer, fCharBufferLength);
85 EOUT(
"Cannot open file %s for reading", CurrentFileName().c_str());
95 if (fFile.is_open()) fFile.close();
96 ClearCurrentFileName();
112 unsigned rawdatasize = RawDataSize();
115 while (iter.
NewEvent(fEventCounter)) {
120 memset(iter.
rawdata(), 0, rawdatasize);
124 const char* sbuf =
nullptr;
131 fFile.getline(fCharBuffer, fCharBufferLength);
133 if ((strlen(fCharBuffer) == 0) && fFile.eof()) {
134 DOUT1(
"empty line in end of file");
139 EOUT(
"File: %s reading error", CurrentFileName().c_str());
144 while ((*sbuf!=0) && ((*sbuf==
' ') || (*sbuf==
'\t'))) sbuf++;
146 if (strlen(sbuf)==0)
DOUT1(
"Empty string eof fail = %d %d", fFile.eof(), fFile.fail());
148 }
while (strlen(sbuf)==0);
150 unsigned filledsize = FillRawData(fCharBuffer, iter.
rawdata(), rawdatasize);
156 EOUT(
"Problem with iterator");
175 return fNumData * fDataUnitSize;
183 std::istringstream src(str);
187 float* tgt = (
float*) rawdata;
188 for(
int n=0;n<fNumData;n++) {
191 EOUT(
"Fail to decode stream into float, cnt = %d", n);
192 EOUT(
"Error Line %s", str);
201 int32_t* tgt = (int32_t*) rawdata;
202 for(
int n=0;n<fNumData;n++) {
205 EOUT(
"Fail to decode stream into int32_t, cnt = %d", n);
206 EOUT(
"Error Line %s", str);
215 uint32_t* tgt = (uint32_t*) rawdata;
216 for(
int n=0;n<fNumData;n++) {
219 EOUT(
"Fail to decode stream into uint32_t, cnt = %d", n);
220 EOUT(
"Error Line %s", str);
Reference on memory from memory pool.
Represents command with its arguments.
std::string AsStr(const std::string &dflt="") const
int64_t AsInt(int64_t dflt=0) const
Uniform Resource Locator interpreter.
std::string GetOptionStr(const std::string &optname, const std::string &dflt="") const
int GetOptionInt(const std::string &optname, int dflt=0) const
Reference on dabc::Worker
RecordField Cfg(const std::string &name, Command cmd=nullptr) const
Returns configuration record of specified name.
virtual unsigned Read_Complete(dabc::Buffer &buf)
Complete reading of the buffer from source,.
virtual unsigned RawDataSize()
virtual bool Read_Init(const dabc::WorkerRef &wrk, const dabc::Command &cmd)
Initialize data input, using port and command.
virtual unsigned FillRawData(const char *str, void *rawdata, unsigned maxsize)
virtual unsigned Read_Size()
Defines required buffer size for next operation.
TextInput(const dabc::Url &url)
Write iterator for MBS events/subevents.
bool FinishSubEvent(uint32_t rawdatasz=0)
bool NewSubevent(uint32_t minrawsize=0, uint8_t crate=0, uint16_t procid=0, uint8_t control=0)
bool NewEvent(EventNumType event_number=0, uint32_t subeventsize=0)
const char * xmlTextCharBuffer
const char * xmlTextNumData
const char * xmlTextHeaderLines
const char * xmlTextDataFormat