Skip to content

ftsw500_interface

frog.hardware.plugins.spectrometer.ftsw500_interface ¤

Module containing code for sending commands to FTSW500 for the ABB spectrometer.

Communication is via TCP.

The FTSW500 program must be running on the computer at FTSW500_HOST for the commands to work. The server always returns a response after having received a command. The response will start with the tag "ACK" in case of success, or "NAK" otherwise, and is terminated by the end-of-line character "\n". An answer can also contain a string value or message after the tag, which will be preceded by "&". For example, querying whether the instrument is currently measuring data would yield a response "ACK&true\n" or "ACK&false\n".

Attributes¤

Classes¤

FTSW500Interface(host=DEFAULT_FTSW500_HOST, port=DEFAULT_FTSW500_PORT, polling_interval=DEFAULT_FTSW500_POLLING_INTERVAL) ¤

Bases: FTSW500InterfaceBase

Interface for communicating with the FTSW500 program.

Create a new FTSW500Interface.

Parameters:

Name Type Description Default
host str

The hostname or IP of the machine running the FTSW500 software

DEFAULT_FTSW500_HOST
port int

The port on which to make requests

DEFAULT_FTSW500_PORT
polling_interval float

How often to poll the spectrometer's status (seconds)

DEFAULT_FTSW500_POLLING_INTERVAL
Source code in frog/hardware/plugins/spectrometer/ftsw500_interface.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def __init__(
    self,
    host: str = DEFAULT_FTSW500_HOST,
    port: int = DEFAULT_FTSW500_PORT,
    polling_interval: float = DEFAULT_FTSW500_POLLING_INTERVAL,
) -> None:
    """Create a new FTSW500Interface.

    Args:
        host: The hostname or IP of the machine running the FTSW500 software
        port: The port on which to make requests
        polling_interval: How often to poll the spectrometer's status (seconds)
    """
    super().__init__()

    sock = socket(AF_INET, SOCK_STREAM)
    sock.settimeout(FTSW500_TIMEOUT)
    sock.connect((host, port))
    self._socket = sock

    # Timer to poll status
    self._status_timer = QTimer()
    self._status_timer.timeout.connect(self.pubsub_errors(self._update_status))
    self._status_timer.setInterval(int(polling_interval * 1000))
    self._status_timer.setSingleShot(True)

    # Find out what the initial status is
    self._status = SpectrometerStatus.UNDEFINED
    self._update_status()
Functions¤
close() ¤

Close the device.

Source code in frog/hardware/plugins/spectrometer/ftsw500_interface.py
 96
 97
 98
 99
100
101
102
103
def close(self) -> None:
    """Close the device."""
    self._status_timer.stop()

    if self._socket.fileno() != -1:  # check if closed already
        self._socket.close()

    super().close()
request_command(command) ¤

Request that FTSW500 run the specified command.

The status is requested after sending the command so that we are immediately notified if it has changed in response to the command (e.g. recording has started).

Parameters:

Name Type Description Default
command str

Name of command to run

required
Source code in frog/hardware/plugins/spectrometer/ftsw500_interface.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def request_command(self, command: str) -> None:
    """Request that FTSW500 run the specified command.

    The status is requested after sending the command so that we are immediately
    notified if it has changed in response to the command (e.g. recording has
    started).

    Args:
        command: Name of command to run
    """
    self._make_request(command)

    # Request a status update
    self._update_status()