Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
FastbusModule.cxx
Go to the documentation of this file.
1
2//
3// FastbusModule
4//
6
7#include "FastbusModule.h"
8#include "THaSlotData.h"
9#include <iostream>
10#include <stdexcept>
11
12using namespace std;
13
14namespace Decoder {
15
17 : Module(crate, slot), fHasHeader(false),
18 fSlotMask(0), fSlotShift(0), fChanMask(0), fChanShift(0),
19 fDataMask(0), fOptMask(0), fOptShift(0),
20 fChan(0), fData(0), fRawData(0)
21{
22 FastbusModule::SetSlot(crate, slot); //FIXME redundant/useless?
23}
24
27 fSlotMask = 0xf8000000;
28 fSlotShift = 27;
29}
30
32 fChan = Chan(*evbuffer);
33 fData = Data(*evbuffer);
34 fRawData = *evbuffer;
35 return 1;
36}
37
38void FastbusModule::SetSlot( UInt_t crate, UInt_t slot, UInt_t header,
39 UInt_t mask, Int_t modelnum )
40{
41 // SetSlot function with parameter checks appropriate for Fastbus
42 if( fCrate >= MAXROC )
43 throw invalid_argument("FastBusModule::ERROR: crate out of bounds");
44 if( fSlot >= MAXSLOT_FB )
45 throw invalid_argument("FastBusModule::ERROR: slot out of bounds");
46
47 Module::SetSlot(crate, slot, header, mask, modelnum);
48}
49
50
52 const UInt_t* pstop )
53{
54 fWordsSeen = 0;
56 const UInt_t *p = evbuffer;
57 if (fDebugFile) {
58 *fDebugFile << "FastbusModule:: loadslot "<<endl;
59 if (fHasHeader) {
60 *fDebugFile << "TFB:: Has header "<<endl;
61 } else {
62 *fDebugFile << "TFB:: Has NO header "<<endl;
63 }
64 *fDebugFile << "FBModule:: Model number "<<dec<<fModelNum<<endl;
65 }
66 while (IsSlot( *p )) {
67 if (fHasHeader && fWordsSeen==0) {
68 fHeader = *p;
69 if (fDebugFile) *fDebugFile << "FastbusModule:: header "<<hex<<fHeader<<dec<<endl;
70 } else {
71 Decode(p);
72 if (fDebugFile) *fDebugFile << "FastbusModule:: chan "<<dec<<fChan<<" data "<<fData<<" raw "<<hex<<*p<<dec<<endl;
73 sldat->loadData(fChan, fData, fRawData);
74 }
75 fWordsSeen++;
76 p++;
77 if (p > pstop) break;
78 }
79 if (fHeader) {
81 if (fDebugFile) *fDebugFile << "FastbusModule:: words expected "<<dec<<fWordsExpect<<endl;
82 if (fWordsExpect != fWordsSeen) {
83 if (fDebugFile) *fDebugFile << "ERROR: FastbusModule: crate "<<fCrate<<" slot "<<fSlot<<" number of words expected "<<fWordsExpect<<" not equal num words seen "<<fWordsSeen<<endl;
84// This happens a lot for some modules, and appears to be harmless, so I suppress it.
85// cerr << "ERROR: FastbusModule: number of words expected "<<fWordsExpect<<" not equal num words seen "<<fWordsSeen<<endl;
86 }
87 }
88 return fWordsSeen;
89}
90
92
93 if (fDebugFile) {
94 *fDebugFile << "FastbusModule DoPrint. name = "<<fName<<
95 " Crate "<<fCrate<<" slot "<<fSlot<<endl;
96 *fDebugFile << "FastbusModule model num "<<fModelNum;
97 *fDebugFile << " masks "<<hex<<fChanMask<<" "<<fDataMask<<" "<<fWdcntMask<<endl;
98 if (fHasHeader) {
99 *fDebugFile << "FastbusModule :: has a header "<<endl;
100 } else {
101 *fDebugFile << "FastbusModule :: has NO header "<<endl;
102
103 }
104 }
105
106}
107
108}
109
int Int_t
unsigned int UInt_t
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
UInt_t Chan(UInt_t rdata) const
virtual void SetSlot(UInt_t crate, UInt_t slot, UInt_t header=0, UInt_t mask=0, Int_t modelnum=0)
virtual UInt_t LoadSlot(THaSlotData *sldat, const UInt_t *evbuffer, const UInt_t *pstop)
virtual Bool_t IsSlot(UInt_t rdata)
virtual Int_t Decode(const UInt_t *evbuffer)
UInt_t Data(UInt_t rdata) const
UInt_t fCrate
Definition Module.h:142
virtual void Init()
Definition Module.cxx:51
std::ofstream * fDebugFile
Definition Module.h:156
UInt_t fWdcntMask
Definition Module.h:146
Int_t fModelNum
Definition Module.h:147
UInt_t fWordsExpect
Definition Module.h:145
UInt_t fHeader
Definition Module.h:143
UInt_t fSlot
Definition Module.h:142
UInt_t fWordsSeen
Definition Module.h:145
virtual void SetSlot(UInt_t crate, UInt_t slot, UInt_t header=0, UInt_t mask=0, Int_t modelnum=0)
Definition Module.h:82
Int_t loadData(const char *type, UInt_t chan, UInt_t dat, UInt_t raw)
TString fName
static const UInt_t MAXSLOT_FB
Definition Decoder.h:36
static const UInt_t MAXROC
Definition Decoder.h:33
STL namespace.
ClassImp(TPyArg)