The listing below is the skeleton of a producer which
first creates the DD system (if it
doesn't exist, attaches to the INPUT_FIFO and then
injects 100 event into the DD system. If there are no buffers
available, the process falls asleep (FMODE_SLEEP) until one
has become free.
int main()
{
char *dd_name = "dd.brook.drive";
char *dd_config_file = NULL;
//
// create first the DD_factory, then the DD system
//
DD_factory *pDDFactory = new DD_factory();
DD *my_dd = pDDFactory->create_dd( dd_name, "w", dd_config_file );
if ( my_dd->get_status() != DD_STATUS_OK ) {
cout << "test_producer: error in creating DD system " <<
dd_name << endl;
exit(EXIT_FAILURE);
}
int iEvent = 10;
for ( iEvent = 0; iEvent < nEvents; iEvent++ ) {
Fifo_entry fev;
int iSize = 10;
int iStatus;
iStatus = my_dd->req_fev( iSize, fev );
if ( iStatus != ddcSuccess ) {
cout << "req_fev returns status " << iStatus << endl;
break;
}
else {
int iVal, *pData = fev.get_pData();
for ( iVal = 0; iVal < iSize; iVal++) {
*pData++ = iVal;
}
// adjust the size of the data
fev.set_len( iSize );
int iMod = iEvent%4;
int iTrigBit = 1 << iMod;
fifo_ctl ctl = { iMod, iTrigBit, iEvent%10, 7};
fev.set_ctl( ctl );
iStatus = my_dd->put_fev( fev );
if ( iStatus != ddcSuccess ) {
cout << "put_fev returns status " << iStatus << endl;
break;
}
}
}
// delete my_dd is done automatically or call explicit
// delete my_dd
return 0;
}
Alphabetic index Hierarchy of classes