Source code for herosdevices.hardware.generic.dac

"""Generic DAC drivers."""
from heros import RemoteHERO

from herosdevices.interfaces import atomiq


[docs] class DACChannel(atomiq.DACChannel): """A generic DAC channel that can be connected to a multi channel DAC that implements the atomiq DAC interface. Args: dac_device: the DAC the channel belongs to channel: the number of the channel """ def __init__(self, dac_device: atomiq.DAC | RemoteHERO, channel: int, min_voltage: float | None = None, max_voltage: float | None = None ) -> None: self.dac_device = dac_device self.channel = channel if min_voltage is not None: self.min_voltage = min_voltage elif hasattr(self.dac_device, "min_voltage"): self.min_voltage = self.dac_device.min_voltage if max_voltage is not None: self.max_voltage = max_voltage elif hasattr(self.dac_device, "max_voltage"): self.max_voltage = self.dac_device.max_voltage def _set_voltage(self, voltage: float, update_dac: bool = True) -> None: # noqa: ARG002 """Set the voltage for this DAC channel. This underscored method is required for the artiq interface. """ self.dac_device.set_channel_voltage(self.channel, voltage)
[docs] def set_voltage(self, voltage: float, update_dac: bool = True) -> None: """Set the voltage for this DAC channel.""" return self._set_voltage(voltage=voltage, update_dac=update_dac)