photons.equipment.base module

Base classes and decorators for equipment.

class photons.equipment.base.BaseEquipment(record, **kwargs)[source]

Bases: QObject, Service

Base class for all equipment connections.

Parameters:
  • record (EquipmentRecord) – The equipment record.

  • **kwargs – Keyword arguments that a subclass requires. Can be specified as attributes of an XML element in a configuration file (with the tag of the element equal to the alias of record).

__getattr__(item)[source]

Pass all attributes that do not exist to the connection object.

Return type:

Any

static convert_to_enum(obj, enum, prefix=None, to_upper=False)[source]

See convert_to_enum() for more details.

Return type:

TypeVar(E, bound= Enum)

disconnect_equipment()[source]

Disconnect from the equipment and log an INFO message.

Return type:

None

property logger

Reference to the package logger.

maybe_emit_notification(*args, **kwargs)[source]

Emit a notification to all Clients that are linked with this Service.

Return type:

None

property notifications_allowed: bool

Returns whether notifications are allowed to be sent to Clients.

raise_exception(message)[source]

Log the message then raise an exception.

Return type:

None

record_to_json()[source]

Returns the EquipmentRecord as a JSON-serializable object.

Return type:

dict

property timeout: float | None

The timeout, in seconds, for read and write operations.

This property is valid only if the underlying connection is ConnectionMessageBased.

class photons.equipment.base.BaseEquipmentWidget(connection, *, parent=None, **kwargs)[source]

Bases: QWidget

Base class for all Qt widgets that connect to equipment.

Parameters:
  • connection (Link | BaseEquipment | Connection) – The connection to the equipment.

  • parent (QWidget) – The parent widget.

  • **kwargs – All keyword arguments are passed to super().

closing: SignalInstance
closeEvent(event)[source]

Overrides QtWidgets.QWidget.closeEvent().

Return type:

None

property logger

Reference to the package logger.

notification_handler(*args, **kwargs)[source]

Override in subclass to handle notifications emitted by a Service.

Return type:

None

class photons.equipment.base.EquipmentMatcher(cls, manufacturer, model, flags)[source]

Bases: object

Performs match operations on an EquipmentRecord.

Parameters:
  • cls (type[BaseEquipment | BaseEquipmentWidget]) – The class to associate with the matcher. The class must not be instantiated.

  • manufacturer (str | None) – The name of the manufacturer. Can be a regex pattern.

  • model (str | None) – The model number of the equipment. Can be a regex pattern.

  • flags (int) – The flags to use to compile the regex patterns.

matches(record)[source]

Checks if record is a match.

Parameters:

record (EquipmentRecord) – The equipment record to check if the manufacturer and the model number are a match.

Return type:

bool

Returns:

Whether record is a match.

photons.equipment.base.equipment(*, manufacturer=None, model=None, flags=0)[source]

A decorator to register equipment (for connections).

Parameters:
  • manufacturer (str) – The name of the manufacturer. Can be a regex pattern.

  • model (str) – The model number of the equipment. Can be a regex pattern.

  • flags (int) – The flags to use to compile the regex patterns.

photons.equipment.base.widget(*, manufacturer=None, model=None, flags=0)[source]

A decorator to register a widget (for equipment).

Parameters:
  • manufacturer (str) – The name of the manufacturer. Can be a regex pattern.

  • model (str) – The model number of the equipment. Can be a regex pattern.

  • flags (int) – The flags to use to compile the regex patterns.