/******************************************* * Look the parameters in the CAEN Mail_box * * * *******************************************/ #include #include #include #include #include #include #include "a200.h" /* definitions relative to the CAEN system */ #include "a200.hmn" #include "../lib/mylib1.h" #include "../dbase/hv_dbase.h" #define SLEEP_MAX 3 /* number of cycles in which a chan. is put to sleep */ #define SECONDS #define MINUTES * 60 #define MAX_BAD_CH 100 #define IMAX_D 2000 SY227_MBOX *sy227_mod; int sem_227mod_id; SY127_MBOX *sy127_mod; int sem_127mod_id; char *caller; char line[80]; int n_order, alarm[40], sleep_count[40]; FILE *fp, *fopen(); char *infile_dummy = "tubi_sitter.log"; char *infile_dummy_h = "tubi_sitter_hosp.log"; char *infile; main(argc, argv) int argc; char *argv[]; { hv_mod_struct *mid; char *chamber_code; char *mod_name0 = "hv_config0"; char *mod_name1 = "hv_config1"; char *mod_name2 = "hv_config2"; char *mod_name, *hv_config[3]; int dis, sl; int cpu_nr, tcp_ip_nr; int i, ir, j, k, chan; int n_good, n_bad; float imean, vmean; int ch_imax, imax; short d_vmon[32], d_imon[32], d_status[32]; short hv_ch, on_off, hv_in; int status_hv_ch; int v0_hv_ch; int vmon_hv_ch; int i0_hv_ch; int imon_hv_ch; int yy, mm, dd, hh, min, sec; char *cable_name[10]; int ch_code, done; struct bad_ch_str{ short code; short nr; short vmin; short vmax; short fmm; short fdd; short fhh; short fmin; short lmm; short ldd; short lhh; short lmin; } bad_ch[MAX_BAD_CH]; int max_bad_ch = MAX_BAD_CH; /* the program is inhibited (GdA, 3/7/95) */ if (1){ printf(" this command is obsolete: \n"); printf(" use instead: \n"); printf(" - ''list fili_caldi''\n"); printf(" or - ''fil_parade''\n"); exit(0); } if (argc < 2) infile = infile_dummy; else if (strcmp(argv[1], "h") == 0 || strcmp(argv[1], "H") == 0) infile = infile_dummy_h; else infile = argv[1]; get_config(&tcp_ip_nr, &cpu_nr, hv_config); mod_name = hv_config[cpu_nr]; if ((mid = (hv_mod_struct *)modlink(mod_name, 0)) == (hv_mod_struct *)-1) if ((mid = (hv_mod_struct *)modload(mod_name, 0)) == (hv_mod_struct *)-1) exit(_errmsg(errno, "%s: error linking module %s\n", argv[0], mod_name)); for ( i = 0; i < max_bad_ch; i++){ bad_ch[i].code = -1; bad_ch[i].nr = -1; bad_ch[i].vmin = 9999; bad_ch[i].vmax = 0; bad_ch[i].fdd = 0; bad_ch[i].fmm = 0; bad_ch[i].fhh = 0; bad_ch[i].fmin = 0; bad_ch[i].ldd = 0; bad_ch[i].lmm = 0; bad_ch[i].lhh = 0; bad_ch[i].lmin = 0; } fp = fopen(infile, "r"); for (;;){ if ( fscanf(fp, "%d/%d %d:%d %s OFF", &dd, &mm, &hh, &min, cable_name) == EOF) break; if ( fscanf(fp, " V=%d,st=0x%x;=%f,imax=%d(ch%d),", &vmon_hv_ch, &status_hv_ch, &imean, &imax, &ch_imax) == EOF) break; if ( fscanf(fp, "n_bad=%d\n", &n_bad) == EOF) break; /* printf("%2d/%2d %2d:%2d %s OFF", dd, mm, hh, min, cable_name); printf(" V=%4d,st=0x%2x;=%4.0f,imax=%4d(ch%2d),", vmon_hv_ch, status_hv_ch, imean, imax, ch_imax); printf("n_bad=%2d\n", n_bad); */ for (dis = 0; dis < mid->n_crates; dis++) for (sl = 0; sl < 4; sl++) if (strcmp(cable_name, mid->distr[dis].slot[sl].cable_name) == 0){ if (imax >= IMAX_D) ch_code = dis * 1000 + sl * 100 + ch_imax; else ch_code = dis * 1000 + sl * 100 + 32; /* printf(" ch_code = %d\n", ch_code); */ } done = 0; for ( i = 0; i < max_bad_ch; i++){ if (bad_ch[i].code == (short)ch_code){ /* printf(" i = %d, bad_ch[i].code %d\n", i, bad_ch[i].code); */ done++; bad_ch[i].nr++; if (bad_ch[i].vmin > (short)vmon_hv_ch ) bad_ch[i].vmin = (short)vmon_hv_ch; if (bad_ch[i].vmax < (short)vmon_hv_ch ) bad_ch[i].vmax = (short)vmon_hv_ch; bad_ch[i].lmm = (short)mm; bad_ch[i].ldd = (short)dd; bad_ch[i].lhh = (short)hh; bad_ch[i].lmin = (short)min; } else if (bad_ch[i].code < 0){ done++; /* printf(" i = %d, bad_ch[i].code %d\n", i, bad_ch[i].code); */ bad_ch[i].nr = 1; bad_ch[i].code = (short)ch_code; bad_ch[i].vmin = vmon_hv_ch; bad_ch[i].vmax = vmon_hv_ch; bad_ch[i].fmm = (short)mm; bad_ch[i].fdd = (short)dd; bad_ch[i].fhh = (short)hh; bad_ch[i].fmin = (short)min; } if ( done ) break; } if ( !done ) printf("more than %d channel to be reported !!\n", max_bad_ch); } fclose(fp); for (i = 0; i < max_bad_ch; i++){ /*printf(" i = %d, bad_ch[i].nr = %d\n", i, bad_ch[i].nr); */ if (bad_ch[i].nr < 1) break; dis = bad_ch[i].code/1000; sl = (bad_ch[i].code - dis * 1000)/100; chan = bad_ch[i].code - dis * 1000 - sl * 100; /* printf(" code: %d -> dis %d, sl %d, chan %d\n", bad_ch[i].code, dis, sl, chan); */ printf("%s:", mid->distr[dis].slot[sl].cable_name); if ((chan < 32) && (mid->distr[dis].slot[sl].d_used_ch & (1 << chan))) printf(" ch%2d %3d times with V =%4d-%4d", chan, bad_ch[i].nr, bad_ch[i].vmin, bad_ch[i].vmax); else if (chan < 32 ) printf(" * ch%2d %3d times with V =%4d-%4d", chan, bad_ch[i].nr, bad_ch[i].vmin, bad_ch[i].vmax); else printf(" OVC, %3d times", bad_ch[i].nr); printf(" from %2d-%2d %2d:%2d to %2d-%2d %2d:%2d\n", bad_ch[i].fdd, bad_ch[i].fmm, bad_ch[i].fhh, bad_ch[i].fmin, bad_ch[i].ldd, bad_ch[i].lmm, bad_ch[i].lhh, bad_ch[i].lmin); } printf("\n( \"*\" : channel already disconnected )\n"); munlink(mid); }