p5control.measure.status

Class to facilitate measurement of the status of the instruments while the instrument server is running. A thread with this measurement is automatically started with the instrument server.

exception p5control.measure.status.StatusMeasurementError

Bases: Exception

Exception related to the status measurement

class p5control.measure.status.StatusMeasurement(devices: Dict[str, Any], refresh_delay: float = 1)

Bases: object

Calls get_status on all provided devices. Implements the python context manager.

Parameters:
  • devices (Dict[str, Any]) – the devices for which the status should be recorded

  • refresh_delay (float, default = 10) – pause between collecting status, by default 10s

start()

Start the status measurement thread. Does not block but returns after starting the thread.

stop()

Stop the status measurement thread. Blocks until the thread has finished.

_status_measurement_thread(stop_event: Event, refresh_delay: float | None = None)

This function continuously collects the output of get_status of the devices in regular intervals and safes the result to the data server. Between these collections, the time refresh_delay is waited and the stop_event, meaning that the actual time between calls is longer than the provided delay.

Instrument drivers which do not implement get_status are automatically skipped. If you want to closely control how the data is safed, implement _save_status for the driver. If the driver does not have this attribute, a default saving method is used and a timestamp is automatically added.

Parameters:
  • stop_event (threading.Event) – this function stops running when this event is set

  • refresh_delay (optional, float) – how long to wait between collecting the status of the devices. Can be used to overwrite the value which has been provided in __init__