EDT - edt
Camera driver module¶
EDT refers to the C application program interface (API) for the Engineering Design Team series of frame-grabbers. ShaneAO uses two varieties of EDT frame-grabber:
- EDT PCIe8 DVa C-Link for the wavefront sensor camera (160x160 pixel)
- EDT PCIe4 DVa C-Link for the tip/tilt sensor camera (80x80 pixel)
class Camera¶
-
class
edt.
Camera
((int)unit, (string)filename)¶ Creates a new object of type Camera. An integer unit and configuration filename must be specified when creating a
Camera
instance. A background pthread will be invoked to handle image acquisition; the handling of image data is determined dynamically via thehandler()
method.The currently used configuration files and unit numbers are:
Camera Configuration File Unit Wavefront Sensor WFS_BigJoe.cfg 1 Tip/Tilt Sensor TipTilt_LittleJoe.cfg 0 Example of use:
import edt wfsCam = edt.Camera (1, 'WFS_BigJoe.cfg') wfsCam.handler('wfsFunction') ttCam = edt.Camera (0, 'TipTilt_LittleJoe.cfg') ttCam.handler('ttFunction') wfsCam.start() ttCam.start() ... wfsCam.stop() ttCam.stop()
Methods¶
Exposures & Handler¶
-
edt.Camera.
handler
(handler)¶ Assign a handler function for any/all camera frames acquired by the background processing thread. The sole argument can be None, which will remove all handlers; it can be a single
Handler
instance; and it can be an iterable sequence ofHandler
instances.
-
edt.Camera.
start
()¶ Request that the camera begin exposures, which should in turn prompt the background processing thread to handle the resulting images.
-
edt.Camera.
stop
()¶ Request that the camera stop exposures, and pause all activity in the background processing thread.
Camera Commands & Messages¶
-
edt.Camera.
messages
()¶ Retrieve all pending messages associated with this
Camera
instance. If there are no messages, an empty tuple will be returned. Once retrieved, the internal queue of messages is emptied.
-
edt.Camera.
notify
()¶ Different
Camera
methods may generate messages that could be interpreted for the benefit of a single listening application, such as a KTL dispatcher. The function registered withnotify()
should accept no arguments, and is only invoked as an indication that events are available. To retrieve messages, invokemessages()
. If function is set to None, notification will be “disabled.”
-
edt.Camera.
serial
(string)¶ Send a command string via the serial interface for this Camera instance. The response, if any, will be returned as a string; if there is an error with the command, a
SerialException
will be raised. If wait is set to False,serial()
will not wait for a response string, and will return None. In practice, all serial commands generate a response, even if it is just an ACK.Warning
If the serial command does generate a response, and wait is set to False, this can permanently confuse the edt kernel driver. At least, it does with version 4.2.1.7 of the driver. Queries that expect a response will return nothing; other queries may receive the response generated for a previous query. Unloading and reloading the driver fixes the problem. And yet, when this occurs, the serial_cmd binary continues to work normally; perhaps this is because it doesn’t care about the return result from
pdv_serial_wait()
.
-
edt.Camera.
timing
()¶ Return a dictionary containing the current timing information recorded in the
Camera
instance by the background processing thread.
Members¶
-
edt.Camera.
config
¶ EDT configuration file
-
edt.Camera.
depth
¶ camera color depth
-
edt.Camera.
handlers
¶ sequence of image handling functions
-
edt.Camera.
height
¶ image height in pixels
-
edt.Camera.
interval
¶ frame interval in microtenths
-
edt.Camera.
processing
¶ frame processing in microtenths
-
edt.Camera.
unit
¶ EDT device unit number
-
edt.Camera.
width
¶ image width in pixels
class Handler¶
-
class
edt.
Handler
(CameraObject, (string)functionName)¶ The
Handler
class encapsulates all the necessary metadata for a single image analysis routine. IndividualHandler
instances are linked to a singleCamera
instance.The Handler object is tied to the given Camera object and provides the name of the c function. Calls dlsym() to resolve the pointer to the function with that name.
Methods¶
-
edt.Handler.
configure
(data, (string)functionName)¶ A
Handler
instance may be configured before it is invoked, or reconfigured at any time while a sequence of camera frames are being processed.configure()
will block if the currentHandler
instance is being run by the processing thread. The two arguments forconfigure()
are a Python data object, and a C function name that will be used to interpret the data argument; Handler->pyobject will remain unchanged, leaving it for the function to manipulate directly. If a function is not specified, data will be assigned directly to Handler->pyobject.
Processing Thread¶
The processingThread.c file implements the background thread for camera data grabbing and processing.
-
frameProcessing
(void *instance)¶ Started up as a background thread during Camera initialization (Camera_init).
edt.Camera.start
will set self->pause = FALSE which will trigger calls to the handler routine by frameProcessing (line 147):handler->function (handler, image_data);
-
void
functionName
(Camera *instance, u_char *data)¶ All .c files in the directory ../handlers will be linked into the ../edt/edt.so module. Each “handler” defined here should have a function of the following form as its entry point:
void functionName (Camera *instance, u_char *data);
Selection of which function to use to handle new data frames is performed via the
edt.Camera.handler
method.Some questions:
- Looks like there is an inconsistency about the first argument - is it the pointer to the Camera instance, or the Handler instance?
- How does one call the dpio2 object from this handler?