update BinReader.h from NoHeader branch
This commit is contained in:
parent
5ae7c256f2
commit
e54752cf5d
24
BinReader.h
24
BinReader.h
|
@ -94,6 +94,7 @@ class BinReader{
|
|||
~BinReader();
|
||||
|
||||
void OpenFile(TString inFileName, int64_t timeOffset = 0, bool noHeader = false);
|
||||
void SetCustomHeader(uint16_t Header);
|
||||
// void SetDataFormat(bool has );
|
||||
void CloseFile();
|
||||
void UpdateFileSize();
|
||||
|
@ -135,7 +136,7 @@ BinReader::BinReader(){
|
|||
}
|
||||
|
||||
BinReader::~BinReader(){
|
||||
fclose(inFile); /// fclose already delete inFile;
|
||||
if( inFile ) fclose(inFile); /// fclose already delete inFile;
|
||||
}
|
||||
|
||||
BinReader::BinReader(TString inFileName, int64_t timeOffset, bool noHeader){
|
||||
|
@ -168,6 +169,11 @@ void BinReader::OpenFile(TString inFileName, int64_t timeOffset, bool noHeader){
|
|||
|
||||
isOpened = true;
|
||||
|
||||
// normal format: isHeaderOK = true, isNoHeaderFormat= false, isOldFormat = false
|
||||
// old format: isHeaderOK = true, isNoHeaderFormat= false, isOldFormat = true
|
||||
//no header format: isHeaderOK = false, isNoHeaderFormat= true, isOldFormat = false
|
||||
|
||||
|
||||
if( noHeader ){
|
||||
data.Header = 0x0;
|
||||
isOldFormat = false;
|
||||
|
@ -202,12 +208,19 @@ void BinReader::OpenFile(TString inFileName, int64_t timeOffset, bool noHeader){
|
|||
return ;
|
||||
}
|
||||
|
||||
printf(" Header format. 0x%04x\n", data.Header);
|
||||
isHeaderOK = true;
|
||||
}
|
||||
};
|
||||
|
||||
void BinReader::SetCustomHeader(uint16_t Header){
|
||||
data.Header = Header;
|
||||
isHeaderOK = true;
|
||||
}
|
||||
|
||||
void BinReader::CloseFile(){
|
||||
fclose(inFile);
|
||||
if(inFile) fclose(inFile);
|
||||
inFile = nullptr;
|
||||
isOpened = false;
|
||||
data.Clear();
|
||||
inFileSize = 0;
|
||||
|
@ -226,6 +239,7 @@ void BinReader::UpdateFileSize(){
|
|||
|
||||
bool BinReader::IsEndOfFile() {
|
||||
if( endOfFile ) return true;
|
||||
if( inFile == nullptr ) return true;
|
||||
return feof(inFile) > 0 ? true: false;
|
||||
}
|
||||
|
||||
|
@ -244,8 +258,7 @@ int BinReader::ReadBlock(int skipTrace){
|
|||
if( feof(inFile) ) return -1;
|
||||
if( endOfFile ) return -1;
|
||||
|
||||
|
||||
if( isNoHeaderFormat ) {
|
||||
if( isNoHeaderFormat && data.Header == 0x0 ) {
|
||||
FillData(&data.BoardID);
|
||||
FillData(&data.Channel);
|
||||
FillData(&data.TimeStamp);
|
||||
|
@ -331,7 +344,7 @@ void BinReader::ScanNumHit(){
|
|||
printf("scan complete: number of data Block : %ld\n", numHit);
|
||||
|
||||
rewind(inFile); ///back to the File begining
|
||||
if( !isOldFormat && isHeaderOK ){
|
||||
if( isOldFormat == false && isNoHeaderFormat == false ){ // only when normal format
|
||||
FillData(&data.Header);
|
||||
}
|
||||
inFilePos = 0;
|
||||
|
@ -364,5 +377,4 @@ void BinReader::PrintStatus(int mod){
|
|||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user