00001 #include <sys/types.h>
00002 #include <string.h>
00003
00004 #include <rtsLog.h>
00005 #include <rtsSystems.h>
00006
00007 #include <DAQ_READER/daqReader.h>
00008 #include <DAQ_READER/daq_dta.h>
00009
00010 #include "daq_ric.h"
00011
00012 extern int ric_reader(char *m, struct ric_t *ric, u_int driver) ;
00013
00014 const char *daq_ric::help_string = "RIC tst\n" ;
00015
00016
00017 class daq_det_ric_factory : public daq_det_factory
00018 {
00019 public:
00020 daq_det_ric_factory() {
00021 daq_det_factory::det_factories[RIC_ID] = this ;
00022 }
00023
00024 daq_det *create() {
00025 return new daq_ric ;
00026 }
00027 } ;
00028
00029 static daq_det_ric_factory ric_factory ;
00030
00031
00032
00033 daq_ric::daq_ric(daqReader *rts_caller)
00034 {
00035 LOG(DBG,"RIC: rts_id %d, name %s",rts_id,name) ;
00036
00037
00038 rts_id = RIC_ID ;
00039 sfs_name = name = rts2name(rts_id) ;
00040 caller = rts_caller ;
00041 if(caller) caller->insert(this, rts_id) ;
00042
00043 legacy = new daq_dta ;
00044
00045 LOG(DBG,"%s: constructor: caller %p",name,caller) ;
00046 }
00047
00048 daq_ric::~daq_ric()
00049 {
00050 LOG(DBG,"%s: destructor",name) ;
00051 if(caller) caller->de_insert(rts_id) ;
00052
00053 delete legacy ;
00054
00055 return ;
00056 }
00057
00058
00059 daq_dta *daq_ric::get(const char *bank, int c1, int c2, int c3, void *p1, void *p2)
00060 {
00061 Make() ;
00062 if(!present) return 0 ;
00063
00064 if(strcmp(bank,"*")==0) bank = "legacy" ;
00065
00066 if(strcasecmp(bank,"legacy") != 0) {
00067 LOG(ERR,"%s: unknown bank %s",name,bank) ;
00068 return 0 ;
00069 }
00070
00071 return handle_legacy() ;
00072
00073 }
00074
00075
00076 daq_dta *daq_ric::handle_legacy()
00077 {
00078
00079
00080 legacy->create(1,"ric_t",rts_id,DAQ_DTA_STRUCT(ric_t)) ;
00081
00082
00083 ric_t *ric_p = (ric_t *) legacy->request(1) ;
00084
00085 ric_reader(caller->mem, ric_p, m_Debug) ;
00086
00087 legacy->finalize(1,0,0,0) ;
00088 legacy->rewind() ;
00089
00090 return legacy ;
00091 }