generated from ImperialCollegeLondon/poetry_template_2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dummy_temperature_monitor.py
49 lines (38 loc) · 1.58 KB
/
dummy_temperature_monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""This module provides an interface to dummy DP9800 temperature readers."""
from collections.abc import Sequence
from decimal import Decimal
from finesse.config import NUM_TEMPERATURE_MONITOR_CHANNELS
from finesse.hardware.noise_producer import NoiseParameters, NoiseProducer
from finesse.hardware.plugins.temperature.temperature_monitor_base import (
TemperatureMonitorBase,
)
_BASE_TEMPS = (19, 17, 26, 22, 24, 68, 69, 24)
"""The mean temperatures for each of the channels."""
_DEFAULT_TEMP_PARAMS = [
NoiseParameters(mean=temp, standard_deviation=0.1, seed=None)
for temp in _BASE_TEMPS
]
"""The default random parameters.
A random seed is used."""
class DummyTemperatureMonitor(
TemperatureMonitorBase, description="Dummy temperature monitor"
):
"""A dummy temperature monitor for GUI testing."""
def __init__(
self, temperature_params: Sequence[NoiseParameters] = _DEFAULT_TEMP_PARAMS
) -> None:
"""Create a new DummyTemperatureMonitor."""
if len(temperature_params) != NUM_TEMPERATURE_MONITOR_CHANNELS:
raise ValueError(
f"Must provide {NUM_TEMPERATURE_MONITOR_CHANNELS} parameters"
)
self._temperature_producers = [
NoiseProducer.from_parameters(params, type=Decimal)
for params in temperature_params
]
super().__init__()
def close(self) -> None:
"""Close the connection to the device."""
def get_temperatures(self) -> Sequence:
"""Get current temperatures."""
return [producer() for producer in self._temperature_producers]