Files
ADAndor/documentation/simDetectorDoc.html
rivers a4c75d60bc New file
git-svn-id: https://subversion.xor.aps.anl.gov/synApps/areaDetector/trunk@7583 dc6c5ff5-0b8b-c028-a01f-ffb33f00fc8b
2008-09-05 19:48:13 +00:00

142 lines
5.7 KiB
HTML
Executable File

<HTML>
<HEAD>
<TITLE>areaDetector Simulation driver</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>areaDetector Simulation driver</H1>
<H2> September 5, 2008</H2>
<H2> Mark Rivers</H2>
<H2> University of Chicago</H2>
</CENTER>
<P>&nbsp;</P>
<CENTER><H2>Contents</H2></CENTER>
<UL>
<LI><A href="#Overview">
Overview</A>
<LI><A href="#Performance measurements">
Performance measurements</A>
<LI><A href="#Hardware notes">
Hardware notes</A>
<LI><A href="#Restrictions">
Restrictions</A>
</UL>
<CENTER><H2><A name=Simulation_detector_driver>
Simulation detector driver</A></H2></CENTER>
simDetector is a driver for a simulated area detector. It inherits from ADDriver. The simulation detector implements
nearly all of the parameters defined in ADStdDriverParams.h, with the exception of the file saving parameters, which is does not
implement. It also implements a few parameters that are specific
to the simulation detector. The simulation detector is useful as a model for writing real detector drivers. It is
also very useful for testing plugins and channel access clients.
This is part of the definition of the simDetector class:
<PRE>
class simDetector : public ADDriver {
public:
simDetector(const char *portName, int maxSizeX, int maxSizeY, NDDataType_t dataType,
int maxBuffers, size_t maxMemory);
/* These are the methods that we override from ADDriver */
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo,
const char **pptypeName, size_t *psize);
void report(FILE *fp, int details);
</PRE>
The portName, maxBuffers, and maxMemory arguments are passed to the ADDriver base class constructor. The maxSizeX, maxSizeY, and
dataType arguments are specific to the simulation driver, controlling the maximum image size and initial data type of the
computed images. The writeInt32 and writeFloat64 methods override those in the base class. The driver takes action
when new parameters are passed via those interfaces. For example, the ADAcquire parameter (on the asynInt32 interface) is
used to turn acquisition (i.e. computing new images) on and off.
<P>
The simulation driver initially sets the image[i, j] = i*gainX + j*gainY * gain * exposureTime * 1000. Thus the
image is a linear ramp in the X and Y directions, with the gains in each direction being detector-specific parameters.
Each subsquent acquisition increments each pixel value by gain*exposureTime*1000. Thus if gain=1 and exposureTime=.001
second then the pixels are incremented by 1. If the array is an unsigned 8 or 16 bit integer then the pixels
will overflow and wrap around to 0 after some period of time. This gives the appearance of bands that appear to move
with time. The slope of the bands and their periodicity can be adjusted by changing the gains and exposure times.
<P>
The driver creates a thread that waits for a signal to start acquisition. When acquisition is started that thread
computes new images and then calls back any registered plugins as follows:
<PRE>
/* Put the frame number and time stamp into the buffer */
pImage->uniqueId = imageCounter;
pImage->timeStamp = startTime.secPastEpoch + startTime.nsec / 1.e9;
/* Call the NDArray callback */
/* Must release the lock here, or we can get into a deadlock, because we can
* block on the plugin lock, and the plugin can be calling us */
epicsMutexUnlock(this->mutexId);
asynPrint(this->pasynUser, ASYN_TRACE_FLOW,
"%s:%s: calling imageData callback\n", driverName, functionName);
doCallbacksGenericPointer(pImage, NDArrayData, addr);
epicsMutexLock(this->mutexId);
</PRE>
The simulation driver-specific parameters are the following:
<P>
<TABLE style="TEXT-ALIGN: left" cellSpacing=2 cellPadding=2 border=1>
<TBODY>
<TR>
<TD COLSPAN=7, ALIGN=CENTER><B>Parameter Definitions in simDetector.cpp and EPICS Record Definitions in simDetector.template</B></TD>
</TR>
<TR>
<TH>Enum name</TH>
<TH>asyn interface</TH>
<TH>Access</TH>
<TH>Description</TH>
<TH>drvUser string</TH>
<TH>EPICS record name</TH>
<TH>EPICS record type</TH>
</TR>
<TR>
<TD>SimGainX</TD>
<TD>asynFloat64</TD>
<TD>r/w</TD>
<TD>Gain in the X direction</TD>
<TD>SIM_GAINX</TD>
<TD>$(P)$(R)GainX<BR>$(P)$(R)GainX_RBV</TD>
<TD>ao<BR>ai</TD>
</TR>
<TR>
<TD>SimGainY</TD>
<TD>asynFloat64</TD>
<TD>r/w</TD>
<TD>Gain in the Y direction</TD>
<TD>SIM_GAINY</TD>
<TD>$(P)$(R)GainY<BR>$(P)$(R)GainY_RBV</TD>
<TD>ao<BR>ai</TD>
</TR>
<TR>
<TD>SimResetImage</TD>
<TD>asynInt32</TD>
<TD>r/w</TD>
<TD>Reset image back to initial conditions when 1.</TD>
<TD>RESET_IMAGE</TD>
<TD>$(P)$(R)Reset<BR>$(P)$(R)Reset_RBV</TD>
<TD>longout<BR>longin</TD>
</TR>
</TBODY>
</TABLE>
<P>
The following is the MEDM screen ADBase.adl connected to a simulation detector.
<P>
<CENTER><IMG src="ADBase_sim.png"></CENTER>
<P>
The following is the MEDM screen that provides access to the specific parameters for the simulation detector.
<P>
<CENTER><IMG src="simDetector.png"></CENTER>
<P>
<P>
The following is an IDL epics_ad_display screen using image_display (discussed below) illustrating the simulation detector images.
<P>
<CENTER><IMG src="simDetector_image_display.png"></CENTER>
</BODY>
</HTML>