attach()#
- attach(
- instrument: T,
- name: str,
- publishers: list[Publisher] | None = None,
- *,
- channel_map: ChannelMap | dict[str, Any] | str | Path | None = None,
- poll: list[str] | None = None,
- **kwargs: Any,
Start publishing an existing pymeasure instrument’s traffic, without changing how it is used.
Your code keeps the pymeasure object and keeps calling it; this only adds publishing. Closing the returned handle flushes and closes the publishers and detaches, but leaves the instrument connected (
close_device=False).Example:
keithley = Keithley2400("GPIB::24") # existing code recorder = attach(keithley, "smu", [FilePublisher(format="jsonl")]) keithley.source_voltage = 1.0 # existing code, now published recorder.close()
- Parameters:
instrument
The pymeasure instrument.
name
Channel-name prefix for everything published.
publishers
Publishers that receive the commands and measurements.
channel_map
See
PymeasureInstrument.poll
See
PymeasureInstrument.**kwargs
Any other
PymeasureInstrumentargument, default tags, ordataset_rid=.
- Returns:
The
PymeasureInstrumentdoing the publishing; use it as a context manager or callclose().