#include #include #include #include #include "../dbase/hv_dbase.h" #include "../dbase/hv_config1" main() { hv_mod_struct *mid; char *mod_name = "hv_config1"; char cline[80]; int i, ch, dis, sl, k; if ((mid = (hv_mod_struct *)_mkdata_module(mod_name, sizeof(hv_mod_struct), 0x8001, 0x0133)) == (hv_mod_struct *)-1) exit(_errmsg(errno, "hv_env1.c: error creating data module %s\n", mod_name)); mid->n_crates = number_of_d_crates; gcopy (distr0, &mid->distr[0].crate_nr, sizeof(distr0)); mid->hv_crate = 0; mid->sy127_vi_mon_cycle = 3; mid->sy127_st_mon_cycle = 3; mid->sy127_par_mon_cycle = 600; mid->sy227_vi_mon_cycle = -1; mid->sy227_st_mon_cycle = -1; mid->a200_resetter_cycle = 200; mid->sy127_vi_send_cycle = 600; mid->sy227_vi_send_cycle = 600; for (i = 0; i < 40; i++) mid->hv_used_ch[i] = 0; /* determine the used channels */ for (dis = 0; dis < mid->n_crates; dis++) for (sl = 0; sl < 4; sl++){ for(ch=0; ch < max_ch_work; ch++) if(strcmp(ch_work[ch], mid->distr[dis].slot[sl].chamber) == 0){ if ( mid->distr[dis].slot[sl].hv_ch_A >= 0 ) mid->hv_used_ch[ mid->distr[dis].slot[sl].hv_ch_A ] = 1; if ( mid->distr[dis].slot[sl].hv_ch_Ref >= 0 ) mid->hv_used_ch[ mid->distr[dis].slot[sl].hv_ch_Ref ] = 1; } } for (i = 0; i < 40; i++) if (mid->hv_used_ch[i]) mid->def_group[i] |= 0x80; /* -> to group G */ /* ridetermina il CRC */ if(_setcrc(mid) == -1) exit(_errmsg(errno, "hv_config1: error determining CRC of %s\n", mod_name)); /* salva il data module */ strcpy(cline, "save -r -f=/h0/cmds/hwc/"); strncat(cline, mod_name, strlen(mod_name)); strncat(cline, " ", strlen(" ")); strncat(cline, mod_name, strlen(mod_name)); system(cline); /* unlink */ munlink(mid); printf(" module %s saved \n", mod_name); } gcopy( a , b, n) char *a, *b; int n; { printf(" gcopy: n = %d\n", n); while (n--) *(b++) = *(a++); }