Source code for herosdevices.hardware.dummy.electronics

"""Dummy low level electronics for use in testing. Do not use in production."""

from herosdevices.helper import log
from herosdevices.interfaces import atomiq


[docs] class RFSourceDummy(atomiq.RFSource): """Dummy class implementing an atomiq compatible RF source.""" def _set_amplitude(self, amp: float) -> None: log.debug(f"setting amplitude to {amp}") def _set_frequency(self, frequency: float) -> None: log.debug(f"setting frequency to {frequency}") def _set_phase(self, phase: float) -> None: log.debug(f"setting phase to {phase}")
[docs] class VoltageSourceDummy(atomiq.VoltageSource): """Dummy class implementing an atomiq compatible voltage source.""" def _set_voltage(self, voltage: float) -> None: log.debug(f"setting voltage to {voltage}")
[docs] class CurrentSourceDummy(atomiq.CurrentSource): """Dummy class implementing an atomiq compatible current source.""" def _set_current(self, current: float) -> None: log.debug(f"setting voltage to {current}")
[docs] class DACDummy(atomiq.DAC): """Dummy class implementing an atomiq compatible multichannel DAC."""
[docs] def set_channel_voltage(self, channel: int, voltage: float) -> None: """Set the specified voltage at the specified channel.""" log.debug(f"Setting channel {channel} to {voltage} V.")
[docs] def update(self) -> None: """Update the DAC voltages.""" log.debug("Updating DAC voltages")
[docs] class ADCDummy(atomiq.ADC): """Dummy class implementing an atomiq compatible multichannel ADC.""" def __init__(self, num_channels: int) -> None: super().__init__() self.num_channels = num_channels
[docs] def measure(self, samples: int, channel: str = "") -> list[float]: """Set the specified voltage at the specified channel.""" log.debug(f"measuring {samples} samples from channel {channel}") return [42.0342] * self.num_channels
[docs] class ADCChannelDummy(atomiq.ADCChannel): """Dummy class implementing a single atomiq compatible ADC channel."""
[docs] def measure(self, samples: int = 1, cached: bool = False, channel: str = "") -> float: """'Meaure' a fake voltage.""" del channel, cached, samples return 3.14
[docs] class SwitchDummy(atomiq.Switch): """Dummy class implementing an atomiq compatible switch.""" _state: bool = False
[docs] def on(self) -> None: """Set the switch state to True.""" self._state = True log.debug("Switch turned on")
[docs] def off(self) -> None: """Set the switch state to False.""" self._state = False log.debug("Switch turned off")
[docs] def is_on(self) -> bool: """Return the current switch state.""" return self._state