Commit 2e26ca9e authored by Perceval Guillou's avatar Perceval Guillou Committed by Matias Guijarro
Browse files

sorting methods and better comments

parent 1477c30e
......@@ -193,6 +193,7 @@ class Input(SamplingCounterController):
self._controller = controller
self._config = config
self._channel = None
# useful attribute for a temperature controller writer
self._attr_dict = {}
......@@ -223,7 +224,11 @@ class Input(SamplingCounterController):
return self._config
# ----------- METHODS THAT A CHILD CLASS MUST CUSTOMIZE ------------------
@property
def channel(self):
return self.config.get("channel")
# ----------- METHODS THAT A CHILD CLASS MAY CUSTOMIZE ------------------
@lazy_init
def read(self):
......@@ -260,7 +265,7 @@ class ExternalInput(Input):
except Exception:
pass
# ----------- METHODS THAT A CHILD CLASS SHOULD CUSTOMIZE ------------------
# ----------- METHODS THAT A CHILD CLASS MAY CUSTOMIZE ------------------
def read(self):
""" Return the input device value (in input unit) """
......@@ -354,9 +359,13 @@ class Output(SamplingCounterController):
return self._limits
@property
def channel(self):
return self.config.get("channel")
@autocomplete_property
def ramp(self):
""" Get the ramp object """
def soft_ramp(self):
""" Get the software ramp object """
return self._ramp
......@@ -380,7 +389,7 @@ class Output(SamplingCounterController):
setattr(self, name, method)
self.__custom_methods_list.append((name, types_info))
# ----------- METHODS THAT A CHILD CLASS SHOULD CUSTOMIZE ------------------
# ----------- METHODS THAT A CHILD CLASS MAY CUSTOMIZE ------------------
@lazy_init
def state(self):
......@@ -432,7 +441,10 @@ class Output(SamplingCounterController):
if (
self._use_soft_ramp is None
): # case where '_start_ramping' was never called previously.
return False
try:
return self._controller.is_output_ramping(self)
except NotImplementedError:
return False
elif self._use_soft_ramp:
......@@ -486,8 +498,14 @@ class Output(SamplingCounterController):
log_debug(self, "Output:_stop_ramping")
if self._use_soft_ramp is None:
self._controller.stop_output_ramp(self)
if (
self._use_soft_ramp is None
): # case where '_start_ramping' was never called previously.
try:
self._controller.stop_output_ramp(self)
except NotImplementedError:
pass
elif self._use_soft_ramp:
self._ramp.stop()
else:
......@@ -560,7 +578,7 @@ class ExternalOutput(Output):
self._ramp.stop()
# ----------- METHODS THAT A CHILD CLASS SHOULD CUSTOMIZE ------------------
# ----------- METHODS THAT A CHILD CLASS MAY CUSTOMIZE ------------------
def state(self):
""" Return the state of the output device"""
......@@ -712,6 +730,10 @@ class Loop(SamplingCounterController):
return self._config
@property
def channel(self):
return self.config.get("channel")
# @property
@autocomplete_property
def counters(self):
......@@ -738,8 +760,8 @@ class Loop(SamplingCounterController):
return self._output
@autocomplete_property
def ramp(self):
""" Get the ramp object """
def soft_ramp(self):
""" Get the software ramp object """
return self._ramp
......@@ -1013,7 +1035,7 @@ class Loop(SamplingCounterController):
<WaitMode.DEADBAND: 2> : READY when the processed value is in the 'deadband' around the scan point for a time >= 'deadband_time'.
"""
log_debug(self, "Loop:get_deadband")
log_debug(self, "Loop:get_wait_mode")
return self._wait_mode
@wait_mode.setter
......@@ -1023,7 +1045,7 @@ class Loop(SamplingCounterController):
<WaitMode.DEADBAND: 2> : READY when the processed value is in the 'deadband' around the scan point for a time >= 'deadband_time'.
"""
log_debug(self, "Loop:set_deadband: %s" % (value))
log_debug(self, "Loop:set_wait_mode: %s" % (value))
if isinstance(value, int):
self._wait_mode = self.WaitMode(value)
......@@ -1048,7 +1070,7 @@ class Loop(SamplingCounterController):
b = ymin - a * xmin
return value * a + b
# ----------- METHODS THAT A CHILD CLASS SHOULD CUSTOMIZE ------------------
# ----------- METHODS THAT A CHILD CLASS MAY CUSTOMIZE ------------------
@property
@lazy_init
......@@ -1198,7 +1220,10 @@ class Loop(SamplingCounterController):
if (
self._use_soft_ramp is None
): # case where '_start_ramping' was never called previously.
return False
try:
return self._controller.is_ramping(self)
except NotImplementedError:
return False
elif self._use_soft_ramp:
......@@ -1257,14 +1282,19 @@ class Loop(SamplingCounterController):
log_debug(self, "Loop:_stop_ramping")
if self._use_soft_ramp is None:
self._controller.stop_ramp(self)
if (
self._use_soft_ramp is None
): # case where '_start_ramping' was never called previously.
try:
self._controller.stop_ramp(self)
except NotImplementedError:
pass
elif self._use_soft_ramp:
self._ramp.stop()
else:
self._controller.stop_ramp(self)
@property
# @property
def plot(self):
if not self.reg_plot:
self.reg_plot = RegPlot(self)
......@@ -1717,7 +1747,7 @@ class RegPlot:
)
self.fig.submit(
"setGraphYLabel",
f"Output ({self.loop.output.config['unit']})",
f"Output ({self.loop.output.config.get('unit','')})",
axis="right",
)
self.fig.submit("setGraphGrid", which=True)
......
......@@ -53,10 +53,10 @@ with the mandatory fields:
"""
from gevent import lock
from bliss.common.regulation import Input, Output, Loop
from bliss.common.utils import set_custom_members
from bliss.common.logtools import log_info
from gevent import lock
class Controller:
......@@ -289,43 +289,6 @@ class Controller:
log_info(self, "Controller:state_output: %s" % (toutput))
raise NotImplementedError
# ------ raw methods ------------------------
def Wraw(self, str):
"""
A string to write to the controller
Raises NotImplementedError if not defined by inheriting class
Args:
str: the string to write
"""
log_info(self, "Controller:Wraw:")
raise NotImplementedError
def Rraw(self):
"""
Reading the controller
Raises NotImplementedError if not defined by inheriting class
returns:
answer from the controller
"""
log_info(self, "Controller:Rraw:")
raise NotImplementedError
def WRraw(self, str):
"""
Write then Reading the controller
Raises NotImplementedError if not defined by inheriting class
Args:
str: the string to write
returns:
answer from the controller
"""
log_info(self, "Controller:WRraw:")
raise NotImplementedError
# ------ PID methods ------------------------
def set_kp(self, tloop, kp):
......@@ -460,7 +423,7 @@ class Controller:
log_info(self, "Controller:get_setpoint: %s" % (tloop))
raise NotImplementedError
# ------ setpoint ramping methods ------------------------
# ------ setpoint ramping methods (optional) ------------------------
def start_ramp(self, tloop, sp, **kwargs):
"""
......@@ -583,10 +546,44 @@ class Controller:
log_info(self, "Controller:get_step: %s" % (tloop))
raise NotImplementedError
# ------ others ------------------------------
# ------ raw methods (optional) ------------------------
def _f(self):
pass
def Wraw(self, string):
"""
A string to write to the controller
Raises NotImplementedError if not defined by inheriting class
Args:
string: the string to write
"""
log_info(self, "Controller:Wraw:")
raise NotImplementedError
def Rraw(self):
"""
Reading the controller
Raises NotImplementedError if not defined by inheriting class
returns:
answer from the controller
"""
log_info(self, "Controller:Rraw:")
raise NotImplementedError
def WRraw(self, string):
"""
Write then Reading the controller
Raises NotImplementedError if not defined by inheriting class
Args:
string: the string to write
returns:
answer from the controller
"""
log_info(self, "Controller:WRraw:")
raise NotImplementedError
# ------ safety methods (optional) ------------------------------
def set_in_safe_mode(self, toutput):
"""
......@@ -599,7 +596,7 @@ class Controller:
log_info(self, "Controller:set_in_safe_mode: %s" % (toutput))
raise NotImplementedError
# ------ soft regulation only ??? ------------------------
# --- controller methods to customize the PID algo (optional) ------------------------
def get_sampling_frequency(self, tloop):
"""
......@@ -638,6 +635,8 @@ class Controller:
log_info(self, "Controller:set_pid_range: %s %s" % (tloop, pid_range))
raise NotImplementedError
# --- controller method to set the Output to a given value (optional) -----------
def set_output_value(self, toutput, value):
"""
Set the value on the Output device.
......@@ -650,7 +649,9 @@ class Controller:
log_info(self, "Controller:set_output_value: %s %s" % (toutput, value))
raise NotImplementedError
def start_output_ramp(self, toutput, value, **kwargs): # required by Output obj
# --- controller methods to handle the ramping on the Output (optional) -----------
def start_output_ramp(self, toutput, value, **kwargs):
"""
Start ramping on the output
Raises NotImplementedError if not defined by inheriting class
......@@ -691,7 +692,7 @@ class Controller:
log_info(self, "Controller:is_output_ramping: %s" % (toutput))
raise NotImplementedError
def set_output_ramprate(self, toutput, rate): # required by Output obj
def set_output_ramprate(self, toutput, rate):
"""
Set the output ramp rate
Raises NotImplementedError if not defined by inheriting class
......@@ -703,7 +704,7 @@ class Controller:
log_info(self, "Controller:set_output_ramprate: %s %s" % (toutput, rate))
raise NotImplementedError
def get_output_ramprate(self, toutput): # required by Output obj
def get_output_ramprate(self, toutput):
"""
Get the output ramp rate
Raises NotImplementedError if not defined by inheriting class
......
Supports Markdown
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