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