示例#1
0
    def __acb_com_cmd_list(self, cmd_list, check_relay_position=False):
        """
        execute sequentially a list of action on relays

        :type cmd_list: list
        :param cmd_list: list of (action,relay where to apply action)

        :type check_relay_position: boolean
        :param check_relay_position: if True then will check all the relay state before doing
                                    the relay activation and if all is already in the wanted state
                                    then no action will be taken

        :rtype: boolean
        :return: True if actions have been taken on relay, False otherwise
        """
        if check_relay_position:
            is_relay_position_ok = True
            # check all relay in given command
            for action, relay in cmd_list:
                # exit if at least one relay is not in the wanted position
                if action != W.GetState(self, relay):
                    is_relay_position_ok = False
                    break

            # if all relay are already positioned then skip any action
            if is_relay_position_ok:
                return False

        for action, relay in cmd_list:
            self.__acb_com_cmd(action, relay)

        return True
示例#2
0
    def _is_relay_already_positioned(self, cmd_list):
        """
        Check if an array of relay is already well positioned
        according of expecting state given by the array.

        :type cmd_list: list
        :param cmd_list: list of (action,relay where to apply action)
                        or you can add a 3rd element like following (action, relay,time_to_wait)

        :rtype: boolean
        :return: True if relays are well positioned, False otherwise
        """
        is_relay_position_ok = True
        # check all relay in given command
        for element in cmd_list:
            action = element[0]
            relay = element[1]
            # exit if at least one relay is not in the wanted position
            if action != W.GetState(self, relay):
                is_relay_position_ok = False
                break

        return is_relay_position_ok