Skip to content

opus_interface_base

frog.hardware.plugins.spectrometer.opus_interface_base ¤

Provides a base class for interfacing with the OPUS program.

Classes¤

OPUSError ¤

Bases: Exception

Indicates that an error occurred with an OPUS device.

Functions¤
from_response(errcode, errtext) classmethod ¤

Create an OPUSError from the information given in the device response.

Source code in frog/hardware/plugins/spectrometer/opus_interface_base.py
13
14
15
16
@classmethod
def from_response(cls, errcode: int, errtext: str) -> OPUSError:
    """Create an OPUSError from the information given in the device response."""
    return cls(f"Error {errcode}: {errtext}")

OPUSInterfaceBase() ¤

Bases: SpectrometerBase

Base class providing an interface to the OPUS program.

Source code in frog/hardware/plugins/spectrometer/spectrometer_base.py
13
14
15
16
17
18
19
20
21
22
def __init__(self) -> None:
    """Create a new SpectrometerBase."""
    super().__init__()

    for command in (
        "connect",
        "start_measuring",
        "stop_measuring",
    ):
        self.subscribe(getattr(self, command), command)
Functions¤
connect() ¤

Connect to the spectrometer.

Source code in frog/hardware/plugins/spectrometer/opus_interface_base.py
22
23
24
def connect(self) -> None:
    """Connect to the spectrometer."""
    self.request_command("connect")
request_command(command) abstractmethod ¤

Request that OPUS run the specified command.

Parameters:

Name Type Description Default
command str

Name of command to run

required
Source code in frog/hardware/plugins/spectrometer/opus_interface_base.py
34
35
36
37
38
39
40
@abstractmethod
def request_command(self, command: str) -> None:
    """Request that OPUS run the specified command.

    Args:
        command: Name of command to run
    """
start_measuring() ¤

Start a new measurement.

Source code in frog/hardware/plugins/spectrometer/opus_interface_base.py
26
27
28
def start_measuring(self) -> None:
    """Start a new measurement."""
    self.request_command("start")
stop_measuring() ¤

Stop the current measurement.

Source code in frog/hardware/plugins/spectrometer/opus_interface_base.py
30
31
32
def stop_measuring(self) -> None:
    """Stop the current measurement."""
    self.request_command("cancel")