#ifndef __ANTARESDAQ__FRAMEPREAMBLE__ #define __ANTARESDAQ__FRAMEPREAMBLE__ /** * @file FramePreamble.hh * @author Joris van Rantwijk * @date Feb 2002 * * Class definition for Antares DAQ Data-Frame Preamble. */ #include #include #include #include #include "antares-dataformat/ulonglong.hh" /** * This object holds the information from the 'preamble' of a data frame. */ class DaqFramePreamble { public: /** Total length of the frame in 4-byte words. */ unsigned int frameSize; /** Data type code (DAQ_xxx) */ unsigned short dataType; /** Unique code representing the shore station for this frame */ unsigned short frameTarget; /** Frame 'time stamp' in units of 50ns (MSW) */ unsigned int frameTime1; /** Frame 'time stamp' in units of 50ns (LSW) */ unsigned int frameTime2; /** \return 64 bit frame time */ ulonglong frameTime() { return ulonglong(frameTime1,frameTime2); } /** Number of frames since start of the run */ unsigned int frameIndex; /** Status of frame Xon/Xoff */ unsigned short status; /** Number of items actually sent in this frame */ unsigned short nbItems; /** ID of originating LCM */ unsigned short LCM_ID; /** ID of originating ARS */ unsigned short ARS_ID; /** Run-number as given by the RunControl */ unsigned int runNumber; /** * get LCM idendifier * \return LCM identifier */ const unsigned short lcm_id() const { return LCM_ID; } /** * get ARS idendifier * \return ARS identifier */ const unsigned short ars_id() const { return ARS_ID; } /** * get data type * \return data type */ const unsigned short data_type() const { return dataType; } /** * get number of items * \return number of items */ const unsigned short numberOfItems() const { return nbItems; } /** * Return a pointer to the frame data buffer. * The returned value points to the start of the frame preamble. * \return pointer to data */ virtual const unsigned char* getdata() const { return NULL; } /** * Return the length of the frame data buffer. * The returned value is in bytes (not words), and includes * the frame preamble. * \return length of data */ virtual const unsigned int getdatalen() const { return Length(); } /** Construct an empty preamble object. */ DaqFramePreamble() { }; /** * destructor */ virtual ~DaqFramePreamble() {}; /** Return length of an encoded frame preamble in bytes. */ static const unsigned int Length() { return 32; } /** * Print ASCII. * * \param out output stream * \param object frame preamble * \return output stream */ friend std::ostream& operator<<(std::ostream& out, const DaqFramePreamble& object) { using namespace std; out << "frameSize " << object.frameSize << endl; out << "dataType " << object.dataType << endl; out << "frameTarget " << object.frameTarget << endl; out << "frameTime1 " << object.frameTime1 << endl; out << "frameTime2 " << object.frameTime2 << endl; out << "frameIndex " << object.frameIndex << endl; out << "status " << object.status << endl; out << "nbItems " << object.nbItems << endl; out << "LCM_ID " << object.LCM_ID << endl; out << "ARS_ID " << object.ARS_ID << endl; out << "runNumber " << object.runNumber << endl; return out; } ClassDef(DaqFramePreamble, 2); }; /** * equal operator for DAQ frame preamble * * \param first DAQ frame preamble * \param second DAQ frame preamble * \return true if first equals second; else false */ static inline const bool operator==(const DaqFramePreamble& first, const DaqFramePreamble& second) { return (first.dataType == second.dataType && first.frameIndex == second.frameIndex && first.LCM_ID == second.LCM_ID && first.ARS_ID == second.ARS_ID && first.runNumber == second.runNumber); } /** * not-equal operator for DAQ frame preamble * * \param first DAQ frame preamble * \param second DAQ frame preamble * \return true if first not equals second; else false */ static inline const bool operator!=(const DaqFramePreamble& first, const DaqFramePreamble& second) { return (first.dataType != second.dataType || first.frameIndex != second.frameIndex || first.LCM_ID != second.LCM_ID || first.ARS_ID != second.ARS_ID || first.runNumber != second.runNumber); } #endif /* End */