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