3 #ifndef GCP_UTIL_ARCHIVEREADER_H
4 #define GCP_UTIL_ARCHIVEREADER_H
20 #include "gcp/util/common/ArchiveConvFn.h"
21 #include "gcp/util/common/ArchiveFileHandler.h"
22 #include "gcp/util/common/RegDescription.h"
24 #include "gcp/control/code/unix/libunix_src/common/arcfile.h"
25 #include "gcp/control/code/unix/libunix_src/common/arraymap.h"
45 enum ArchiveTransposeType {
74 return (currFrame_ > stopFrame_);
94 DataType::Type outputType_;
107 std::vector<Range<unsigned> > byteRanges_;
112 std::vector<Range<unsigned> > slotRanges_;
117 unsigned nTotalBytes_;
135 std::valarray<unsigned char> buf_;
146 std::valarray<unsigned int> inInds_;
147 std::valarray<unsigned int> outInds_;
152 ARC_CONV_FN(*convFn_);
153 ARC_PRINT_FN(*printFn_);
158 std::vector<RegCal::RegCalSlot> regCalSlots_;
162 ArchiveTransposeType transpose_;
166 std::ostringstream strVal_;
170 void convertVals(
unsigned iFrame,
unsigned nFrame) {
171 convFn_(&buf_[0], cRePtr_, cImPtr_, args_, ®CalSlots_[0], nEl_, &inInds_[0],
173 (transpose_ == ArchiveReader::LAST) ? iFrame*nEl_ :
174 (transpose_ == ArchiveReader::FIRST ? iFrame*nEl1_ : iFrame));
179 void printVals(std::ostringstream& os) {
180 printFn_(&buf_[0], os, args_, ®CalSlots_[0], nEl_, width_, prec_);
185 printFn_(&buf_[0], strVal_, args_, ®CalSlots_[0], nEl_, width_, prec_);
202 transpose_ = ArchiveReader::NONE;
212 ArchiveTransposeType transpose,
int width,
int prec,
213 bool convert=
true,
bool read=
false) {
216 outputType_ = outputType;
217 transpose_ = transpose;
224 ArchiveConvFn::setConvFn(type_, outputType_, &convFn_);
227 ReportError(
"No conv function for register: " << desc);
228 ThrowError(
"No conv function for register: " << desc);
232 ArchiveConvFn::setPrintFn(type_, outputType_, &printFn_);
235 ReportError(
"No print function for register: " << desc);
236 ThrowError(
"No print function for register: " << desc);
243 ReportError(err.what() <<
" (" << desc <<
")");
244 ThrowError(err.what() <<
" (" << desc <<
")");
252 arregmap_ = desc.
regMap();
253 board_ = arregmap_->regmap->boards_[desc.iBoard()];
254 block_ = board_->blocks[desc.iBlock()];
258 nTotalBytes_ = desc.
nByte();
259 aspect_ = desc.aspect();
261 buf_.resize(nTotalBytes_);
262 regCalSlots_.resize(nEl_);
280 arregmap_ = reg.arregmap_;
283 convFn_ = reg.convFn_;
284 printFn_ = reg.printFn_;
285 cRePtr_ = reg.cRePtr_;
286 cImPtr_ = reg.cImPtr_;
290 byteRanges_ = reg.byteRanges_;
291 slotRanges_ = reg.slotRanges_;
292 nTotalBytes_ = reg.nTotalBytes_;
293 aspect_ = reg.aspect_;
294 outputType_ = reg.outputType_;
295 transpose_ = reg.transpose_;
299 buf_.resize(reg.buf_.size());
300 regCalSlots_.resize(nEl_);
306 void setInputIndices(std::valarray<unsigned int>& inds) {
307 inInds_.resize(inds.size());
309 for(
unsigned i=0; i < inds.size(); i++)
310 inInds_[i] = inds[i];
313 void setOutputIndices(std::valarray<unsigned int>& inds) {
314 outInds_.resize(inds.size());
316 for(
unsigned i=0; i < inds.size(); i++)
317 outInds_[i] = inds[i];
320 void setExternalMemory(
void* rePtr,
void* imPtr,
void* args) {
328 friend std::ostream& gcp::util::operator<<(std::ostream& os,
339 unsigned byteOffsetFromStartOfFrame_;
350 void initialize(
bool memMap,
bool convert,
bool read);
352 ArchiveReader(
bool memMap=
false,
bool convert=
true,
bool read=
false);
354 std::string startUtc, std::string stopUtc,
355 bool memMap=
false,
bool convert=
true,
bool read=
false);
402 void setCalFile(std::string calFile);
404 void setDates(std::string startUtc, std::string stopUtc);
418 void printAddresses();
434 std::string calFile_;
437 std::vector<ArchiveByteRange> byteRanges_;
445 std::string startUtc_;
446 std::string stopUtc_;
449 std::vector<ArchiveReader::ArchiveFile> fileList_;
450 std::vector<ArchiveReader::ArchiveFile>::iterator currFile_;
459 std::vector<bool> regSpecValid_;
460 std::vector<std::string> regSpecs_;
461 std::vector<std::string> formatSpecs_;
462 std::vector<ArchiveTransposeType> transposeTypes_;
463 std::vector<int> widths_;
464 std::vector<int> precs_;
472 void printRegsSize();
474 std::vector<ArchiveRegister>& getRegs();
475 std::vector<RegDescription>& getRegDescs();
479 std::vector<ArchiveRegister> regs_;
480 std::vector<DataType::Type> formatTypes_;
481 std::vector<RegDescription> regDescs_;
490 static DataType::Type parseFormat(std::string format);
494 void checkFirstFile();
514 std::vector<RegDescription> selectedRegs();
516 std::vector<DataType::Type> selectedFormats();
525 #endif // End #ifndef GCP_UTIL_ARCHIVEREADER_H
static Type typeOf(RegMapBlock *blk)
Definition: DataType.cc:223
void setArchiveDirectory(std::string arcDir)
Definition: ArchiveReader.cc:297
Definition: ArchiveFileHandler.h:29
void addRegisterOnly(std::string regSpec)
Definition: ArchiveReader.cc:615
unsigned readTimeStamps()
Definition: ArchiveReader.cc:414
Definition: ArchiveReader.h:32
std::vector< Range< unsigned > > getSlotRanges(CoordRange *range=0)
Definition: RegDescription.cc:416
void updateRegBufPtrCache(unsigned nByteRanges)
Definition: ArchiveReader.cc:875
CoordAxes axes()
Definition: RegDescription.h:148
void addRegister(std::string regSpec)
Definition: ArchiveReader.cc:644
void updateRegSelection()
Definition: ArchiveReader.cc:716
void readRegs()
Definition: ArchiveReader.cc:942
Definition: arraymap.h:63
bool advanceFile()
Definition: ArchiveReader.cc:530
ArrRegMap * regMap()
Definition: RegDescription.cc:573
void printRegs(std::ostringstream &os)
Definition: ArchiveReader.cc:979
void readFirstArrayMap()
Definition: ArchiveReader.cc:555
bool updateArrayMap()
Definition: ArchiveReader.cc:587
friend std::ostream & operator<<(std::ostream &os, ArchiveReader &obj)
void initialize(bool memMap, bool convert, bool read)
Definition: ArchiveReader.cc:42
unsigned nEl(CoordRange *range=0)
Definition: RegDescription.cc:474
bool stageNextFile()
Definition: ArchiveReader.cc:496
unsigned nByte(CoordRange *range=0)
Definition: RegDescription.cc:465
virtual ~ArchiveReader()
Definition: ArchiveReader.cc:119
void operator=(const ArchiveReader &objToBeAssigned)
Definition: ArchiveReader.cc:94
std::vector< Range< unsigned > > getByteRanges(CoordRange *range=0)
Definition: RegDescription.cc:433
Definition: ArchiveReader.h:55
bool readNextFrame()
Definition: ArchiveReader.cc:437
void resetToBeginning()
Definition: ArchiveReader.cc:511
Definition: RegDescription.h:26
unsigned countFrames()
Definition: ArchiveReader.cc:306
unsigned int nEl(int axis=-1)
Definition: CoordAxes.cc:136
Definition: Exception.h:30
Definition: ArchiveReader.h:336
Definition: ArchiveReader.h:86
void updateRegisterCalibration()
Definition: ArchiveReader.cc:699
ArchiveReader(bool memMap=false, bool convert=true, bool read=false)
Definition: ArchiveReader.cc:61
Definition: arraymap.h:177
void getFileList()
Definition: ArchiveReader.cc:147
unsigned int nAxis()
Definition: CoordAxes.cc:128