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
2525from . import states
2626
2727
28+ class ControlModes (object ):
29+ INTERNAL = 0
30+ EXTERNAL = 1
31+
32+
2833class 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 ""
0 commit comments