Skip to content

Commit 5c04f42

Browse files
committed
Split AnalogIn into it's own module so that documentation makes a little more sese
1 parent 59757a4 commit 5c04f42

File tree

5 files changed

+65
-57
lines changed

5 files changed

+65
-57
lines changed

docs/source/api/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ API Reference
99

1010
labscript.core
1111
labscript.outputs
12+
labscript.inputs
1213
labscript.remote
1314
labscript.constants
1415
labscript.labscript

docs/source/connection_table.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Here we see two :py:class:`PseudoclockDevice <labscript.core.PseudoclockDevice>`
99

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

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

labscript/inputs.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""Classes for device channels that are inputs"""
2+
3+
from .base import Device
4+
from .utils import set_passed_properties
5+
6+
7+
class AnalogIn(Device):
8+
"""Analog Input for use with all devices that have an analog input."""
9+
description = "Analog Input"
10+
11+
@set_passed_properties(property_names={})
12+
def __init__(
13+
self, name, parent_device, connection, scale_factor=1.0, units="Volts", **kwargs
14+
):
15+
"""Instantiates an Analog Input.
16+
17+
Args:
18+
name (str): python variable to assign this input to.
19+
parent_device (:obj:`IntermediateDevice`): Device input is connected to.
20+
scale_factor (float, optional): Factor to scale the recorded values by.
21+
units (str, optional): Units of the input.
22+
**kwargs: Keyword arguments passed to :func:`Device.__init__`.
23+
"""
24+
self.acquisitions = []
25+
self.scale_factor = scale_factor
26+
self.units=units
27+
Device.__init__(self, name, parent_device, connection, **kwargs)
28+
29+
def acquire(
30+
self, label, start_time, end_time, wait_label="", scale_factor=None, units=None
31+
):
32+
"""Command an acquisition for this input.
33+
34+
Args:
35+
label (str): Unique label for the acquisition. Used to identify the saved trace.
36+
start_time (float): Time, in seconds, when the acquisition should start.
37+
end_time (float): Time, in seconds, when the acquisition should end.
38+
wait_label (str, optional):
39+
scale_factor (float): Factor to scale the saved values by.
40+
units: Units of the input, consistent with the unit conversion class.
41+
42+
Returns:
43+
float: Duration of the acquistion, equivalent to `end_time - start_time`.
44+
"""
45+
if scale_factor is None:
46+
scale_factor = self.scale_factor
47+
if units is None:
48+
units = self.units
49+
self.acquisitions.append(
50+
{
51+
"start_time": start_time,
52+
"end_time": end_time,
53+
"label": label,
54+
"wait_label": wait_label,
55+
"scale_factor": scale_factor,
56+
"units": units,
57+
}
58+
)
59+
return end_time - start_time
60+

labscript/labscript.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
PseudoclockDevice,
6363
TriggerableDevice,
6464
)
65+
from .inputs import AnalogIn
6566
from .outputs import (
6667
Output,
67-
AnalogIn,
6868
AnalogOut,
6969
AnalogQuantity,
7070
DDS,

labscript/outputs.py

+2-55
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Classes for devices channels that out outputs"""
2+
13
import sys
24

35
import numpy as np
@@ -1492,61 +1494,6 @@ class StaticDigitalOut(StaticDigitalQuantity):
14921494
description = "static digital output"
14931495

14941496

1495-
class AnalogIn(Device):
1496-
"""Analog Input for use with all devices that have an analog input."""
1497-
description = "Analog Input"
1498-
1499-
@set_passed_properties(property_names={})
1500-
def __init__(
1501-
self, name, parent_device, connection, scale_factor=1.0, units="Volts", **kwargs
1502-
):
1503-
"""Instantiates an Analog Input.
1504-
1505-
Args:
1506-
name (str): python variable to assign this input to.
1507-
parent_device (:obj:`IntermediateDevice`): Device input is connected to.
1508-
scale_factor (float, optional): Factor to scale the recorded values by.
1509-
units (str, optional): Units of the input.
1510-
**kwargs: Keyword arguments passed to :func:`Device.__init__`.
1511-
"""
1512-
self.acquisitions = []
1513-
self.scale_factor = scale_factor
1514-
self.units=units
1515-
Device.__init__(self, name, parent_device, connection, **kwargs)
1516-
1517-
def acquire(
1518-
self, label, start_time, end_time, wait_label="", scale_factor=None, units=None
1519-
):
1520-
"""Command an acquisition for this input.
1521-
1522-
Args:
1523-
label (str): Unique label for the acquisition. Used to identify the saved trace.
1524-
start_time (float): Time, in seconds, when the acquisition should start.
1525-
end_time (float): Time, in seconds, when the acquisition should end.
1526-
wait_label (str, optional):
1527-
scale_factor (float): Factor to scale the saved values by.
1528-
units: Units of the input, consistent with the unit conversion class.
1529-
1530-
Returns:
1531-
float: Duration of the acquistion, equivalent to `end_time - start_time`.
1532-
"""
1533-
if scale_factor is None:
1534-
scale_factor = self.scale_factor
1535-
if units is None:
1536-
units = self.units
1537-
self.acquisitions.append(
1538-
{
1539-
"start_time": start_time,
1540-
"end_time": end_time,
1541-
"label": label,
1542-
"wait_label": wait_label,
1543-
"scale_factor": scale_factor,
1544-
"units": units,
1545-
}
1546-
)
1547-
return end_time - start_time
1548-
1549-
15501497
class Shutter(DigitalOut):
15511498
"""Customized version of :obj:`DigitalOut` that accounts for the open/close
15521499
delay of a shutter automatically.

0 commit comments

Comments
 (0)