Commit 82b3bcd5 authored by Anthony Mauro's avatar Anthony Mauro

Remove custom_method_input&output

factorizing alarm_reset and alarm_status
parent 4daef5c7
Pipeline #11646 failed with stages
in 31 minutes and 8 seconds
......@@ -109,6 +109,30 @@ class LakeshoreInput(Input):
channel = self.config.get("channel")
return self.controller._lakeshore._sensor_type(channel, **kwargs)
def alarm_status(self):
""" Shows high and low alarm state for given input
Args:
None
Returns:
high and low alarm state (str, str): "On/Off"
"""
self._logger.info("alarm_status")
channel = self.config.get("channel")
return self.controller._lakeshore._alarm_status(channel)
def alarm_reset(self):
""" Clears both the high and low status of all alarms
Args:
None (though this command does not need the input channel,
we put it here, since alarms are related to the state
on input like for ex. measured temperature above
alarm high-limit etc.)
Returns:
None
"""
self._logger.info("alarm_reset")
return self.controller._lakeshore._alarm_reset()
class LakeshoreOutput(Output):
def __repr__(self):
......
......@@ -121,19 +121,16 @@ class LakeShore331(LogMixin):
# ------------
def _initialize_input(self, input):
self._logger.info("_initialize_input")
self._add_custom_method_input(input)
# - Output object
# -------------
def _initialize_output(self, output):
self._logger.info("_initialize_output")
# self._add_custom_method_output(output)
# - Loop object
# -----------
def _initialize_loop(self, loop):
self._logger.info("_initialize_loop")
self._add_custom_method_loop(loop)
# Get input object channel
ipc = loop.input.config["channel"]
# Get output object unit
......@@ -182,45 +179,15 @@ class LakeShore331(LogMixin):
"Temperature OverRange in Sensor_unit on input %s" % channel
)
# Adding CUSTOM INPUT-object related method(s)
# --------------------------------------------
def _add_custom_method_input(self, input):
self._logger.info("_add_custom_method_input")
def alarm_status():
""" Shows high and low alarm state for given input
Args:
None
Returns:
high and low alarm state (str, str): "On/Off"
"""
self._logger.info("alarm_status")
return self._alarm_status(input.config.get("channel"))
input.alarm_status = alarm_status
def alarm_reset():
""" Clears both the high and low status of all alarms
Args:
None (though this command does not need the input channel,
we put it here, since alarms are related to the state
on input like for ex. measured temperature above
alarm high-limit etc.)
Returns:
None
"""
self._logger.info("alarm_reset")
return self._alarm_reset()
input.alarm_reset = alarm_reset
def _sensor_type(self, channel, type=None, compensation=None):
""" Read
""" Read or set input type parameters
Args: According to the model, use the appropriate args
type (int): 0 to ?
compensation (int): 0=off and 1=on
example: input.sensor_type(type=3,compensation=1)
Returns:
<type>, <compensation>
"""
self._logger.info("_sensor_type")
if type is None:
......@@ -263,7 +230,6 @@ class LakeShore331(LogMixin):
state = "ON" if int(r[0]) == 1 else "OFF"
rate_value = float(r[1])
return {"state": state, "rate": rate_value}
if value < 0.1 or value > 100:
raise ValueError("Ramp value %s is out of bounds [0.1,100]" % value)
self.send_cmd("RAMP", 0, value, channel=channel)
......@@ -340,11 +306,6 @@ class LakeShore331(LogMixin):
kp, ki, kd = self.send_cmd("PID?", channel=channel).split(",")
return float(kp), float(ki), float(kd)
# Adding CUSTOM LOOP-object related method(s)
# ---------------------------------------------
def _add_custom_method_loop(self, loop):
self._logger.info("_add_custom_method_loop")
# General CUSTOM methods [valid for any type of object:
# input, output, loop]
# -----------------------------------------------------
......@@ -527,6 +488,7 @@ class LakeShore331(LogMixin):
self._logger.debug("values = {0}".format(values))
if "?" in command:
asw = self._comm.write_readline(cmd.encode() + self.eol.encode())
# print("asw = {0}".format(asw.decode()))
return asw.decode()
else:
self._comm.write(cmd.encode() + self.eol.encode())
......
......@@ -125,19 +125,16 @@ class LakeShore332(LogMixin):
# ------------
def _initialize_input(self, input):
self._logger.info("_initialize_input")
self._add_custom_method_input(input)
# - Output object
# -------------
def _initialize_output(self, output):
self._logger.info("_initialize_output")
# self._add_custom_method_output(output)
# - Loop object
# -----------
def _initialize_loop(self, loop):
self._logger.info("_initialize_loop")
self._add_custom_method_loop(loop)
# Get input object channel
ipc = loop.input.config["channel"]
# Get output object unit
......@@ -154,7 +151,7 @@ class LakeShore332(LogMixin):
Args:
channel (int): input channel. Valid entries: A or B
scale (str): temperature unit for reading: Kelvin or Celsius
or Sensor unit (Ohm or Volt)
or Sensor_unit (Ohm or Volt)
Returns:
(float): current temperature
"""
......@@ -186,38 +183,6 @@ class LakeShore332(LogMixin):
"Temperature OverRange in Sensor_unit on input %s" % channel
)
# Adding CUSTOM INPUT-object related method(s)
# --------------------------------------------
def _add_custom_method_input(self, input):
self._logger.info("_add_custom_method_input")
def alarm_status():
""" Shows high and low alarm state for given input
Args:
None
Returns:
high and low alarm state (str, str): "On/Off"
"""
self._logger.info("alarm_status")
return self._alarm_status(input.config.get("channel"))
input.alarm_status = alarm_status
def alarm_reset():
""" Clears both the high and low status of all alarms
Args:
None (though this command does not need the input channel,
we put it here, since alarms are related to the state
on input like for ex. measured temperature above
alarm high-limit etc.)
Returns:
None
"""
self._logger.info("alarm_reset")
self._alarm_reset()
input.alarm_reset = alarm_reset
def _sensor_type(self, channel, type=None, compensation=None):
""" Read or set input type parameters
Args: According to the model, use the appropriate args
......@@ -231,11 +196,6 @@ class LakeShore332(LogMixin):
if type is None:
return self.send_cmd("INTYPE?", channel=channel)
else:
typec, compensationc = self.send_cmd("INTYPE?", channel=channel)
if type is None:
type = typec
if compensation is None:
compensation = compensationc
self.send_cmd("INTYPE", type, compensation, channel=channel)
# Standard OUTPUT-object related method(s)
......@@ -350,11 +310,6 @@ class LakeShore332(LogMixin):
kp, ki, kd = self.send_cmd("PID?", channel=channel).split(",")
return float(kp), float(ki), float(kd)
# Adding CUSTOM LOOP-object related method(s)
# ---------------------------------------------
def _add_custom_method_loop(self, loop):
self._logger.info("_add_custom_method_loop")
# General CUSTOM methods [valid for any type of object:
# input, output, loop]
# -----------------------------------------------------
......@@ -541,6 +496,7 @@ class LakeShore332(LogMixin):
self._logger.debug("values = {0}".format(values))
if "?" in command:
asw = self._comm.write_readline(cmd.encode() + self.eol.encode())
# print("asw = {0}".format(asw.decode()))
return asw.decode()
else:
self._comm.write(cmd.encode() + self.eol.encode())
......
......@@ -124,19 +124,16 @@ class LakeShore340(LogMixin):
# ------------
def _initialize_input(self, input):
self._logger.info("_initialize_input")
self._add_custom_method_input(input)
# - Output object
# -------------
def _initialize_output(self, output):
self._logger.info("_initialize_output")
# self._add_custom_method_output(output)
# - Loop object
# -----------
def _initialize_loop(self, loop):
self._logger.info("_initialize_loop")
self._add_custom_method_loop(loop)
# Get input object channel
ipc = loop.input.config["channel"]
# Get output object unit
......@@ -153,7 +150,7 @@ class LakeShore340(LogMixin):
Args:
channel (int): input channel. Valid entries: A or B
scale (str): temperature unit for reading: Kelvin or Celsius
or Sensor unit (Ohm or Volt)
or Sensor_unit (Ohm or Volt)
Returns:
(float): current temperature
"""
......@@ -185,38 +182,6 @@ class LakeShore340(LogMixin):
"Temperature OverRange in Sensor_unit on input %s" % channel
)
# Adding CUSTOM INPUT-object related method(s)
# --------------------------------------------
def _add_custom_method_input(self, input):
self._logger.info("_add_custom_method_input")
def alarm_status():
""" Shows high and low alarm state for given input
Args:
None
Returns:
high and low alarm state (str, str): "On/Off"
"""
self._logger.info("alarm_status")
return self._alarm_status(input.config.get("channel"))
input.alarm_status = alarm_status
def alarm_reset():
""" Clears both the high and low status of all alarms
Args:
None (though this command does not need the input channel,
we put it here, since alarms are related to the state
on input like for ex. measured temperature above
alarm high-limit etc.)
Returns:
None
"""
self._logger.info("alarm_reset")
return self._alarm_reset(input.config.get("channel"))
input.alarm_reset = alarm_reset
def _sensor_type(
self,
channel,
......@@ -366,11 +331,6 @@ class LakeShore340(LogMixin):
kp, ki, kd = self.send_cmd("PID?", channel=channel).split(",")
return float(kp), float(ki), float(kd)
# Adding CUSTOM LOOP-object related method(s)
# ---------------------------------------------
def _add_custom_method_loop(self, loop):
self._logger.info("_add_custom_method_loop")
# General CUSTOM methods [valid for any type of object:
# input, output, loop]
# -----------------------------------------------------
......@@ -437,6 +397,7 @@ class LakeShore340(LogMixin):
def _alarm_status(self, channel):
""" Shows high and low alarm state for given input
Args:
channel (str): A or B
Returns:
high and low alarm state (str, str): "On/Off"
......@@ -555,7 +516,7 @@ class LakeShore340(LogMixin):
self._logger.debug("values = {0}".format(values))
if "?" in command:
asw = self._comm.write_readline(cmd.encode() + self.eol.encode())
# print("asw = {0}".format(asw))
# print("asw = {0}".format(asw.decode()))
return asw.decode()
else:
self._comm.write(cmd.encode() + self.eol.encode())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment