StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
daq_svt.cxx
1 #include <sys/types.h>
2 #include <string.h>
3 
4 #include <rtsLog.h>
5 #include <rtsSystems.h>
6 
7 #include <DAQ_READER/daqReader.h>
8 #include <DAQ_READER/daq_dta.h>
9 
10 #include "daq_svt.h"
11 
12 extern int svt_reader(char *m, struct svt_t *svt, u_int driver) ;
13 
14 const char *daq_svt::help_string = "SVT tst\n" ;
15 
16 
18 {
19 public:
21  daq_det_factory::det_factories[SVT_ID] = this ;
22  }
23 
24  daq_det *create() {
25  return new daq_svt ;
26  }
27 } ;
28 
29 static daq_det_svt_factory svt_factory ;
30 
31 
32 
33 daq_svt::daq_svt(daqReader *rts_caller)
34 {
35  LOG(DBG,"SVT: rts_id %d, name %s",rts_id,name) ;
36 
37  // dname is ignored
38  rts_id = SVT_ID ;
39  name = rts2name(rts_id) ;
40  sfs_name = "svt" ;
41  caller = rts_caller ;
42  if(caller) caller->insert(this, rts_id) ;
43 
44 
45  legacy = new daq_dta ;
46 
47  LOG(DBG,"%s: constructor: caller %p",name,caller) ;
48 }
49 
50 daq_svt::~daq_svt()
51 {
52  LOG(DBG,"%s: destructor",name) ;
53 
54  if(caller) caller->de_insert(rts_id) ;
55 
56  delete legacy ;
57 
58  return ;
59 }
60 
61 
62 daq_dta *daq_svt::get(const char *bank, int c1, int c2, int c3, void *p1, void *p2)
63 {
64  Make() ;
65  if(!present) return 0 ;
66 
67  if(strcmp(bank,"*")==0) bank = "legacy" ; // set default, if called with *
68 
69  if(strcasecmp(bank,"legacy") != 0) {
70  LOG(ERR,"%s: unknown bank %s",name,bank) ;
71  return 0 ;
72  }
73 
74  return handle_legacy() ;
75 
76 }
77 
78 
79 daq_dta *daq_svt::handle_legacy()
80 {
81 
82  // I need one object of svt_t type but let the create decide on the necessary size
83  legacy->create(1,"svt_t",rts_id,DAQ_DTA_STRUCT(svt_t)) ;
84 
85 
86  svt_t *svt_p = (svt_t *) legacy->request(1) ; // need ONE svt_t object
87 
88  svt_reader(caller->mem, svt_p, m_Debug) ;
89 
90  legacy->finalize(1,0,0,0) ; // 1 entry; sector 0, row 0, pad 0
91  legacy->rewind() ;
92 
93  return legacy ;
94 }
Definition: daq_svt.h:9