#ifndef __TMrbTransport_h__
#define __TMrbTransport_h__
namespace std {} using namespace std;
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <fstream>
#include "Rtypes.h"
#include "TNamed.h"
#include "TSystem.h"
#include "TMrbLofNamedX.h"
#include "mbsio.h"
class TMrbTransport : public TNamed {
public:
enum { kSizeOfData = 0x4000 };
enum { kERROR = -1 };
enum { kEOF = 0 };
enum { kEOE = kEOF };
enum { kMaxErrors = 10 };
enum EMrbRunStatus { kReady = 0,
kRunning = 0x1,
kTerminate = 0x2,
kError = 0x4
};
enum EMrbTransportMode { kUndefined = 0,
kSync = MBS_CTYPE_SYNC,
kAsync = MBS_CTYPE_ASYNC,
kFile = MBS_CTYPE_FILE,
kRemote = MBS_CTYPE_REMOTE
};
enum EMrbBufferElements { kBufferHeader = 0x1,
kFileHeader = 0x2,
kEventHeader = 0x4,
kSubeventHeader = 0x8,
kSubeventData = 0x10
};
public:
TMrbTransport(const Char_t *, const Char_t * XptTitle = "");
~TMrbTransport() {};
Bool_t Open(const Char_t *, const Char_t * Mode = "FILE", Int_t BufferSize = TMrbTransport::kSizeOfData);
Bool_t Close();
Bool_t FreeBuffers();
Int_t ReadEvents(Int_t NofEvents = 0);
UInt_t NextSubevent(UShort_t *);
const UShort_t * NextSubevent();
inline UInt_t SubeventWC() { return(fMBSDataIO->sevt_wc); };
inline UInt_t SubeventID() { return(fMBSDataIO->sevt_id); };
inline MBSDataIO * GetMbsBase() { return(fMBSDataIO); };
Bool_t OpenMEDFile(const Char_t * MEDFile);
Bool_t CloseMEDFile();
Bool_t OpenLMDFile(const Char_t * LMDFile);
Bool_t CloseLMDFile();
Bool_t Show(const Char_t * BufElemKey = "Subevents", const Char_t * Output = NULL);
Bool_t SetShow(const Char_t * BufElemStr = "Events:Subevents", Int_t ScaleDown = 100, const Char_t * Output = NULL);
Bool_t ShowStat(const Char_t * Output = NULL);
Bool_t SetStat(Int_t ScaleDown = 100, const Char_t * Output = NULL);
Bool_t SetStream(Int_t MaxStreams = 0, Int_t SlowDown = 0);
Bool_t SetDumpInterval(Int_t NofRecs = 0);
virtual Bool_t ProcessEvent(s_vehe *);
Bool_t PrintMbsIoError(const Char_t *);
inline Bool_t IsError() { return(fErrorFlag); };
inline void ClearError() { fErrorFlag = kFALSE; };
inline void SetError() { fErrorFlag = kTRUE; };
Bool_t Version();
Bool_t OpenLogFile(const Char_t *);
inline void SetStopFlag(Bool_t Flag = kTRUE) { fStopFlag = Flag; };
inline Bool_t IsToBeStopped() { return(fStopFlag); };
inline void Help() { gSystem->Exec(Form("mrbHelp %s", this->ClassName())); };
public:
TMrbLofNamedX fLofTransportModes;
TMrbLofNamedX fLofBufferElements;
protected:
TString fInputFile;
EMrbTransportMode fTransportMode;
Int_t fBufferSize;
TString fErrorString;
MBSDataIO *fMBSDataIO;
Bool_t fErrorFlag;
Bool_t fStopFlag;
ClassDef(TMrbTransport, 0)
};
#endif