next up previous contents
Next: Status and Error Up: Example Programs Previous: A Monitor Process

A Modifying DD Consumer Process

The following sample program is a process, that receives every event which has the control word fev.ctlw1 = 1 set. It then merges two consequetive events into a single event and inject these back into the DD systemgif. Note that the fev.ctlw1 for the new event has changed in order to avoid turning in circles. (Note: for simplicity no proper error handling is included in the code).

#include <dd_user.h>

 
main(int argc,char **argv)

{

int len, status, status1, status2, status3

char fname[100];

int mode, reqcnt, prescale, wait,ctl[4];

struct fifo_entry fev1, fev2, fev3;

int go_on;

if (argc < 2) {

printf("syntax: argument fifo name needed \n");

exit(0);

}

strcpy(fname,argv[1]);

mode = FMODE_COND;

wait = DD_WAIT_SLEEP;

prescale = 1;

ctl[0] = 1 ;

ctl[1] = -1;

ctl[2] = -1;

ctl[3] = -1;

if ( (status = ddu_init(fname,mode,prescale,wait,ctl)) != 0 ) {

printf("ddu_init: status returned %d\n",status);

exit(1);

}

ddu_start();

go_on = 1;

while (go_on & & ddu_attached() ) {

status1 = ddu_get_fev(&fev1);

status2 = ddu_get_fev(&fev2);

if ( (status1 || status2) == 0) {

len = fev1.len + fev2.len;

if ( (status3 = ddu_req_fev(&fev3) ) == 0 ) {

memcpy(fev3.p2da, fev1.p2da, 4*fev1.len);

memcpy(fev3.p2da+4*fev1.len, fev2.p2da, 4*fev2.len);

fev3.len = len;

fev3.ctlw1 = 2;

fev3.ctlb1 = -1;

fev3.ctlw2 = -1;

fev3.ctlb2 = -1;

if ( (status = ddu_ins_fev(fev3)) != 0 ) {

/* handle error */

}

if ( (status = ddu_put_fev(fev2)) != 0 ) {

/* handle error */

}

if ( (status = ddu_put_fev(fev1)) != 0 ) {

/* handle error */

}

else {

/* handle error */

}

else {

/* handle error */

}

}

ddu_stop();

ddu_close();

exit(0);

}



Online software development
Thu Mar 14 10:35:53 EST 1996