diff --git a/src/PilatusXM.py b/src/PilatusXM.py index 7648c16dc2c3401249f5ac8ee2dace59d3b318d8..44e1d53751ef01e62844f2930313f2f9fd6cb01b 100755 --- a/src/PilatusXM.py +++ b/src/PilatusXM.py @@ -730,14 +730,19 @@ class PilatusXM (PyTango.LatestDeviceImpl): if not self.Simulation: cmd = "SetThreshold" reply_cmd = "threshold: " - reply = self.comm.send_to_detector(cmd) - if reply is None: - PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_Threshold") - elif reply_cmd in reply: - self.attr_Threshold_read = int((reply.split(reply_cmd)[-1]).split(" ")[0]) - elif "Threshold has not been set" in reply: - PyTango.Except.throw_exception("Pilatus error","Threshold has not been set","read_Threshold") - else: + retries = 5 + while (retries > 0): + reply = self.comm.send_to_detector(cmd) + if reply is None: + PyTango.Except.throw_exception("Communication error","Pilatus does not reply","read_Threshold") + elif reply_cmd in reply: + self.attr_Threshold_read = int((reply.split(reply_cmd)[-1]).split(" ")[0]) + break + elif "Threshold has not been set" in reply: + PyTango.Except.throw_exception("Pilatus error","Threshold has not been set","read_Threshold") + retries -= 1 + time.sleep(0.2) + if retries == 0: PyTango.Except.throw_exception("Communication error","Pilatus wrong reply","read_Threshold") attr.set_value(self.attr_Threshold_read)