ALBA-Synchrotron / sardana-icepap

IcePAP plugins for Sardana
GNU General Public License v3.0
0 stars 2 forks source link

Remove memorization of IcePAPCtrl PowerOn attr #18

Closed ajoubertza closed 1 year ago

ajoubertza commented 1 year ago

Having the PowerOn attribute memorized can cause a problem when the controller is restarted. Specifically, if the memorized value is true, but the IcePAP controller cannot turn on the power. This means the attribute initialisation fails, and the controller gets stuck in Alarm state. The only way to recover is to write a value of false to the attribute, and then restart the controller (i.e., Sardana Pool) again.

This often occurs after a PLC lockout on the motors, and prevents us homing the motor again.

Not memorizing the attribute solves this problem. In general, we prefer Tango devices that do not try to modify the state of the hardware they control on startup.

Is there a reason the attribute must be memorized?

Example stack trace showing error during Pool startup (Sardana 3.3.5, sardana-icepap 1.0.2):

MainThread     DEBUG    2022-10-10 10:06:34,589 mono_gpit: PowerOn failed to init with True
Traceback (most recent call last):
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolcontroller.py", line 552, in set_axis_attr
    return getattr(self.ctrl, axis_attr_info.fset)(axis, value)
AttributeError: 'IcepapController' object has no attribute 'setPowerOn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolelement.py", line 132, in init_attribute_values
    self._set_attribute_value(attr_name, value)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolelement.py", line 101, in _set_attribute_value
    self.set_extra_par(attr_name, value)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolelement.py", line 222, in set_extra_par
    return self.controller.set_axis_attr(self.axis, name, value)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolcontroller.py", line 284, in wrapper
    return fn(pool_ctrl, *args, **kwargs)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana/pool/poolcontroller.py", line 554, in set_axis_attr
    return self.ctrl.SetAxisExtraPar(axis, name, value)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/sardana_icepap/ctrl/IcePAPCtrl.py", line 714, in SetAxisExtraPar
    self.ipap[axis].__setattr__(attr, value)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/icepap/axis.py", line 559, in power
    self.send_cmd(cmd)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/icepap/axis.py", line 1409, in send_cmd
    return self._ctrl.send_cmd(cmd)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/icepap/controller.py", line 335, in send_cmd
    return self._comm.send_cmd(cmd)
  File "/opt/conda/envs/sardana/lib/python3.9/site-packages/icepap/communication.py", line 98, in send_cmd
    raise RuntimeError(msg.format(ans))
RuntimeError: Error sending command, IcePAP answered 17:POWER ERROR Power cannot be switched on
rhomspuron commented 1 year ago

Hi @ajoubertza,

This is a good point, the version 1.3.2 fix this problem it happens not only with the poweron, the velocity, acceleration and other attributes can not set if the axis has problems.

Roberto

ajoubertza commented 1 year ago

This is a good point, the version 1.3.2 fix this problem

@rhomspuron I guess you referring to this change: https://github.com/ALBA-Synchrotron/sardana-icepap/pull/6. I see how that will prevent this exception happening.

It could also hide real problems that occur after initialisation. However, since we can't really tell when Sardana is busy with the device initialisation there isn't an easy solution.

Closing this, as not longer required.