Commit d818139f authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

AT5-262: removed a subtle bug from CmdInputArgsCheck decorator.

parent c61b7fe6
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -133,11 +133,19 @@ class CmdInputArgsCheck(object):
                                             tango.ErrSeverity.ERR)
            input_arg = args[1]
            device_list = input_arg
            # Note: device list is a reference to args[1]: changing
            # device_list content, args[1] changes accordingly!
            num_of_devices = len(input_arg)
            if num_of_devices == 0:
                # no input argument -> switch on all sub-elements
                num_of_devices = len(dev_instance._se_fqdn)
                device_list = dev_instance._se_fqdn
                # !!Note!!:
                # need to copy inside device_list to maintain the reference to args[1]
                # if we do 
                # device_list = dev_instance._se_fqdn 
                # we get a new variable address and we lose the reference to args[1]
                for fqdn in dev_instance._se_fqdn:
                    device_list.append(fqdn)
            else:
                if num_of_devices > len(dev_instance._se_fqdn):
                    # too many devices specified-> log the warning but go on
@@ -207,6 +215,7 @@ class CmdInputArgsCheck(object):
            # expected value.
            cmd_time_attr_name = cmd_to_exec + "DurationExpected"
            for device in device_list:
                print("Processing device:", device)
                # set to QUEUED. This state can be useful in case of command abort.
                dev_instance._se_cmd_execution_state[device][cmd_to_exec] = CmdExecState.QUEUED
                # reset the timeout and alarm attribute content
@@ -222,7 +231,9 @@ class CmdInputArgsCheck(object):
                    # call device_proxy.onCmdDurationExpected throws an AttributeError exception 
                    # (not tango.DevFailed)
                    #dev_instance._se_cmd_duration_expected[device][cmd_to_exec] = device_proxy.onCmdDurationExpected
                    dev_instance._se_cmd_duration_expected[device][cmd_to_exec] = device_proxy.read_attribute(cmd_time_attr_name)
                    # read_Attribute returns a DeviceAttribute object
                    device_attr = device_proxy.read_attribute(cmd_time_attr_name)
                    dev_instance._se_cmd_duration_expected[device][cmd_to_exec] = device_attr.value
                except tango.DevFailed as tango_err:
                    # we get here if the attribute is not implemented
                    dev_instance.dev_logging((tango_err.args[0].desc), tango.LogLevel.LOG_INFO)
@@ -238,13 +249,16 @@ class CmdInputArgsCheck(object):
                # note: if the xxxDurationExpected attribute read fails, it is used the default value 
                # returned from the defauld dictionary used to initialize the _se_cmd_duration_expected
                # attribute
                print("_se_cmd_duration_expected:",dev_instance._se_cmd_duration_expected[device][cmd_to_exec] )
                command_timeout +=  dev_instance._se_cmd_duration_expected[device][cmd_to_exec]
                print("command:", command_timeout)
            # device loop end
            # use the greatest value for the onCommand duration expected.
            if command_timeout > dev_instance._cmd_duration_expected[cmd_to_exec]:
                dev_instance._cmd_duration_expected[cmd_to_exec] = command_timeout
                dev_instance.dev_logging("Modified the {} command Duration Expected value!!".format(cmd_to_exec),
                                tango.LogLevel.LOG_INFO)
            print("decorator end")
            return f(*args, **kwargs)
        return input_args_check