Experimental Physics and
| |||||||||||||||||
|
Liyu, Andrei wrote: I assume you are concerned about performance and thus want to directly access the array.I would like to write to waveform record (long or float type) directly. At first, I can use dbPutField( ...) but it would take much time because I need to change 30% of record's array. At second, I will also assume that your code is not run under a scan task, i.e. it is not part of record or device support or a subroutine connected to a record. Do the following: At initialization: struct dbAddr addr; dbCommon *pdbCommon; rset *prset;
Now get ready to access the array long no_elements,offset,nNew; double *pdata; dbScanLock(pdbCommon); status = prset->get_array_info(&addr,&no_elements,&offset) /* check the following things to see if your code can handle the array Is offset 0? The current number of elements is no_elements. The maximum number of elements is addr.no_elements. Are these OK with you? Is addr.field_type OK with you? You probable want DBF_DOUBLE. This example assumes double */ if(addr.field_type!=DBF_DOUBLE) /*ERROR handle it*/ pdata = (double *)addr.pfield; /* You can now write the data. also set nNew */ status = put_array_info(&addr,nNew); status = dbProcess(pdbCommon); dbScanUnlock(pdbCommon);
| ||||||||||||||||
ANJ, 10 Aug 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |