Skip to content

Commit 74e85f7

Browse files
committed
add ISIS devices (from DeviceEmulator) to lewis
1 parent da8616c commit 74e85f7

File tree

7 files changed

+65
-103
lines changed

7 files changed

+65
-103
lines changed

lewis/devices/julabo/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -16,3 +16,5 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
# *********************************************************************
19+
20+

lewis/devices/julabo/devices/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by

lewis/devices/julabo/devices/device.py

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -25,6 +25,11 @@
2525
from . import states
2626

2727

28+
class ControlModes(object):
29+
INTERNAL = 0
30+
EXTERNAL = 1
31+
32+
2833
class SimulatedJulabo(StateMachineDevice):
2934
internal_p = 0.1 # The proportional
3035
internal_i = 3 # The integral
@@ -43,10 +48,10 @@ class SimulatedJulabo(StateMachineDevice):
4348
external_temperature = 26.0 # External temperature in C
4449
circulate_commanded = False
4550
temperature_ramp_rate = 5.0 # Guessed value in C/min
51+
control_mode = ControlModes.EXTERNAL
4652

47-
def _initialize_data(self) -> None:
48-
"""
49-
This method is called once on construction. After that, it may be
53+
def _initialize_data(self):
54+
"""This method is called once on construction. After that, it may be
5055
manually called again to reset the device to its default state.
5156
5257
After the first call during construction, the class is frozen.
@@ -63,7 +68,7 @@ def _get_state_handlers(self):
6368
"not_circulate": states.DefaultNotCirculatingState(),
6469
}
6570

66-
def _get_initial_state(self) -> str:
71+
def _get_initial_state(self):
6772
return "not_circulate"
6873

6974
def _get_transition_handlers(self):
@@ -74,9 +79,8 @@ def _get_transition_handlers(self):
7479
]
7580
)
7681

77-
def set_set_point(self, param) -> str:
78-
"""
79-
Sets the target temperature.
82+
def set_set_point(self, param):
83+
"""Sets the target temperature.
8084
8185
:param param: The new temperature in C. Must be positive.
8286
:return: Empty string.
@@ -85,9 +89,8 @@ def set_set_point(self, param) -> str:
8589
self.set_point_temperature = param
8690
return ""
8791

88-
def set_circulating(self, param) -> str:
89-
"""
90-
Sets whether to circulate - in effect whether the heater is on.
92+
def set_circulating(self, param):
93+
"""Sets whether to circulate - in effect whether the heater is on.
9194
9295
:param param: The mode to set, must be 0 or 1.
9396
:return: Empty string.
@@ -101,9 +104,8 @@ def set_circulating(self, param) -> str:
101104
return ""
102105

103106
@check_limits(0.1, 99.9)
104-
def set_internal_p(self, param) -> str:
105-
"""
106-
Sets the internal proportional.
107+
def set_internal_p(self, param):
108+
"""Sets the internal proportional.
107109
Xp in Julabo speak.
108110
109111
:param param: The value to set, must be between 0.1 and 99.9
@@ -113,9 +115,8 @@ def set_internal_p(self, param) -> str:
113115
return ""
114116

115117
@check_limits(3, 9999)
116-
def set_internal_i(self, param) -> str:
117-
"""
118-
Sets the internal integral.
118+
def set_internal_i(self, param):
119+
"""Sets the internal integral.
119120
Tn in Julabo speak.
120121
121122
:param param: The value to set, must be an integer between 3 and 9999
@@ -125,9 +126,8 @@ def set_internal_i(self, param) -> str:
125126
return ""
126127

127128
@check_limits(0, 999)
128-
def set_internal_d(self, param) -> str:
129-
"""
130-
Sets the internal derivative.
129+
def set_internal_d(self, param):
130+
"""Sets the internal derivative.
131131
Tv in Julabo speak.
132132
133133
:param param: The value to set, must be an integer between 0 and 999
@@ -137,9 +137,8 @@ def set_internal_d(self, param) -> str:
137137
return ""
138138

139139
@check_limits(0.1, 99.9)
140-
def set_external_p(self, param) -> str:
141-
"""
142-
Sets the external proportional.
140+
def set_external_p(self, param):
141+
"""Sets the external proportional.
143142
Xp in Julabo speak.
144143
145144
:param param: The value to set, must be between 0.1 and 99.9
@@ -149,9 +148,8 @@ def set_external_p(self, param) -> str:
149148
return ""
150149

151150
@check_limits(3, 9999)
152-
def set_external_i(self, param) -> str:
153-
"""
154-
Sets the external integral.
151+
def set_external_i(self, param):
152+
"""Sets the external integral.
155153
Tn in Julabo speak.
156154
157155
:param param: The value to set, must be an integer between 3 and 9999
@@ -161,13 +159,21 @@ def set_external_i(self, param) -> str:
161159
return ""
162160

163161
@check_limits(0, 999)
164-
def set_external_d(self, param) -> str:
165-
"""
166-
Sets the external derivative.
162+
def set_external_d(self, param):
163+
"""Sets the external derivative.
167164
Tv in Julabo speak.
168165
169166
:param param: The value to set, must be an integer between 0 and 999
170167
:return: Empty string.
171168
"""
172169
self.external_d = param
173170
return ""
171+
172+
@check_limits(0, 1)
173+
def set_control_mode(self, control_mode):
174+
"""Sets the control mode of the julabo.
175+
:param control_mode: (int) 1 for external control, 0 for internal control
176+
:return: Empty string
177+
"""
178+
self.control_mode = ControlModes.EXTERNAL if control_mode == 1 else ControlModes.INTERNAL
179+
return ""

lewis/devices/julabo/devices/states.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@ class DefaultNotCirculatingState(State):
2626

2727

2828
class DefaultCirculatingState(State):
29-
def in_state(self, dt) -> None:
29+
def in_state(self, dt):
3030
# Approach target temperature at a set rate
3131
self._context.temperature = approaches.linear(
3232
self._context.temperature,

lewis/devices/julabo/interfaces/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by

lewis/devices/julabo/interfaces/julabo_stream_interface_1.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -30,22 +30,10 @@ class JulaboStreamInterfaceV1(StreamInterface):
3030

3131
commands = {
3232
Var("temperature", read_pattern="^IN_PV_00$", doc="The bath temperature."),
33-
Var(
34-
"external_temperature",
35-
read_pattern="^IN_PV_01$",
36-
doc="The external temperature.",
37-
),
33+
Var("external_temperature", read_pattern="^IN_PV_01$", doc="The external temperature."),
3834
Var("heating_power", read_pattern="^IN_PV_02$", doc="The heating power."),
39-
Var(
40-
"set_point_temperature",
41-
read_pattern="^IN_SP_00$",
42-
doc="The temperature setpoint.",
43-
),
44-
Cmd(
45-
"set_set_point",
46-
r"^OUT_SP_00 ([0-9]*\.?[0-9]+)$",
47-
argument_mappings=(float,),
48-
),
35+
Var("set_point_temperature", read_pattern="^IN_SP_00$", doc="The temperature setpoint."),
36+
Cmd("set_set_point", "^OUT_SP_00 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
4937
Var(
5038
"temperature_high_limit",
5139
read_pattern="^IN_SP_01$",
@@ -58,32 +46,22 @@ class JulaboStreamInterfaceV1(StreamInterface):
5846
),
5947
Var("version", read_pattern="^VERSION$", doc="The Julabo version."),
6048
Var("status", read_pattern="^STATUS$", doc="The Julabo status."),
61-
Var(
62-
"is_circulating",
63-
read_pattern="^IN_MODE_05$",
64-
doc="Whether it is circulating.",
65-
),
49+
Var("is_circulating", read_pattern="^IN_MODE_05$", doc="Whether it is circulating."),
6650
Cmd("set_circulating", "^OUT_MODE_05 (0|1)$", argument_mappings=(int,)),
6751
Var("internal_p", read_pattern="^IN_PAR_06$", doc="The internal proportional."),
68-
Cmd(
69-
"set_internal_p",
70-
r"^OUT_PAR_06 ([0-9]*\.?[0-9]+)$",
71-
argument_mappings=(float,),
72-
),
52+
Cmd("set_internal_p", "^OUT_PAR_06 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
7353
Var("internal_i", read_pattern="^IN_PAR_07$", doc="The internal integral."),
7454
Cmd("set_internal_i", "^OUT_PAR_07 ([0-9]*)$", argument_mappings=(int,)),
7555
Var("internal_d", read_pattern="^IN_PAR_08$", doc="The internal derivative."),
7656
Cmd("set_internal_d", "^OUT_PAR_08 ([0-9]*)$", argument_mappings=(int,)),
7757
Var("external_p", read_pattern="^IN_PAR_09$", doc="The external proportional."),
78-
Cmd(
79-
"set_external_p",
80-
r"^OUT_PAR_09 ([0-9]*\.?[0-9]+)$",
81-
argument_mappings=(float,),
82-
),
58+
Cmd("set_external_p", "^OUT_PAR_09 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
8359
Var("external_i", read_pattern="^IN_PAR_11$", doc="The external integral."),
8460
Cmd("set_external_i", "^OUT_PAR_11 ([0-9]*)$", argument_mappings=(int,)),
8561
Var("external_d", read_pattern="^IN_PAR_12$", doc="The external derivative."),
8662
Cmd("set_external_d", "^OUT_PAR_12 ([0-9]*)$", argument_mappings=(int,)),
63+
Var("control_mode", read_pattern="^IN_MODE_04", doc="The control mode internal/external"),
64+
Cmd("set_control_mode", "^OUT_MODE_04 (0|1)$", argument_mappings=(int,)),
8765
}
8866

8967
in_terminator = "\r"

lewis/devices/julabo/interfaces/julabo_stream_interface_2.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
# *********************************************************************
3-
# lewis - a library for creating hardware device simulators
4-
# Copyright (C) 2016-2021 European Spallation Source ERIC
3+
# plankton - a library for creating hardware device simulators
4+
# Copyright (C) 2016-2017 European Spallation Source ERIC
55
#
66
# This program is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -30,22 +30,10 @@ class JulaboStreamInterfaceV2(StreamInterface):
3030

3131
commands = {
3232
Var("temperature", read_pattern="^IN_PV_00$", doc="The bath temperature."),
33-
Var(
34-
"external_temperature",
35-
read_pattern="^IN_PV_01$",
36-
doc="The external temperature.",
37-
),
33+
Var("external_temperature", read_pattern="^IN_PV_01$", doc="The external temperature."),
3834
Var("heating_power", read_pattern="^IN_PV_02$", doc="The heating power."),
39-
Var(
40-
"set_point_temperature",
41-
read_pattern="^IN_SP_00$",
42-
doc="The temperature setpoint.",
43-
),
44-
Cmd(
45-
"set_set_point",
46-
r"^OUT_SP_00 ([0-9]*\.?[0-9]+)$",
47-
argument_mappings=(float,),
48-
),
35+
Var("set_point_temperature", read_pattern="^IN_SP_00$", doc="The temperature setpoint."),
36+
Cmd("set_set_point", "^OUT_SP_00 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
4937
# Read pattern for high limit is different from version 1
5038
Var(
5139
"temperature_high_limit",
@@ -60,28 +48,16 @@ class JulaboStreamInterfaceV2(StreamInterface):
6048
),
6149
Var("version", read_pattern="^VERSION$", doc="The Julabo version."),
6250
Var("status", read_pattern="^STATUS$", doc="The Julabo status."),
63-
Var(
64-
"is_circulating",
65-
read_pattern="^IN_MODE_05$",
66-
doc="Whether it is circulating.",
67-
),
51+
Var("is_circulating", read_pattern="^IN_MODE_05$", doc="Whether it is circulating."),
6852
Cmd("set_circulating", "^OUT_MODE_05 (0|1)$", argument_mappings=(int,)),
6953
Var("internal_p", read_pattern="^IN_PAR_06$", doc="The internal proportional."),
70-
Cmd(
71-
"set_internal_p",
72-
r"^OUT_PAR_06 ([0-9]*\.?[0-9]+)$",
73-
argument_mappings=(float,),
74-
),
54+
Cmd("set_internal_p", "^OUT_PAR_06 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
7555
Var("internal_i", read_pattern="^IN_PAR_07$", doc="The internal integral."),
7656
Cmd("set_internal_i", "^OUT_PAR_07 ([0-9]*)$", argument_mappings=(int,)),
7757
Var("internal_d", read_pattern="^IN_PAR_08$", doc="The internal derivative."),
7858
Cmd("set_internal_d", "^OUT_PAR_08 ([0-9]*)$", argument_mappings=(int,)),
7959
Var("external_p", read_pattern="^IN_PAR_09$", doc="The external proportional."),
80-
Cmd(
81-
"set_external_p",
82-
r"^OUT_PAR_09 ([0-9]*\.?[0-9]+)$",
83-
argument_mappings=(float,),
84-
),
60+
Cmd("set_external_p", "^OUT_PAR_09 ([0-9]*\.?[0-9]+)$", argument_mappings=(float,)),
8561
Var("external_i", read_pattern="^IN_PAR_11$", doc="The external integral."),
8662
Cmd("set_external_i", "^OUT_PAR_11 ([0-9]*)$", argument_mappings=(int,)),
8763
Var("external_d", read_pattern="^IN_PAR_12$", doc="The external derivative."),

0 commit comments

Comments
 (0)