/******************************************* * 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 NMAX 45 #define NOK 40 #define SECONDS #define MINUTES * 60 #define FINE 1001 SY127_MBOX *sy127_mod; int sem_127mod_id; char *caller; sighand(signal) register int signal; { printf(" %s : signal %d received \n", *caller, signal); if ( signal >= 2 && signal <= 3){ /* ^C or ^E ? */ A200_end(); sem_unl_del(sem_127mod_id, "sy127mod", caller); munlink(sy127_mod); exit(0); } } main(argc, argv) int argc; char *argv[]; { hv_mod_struct *mid; char *chamber_code; char old_chamber[10]; 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 ch1, ch2, first_print; int nwrite, nerror, par_val; short ndata, data[45], prot_word; short i, ir, j, k, chan, value, code; int n_good, n_bad; float imean, vmean; short d_imax_min, d_imax_max, d_imax[32]; short hv_ch_A, hv_ch_Ref, on_off, hv_in; int anno, mese, giorno, ora, minuti, secondi; int sy127_mod_pset_tim[6]; int sy127_mod_pchk_tim[6]; int sy127_mod_nchk; int sy127_mod_nchk_err; short status_hv_ch_A; short v0_hv_ch_A; short v1_hv_ch_A; short i0_hv_ch_A; short i1_hv_ch_A; short ramp_up_hv_ch_A; short ramp_down_hv_ch_A; short trip_hv_ch_A; short status_hv_ch_Ref; short v0_hv_ch_Ref; short v1_hv_ch_Ref; short i0_hv_ch_Ref; short i1_hv_ch_Ref; short ramp_up_hv_ch_Ref; short ramp_down_hv_ch_Ref; short trip_hv_ch_Ref; int r_v = 1; if (argc == 2) if (*argv[1] == 's' || *argv[1] == 'S') r_v = 0; /* look at set values instead of read values */ intercept(sighand); if((sy127_mod = (SY127_MBOX *)modlink("sy127mod", 0)) == (SY127_MBOX *) -1) exit(_errmsg(errno,"hv_status: err. link data module\n")); sem_127mod_id = sem_link_cr("SY127mod", argv[0]); 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)); chamber_code = "0"; strcpy(old_chamber, "--", strlen("--") ); sem_wait(sem_127mod_id, argv[0]); if (r_v){ for ( i = 0; i < 6; i++) sy127_mod_pchk_tim[i] = sy127_mod->pchk_tim[i]; sy127_mod_nchk = sy127_mod->nchk; sy127_mod_nchk_err = sy127_mod->nchk_err; } else { for ( i = 0; i < 6; i++) sy127_mod_pset_tim[i] = sy127_mod->pset_tim[i]; } sem_free(sem_127mod_id, argv[0]); data_ora( &anno, &mese, &giorno, &ora, &minuti, &secondi); printf( "Present time: %2d-%2d-%4d %2d:%2d:%2d\n", giorno, mese, anno, ora, minuti, secondi); if (r_v) { printf("Last check ( sy127_par_mon) %2d-%2d-%4d %2d:%2d:%2d", sy127_mod_pchk_tim[2], sy127_mod_pchk_tim[1], sy127_mod_pchk_tim[0], sy127_mod_pchk_tim[3], sy127_mod_pchk_tim[4], sy127_mod_pchk_tim[5]); printf(" nread %7d, err %4d\n", sy127_mod_nchk, sy127_mod_nchk_err); } else { printf("Last parameter modification: %2d-%2d-%4d %2d:%2d:%2d\n", sy127_mod_pset_tim[2], sy127_mod_pset_tim[1], sy127_mod_pset_tim[0], sy127_mod_pset_tim[3], sy127_mod_pset_tim[4], sy127_mod_pset_tim[5]); } printf("\n\n P O W E R S U P P L Y Parameters \n"); printf("\n"); printf(" CH V0 V1 I0 I1 "); printf(" RAMP_UP RAMP_DOWN TRIP \n"); printf(" (V) (V) (uA) (uA)"); printf(" (V/s) ( V/s ) (1/10)*s \n"); printf("\n"); for(dis = 0; dis < mid->n_crates; dis++) for(sl = 0; sl < 4; sl++) /* successivamente si potrebbe chiedere soltanto una camera */ if(strcmp(chamber_code, mid->distr[dis].slot[sl].chamber) == 0 || strcmp(chamber_code, mid->distr[dis].slot[sl].cable_name) == 0 || ( strcmp("0", chamber_code) == 0 && mid->distr[dis].slot[sl].hv_ch_Ref >= 0 ) ){ if (mid->distr[dis].slot[sl].d_used_ch && strcmp( old_chamber, mid->distr[dis].slot[sl].chamber) != 0){ strcpy( old_chamber, mid->distr[dis].slot[sl].chamber, strlen(mid->distr[dis].slot[sl].chamber) ); printf(" %s ", mid->distr[dis].slot[sl].chamber); hv_ch_A = mid->distr[dis].slot[sl].hv_ch_A; hv_ch_Ref = mid->distr[dis].slot[sl].hv_ch_Ref; sem_wait(sem_127mod_id, argv[0]); status_hv_ch_A = sy127_mod->hv_par[r_v].status[hv_ch_A]; v0_hv_ch_A = sy127_mod->hv_par[r_v].v0[hv_ch_A]; v1_hv_ch_A = sy127_mod->hv_par[r_v].v1[hv_ch_A]; i0_hv_ch_A = sy127_mod->hv_par[r_v].i0[hv_ch_A]; i1_hv_ch_A = sy127_mod->hv_par[r_v].i1[hv_ch_A]; ramp_up_hv_ch_A = sy127_mod->hv_par[r_v].ramp_up[hv_ch_A]; ramp_down_hv_ch_A = sy127_mod->hv_par[r_v].ramp_down[hv_ch_A]; trip_hv_ch_A = sy127_mod->hv_par[r_v].trip[hv_ch_A]; status_hv_ch_A = sy127_mod->hv_par[r_v].status[hv_ch_A]; v0_hv_ch_Ref = sy127_mod->hv_par[r_v].v0[hv_ch_Ref]; v1_hv_ch_Ref = sy127_mod->hv_par[r_v].v1[hv_ch_Ref]; i0_hv_ch_Ref = sy127_mod->hv_par[r_v].i0[hv_ch_Ref]; i1_hv_ch_Ref = sy127_mod->hv_par[r_v].i1[hv_ch_Ref]; ramp_up_hv_ch_Ref = sy127_mod->hv_par[r_v].ramp_up[hv_ch_Ref]; ramp_down_hv_ch_Ref = sy127_mod->hv_par[r_v].ramp_down[hv_ch_Ref]; trip_hv_ch_Ref = sy127_mod->hv_par[r_v].trip[hv_ch_Ref]; sem_free(sem_127mod_id, argv[0]); printf(" V_A : "); printf(" %4d ", v0_hv_ch_A); printf(" %4d ", v1_hv_ch_A); printf(" %3d ", i0_hv_ch_A); printf(" %3d ", i1_hv_ch_A); printf(" %4d ", ramp_up_hv_ch_A); printf(" %4d ", ramp_down_hv_ch_A); printf(" %4d\n", trip_hv_ch_A); printf(" V_Ref: "); printf(" %4d ", v0_hv_ch_Ref); printf(" %4d ", v1_hv_ch_Ref); printf(" %3d ", i0_hv_ch_Ref); printf(" %3d ", i1_hv_ch_Ref); printf(" %4d ", ramp_up_hv_ch_Ref); printf(" %4d ", ramp_down_hv_ch_Ref); printf(" %4d\n", trip_hv_ch_Ref); } } sem_unl_del(sem_127mod_id, "SY127mod", caller); munlink(sy127_mod); munlink(mid); }