Source code for semi_cr.core.lab.instrument.dummy_oscilloscope
from qcodes.instrument import Instrument
[docs]
class DummyOscilloscope(Instrument):
"""
Dummy oscilloscope that samples voltage parameters from other instruments in
the station. Intended to be paired with its GUI counterpart which live-plots
the readings.
Attach voltage Parameter objects to watch via add_channel().
Example:
>>> osc = DummyOscilloscope("osc")
>>> osc.add_channel("d5a_1.ch0", d5a.ch0.voltage)
>>> osc.read_all()
{'d5a_1.ch0': 0.0}
"""
def __init__(self, name: str, **kwargs):
super().__init__(name, **kwargs)
self._channels: dict = {} # label -> Parameter
[docs]
def add_channel(self, label: str, parameter):
"""Register a voltage Parameter to monitor under the given label."""
self._channels[label] = parameter
[docs]
def remove_channel(self, label: str):
self._channels.pop(label, None)
[docs]
def get_channel_labels(self) -> list[str]:
return list(self._channels.keys())
[docs]
def read_all(self) -> dict[str, float]:
"""Sample all registered channels and return {label: value}."""
return {label: param.get() for label, param in self._channels.items()}
[docs]
def get_idn(self):
return {
"vendor": "Dummy",
"model": "Oscilloscope",
"serial": None,
"firmware": None,
}