int main() { initNames(); //testQueue(); for (int k = 0; k != 100; ++k) { testHashTable(); } //testSet(); return 0; }
Defendant::Defendant() { static int amountOfNames = (initNames(), names.size()); _name = names[rand() % amountOfNames]; static int amountOfCrimes = (initCrimes(), crimes.size()); _crime = crimes [rand() % amountOfCrimes]; _alibi = rand() % 101; _evidence = rand() % 101; _criminal_record = rand() % 101; _behaviour = rand() % 101; _plead_guilty = rand() % 2; }
/*FGROUP SMAQ - Snapshot Memory Aquisition intboard - if 0 : do not take int board 1 : take int board and trigger on l0 input board 2 : take int board and trigger on l0int1 counters 3 : take int board and trigger on l0int2 counters inpnum - inpnumber on l0 level to trigger on: 1..48 on l1 level to trigger on:51..74 101..148 -take 2 ssms triggering on 1..48 input of L0 151..174 -take 2 ssms triggering on 1..24 input of L1 0: trigger on LHCpp (BOBR card in the CTP crate) rc: 0: ok 1: cannot open BOBR vme 2. input not onnected (LM0) 3: cannot stop SSM Output: - log file - contains also BC of interaction records - l0 ssm dump */ int inputsSMAQ(int intboard ,int inpnum012){ //w32 L0counts[MAXCOUNTERS]; w32 last[MAXCOUNTERS]; w32 l0first[MAXCOUNTERS]; int counteroffset,countermax; int trigboard; // with this board we trigger 1:L0 2:L1 3:L2 int boards[3]; w32 timeadr; int i,timeold,time; int inpnum, inpnum_ix; // triggering on this input, rel. position in board counts double timediff; int trigold,trigcur; int vspbobr; int trigcond,beepcond; Tlhcpp lhcpp; FILE *flog=NULL; char *environ; char fnpath[1024],logname[1024]; char dt[32]; int nottriggered=0; w32 timebefore; // Open the log file getdatetime(dt); dt[10]='_'; environ= getenv("VMEWORKDIR"); strcpy(fnpath, environ); strcat(fnpath,"/WORK/"); sprintf(logname,"%ssmaq_%s.log",fnpath,dt); /* flog=fopen(logname,"w"); if(flog==NULL){ printf("Cannot open file %s \n",logname); return 1; }*/ printf("Log file %s not opened, using stdout.\n",logname); // Check the site (ALICE or else) environ= getenv("SMAQ_C"); if(environ!=0) {strcpy(SMAQ_C, environ);}; // initCorrel(); // boards[2]= 1; // 1 board only if(inpnum012>100) { // we want l0+l1(l2) snapshot boards[2]= 2; // 2 boards boards[0]= 2; boards[1]= 1; // start order: l0, l1 inpnum012= inpnum012-100; }; // boards[2]: # of boards inpnum012:1..48 or 51..74 if(inpnum012>50) { // trigger: L1 inpnum= inpnum012-50; trigboard=2; boards[0]= trigboard; timeadr=L1OFFSET; counteroffset= L1OFFSET; // inps start just after time inpnum_ix= counteroffset + inpnum; } else { // trigger: L0 int swin; inpnum= inpnum012; trigboard=1; timeadr=L0TIMEOFFSET; counteroffset=L0OFFSET; swin= getSwnDB(inpnum); if(swin== -1) return(2); inpnum_ix= counteroffset + swin; printf("input %d is connected to CTP switch counter l0inp%d\n", inpnum,swin); }; countermax=counteroffset+NINP+6; // 6 for int counters if(boards[2]== 1 ) { boards[0]= trigboard; printf("triggering with L%d inp%d/%d max:%d. Readout board: L%d\n", trigboard-1, inpnum, counteroffset, countermax, boards[0]-1); } else { printf("triggering with L%d inp%d/%d max:%d. Readout boards: L%d L%d\n", trigboard-1, inpnum, counteroffset, countermax, boards[0]-1, boards[1]-1); }; /* now boards[2]: number of boards to be readout 2: boards[0..1] is l1+l0 1: boards[0] is l1 or l0 */ initNames(trigboard); if(intboard == 2){ // trigger on int1 // set also lut table inpnum=27; } else if(intboard == 3){ // trigger on int 2 inpnum=28; } /* inpnum: CTP input number (1..24), or special: 27,28: trigger on int1,2 (to be checked) inpnum_ix -rel. address in counter's array */ getCountersBoard(trigboard,counteroffset + NINP,l0first,3); for(i=0;i<NINP;i++){ int ic; ic= counteroffset+i+1; firstRead[i]=l0first[ic]; prevRead[i]=l0first[ic]; prevtime= l0first[L0TIMEOFFSET]; } // open bobr vmespace if(inpnum==0) { if((vspbobr=bobrOpen()) == -1){ printf("Cannot open bobr vme space\n"); return 1; } else { int rc; rc= getlhcpp(vspbobr,1,0, &lhcpp); // get next BST message if(rc!=0) { printf("rc:%d from getlhcpp()\n",rc); exit(8); }; }; }; // 1st readings getCountersBoard(trigboard,countermax,last,3); timeold=last[timeadr]; timebefore= timeold; if(inpnum)trigold=last[inpnum_ix]; //counting from 1 else beepcond= (((lhcpp.Byte54)&0x1) != 0); setstart_ssm(boards); /* if(intboard){ setomSSM(4,0x3);startSSM1(4); // OUT, continuous initprintBCs(); } usleep(100000); */ while(1){ int rc; w32 ts1,ts2,us1,us2, cntr_us; if(inpnum==0) { // we trigger on lhcpp rc= getlhcpp(vspbobr,1, PP_PERIOD, &lhcpp); if(rc!=0) { printf("No LHCpp after %d secs. getlhcpp() rc:%d\n", PP_PERIOD, rc); trigcond=0; } else { trigcond=1; }; } else { // we trigger on CTP inputs counter change GetMicSec(&ts1, &us1); getCountersBoard(trigboard,countermax,last,3); //GetMicSec(&ts2, &us2); when here, we do not see signal we // are triggering on! Got better when moved down (trigcond fulfilled) time=last[timeadr]; trigcur=last[inpnum_ix]; trigcond= (trigcur != trigold); //printf("trigcond:%d %d %d trigcur:%u time:%u\n", trigcond, trigboard, countermax,trigcur, time); }; if(trigcond){ int rc; w32 trigdif; double td; char msg[200]; rc= stop_ssm(boards); if(rc== 10) { sprintf(msg, "cannot stop ssm(s)"); prtLog(msg); return(3); }; if(intboard)stopSSM(4); //beepni(); cicolino not used recently GetMicSec(&ts2, &us2); rc= getSSMs(boards, trigboard, inpnum,intboard,flog); trigdif= dodif32(trigold,trigcur); td= getTime(timebefore, time); timebefore= time; cntr_us= DiffSecUsec(ts2,us2,ts1,us1); /*sprintf(msg, "inpnum:%d empty loops:%d old: %u new: %u td:%9.2f ms", inpnum,nottriggered,trigold,trigcur, td); prtLog(msg);*/ printf("trigdif:0x%x 0x%x %d inpnum_ix:%d\n", trigold, trigcur, trigdif, inpnum_ix); sprintf(msg, "empty loops:%d td:%9.2f ms getSSMs rc:%d cnts reading %d us", nottriggered, td, rc, cntr_us); prtLog(msg); nottriggered= 0; setstart_ssm(boards); // following should be after start -better to throw out rare signal and wait for other than // to take empty ssm getCountersBoard(trigboard,countermax,last,3); time=last[timeadr]; trigcur=last[inpnum_ix]; trigold=trigcur; if(rc!=0) { break; }; } else { nottriggered++; }; if(quit!=0) { int rc; // the request 'stop smaqing' registered (signal -s SIGUSR1 pid), let's stop: rc= stop_ssm(boards); printf("quitting on signal:%d stop_ssm rc:%d\n", quit, rc); break; }; //usleep(200000); // was 200 at the start of Aug (can be much more for 1bobr/48 secs) timediff=getTime(timeold,time); //printf("time: old %u new %u diff %f\n",timeold,time,timediff); if(timediff>100000){ // 10**5 == 100secs //char dt[32]; //smaqprintCounters(trigboard,L0counts, inpnum, f); getdatetime(dt); dt[10]='_'; printf("time: diff %f %s\n",timediff,dt); timeold=time; }; } if(inpnum==0) bobrClose(vspbobr); //fclose(flog); return 0; }