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