instrumentserver.testing.dummy_instruments.generic#

Classes

AnnotatedMethodsInstrument(*args, **kwargs)

Dummy whose public methods use module-level classes as annotations.

DefaultValuesInstrument(*args, **kwargs)

Dummy whose public methods have defaults whose repr is not valid Python.

DummyBroadcasterInstrument(*args, **kwargs)

A dummy instrument implementing the Broadcaster contract.

DummyChannel(*args, **kwargs)

DummyInstrumentRandomNumber(*args, **kwargs)

A dummy instrument with a few parameters that have random numbers generated on demand

DummyInstrumentTimeout(*args, **kwargs)

A dummy instrument to test timeout situations.

DummyInstrumentWithFlags(*args, **kwargs)

Dummy instrument whose parameters return IntFlag values.

DummyInstrumentWithSubmodule(*args, **kwargs)

A dummy instrument with submodules.

FieldVectorIns(*args, **kwargs)

class used to develop json serialization and guis

MutableInterfaceInstrument(*args, **kwargs)

Dummy whose parameters, methods, and submodules can change at runtime.

SerializationInstrument(*args, **kwargs)

Dummy that returns representative values across the Client transport.

StatusFlag(*values)

An IntFlag mirroring drivers like the Yokogawa GS200 status byte.

SweepRequest(center_hz, span_hz, metadata, ...)

Serializable request used by Client transport tests and examples.

SweepResult(frequency_hz, magnitude_db)

Serializable result used by Client transport tests and examples.

class instrumentserver.testing.dummy_instruments.generic.AnnotatedMethodsInstrument(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

Dummy whose public methods use module-level classes as annotations.

Mirrors drivers like the QDevil QDAC2 (allocate_trace(...) -> Trace_Context). inspect.signature renders these annotations with their full module path, which the client has to be able to rebuild when it creates proxy methods.

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

make_request(center_hz: float, span_hz: float) → SweepRequest[source]#

Custom class as the return annotation.

request_span(request: SweepRequest) → float[source]#

Custom class as a parameter annotation.

class instrumentserver.testing.dummy_instruments.generic.DefaultValuesInstrument(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

Dummy whose public methods have defaults whose repr is not valid Python.

inspect.signature renders these as <StatusFlag.EAV: 4> or <object object at 0x...>, which the client cannot paste into source when it creates proxy methods.

add(a, b=10)[source]#

Plain literal default.

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

combine(a, b=1, c=2)[source]#

Lets a caller skip a middle default.

flag_value(flag=<StatusFlag.EAV: 4>)[source]#

Enum member as the default.

gather(a, b=1, *args, **kwargs)[source]#

Defaults mixed with variadic arguments.

is_default(value=<object object>)[source]#

Sentinel object as the default.

positional_only(a, b=1, /)[source]#

Positional-only parameters with a default.

required_keyword(x, *, k)[source]#

Keyword-only parameter without a default.

scaled(x, *, factor=<object object>)[source]#

Sentinel object as a keyword-only default.

class instrumentserver.testing.dummy_instruments.generic.DummyBroadcasterInstrument(*args: Any, **kwargs: Any)[source]#

Bases: Broadcaster, Instrument

A dummy instrument implementing the Broadcaster contract.

The Server registers itself as a Broadcast sink when this instrument joins the Station. Tests call emit_broadcast() through a proxy to make the instrument emit a Broadcast over the Server’s PUB socket.

emit_broadcast(value=1.0, unit='V', action='parameter-update')[source]#

Emit a Broadcast about param0 and return the blueprint that was sent.

Parameters:
  • value – The value carried by the Broadcast.

  • unit – The unit carried by the Broadcast.

  • action – The action string carried by the Broadcast.

class instrumentserver.testing.dummy_instruments.generic.DummyChannel(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

dummy_function(*args, **kwargs)[source]#

Dummy function for specific channels used for testing

class instrumentserver.testing.dummy_instruments.generic.DummyInstrumentRandomNumber(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

A dummy instrument with a few parameters that have random numbers generated on demand

generate_data(name: str)[source]#
get(param_name)[source]#

Shortcut for getting a parameter from its name.

Parameters:

param_name – The name of a parameter of this instrument.

Returns:

The current value of the parameter.

Note

This is deprecated. Call get directly on the parameter.

class instrumentserver.testing.dummy_instruments.generic.DummyInstrumentTimeout(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

A dummy instrument to test timeout situations.

ask_raw(cmd: str) → str[source]#

Answer identification queries without touching timeout behavior.

get_random()[source]#
get_random_timeout(wait_time=10)[source]#
class instrumentserver.testing.dummy_instruments.generic.DummyInstrumentWithFlags(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

Dummy instrument whose parameters return IntFlag values.

Mirrors the Yokogawa GS200 status/event register parameters, which store IntFlag instances as their value. Used to test that station snapshots containing flag values serialize (and round-trip) correctly.

get_condition()[source]#
get_status()[source]#
class instrumentserver.testing.dummy_instruments.generic.DummyInstrumentWithSubmodule(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

A dummy instrument with submodules.

ask_raw(cmd)[source]#

Dummy ask_raw so *IDN? and similar SCPI queries don’t explode the GUI.

close() → None[source]#

Irreversibly stop this instrument and free its resources.

Subclasses should override this if they have other specific resources to close.

dummy_function(*args, **kwargs)[source]#

Such a dumb dummy function here doing nothing other than printing and occupying your precious, precious terminal space.

test_func(a, b, *args, c: List[int] = [10, 11], **kwargs)[source]#

This is a test function, of course you knew this from the tittle but It’s nice to have documentation, isn’t it?

Parameters:
  • a – Very nice parameter.

  • b – Even nicer parameter

  • c – This one sucks though.

class instrumentserver.testing.dummy_instruments.generic.FieldVectorIns(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

class used to develop json serialization and guis

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

generic_function()[source]#
get_complex()[source]#
get_complex_list()[source]#
get_field()[source]#
get_starting_parameter()[source]#
set_complex(value: complex)[source]#
set_complex_list(value)[source]#
set_field(field_vector: FieldVector)[source]#
set_starting_parameter(new_value)[source]#
class instrumentserver.testing.dummy_instruments.generic.MutableInterfaceInstrument(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

Dummy whose parameters, methods, and submodules can change at runtime.

add_dynamic_interface()[source]#

Add one parameter, method, and submodule for Proxy update tests.

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

remove_dynamic_interface()[source]#

Remove the runtime interface added by add_dynamic_interface().

class instrumentserver.testing.dummy_instruments.generic.SerializationInstrument(*args: Any, **kwargs: Any)[source]#

Bases: Instrument

Dummy that returns representative values across the Client transport.

ask_raw(cmd: str) → str[source]#

Return a minimal response to identification queries.

echo(value)[source]#

Return value unchanged.

get_nested_status()[source]#

Return an enum nested in a list.

get_numeric_text()[source]#

Return numeric-looking text so decoder coercion can be tested.

get_set()[source]#

Return a set so transport container conversion can be tested.

get_status()[source]#

Return an importable top-level enum member.

get_tuple()[source]#

Return a tuple so transport container conversion can be tested.

run_sweep(request)[source]#

Return a three-point sweep for a SweepRequest.

class instrumentserver.testing.dummy_instruments.generic.StatusFlag(*values)[source]#

Bases: IntFlag

An IntFlag mirroring drivers like the Yokogawa GS200 status byte.

On Python >= 3.11 flag members are iterable and a single-bit member iterates to itself, which is what triggers the snapshot serialization recursion bug this instrument is used to test.

EAV = 4#
ESB = 32#
MAV = 16#
class instrumentserver.testing.dummy_instruments.generic.SweepRequest(center_hz: float, span_hz: float, metadata: dict[str, str]=<factory>)[source]#

Bases: object

Serializable request used by Client transport tests and examples.

attributes: ClassVar[tuple[str, ...]] = ('center_hz', 'span_hz', 'metadata')#
center_hz: float#
metadata: dict[str, str]#
span_hz: float#
class instrumentserver.testing.dummy_instruments.generic.SweepResult(frequency_hz: list[float], magnitude_db: list[float])[source]#

Bases: object

Serializable result used by Client transport tests and examples.

attributes: ClassVar[tuple[str, ...]] = ('frequency_hz', 'magnitude_db')#
frequency_hz: list[float]#
magnitude_db: list[float]#