Skip to content

Commit

Permalink
Merge pull request #102 from philipstarkey/philipstarkey/v3-refactor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philipstarkey authored Feb 17, 2024
2 parents 332c180 + 714d982 commit 37be1bf
Show file tree
Hide file tree
Showing 12 changed files with 4,117 additions and 3,113 deletions.
7 changes: 7 additions & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ API Reference
:template: autosummary-module.rst
:recursive:

labscript.core
labscript.outputs
labscript.inputs
labscript.remote
labscript.constants
labscript.labscript
labscript.functions
labscript.base
labscript.utils
10 changes: 7 additions & 3 deletions docs/source/connection_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ The connection table maps out the way input/output devices are connected to each
.. image:: img/connection_diagram.png
:alt: Example wiring diagram.

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.
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.

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).
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).

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!).
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.

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).

.. note::
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.
Loading

0 comments on commit 37be1bf

Please sign in to comment.