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

go4monitor/TRocSource.cxx (r4864/r1750)

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

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