Source code for semi_cr.core.lab.instrument.routable_dmm
from qcodes.instrument_drivers.Keysight import Keysight34465A
from semi_cr.core.lab.station.routing_v1.models import ConnectionRoutable, Routable
from collections.abc import Sequence
from typing import Any
import networkx as nx
from semi_cr.core.lab.station.graphing.models import Node, Edge
from semi_cr.core.lab.station.graphing.operations import build_nx_graph
from semi_cr.core.lab.station.graphing.ids import (
qcodes_node_id,
terminal_node_id,
)
from qcodes.instrument import InstrumentModule
[docs]
class DMMVoltageInput(InstrumentModule, Routable):
def __init__(
self,
parent,
name: str,
role: str | None = None,
):
super().__init__(parent=parent, name=name)
self._role = role
self.add_parameter(
"voltage",
unit="V",
label=f"{self.short_name} voltage",
get_cmd=self.measure_voltage,
set_cmd=False,
get_parser=float,
)
@property
def graph(self) -> nx.MultiDiGraph:
channel_id = qcodes_node_id(self)
terminal_id = terminal_node_id(
self.parent.short_name,
self.short_name,
)
attrs = {
"role": self._role,
"quantity": "voltage",
"modality": "dc",
}
return build_nx_graph(
nodes=[
Node(
id=channel_id,
kind="instrument_channel",
name=self.short_name,
obj=self,
attrs=attrs,
),
Node(
id=terminal_id,
kind="terminal",
name=f"{self.parent.short_name}[{self.short_name}]",
obj=self,
attrs=attrs,
),
],
edges=[
Edge(
source=channel_id,
target=terminal_id,
kind="represents",
)
],
)
[docs]
class QcodesDMM(Keysight34465A, ConnectionRoutable):
def __init__(
self,
name: str,
autorange: bool = True,
nplc: float = 1.0,
connections: Sequence[dict[str, Any]] | None = None,
**kwargs: Any,
):
super().__init__(name=name, **kwargs)
self._autorange = autorange
self._nplc = nplc
if self._autorange:
self.autorange("ON")
else:
self.autorange("OFF")
self.NPLC(self._nplc)
self._init_connections(connections)
for connection in self.connections:
terminal_name = connection["name"]
self.add_submodule(
terminal_name,
DMMVoltageInput(
parent=self,
name=terminal_name,
role=connection.get("role", "meter"),
),
)