- class labterm.instrument.Instrument(channel: int)[source]#
Bases:
ABCAbstract base class for all instruments connected to the dashboard.
Concrete subclasses must implement
update_data()andaction(). The Dashboard expects each instrument to expose adatadict and an optionalloggercallable.- Parameters:
channel (int) – Unique channel id identifying the instrument.
- Variables:
data (dict[str, Any]) – Live instrument data. Keys and value types are instrument-specific. Dashboard items update their values from this dictionary.
logger (Optional[Callable[[str], None]]) – Optional logging callback set by the
Dashboardviainstrument.logger = self._log.
Examples
>>> class MyInstrument(Instrument): ... def __init__(self, channel): ... super().__init__(channel) ... self.data = {'voltage': None} ... def update_data(self): ... self.data['voltage'] = 3.3
- abstractmethod action(action_id: str, *args: Any) None[source]#
Handle an action request from a
DashboardItem.Implementations should perform the action or raise a clear exception.
- Parameters:
action_id (str) – Identifier for the requested action (e.g. “set_voltage”).
*args – Additional action arguments.
- Raises:
ValueError – If arguments are invalid for the requested action.
RuntimeError – If the action could not be completed.