#include #include #include #include #include "hv_dbase.h" struct distr_tab distr0[] = { 1, 0, "51/1", "51", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1, "51/2", "51", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2, "33/2", "33", 0, 5, "41/1", "41", 12, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3, "33/1", "33", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2, 4, "61/1", "61", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 5, "41/2", "41", 0, 19, "52/1", "52", 20, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6, "52/1", "52", 0, 19, "52/2", "52", 20, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 7, "52/2", "52", 0, 19, "52/3", "52", 20, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3, 8, "52/3", "52", 0, 11, "62/1", "62", 12, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 9, "62/1", "62", 0, 11, "62/2", "62", 12, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 10, "62/2", "62", 0, 2, "64/1", "64", 3, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 11, "64/2", "64", 0, 24, "66/1", "66", 25, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 4, 12, "66/1", "66", 0, 25, "66/2", "66", 26, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 13, "66/2", "66", 0, 16, "34/1", "34", 17, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 14, "34/1", "34", 0, 14, "34/2", "34", 15, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 15, "V", "V", -1, -1, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 5, 16, "34/2", "34", 0, 9, "42/2", "42", 10, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 17, "42/2", "42", 0, 9, "93/1", "93", 10, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 18, "93/1", "93", 0, 9, "93/2", "93", 10, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 19, "93/2", "93", 0, 3, "95/1", "95", 4, 31, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6, 20, "95/2", "95", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 21, "94/1", "94", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 22, "94/2", "94", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 23, "94/3", "94", 0, 20, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 7, 24, "96/1", "96", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 25, "96/2", "96", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26, "96/3", "96", 0, 20, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 27, "42/1","42", 0, 31, "V", "V", -1, -1, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; int number_of_d_crates = 7; char *ch_work[] = { /* used chamber ( or subsection -> "cable") */ "33", "34", "41", "42" }; int max_ch_work = 4; /* number of informations contained in used_chamber[] */ main() { hv_mod_struct *mid; char *mod_name = "hv_config"; char cline[80]; int i, ch, dis, sl, k; if ((mid = (hv_mod_struct *)_mkdata_module(mod_name, sizeof(hv_mod_struct), 0x8001, 0x0033)) == (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 = 2; mid->sy127_st_mon_cycle = 1; mid->sy127_par_mon_cycle = 300; mid->sy227_vi_mon_cycle = 2; mid->sy227_st_mon_cycle = -1; mid->a200_resetter_cycle = 600; mid->sy127_vi_send_cycle = 0; /* task will not be activated */ mid->sy227_vi_send_cycle = 1200; /* probably better only one process */ mid->def_v0 = 0; mid->def_v1 = 0; mid->def_i0 = 60; mid->def_i1 = 20; mid->def_ramp_up = 100; mid->def_ramp_down = 100; mid->def_trip = 9999; for (i = 0; i < 40; i++) mid->def_group[i] = 0x1; /* change when runnung conditions known*/ mid->def_imax = 100; /* nanoamps */ 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 (k = 0; k < 2; k++) for (ch = 0; ch < max_ch_work; ch++) if( strcmp(ch_work[ch], mid->distr[dis].slot[sl].cable[k].chamber) == 0 || strcmp(ch_work[ch], mid->distr[dis].slot[sl].cable[k].cable_name) == 0 ){ mid->hv_used_ch [ mid->distr[dis].slot[sl].hv_ch ] = 1; mid->distr[dis].slot[sl].used = 1; for (i = mid->distr[dis].slot[sl].cable[k].first_ch; i <= mid->distr[dis].slot[sl].cable[k].last_ch; i++) mid->distr[dis].slot[sl].d_used_ch[i] = 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_env1.c: error determining CRC of %s\n", mod_name)); /* salva il data module */ strcpy(cline, "save -r -f=/h0/cmds/hwc/balc1/"); 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; { while (n--) *(b++) = *(a++); }