4 #include <rtsSystems.h>
15 static char evpgroups[32][40];
17 int getRccnf(
const char *fn,
rccnf *desc)
23 memset(desc, 0,
sizeof(
rccnf));
25 FILE *f = fopen(fn,
"ro");
28 if(fscanf(f,
"run %d\n",&desc->run) != 1) {
33 if(fscanf(f,
"detmask 0x%x\n",&desc->detMask) != 1) {
39 desc->detMask |= (1<<TRG_ID);
40 desc->detMask |= (1<<SC_ID);
41 desc->detMask &= ~(1<<DAQ_ID);
45 while(fgets(buff,80,f)) {
46 if(strstr(buff,
"evpgroups:") != buff)
continue;
58 while(fscanf(f,
"%s %d %d\n",buff,&in1,&in2) == 3) {
59 desc->grpMask |= (1<<in1);
68 char str[80],str2[80];
69 memset(evpgroups, 0,
sizeof(evpgroups));
72 FILE *f = fopen(
"/RTS/conf/handler/evpGroups.txt",
"ro");
75 while(fgets(str, 80, f) == str) {
76 if(str[0] ==
'#')
continue;
78 sscanf(str,
"%d %s\n",&
id, str2);
80 strcpy(evpgroups[
id],str2);
93 for(
int i=0;i<32;i++) {
94 const char *t = rts2name(i);
96 if(strcasecmp(t,str) == 0)
return i;
104 UINT32 str2detmask(
const char *str)
106 char *_strtok_static;
113 char *t = strtok_r(s,
",",&_strtok_static);
121 LOG(DBG,
"Invalid detector: %s",t,0,0,0,0);
124 t = strtok_r(NULL,
",",&_strtok_static);
131 int s2gid(
const char *str)
133 for(
int i=0;i<32;i++) {
134 if(strcasecmp(str,evpgroups[i]) == 0)
return i;
141 UINT32 str2evpgroupmask(
const char *str)
143 char *_strtok_static;
148 if(init == 0) initEvpGroups();
151 char *t = strtok_r(s,
",",&_strtok_static);
160 LOG(ERR,
"Invalid evpgroup: %s",t,0,0,0,0);
163 t = strtok_r(NULL,
",",&_strtok_static);
171 int main(
int argc,
char *argv[])
174 rtsLogOutput(RTS_LOG_STDERR);
178 getRccnf(
"0.txt",&x);
180 printf(
":::%d : 0x%x : 0x%x\n",x.run,x.detMask,x.grpMask);
182 LOG(ERR,
"Hello",0,0,0,0,0);
183 char *str =
"tpc,daq,trg,svt,horse";
184 char *str2 =
"pedestal,b1,b3,b4";
185 printf(
"dets: %s 0x%x\n",str,str2detmask(str));
186 printf(
"evpgrps: %s 0x%x\n",str2,str2evpgroupmask(str2));