/* * This program is a simple event display consumer. * This process gets events by broadcasting mechanism * from dd producer(at the same time the Event Builder) * and displays it,152 lenght event, on screen. * Author : C.Witzig * Date : Apr ?, 1992 * : Mar 30, 1995: include ddu_ins_fev * : * : YGKIM * : Jul , 1997 : costomising to MVD test. add display. * */ #include #include #include #include #include #include #include #include #include #include "/usr1/mvdonl/coda/dd/v2.5.2/usr/usr.h" #define TRUE 1 #define FALSE 0 void display_fev(struct fifo_entry fev) { int i, mean; int diff[100]; struct data_event *p; printf("\n\n"); printf("fifo event : shmid= %d dboff= %d p2da= %p len= %d \n", fev.shmid, fev.dboff, fev.p2da, fev.len); printf("fifo event : w1= %d b1= %x w2= %d b2= %x\n", fev.ctlw1, fev.ctlb1, fev.ctlw2, fev.ctlb2); p = (struct data_event*) fev.p2da; mean = 0; for(i = 0 ; i < 64 ; i++) { diff[i] = p->post_data[i] - p->pre_data[i]; mean = mean + diff[i]; } mean /= 64; printf("\n coda_header:%d ",p->coda_hd[0]); for(i = 1 ; i < 9 ; i++) printf("%X ",p->coda_hd[i]); printf("\n ornl_header:"); for(i = 0 ; i < 5 ; i++) printf("%4X ",p->ornl_hd1[i]); printf("\n ...... post:"); for(i = 0 ; i < 5 ; i++) printf("%4X ",p->ornl_hd2[i]); printf("\n"); printf("\n ********** pre (hex) ********** ********** post (hex) ********* ************** diff (I) ***************\n"); for(i = 0 ; i < 64 ; i=i+8){ if ( i == 32 ) { printf("\n %4X%4X%4X%4X",p->pre_data[i],p->pre_data[i+1], p->pre_data[i+2],p->pre_data[i+3]); printf("%4X%4X%4X%4X ",p->pre_data[i+4],p->pre_data[i+5], p->pre_data[i+6],p->pre_data[i+7]); printf("%4X%4X%4X%4X",p->post_data[i],p->post_data[i+1], p->post_data[i+2],p->post_data[i+3]); printf("%4X%4X%4X%4X ",p->post_data[i+4],p->post_data[i+5], p->post_data[i+6],p->post_data[i+7]); printf("%5d%5d%5d%5d%5d",diff[i],diff[i+1], diff[i+2],diff[i+3],diff[i+4]); printf("%5d%5d%5d \n",diff[i+5],diff[i+6],diff[i+7]); } else { printf(" %4X%4X%4X%4X",p->pre_data[i],p->pre_data[i+1], p->pre_data[i+2],p->pre_data[i+3]); printf("%4X%4X%4X%4X ",p->pre_data[i+4],p->pre_data[i+5], p->pre_data[i+6],p->pre_data[i+7]); printf("%4X%4X%4X%4X",p->post_data[i],p->post_data[i+1], p->post_data[i+2],p->post_data[i+3]); printf("%4X%4X%4X%4X ",p->post_data[i+4],p->post_data[i+5], p->post_data[i+6],p->post_data[i+7]); printf("%5d%5d%5d%5d%5d",diff[i],diff[i+1], diff[i+2],diff[i+3],diff[i+4]); printf("%5d%5d%5d \n",diff[i+5],diff[i+6],diff[i+7]); } } printf("\n\t\t\t\t\t\t\t\t\t mean diff = %d\n",mean); } main() { int i,i1,i2,i3; int *p; int j,len, dump, brc_flag, error; int idisp,eve_num,key; void show_sys(); int status; int go_on; char ana_fname[50],what2do[100]; char what1[100], answer; int reqcnt, ctl[4]; struct fifo_entry fev; struct fifo_mode ana_fmode; int dd_ctl[FIFO_HDR_CTL_LEN] = {-1,-1,-1,-1}; printf("\n\n"); printf(" ********************************************************\n"); printf(" * *\n"); printf(" * welcome to the DD consumer *\n"); printf(" * *\n"); printf(" ********************************************************\n"); printf("\n\n"); printf("do you want to have the default consumer? (y/n)"); scanf("%c",&answer); if ( ddu_attach() ) dds_create(); if ( (answer == 'y') || (answer == 'Y') ){ strcpy(ana_fname,"CONS"); ana_fmode.mode = 0; ana_fmode.wait = 0; ana_fmode.prescale = 1; ana_fmode.suser = FMODE_MULTI_USER; brc_flag = 1; ana_fmode.p2ctl = dd_ctl; printf("\n\n the default consumer ==> fmode.mode = FMODE_ALL\n"); printf(" fmode.wate = DD_WATE_SLEEP(falls asleep)\n"); printf(" fmode.prescale = 1(get every event)\n"); printf(" fmode.suser = FMODE_MULTI_USER\n"); printf(" fmode.p2ctl = {-1,-1,-1,-1}\n"); printf(" brc_flag = DD_BRC_SIGNAL\n"); } else{ printf("\n\n enter fifo name [use anything for consumer] "); scanf("%s",ana_fname); printf("\n enter fifo mode [ALL=0 COND=1 ONREQ=2]"); scanf("%i",&ana_fmode.mode); if ( ana_fmode.mode == FMODE_ONREQ ){ printf("\n enter the request count "); scanf("%i",&reqcnt); } printf("\n enter fifo prescale factor "); scanf("%i",&ana_fmode.prescale); if ( ana_fmode.prescale <= 0 ) ana_fmode.prescale = 1; printf("\n enter fifo wait [SLEEP=0 ASYNC=8]"); scanf("%i",&ana_fmode.wait); if ( ana_fmode.wait != 0 ) ana_fmode.wait = FWAIT_ASYNC; printf("\n enter single user mode [MULTI=0 SINGLE=1]"); scanf("%i",&ana_fmode.suser); printf("\n enter 4 control words "); scanf("%i %i %i %i",&ctl[0],&ctl[1],&ctl[2],&ctl[3]); ana_fmode.p2ctl = ctl; printf("\n enter brc_flag [OFF=0 SIGNAL=1 USMAIL=2]"); scanf("%i",&brc_flag); } status = ddu_init(ana_fname, ana_fmode); printf("ddu_init status %d \n",status); if ( status ) exit(1); if ( (ana_fmode.mode == FMODE_ONREQ) && (reqcnt > 0) ){ status = ddu_set_reqcnt(reqcnt); printf("ddu_setreq status:%d \n",status); } if (status = ddu_set_brc(brc_flag)) { printf("ddu_set_brc status:%d\n",status); } fflush(stdout); go_on = 1; dump = 0; error = 0; printf("To see menu type \"help\"\n"); while (go_on && (ddu_attached()) ){ printf("dd >> "); if (gets(what2do) == NULL){ if (errno != EINTR) { fprintf(stderr," dummy_consumer: error in gets %s \n",strerror(errno)); perror(" main: gets"); go_on = 0; } } else if ( ddu_attached() ) { if (strstr(what2do,"exit")){ go_on = 0; } else if (strstr(what2do,"get")){ sscanf(what2do,"%s %i1",what1,&i1); error = FALSE; ddu_start(); for ( i=0; (i