示例#1
0
文件: gcalib.c 项目: juskoa/trigger
----------------------------------------*/ void read_gcalibcfg() {
FILE* gcalcfg;
enum Ttokentype token;
char line[MAXLINELENGTH], value[MAXCTPINPUTLENGTH];
char em1[200]="";
gcalcfg= openFile("gcalib.cfg","r");
if(gcalcfg==NULL) {
  prtLog("gcalib cannot be read. Using defaults");
  return;
};
while(fgets(line, MAXLINELENGTH, gcalcfg)){
  int ix,det,milsec, roc,log;
  roc=0; log=0;
  //printf("Decoding line:%s ",line);
  if(line[0]=='#') continue;
  if(line[0]=='\n') continue;
  ix=0; token= nxtoken(line, value, &ix);
  if(token==tSYMNAME) {
    char ltuname[20];
    strcpy(ltuname, value);
    det= findLTUdetnum(ltuname);
    if(det<0) {
      strcpy(em1,"bad LTU name in gcalib.cfg"); goto ERR; 
    };
    token=nxtoken(line, value, &ix);
    if(token==tINTNUM) {         // period in ms
      milsec= str2int(value);
    } else {strcpy(em1,"bad period (integer expected ms) in gcalib.cfg"); goto ERR; };
    ACTIVEDETS[det].periodms= milsec;
    token=nxtoken(line, value, &ix);
    if(token==tINTNUM) {         // roc (decimal)
      roc= str2int(value);
    } else if(token != tEOCMD) {
      strcpy(em1,"bad ROC (0-7 expected) in gcalib.cfg"); goto ERR;
    };
    token=nxtoken(line, value, &ix);
    if(token==tSYMNAME) {
      if(value[0]=='y') {
        log= 1;
      } else if(value[0]=='n') {
        log= 0;
      } else {
        sprintf(em1,"bad LOG option %s (y or n expected) in gcalib.cfg", value); goto ERR;
      }
    } else if((token != tEOCMD) && (token!=tCROSS)) {
      sprintf(em1,"bad LOG option  %s(y or n expected) in gcalib.cfg", value); goto ERR;
    };
    ACTIVEDETS[det].logroc= (log<<4) | roc;
    sprintf(em1,"gcalib.cfg:%s %dms 0x%x", ACTIVEDETS[det].name, ACTIVEDETS[det].periodms,
      ACTIVEDETS[det].logroc);
    prtLog(em1); em1[0]='\0';
  } else {strcpy(em1,"LTU name expected"); goto ERR; };
};
ERR: 
fclose(gcalcfg); if(em1[0]!='\0') prtLog(em1); return;
};
示例#2
0
/*FGROUP busy
0- CTP BUSY
1-24 : detectors
25-30 : clusters
31 test cluster
*/
void busyprobe(char *det){
 int detector;
 float min,max;
 detector=findLTUdetnum(det);
 if(detector == -1){
  printf("Cannot find detector %s \n",det);
  return;
 }
 vmew32(MINIMAX_SELECT,detector);
 //vmew32(MINIMAX_CLEAR,0xff);
 sleep(1);
 max=0.4*vmer32(BUSYMAX_DATA);
 min=0.4*vmer32(BUSYMINI_DATA);
 printf("%i %s MIN:%f MAX:%f \n",detector,det,min,max);
}