Skip to content

Commit 37be1bf

Browse files
Merge pull request #102 from philipstarkey/philipstarkey/v3-refactor
This is a first pass attempt at breaking up `labscript.py` into separate files. The idea here is that, while this might not be how we ultimately want things to be split up, at this point something is better than nothing. This should provide enough of a base that other people begin to feel comfortable moving things around and/or breaking things up logically. It also introduces some conceptual boundaries between output classes and the base device classes that handle timing/clock generation. My hope is that this split will open up the possibility of actually writing tests for some of this stuff. That's probably still a long way off (with several more refactors in between) but it's a step towards that goal! Other changes: * More modern context managers for warning suppression that can actually be used to enable/disable warnings, not just disable. * `config` is moved into `compiler` which means it should get reset between labscript shots and not just globally changed until you reload the compiler subprocess in runmanager. * Some better/more consistent formatting. I didn't run `black`/`ruff` but I think we should think about it soon. * Updated error message string formatting to use `f` strings for increased code readability * Fixed a mistake with trigger error detection that was never raised (and also the `if` condition around the unraised error was wrong anyway) * Fixed a minor bug in an error message for shutters (had open/close the wrong way around) * Probably some other small changes.
2 parents 332c180 + 714d982 commit 37be1bf

12 files changed

+4117
-3113
lines changed

docs/source/api/index.rst

+7
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,12 @@ API Reference
77
:template: autosummary-module.rst
88
:recursive:
99

10+
labscript.core
11+
labscript.outputs
12+
labscript.inputs
13+
labscript.remote
14+
labscript.constants
1015
labscript.labscript
1116
labscript.functions
17+
labscript.base
18+
labscript.utils

docs/source/connection_table.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ The connection table maps out the way input/output devices are connected to each
55
.. image:: img/connection_diagram.png
66
:alt: Example wiring diagram.
77

8-
Here we see two :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>` instances in the top tier of the diagram. They do not have a parent device that tells them when to update their output (this is true for all :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>` instances). However, all but one (the master pseudoclock device) must be triggered by an output clocked by the master pseudoclock device.
8+
Here we see two :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>` instances in the top tier of the diagram. They do not have a parent device that tells them when to update their output (this is true for all :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>` instances). However, all but one (the master pseudoclock device) must be triggered by an output clocked by the master pseudoclock device.
99

10-
Each :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>` instance should have one or more :py:class:`Pseudoclock <labscript.Pseudoclock>` children. Some :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>` instances may automatically create these children for you (check the device specific documentation). In turn, each :py:class:`Pseudoclock <labscript.Pseudoclock>` will have one of more :py:class:`ClockLine <labscript.ClockLine>` instances connected to it. These :py:class:`ClockLine <labscript.ClockLine>` instances generally refer to physical outputs of a device which will be used to clock another device. However, in some cases, one or more :py:class:`ClockLine <labscript.ClockLine>` instances may be internally created for you (check the device specific documentation).
10+
Each :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>` instance should have one or more :py:class:`Pseudoclock <labscript.core.Pseudoclock>` children. Some :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>` instances may automatically create these children for you (check the device specific documentation). In turn, each :py:class:`Pseudoclock <labscript.core.Pseudoclock>` will have one of more :py:class:`ClockLine <labscript.core.ClockLine>` instances connected to it. These :py:class:`ClockLine <labscript.core.ClockLine>` instances generally refer to physical outputs of a device which will be used to clock another device. However, in some cases, one or more :py:class:`ClockLine <labscript.core.ClockLine>` instances may be internally created for you (check the device specific documentation).
1111

12-
If a device is not a :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>`, it must be connected to one via a clockline. such devices inherit from :py:class:`IntermediateDevice <labscript.IntermediateDevice>`. Inputs and outputs are then connected to these devices. If a :py:class:`PseudoclockDevice <labscript.PseudoclockDevice>` also has outputs that are not used for a :py:class:`ClockLine <labscript.ClockLine>`, then an :py:class:`IntermediateDevice <labscript.IntermediateDevice>` is internally instantiated, and should be made available through the ``PseudoclockDevice.direct_outputs`` attribute (for example see PulseBlaster implementation TODO: link!).
12+
If a device is not a :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>`, it must be connected to one via a clockline. such devices inherit from :py:class:`IntermediateDevice <labscript.core.IntermediateDevice>`. Inputs and outputs are then connected to these devices. For example, :py:class:`DigitalOut <labscript.outputs.DigitalOut>`, :py:class:`AnalogOut <labscript.outputs.AnalogOut>`, and :py:class:`DDS <labscript.outputs.DDS>`. See :py:mod:`labscript.outputs` and :py:mod:`labscript.inputs` for a complete list. Note that devices determine what types of inputs and outputs can be connected, see :doc:`labscript-devices <labscript-devices:index>` for device information.
1313

14+
If a :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>` also has outputs that are not used for a :py:class:`ClockLine <labscript.core.ClockLine>`, then an :py:class:`IntermediateDevice <labscript.core.IntermediateDevice>` is internally instantiated, and should be made available through the ``PseudoclockDevice.direct_outputs`` attribute (for example see the :py:class:`PulseBlaster <labscript_devices.PulseBlaster.PulseBlaster>` implementation).
15+
16+
.. note::
17+
Most user's will not need to use :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>`, :py:class:`Pseudoclock <labscript.core.Pseudoclock>`, and :py:class:`IntermediateDevice <labscript.core.IntermediateDevice>` directly. These are generic classes that are subclassed by device implementations in :doc:`labscript-devices <labscript-devices:index>`. It is these device implementations that you are most likely to use.

0 commit comments

Comments
 (0)