/****************************************** * sy227_dbg.c * * * * Performs basic operation on the sy227 * * * ******************************************/ #include #include #include #include "../lib/mylib1.h" #include "a200.h" /* definitions relative to the CAEN system */ /* #include "../dbase/hv_dbase.h" */ #define NMAX 45 #define NOK 40 #define SECONDS #define MINUTES * 60 #define PAUSE 1001 #define CONTINUE 1002 #define STOP 1003 char *caller; int tcycle, command; sighand(signal) register int signal; { printf(" sy227_dbg : signal %d received \n", signal); if ( signal == STOP || signal == 2 || signal == 3) { /* ^C ^E */ A200_end(); /* unlink dbase module */ exit(0); } else if ( signal == PAUSE ) sleep(0); else if ( signal == CONTINUE ) ; /* do nothing , used to awaike the process */ } main(argc, argv) int argc; char *argv[]; { short ndata, data[33]; short ndatav, datav[33]; short ndatai, datai[33]; short ndataix, dataix[33]; short ndatas, datas[33]; int hra[6]; short i, j, chan, value, code, code1, code2, code3, code4, code5, code6; short on_off, hv_in; short dis, cr, sl; short i_res; short ifirst = 1; short n_to_be_read; short n_good_read; intercept(sighand); if (argc < 3) usage(); cr = (short ) atoi(argv[1]); sl = (short) atoi(argv[2]); if ( cr < 1 || cr > 9 || sl < 0 || sl > 3 ) usage(); A200_init(); ndata = 1; if (code = D_Read(D_IRESOL, cr, sl, ALL, data, &ndata)){ printf("%s: error %d reading current resolution\n", argv[0], code); i_res = 5; printf(" : i_res = %d assumed \n", i_res); } else i_res = data[0]; printf(" i_res = %d \n", i_res); /* the Voltage is read only on channel 0 */ ndata = 1; if (code5 = D_Read(D_ONOFF, cr, sl, ALL, data, &ndata)) printf(" %s: error %d reading ONOFF\n", argv[0], code5); on_off = data[0]; ndata = 1; if (code6 = D_Read(D_HV_IN_STATUS, cr, sl, ALL, data, &ndata)) printf(" %s: error %d reading ONOFF\n", argv[0], code6); hv_in = data[0]; ndatav = 32; if (code1 = D_Read(D_VMON, cr, sl, ALL, datav, &ndatav)) printf(" %s: error %d reading V monitor\n", argv[0], code1); if ( ndatav != 32) printf(" ONLY %d channels of VMON read !!\n", ndatav); ndatai = 32; if (code2 = D_Read(D_IMON, cr, sl, ALL, datai, &ndatai)) printf(" %s: error %d reading I monitor\n", argv[0], code2); if ( ndatai != 32) printf(" ONLY %d channels of IMON read !!\n", ndatai); ndataix = 32; if (code3 = D_Read(D_IMAX, cr, sl, ALL, dataix, &ndataix)) printf(" %s: error %d reading I monitor\n", argv[0], code3); if ( ndataix != 32) printf(" ONLY %d channels of IMAX read !!\n", ndataix); ndatas = 32; if (code4 = D_Read(D_STATUS, cr, sl, ALL, datas, &ndatas)) printf(" %s: error %d reading I monitor\n", argv[0], code4); if ( ndatas != 32) printf(" ONLY %d channels of STATUS read !!\n", ndatas); A200_end(); if (on_off D_SWITCH_IS_ON) printf(" Switch ON;"); else printf(" Switch OFF;"); if (on_off D_RELAY_IS_ON) printf(" Relay ON;"); else printf(" Relay OFF;"); if (hv_in D_NO_HV) printf(" NO Input HV "); else if(hv_in D_POS_HV) printf(" Positive Input HV "); else if(hv_in D_NEG_HV) printf(" Negative Input HV "); else printf(" ?? "); printf("\n i vmon imon imax status \n"); for ( i = 0; i < 32; i++){ printf(" %2d %4d %4d %4d 0x%x: ", i, datav[i], datai[i] * i_res, dataix[i] * i_res, datas[i]); if (datas[i] D_IS_OK) printf(" OK "); else printf(" ->> "); if (datas[i] D_IS_OVC) printf(" OVC"); else printf(" "); if (datas[i] D_IS_OFS) printf(" OFS"); else printf(" "); if (datas[i] D_IS_OVC) printf(" OVM"); else printf(" "); printf(" "); printf("\n"); } exit(0); } usage() { printf(" usage : sy227_dbg crate slot \n"); printf(" | |-> 0 - 3 \n"); printf(" ----- > 1 - 9 \n"); exit(0); }