StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
daq_fpd.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_fpd.h"
11 
12 
13 extern int fpd_reader(char *m, struct fpd_t *fpd, u_int driver) ;
14 
15 const char *daq_fpd::help_string = "FPD tst\n" ;
16 
18 {
19 public:
21  daq_det_factory::det_factories[FPD_ID] = this ;
22  }
23 
24  daq_det *create() {
25  return new daq_fpd ;
26  }
27 } ;
28 
29 static daq_det_fpd_factory fpd_factory ;
30 
31 
32 
33 daq_fpd::daq_fpd(daqReader *rts_caller)
34 {
35  LOG(DBG,"FPD: rts_id %d, name %s",rts_id,name) ;
36 
37 
38  rts_id = FPD_ID ;
39  sfs_name = name = rts2name(rts_id) ;
40  caller = rts_caller ;
41  if(caller) caller->insert(this, rts_id) ;
42 
43  legacy = new daq_dta ;
44 
45  LOG(DBG,"%s: constructor: caller %p",name,caller) ;
46 }
47 
48 daq_fpd::~daq_fpd()
49 {
50  LOG(DBG,"%s: destructor",name) ;
51 
52  delete legacy ;
53 
54  return ;
55 }
56 
57 
58 daq_dta *daq_fpd::get(const char *bank, int c1, int c2, int c3, void *p1, void *p2)
59 {
60  if(!present) return 0 ;
61 
62  if(strcmp(bank,"*")==0) bank = "legacy" ; // set default, if called with *
63 
64  if(strcasecmp(bank,"legacy") != 0) {
65  LOG(ERR,"%s: unknown bank %s",name,bank) ;
66  return 0 ;
67  }
68 
69  return handle_legacy() ;
70 
71 }
72 
73 
74 daq_dta *daq_fpd::handle_legacy()
75 {
76 
77  // I need one object of fpd_t type but let the create decide on the necessary size
78  legacy->create(1,"fpd_t",rts_id,DAQ_DTA_STRUCT(fpd_t)) ;
79 
80 
81  fpd_t *fpd_p = (fpd_t *) legacy->request(1) ; // need ONE fpd_t object
82 
83  fpd_reader(caller->mem, fpd_p, m_Debug) ;
84 
85  legacy->finalize(1,0,0,0) ; // 1 entry; sector 0, row 0, pad 0
86  legacy->rewind() ;
87 
88  return legacy ;
89 }
Definition: daq_fpd.h:20