Commit 99af04f6 by dheitbri

added get dropped frames, updated documentation

parent 267d5279
......@@ -2,7 +2,7 @@
///
// DAQ low level IO Library
//
// $Id: DaqFileIO.cxx,v 1.13 2005/08/11 14:08:40 dheitbri Exp $
// $Id: DaqFileIO.cxx,v 1.14 2007/04/25 17:54:35 dheitbri Exp $
// Date: March, 2005
// Author: Yiannis Papelis
//
......@@ -12,7 +12,7 @@
///
#include "DaqIoLib.h"
#include <assert.h>
#include <io.h>
///
/// Small dummy function to act as the default callback
///
......@@ -27,7 +27,9 @@ struct TFrameInfo {
int ofs;
int numChan;
};
//Intel says 8k (2006) is the ideal buffer size for streaming from the HD,
//this may need to be changed with time.
const int cFILE_BUFFER_SIZE = 8192;
CDaqLowLevelIo::CDaqLowLevelIo()
{
......@@ -40,6 +42,7 @@ CDaqLowLevelIo::CDaqLowLevelIo()
m_LastFrame = -1;
m_EofStatus = eDAQ_EOF_UNDEFINED;
m_TocExists = false;
}
CDaqLowLevelIo::~CDaqLowLevelIo()
......@@ -202,7 +205,9 @@ CDaqLowLevelIo::FrameDropped(int frm)
return false;
}
int CDaqLowLevelIo::GetDroppedFrames() const {
return m_DroppedFrames.size();
}
/////////////////////////////////////////////////////////////////////////////
///
/// This function determines if data was logged for a given frame
......@@ -345,11 +350,11 @@ CDaqLowLevelIo::ReadChannelInfo(FILE *p)
//////////////////////////////////////////////////////////////////////////////////
//
// Returns true if the file is currently seeked on a frame header else false.
// Either way, it leaves the file pointer at the same place it found it unless
// it run into a read error.
//
///
/// Returns true if the file is currently seeked on a frame header else false.
/// Either way, it leaves the file pointer at the same place it found it unless
/// it run into a read error.
///
bool
CDaqLowLevelIo::DetectFrameHeader(
int recentFrame)
......@@ -376,10 +381,10 @@ CDaqLowLevelIo::DetectFrameHeader(
//////////////////////////////////////////////////////////////////////////////////
//
// Attempts to re-sync after reading a bad channel definition; usually,
// there are more channel definitions nearby so we can re-sync there
//
///
/// Attempts to re-sync after reading a bad channel definition; usually,
/// there are more channel definitions nearby so we can re-sync there
///
CDaqLowLevelIo::TResyncOutcome
CDaqLowLevelIo::ResyncChannel(
int recentFrame,
......@@ -493,6 +498,8 @@ CDaqLowLevelIo::Close(void)
{
fclose(m_pFile);
m_pFile = 0;
m_UserErrorFunc = DefaultErrorFunc;
m_UserProgrFunc = DefaultProgressFunc;
......@@ -511,6 +518,7 @@ CDaqLowLevelIo::Open(
//
// Check if we have already opened the file
//
if ( m_pFile ) {
m_LastError = "file already open";
return false;
......@@ -518,7 +526,7 @@ CDaqLowLevelIo::Open(
//
// Open the file
//
//
m_pFile = fopen(fname.c_str(), "rb");
if ( m_pFile == 0 ) {
m_LastError = "cannot open file '";
......@@ -1962,23 +1970,25 @@ CDaqLowLevelIo::ReadChannelDataForOneFrame(
/////////////////////////////////////////////////////////////////////////////
//
// This function reads the header for the upcoming frame. It will verify
// it's a correct header and try to re-sync reading if the next bytes do
// not make up a reasonable header.
//
// The frameToRead argument indicates which frame we are trying to
// read. If not set to -1, the function will assume a table of contents
// exists and will seek to the specific offset within the file, but if
// frameToRead is set to -1, the function simply assumes the file
// pointer is set to read the header next.
//
// Upon a successful return, curFrame is the fbs frame number that
// was read and numChan is the number of channels stored for that frame.
//
// The skip variable indicates how many bytes had to be skipped in
// order to find a good header. U
// Return: OK, EOF, SKIPPED, ERROR
///
/// This function reads the header for the upcoming frame. It will verify
/// it's a correct header and try to re-sync reading if the next bytes do
/// not make up a reasonable header.
///
/// The frameToRead argument indicates which frame we are trying to
/// read. If not set to -1, the function will assume a table of contents
/// exists and will seek to the specific offset within the file, but if
/// frameToRead is set to -1, the function simply assumes the file
/// pointer is set to read the header next.
///
/// Upon a successful return, curFrame is the fbs frame number that
/// was read and numChan is the number of channels stored for that frame.
///
/// The skip variable indicates how many bytes had to be skipped in
/// order to find a good header. U
///
///\return OK, EOF, SKIPPED, ERROR
///
CDaqLowLevelIo::TReadErrorCode
CDaqLowLevelIo::ReadFrameHeader(
int frameToRead,// which frame we anticipate reading, use -1 to read next available
......
......@@ -2,8 +2,14 @@
#define _DAQIO_H_
/////////////////////////////////////////////////////////////////////////////
///\defgroup DAQ Data AcQuisition file
///\ingroup clib
///\ingroup DAQ
///
///\class CDaqLowLevelIo
///
///\brief Low Level Reading from a DAQ
///
/// \ingroup clib
/// This class provides an API that does low level reading from a DAQ
/// file. In particular, each DAQ file is treated as a set of independent
/// channels, with each channel having its own type/cardinality/sampling
......@@ -52,6 +58,7 @@ public:
bool FrameDropped(int frm);
bool FrameHasData(int frm);
int GetDroppedFrames() const;
void SetCallbacks( void errf(const char *, const char *), void progf(const char *, int, int));
......@@ -59,18 +66,18 @@ public:
private:
enum TReadErrorCode {
eDAQ_READ_OK,
eDAQ_READ_ERROR, // read error (short file, premature eof etc.
eDAQ_READ_EOF, // found end marker
eDAQ_READ_FAILED, // lost sync
eDAQ_READ_BAD_DATA, // bad data and couldn't recover
eDAQ_NO_SUCH_FRAME, // asked to read a frame that doesn't exist in TOC
eDAQ_READ_ERROR, ///< read error (short file, premature eof etc.
eDAQ_READ_EOF, ///< found end marker
eDAQ_READ_FAILED, ///< lost sync
eDAQ_READ_BAD_DATA, ///< bad data and couldn't recover
eDAQ_NO_SUCH_FRAME, ///< asked to read a frame that doesn't exist in TOC
eDAQ_READ_INTERNAL_ERROR
};
enum TResyncOutcome {
eRESYNC_CHANNEL, // resynced ok, next thing to read is channel
eRESYNC_FRAME, // resynced ok, next thing to read is frame
eRESYNC_NONE // could not resync
eRESYNC_CHANNEL, ///< resynced ok, next thing to read is channel
eRESYNC_FRAME, ///< resynced ok, next thing to read is frame
eRESYNC_NONE ///< could not resync
};
bool ReadHeader(FILE *);
......@@ -85,24 +92,25 @@ private:
TReadErrorCode ReadChannelDataForOneFrame(int, int, CDaqBuffer&, void*, bool&);
string m_Filename;
string m_Version; // file version
string m_Version; ///< file version
FILE* m_pFile;
string m_Title; // Simulation title, as stored in DAQ file
string m_Date; // Date of collection, as stored in DAQ file
string m_Subj; // As stored in DAQ file
string m_Run; // As stored in DAQ file
string m_RunInst; // As stored in DAQ file
int m_NumEntries; // As stored in DAQ file
int m_Frequency; // As stored in DAQ file
string m_Title; ///< Simulation title, as stored in DAQ file
string m_Date; ///< Date of collection, as stored in DAQ file
string m_Subj; ///< As stored in DAQ file
string m_Run; ///< As stored in DAQ file
string m_RunInst; ///< As stored in DAQ file
int m_NumEntries; ///< As stored in DAQ file
int m_Frequency; ///< As stored in DAQ file
void (*m_UserErrorFunc)(const char *, const char *);
void (*m_UserProgrFunc)(const char *, int, int);
bool m_TocExists; // Indicates a TOC exists in a file
bool m_HaveToc; // Indicates if we have TOC in memory
TChanInfoVec m_Channels; // Channel information
long m_DataOffset; // where data starts in the file
map<int, int> m_Toc; // given a sim frame, gives the offset in the file
bool m_TocExists; ///< Indicates a TOC exists in a file
bool m_HaveToc; ///< Indicates if we have TOC in memory
TChanInfoVec m_Channels; ///< Channel information
long m_DataOffset; ///< where data starts in the file
map<int, int> m_Toc; ///< given a sim frame, gives the offset in the file
vector<int> m_DroppedFrames;
int m_FirstFrame;
int m_LastFrame;
......@@ -110,8 +118,8 @@ private:
TDaqEofStatus m_EofStatus;
// These are for data integrity
TIntVec m_FrameDrops; // sequences of skipped frames
TIntVec m_Skips; // groups of bytes skipped
TIntVec m_FrameDrops; ///< sequences of skipped frames
TIntVec m_Skips; ///< groups of bytes skipped
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment