• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

onlinemonitor/rocmonitor/TRocSource.cxx (r4864/r3724)

Go to the documentation of this file.
00001 #include "TRocSource.h"
00002 
00003 #include "TClass.h"
00004 
00005 #include "TGo4Log.h"
00006 #include "TGo4UserSourceParameter.h"
00007 #include "TGo4MbsEvent.h"
00008 #include "TGo4EventErrorException.h"
00009 #include "TGo4EventTimeoutException.h"
00010 #include "TGo4EventEndException.h"
00011 
00012 // class required only to use methods, which are available in TGo4MbsSource
00013 
00014 TRocSource::TRocSource(TGo4UserSourceParameter* par) :
00015    TGo4EventSource(),
00016    fArg(),
00017    fBoard(0),
00018    fFullId(0)
00019 {
00020    TGo4Log::Debug(" New RocSource %s: par: %s", GetName(), par->GetName());
00021 
00022    fArg = par->GetName();
00023 
00024    TGo4Log::Info(" !!! ROC !!!   Create New RocSource  arg: %s", fArg.Data());
00025 
00026    Open();
00027 }
00028 
00029 TRocSource::TRocSource() : TGo4EventSource(), fArg(), fBoard(0)
00030 {
00031 }
00032 
00033 
00034 TRocSource::~TRocSource()
00035 {
00036    Close();
00037 }
00038 
00039 Bool_t TRocSource::CheckEventClass(TClass* cl)
00040 {
00041    return cl->InheritsFrom(TGo4MbsEvent::Class());
00042 }
00043 
00044 Bool_t TRocSource::BuildEvent(TGo4EventElement* dest)
00045 {
00046    if (fBoard==0) throw TGo4EventErrorException(this);
00047 
00048    void* buf(0);
00049    unsigned len(0);
00050 
00051    if (!fBoard->getNextBuffer(buf,len, 5.))
00052       throw TGo4EventTimeoutException(this);
00053 
00054    TGo4MbsEvent* mbs = (TGo4MbsEvent*) dest;
00055 
00056    return mbs->AddSubEvent(fFullId, (Short_t*) buf, len/sizeof(Short_t) + 2) != 0;
00057 }
00058 
00059 
00060 Int_t TRocSource::Open()
00061 {
00062    if(fBoard!=0) return -1;
00063 
00064    fBoard = roc::Board::Connect(fArg.Data(), roc::roleDAQ);
00065 
00066    if (fBoard==0) return -1;
00067 
00068             //  procid - data type, subcrate - rocnumber, control - message type
00069 
00070    fFullId = roc::proc_RawData | (fBoard->rocNumber() << 16) | (fBoard->getMsgFormat() << 24); //
00071    
00072    fBoard->setFlushTimeout(0.1);
00073 
00074    fBoard->startDaq();
00075 
00076    return 0;
00077 }
00078 
00079 
00080 Int_t TRocSource::Close()
00081 {
00082    if(fBoard==0) return -1;
00083 
00084    fBoard->stopDaq();
00085 
00086    roc::Board::Close(fBoard);
00087 
00088    fFullId = 0;
00089 
00090    return 0;
00091 }

Generated on Tue Dec 10 2013 04:52:22 for ROCsoft by  doxygen 1.7.1