mahos.msgs.param_msgs#

Message Types for Generic Parameters.

Param is a wrapper around a value of primitive (mostly Python builtin) type, with a default. NumberParam has bounds (minimum and maximum). ChoiceParam has its available options. Collection of parameters are expressed as a ParamDict: nestable, str-keyed dict of Params.

GetParamDictReq (get_param_dict()) is usually served by meas nodes, to tell the client about required parameters for a measurement. The client can use param_dict to update the parameter values and pass it in StateReq (change_state()). At the meas node side, it is usually required to unwrap the Params using unwrap().

Messages#

class mahos.msgs.param_msgs.GetParamDictReq(label: str = '')#

Request to get ParamDict.

ParamDict#

Measurement parameter can be reported by using ParamDict.

class mahos.msgs.param_msgs.ParamDict(dict=None, /, **kwargs)#
mahos.msgs.param_msgs.PDValue#

Allowed value types for ParamDict

mahos.msgs.param_msgs.RawPDValue#

Allowed value types for Raw (unwrapped) ParamDict

Contents of ParamDict is instances of Param. The Param is mutable object; we can get / set the value.

class mahos.msgs.param_msgs.Param(typ, default, optional: bool, enable: bool, read_only: bool, doc: str)#

Base class for all Param types.

Parameters:
  • optional – If True, the Param can be enabled/disabled via set_enable(). When disabled, value() returns None.

  • enable – Initial enabled state.

  • read_only – If True, set() is rejected.

value()#

Get raw value of this Param.

set(value) bool#

Set value of this Param. Return True on success.

Param has subclasses according to the types.

NumberParam#

NumberParam has bounds: minimum and maximum.

class mahos.msgs.param_msgs.NumberParam(typ, default, minimum, maximum, unit, SI_prefix, digit, step, adaptive_step, adaptive_min_step, optional, enable, read_only, doc)#

Base class for Param types representing numbers.

Parameters:
  • typ – Expected type used for type coercion.

  • default – Default value.

  • minimum – Inclusive lower bound. Set None to disable lower bound.

  • maximum – Inclusive upper bound. Set None to disable upper bound.

  • unit – Unit string used for formatting / display.

  • SI_prefix – (GUI) Enable SI-prefix display in GUI widgets.

  • digit – (GUI) Number of decimals shown in GUI widgets.

  • step – (GUI) Base increment/decrement step for GUI widgets.

  • adaptive_step – (GUI) Enable magnitude-dependent stepping in GUI widgets.

  • adaptive_min_step – (GUI) Minimum step for adaptive stepping in GUI widgets.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

minimum()#

Get minimum value (lower bound) of this NumberParam.

maximum()#

Get maximum value (upper bound) of this NumberParam.

class mahos.msgs.param_msgs.IntParam(default: int = 0, minimum=None, maximum=None, unit: str = '', SI_prefix: bool = False, digit: int = 6, step: int = 1, adaptive_step: bool = False, adaptive_min_step: int | None = None, optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for builtin int.

Parameters:
  • default – Default integer value.

  • minimum – Inclusive lower bound. Set None to disable lower bound.

  • maximum – Inclusive upper bound. Set None to disable upper bound.

  • unit – Unit string used for formatting / display.

  • SI_prefix – (GUI) Enable SI-prefix display in GUI widgets.

  • digit – (GUI) Number of decimals shown in GUI widgets.

  • step – (GUI) Base increment/decrement step for GUI widgets.

  • adaptive_step – (GUI) Enable magnitude-dependent stepping in GUI widgets.

  • adaptive_min_step – (GUI) Minimum step for adaptive stepping in GUI widgets.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

class mahos.msgs.param_msgs.FloatParam(default: float = 0.0, minimum=None, maximum=None, unit: str = '', SI_prefix: bool = False, digit: int = 6, step: float = 1.0, adaptive_step: bool = False, adaptive_min_step: float | None = None, optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for builtin float.

Parameters:
  • default – Default floating-point value.

  • minimum – Inclusive lower bound. Set None to disable lower bound.

  • maximum – Inclusive upper bound. Set None to disable upper bound.

  • unit – Unit string used for formatting / display.

  • SI_prefix – (GUI) Enable SI-prefix display in GUI widgets.

  • digit – (GUI) Number of decimals shown in GUI widgets.

  • step – (GUI) Base increment/decrement step for GUI widgets.

  • adaptive_step – (GUI) Enable magnitude-dependent stepping in GUI widgets.

  • adaptive_min_step – (GUI) Minimum step for adaptive stepping in GUI widgets.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

ChoiceParam#

class mahos.msgs.param_msgs.ChoiceParam(typ, default, options, optional, enable, read_only, doc)#

Base class for Param types expressing a choice from finite set options.

Parameters:
  • typ – Expected type used for type coercion.

  • default – Default value.

  • options – Available options.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

options() tuple#

Get available options for this Param.

class mahos.msgs.param_msgs.BoolParam(default: bool, optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for builtin bool.

Parameters:
  • default – Default boolean value.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

class mahos.msgs.param_msgs.EnumParam(typ: Enum, default, options=None, optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for Enum values.

Parameters:
  • typ – Enum class used for type coercion.

  • default – Default Enum value.

  • options – Available options. If None, all members in typ are used.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

class mahos.msgs.param_msgs.StrChoiceParam(default, options: tuple[str], optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for a finite selection of builtin strs.

Parameters:
  • default – Default string value.

  • options – Available string options.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

class mahos.msgs.param_msgs.IntChoiceParam(default, options: tuple[int], optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for a finite selection of builtin ints.

Parameters:
  • default – Default integer value.

  • options – Available integer options.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

Other Param#

class mahos.msgs.param_msgs.StrParam(default: str = '', optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for builtin str.

Parameters:
  • default – Default string value.

  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

class mahos.msgs.param_msgs.UUIDParam(optional: bool = False, enable: bool = True, read_only: bool = False, doc: str = '')#

Param type for uuid.UUID.

Parameters:
  • optional – If True, this parameter can be enabled/disabled.

  • enable – Initial enabled state.

  • read_only – If True, updates through set() are rejected.

  • doc – Human-readable description for this parameter.

Functions#

mahos.msgs.param_msgs.unwrap(params: ParamDict[str, Param | ParamDict | List[Param | ParamDict | List[PDValue]]] | dict[str, bool | str | int | float | Enum | UUID | dict | List[bool | str | int | float | Enum | UUID | dict | List[RawPDValue]]]) dict[str, bool | str | int | float | Enum | UUID | dict | List[bool | str | int | float | Enum | UUID | dict | List[RawPDValue]]]#

Unwrap the ParamDict to RawParamDict. If params is not a ParamDict, do nothing.

mahos.msgs.param_msgs.isclose(params: ParamDict[str, Param | ParamDict | List[Param | ParamDict | List[PDValue]]] | dict[str, bool | str | int | float | Enum | UUID | dict | List[bool | str | int | float | Enum | UUID | dict | List[RawPDValue]]], other: ParamDict[str, Param | ParamDict | List[Param | ParamDict | List[PDValue]]] | dict[str, bool | str | int | float | Enum | UUID | dict | List[bool | str | int | float | Enum | UUID | dict | List[RawPDValue]]], rtol: float = 1e-05, atol: float = 1e-08) bool#

Check if two ParamDicts or RawParamDicts are close.