Implement mock flag for more devices
rpanderson opened this issue · 1 comments
In developing works-out-of-the-box (and without any connected hardware) functionality and examples (#52, #53, #54), I've largely re-implemented subsets of existing labscript device code. As an alternative (or to supplement this), we could instead have a mock
flag for (more) existing devices, which allows the functionality to be tested without that device being physically present. A good example of this is labscript_devices.IMAQdxCamera
, which can be instantiated with:
# We then initiate an IMAQdxCamera using this RemoteBLACS instance
# using mock=True to bypass any attempts to commmunicate with an
# actual camera
IMAQdxCamera(
name='camera',
parent_device=camera_trigger,
connection='trigger',
serial_number=0xDEADBEEF,
worker=test_remote,
mock=True,
)
With this virtual device, one can even call labscript methods and simulated data will be generated in the shot file during transition_to_manual
, e.g.
camera.expose(t, name='comparison', frametype='before', trigger_duration=0.2)
This has the benefit of being able to simulate control and automation workflows, which is obviously super useful for demonstration, training, etc.
On the other hand, extracting the minimal subset from actual labscript device code into dedicated dummy devices assists developers in writing new labscript device code for unsupported devices.
A good example of this is
labscript_devices.IMAQdxCamera
See, for example, labscript-suite/labscript-utils#55.