Commit dab6e161 by yiannis

Added doxygen docs; modularized classes in source files'

parent 59bb107d
//////////////////////////////////////////////////////////////////////////////////////////
///
/// $Id: DaqBuffer.h,v 1.1 2005/03/14 18:30:48 yiannis Exp $
///
/// Date: December 2004
///
/// Description:
/// A small class that maintains a buffer
///
/////////////////////////////////////////////////////////////////////////////////////////
///
/// \ingroup clib
/// This support class provides buffer space for copying daq data out of a
/// DAQ file. It is used in lieu of raw buffers to minimize the likelihood of
/// memory leaks.
///
/// The class itself is not aware of the type or cardinality of the data,
/// however, it provides a few type-specific access functions to facilitate
/// data access when the user knows the type of data.
///
class CDaqBuffer {
public:
CDaqBuffer() { m_Count = 0; };
~CDaqBuffer() {};
vector<TDaqByte>::const_pointer GetDataPtr() const; ///< Return faw pointer to data
int GetCount() const; ///< Return number of typed elements in buffer
int GetSize() const; ///< Return buffer size in bytes
char* GetChar(int ind=0); ///< Return char type pointer to data
int* GetInt(int ind=0); ///< Return int type pointer to data
float* GetFloat(int ind=0); ///< Return float type pointer to data
double* GetDouble(int ind=0); ///< Return double type pointer to data
short* GetShort(int ind=0); ///< Return short type pointer to data
friend class CDaqLowLevelIo;
vector<TDaqByte> m_Data; ///< data is stored here
protected:
void Append(const void *pData, int size, int count); ///< Add data
void Replace(const void *pData, size_t size, int count); ///< Replace data
void AllocSpace(int size, int count=0); ///< Allocate space
void Clear(void); ///< Release everything
int m_Count; ///< count of data, not in bytes but in type
};
///
/// This function ...
//
inline int
CDaqBuffer::GetSize() const
{
return (int)m_Data.size();
};
///
/// This function ...
inline int
CDaqBuffer::GetCount() const
{
return m_Count;
}
///
/// Return ...
///
inline char*
CDaqBuffer::GetChar(int ind)
{
return ((char *)&m_Data[0]) + ind;
};
///
/// Return ...
///
inline int*
CDaqBuffer::GetInt(int ind)
{
return ((int *)&m_Data[0]) + ind;
};
///
/// This function ...
//
inline float*
CDaqBuffer::GetFloat(int ind) ///< Return float type pointer to data
{
return ((float *)&m_Data[0]) + ind;
};
///
/// This function ...
//
inline double*
CDaqBuffer::GetDouble(int ind) ///< Return double type pointer to data
{
return ((double *)&m_Data[0]) + ind;
};
///
/// This function ...
//
inline short*
CDaqBuffer::GetShort(int ind) ///< Return short type pointer to data
{
return ((short *)&m_Data[0]) + ind;
};
////////////////////////////////////////////////////////////////////////////////
///
/// This function returns a raw pointer to the data in the buffer.
///
inline vector<TDaqByte>::const_pointer
CDaqBuffer::GetDataPtr() const
{
return &m_Data[0];
};
/////////////////////////////////////////////////////////////////////////////////
///
/// This function adds data to the DaqBuffer. It is used by the DAQ library
/// to build the buffers returned to the user, and as such, is not meant to
/// be used by the library client.
///
/// The function receives a pointer to the data, the size of the buffer in
/// bytes and a count of elements in that buffer. The class deals with
/// untyped buffers, so the only way to keep track of how many elements
/// are in the buffer (i.e., 2 integers as opposed to 8 bytes) is for the
/// caller to provide that information, which in this case is the count
/// argument.
///
inline void
CDaqBuffer::Append(
const void* p, ///< pointer to data to append
int size, ///< size in bytes of data
int count) ///< count of data items in that buffer
{
size_t oldsize = m_Data.size();
m_Data.resize(oldsize + size);
memcpy(&m_Data[0]+oldsize, p, size);
m_Count += count;
}
/////////////////////////////////////////////////////////////////////////////////
///
/// This function replaces the existing data with new one.
///
/// The function receives a pointer to the data, the size of the buffer in
/// bytes and a count of elements in that buffer. The class deals with
/// untyped buffers, so the only way to keep track of how many elements
/// are in the buffer (i.e., 2 integers as opposed to 8 bytes) is for the
/// caller to provide that information, which in this case is the count
/// argument.
///
inline void
CDaqBuffer::Replace(
const void* p, ///< pointer to data to append
size_t size, ///< size in bytes of data
int count) ///< count of data items in that buffer
{
size_t oldsize = m_Data.size();
if ( oldsize < size ) {
m_Data.resize(size);
}
memcpy(&m_Data[0], p, size);
m_Count = count;
}
/////////////////////////////////////////////////////////////////////////////////
///
/// This function allocates space in the DaqBuffer.
///
///
inline void
CDaqBuffer::AllocSpace(
int size, ///< size in bytes of data
int count) ///< count of data items in that buffer
{
m_Data.resize(size);
m_Count = count;
}
/////////////////////////////////////////////////////////////////////////////////
///
/// This function allocates space in the DaqBuffer.
///
inline void
CDaqBuffer::Clear(void)
{
m_Data.clear(); m_Count = 0;
}
///////////////////////////////////////////////////////////////////////////////////////////
///
/// \ingroup clib
/// This class represents all information about a channel stored in the DAQ file.
/// Each channel consist of a number of samples, each sample containing one or more
/// values of the same type. The term item is used to refer to one of those values.
/// The term record is used to refer to all the values in a sample.
///
/// The information maintained for each channel includes an identifier (which
/// is nothing more than the ordinal number of the channel in the definition array),
/// the type of the data, the cardinality of the data, its name and the capture
/// rate. The capture rate is given in Hz and is always a sub-multiple of the DAQ
/// maximum sampling rate.
///
/// In addition, there are three options that refer to the method by which the
/// data for a channel is collected. The sampling rate indicates how often
/// data for that channel is sampled. Usually, the maximum sampling rate
/// is 240 Hz, but most channels are sampled at a frequency lower than that.
/// Data stored in 'differential' mode are only stored when their value has
/// changed from the previously stored value. This can save a tremendous
/// amount of space especially for large but largely unchanged channels.
/// Finally, variable length channels are array channels (i.e., cardinality > 1)
/// that have only a subset of the array stored for each sample. This is done
/// to save space, when the real-time software knows that only a subset of the
/// array has valid data.
///
class CDaqChannelInfo {
public:
CDaqChannelInfo() {
m_Id = m_Items = m_CapRate = m_Type = -1;
m_VarLen = false;
m_Name = "";
}
~CDaqChannelInfo() {};
int GetItemSize() const; ///< A
int GetRecSize() const; ///< B
int GetItemCount() const; ///< C
int GetType() const; ///< D
int GetId() const; ///< E
const string& GetName() const; ///< H
int GetCapRate() const; ///< G
bool IsVarLen() const; ///< H
friend class CDaqLowLevelIo;
private:
int m_Id;
int m_Items;
string m_Name;
int m_CapRate;
int m_Type;
bool m_VarLen;
};
/// Return true, if channel is a variable length array
inline bool
CDaqChannelInfo::IsVarLen(void) const
{
return m_VarLen;
}
///// Return sampling rate, in Hz
inline int
CDaqChannelInfo::GetCapRate(void) const
{
return m_CapRate;
}
///// Return name as specified in cell file
inline const string &
CDaqChannelInfo::GetName(void) const
{
return m_Name;
}
///
/// Return the channel identifier, a small integer that can be
/// used to reference the channel in other calls.
///
/// Keep in mind that the channel identifer can change among DAQ files,
/// even if it refers to the same cell variable.
///
inline int
CDaqChannelInfo::GetId(void) const
{
return m_Id;
}
///// Return type (c=char, f=float, i=int, s=short, d=double
inline int
CDaqChannelInfo::GetType(void) const
{
return m_Type;
}
///// Return number of items in each sample
inline int
CDaqChannelInfo::GetItemCount(void) const
{
return m_Items;
}
/////////// Return record size, in bytes
inline int
CDaqChannelInfo::GetRecSize(void) const
{
return GetItemSize() * GetItemCount();
}
/////////////////////////////////////////////////////////////////////////////
//
// DAQ low level IO Library
//
//
///
/// DAQ low level IO Library
///
/// \defgroup clib C++ Library
///
/// @{
///
#include "DaqIo.h"
#include <assert.h>
//
// Small dummy function to act as the default callback
//
///
/// Small dummy function to act as the default callback
///
static void DefaultErrorFunc(const char *, const char *) {}
///
/// Default functionality for the progress callback
///
static void DefaultProgressFunc(const char *, int, int) {}
struct TFrameInfo {
......@@ -71,6 +78,9 @@ CDaqLowLevelIo::SetCallbacks(
///
/// Doc
///
bool
CDaqLowLevelIo::GetChannelInfo(
int chId,
......@@ -91,7 +101,9 @@ CDaqLowLevelIo::GetChannelInfo(
return true;
}
///
/// adf
///
void
NearDump(FILE* p, int ofs)
{
......@@ -794,7 +806,7 @@ CDaqLowLevelIo::ReadTocFile(
//////////////////////////////////////////////////////////////////////////////////
///
/// This functions returns information about the file's integrity. It can
/// This function returns information about the file's integrity. It can
/// only be called after CheckIntegrity has successfully returned.
///
/// The function returns (in the provided arguments) two arrays of
......@@ -807,9 +819,9 @@ CDaqLowLevelIo::ReadTocFile(
///
bool
CDaqLowLevelIo::QueryIntegrityValues(
vector<int>& drops,
vector<int>& dropedFrm,
vector<int>& skips,
TIntVec& drops,
TIntVec& dropedFrm,
TIntVec& skips,
TDaqEofStatus& eofStat)
{
if ( m_HaveToc == false ) return false;
......@@ -1058,7 +1070,6 @@ CDaqLowLevelIo::CheckIntegrity(
}
}
m_LastError = "";
return true;
}
......@@ -1083,8 +1094,8 @@ CDaqLowLevelIo::CheckIntegrity(
///
bool
CDaqLowLevelIo::LowLevelDataRead(
const vector<int>* pWhichChannels,
vector<CDaqBuffer>& userStorage,
const TIntVec* pWhichChannels,
TDataVec& userStorage,
vector<TIntVec>* pFrameList
)
{
......@@ -1751,7 +1762,7 @@ CDaqLowLevelIo::GetFullData(
CDaqLowLevelIo::TReadErrorCode
CDaqLowLevelIo::ReadDataForOneFrame(
int numEntriesInThisRecord,
vector<int> needChannel,
TIntVec needChannel,
TDataVec& storage,
void* pTempSpace,
vector<bool>& gotData
......@@ -1889,5 +1900,6 @@ CDaqLowLevelIo::ReadFrameHeader(
}
frameToRead = -1; // no seeking needed after a resync
}
}
/// @}
......@@ -113,8 +113,17 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\DaqBuffer.h">
</File>
<File
RelativePath=".\DaqChannelInfo.h">
</File>
<File
RelativePath=".\DaqIo.h">
</File>
<File
RelativePath=".\DaqIoLib.h">
</File>
</Filter>
<Filter
Name="Resource Files"
......
using namespace std;
class CDaqBuffer;
class CDaqChannelInfo;
#define DAQ_MAGIC_NUM_VER_2_0 0x2C3D4E5F
#define DAQ_MAGIC_NUM_VER_2_1 0x2C3D4E6F
#define DAQ_MAGIC_NUM_VER_2_2 0x2C3D4E7F
#define DAQ_END_MARK 0x1A2B2C3D
#define DAQ_TOC_MAGIC_NUM 0x2C3ABCDE
typedef unsigned char TDaqByte;
typedef vector<int> TIntVec;
typedef vector<string> TStrVec;
typedef vector<CDaqBuffer> TDataVec;
typedef vector<FILE *> TFileVec;
typedef vector<CDaqChannelInfo> TChanInfoVec;
const int cMaxDaqRec = 128*1024; ///< maximum size of data per DAQ record
const int cMaxChannels = 500; ///< maximum number of channels we can handle
const int cMaxChannResyncLookahead = 2*1024;
///////////////////////////////////////////////////////////////////////////////////
///
/// This enumeration encapsulates various conversion options
/// Appropriate operators have been defined so combining options
/// can be done by using + or |
///
typedef enum {
eNO_OPTION = 0,
eEXPAND_DIFFERENTIAL = 1,
eFILL_MISSING = 2,
eINCLUDE_FRAME = 4,
eBINARY_FORMAT = 32,
eASCII_FORMAT = 64
} TConvertOptions;
inline TConvertOptions
operator+(TConvertOptions left, TConvertOptions right) {
return (TConvertOptions)((int)left + (int)right);
}
inline TConvertOptions
operator|(TConvertOptions left, TConvertOptions right) {
return (TConvertOptions)((int)left | (int)right);
}
///////////////////////////////////////////////////////////////////////////////////////////
///
/// Return code used to specify the status of the end marker of the DAQ file
///
typedef enum {
eDAQ_EOF_OK = 0, ///< Found full EOF marker
eDAQ_EOF_PARTIAL_MARK = 1, ///< Found a partial marker
eDAQ_EOF_NOTFOUND = 2, ///< No EOF marker found
eDAQ_EOF_UNDEFINED = 3 ///< No information available yet
} TDaqEofStatus;
This diff is collapsed. Click to expand it.
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