コード例 #1
0
    def __init__(self, config):
        ablauf.APNState.__init__(self, config["name"])

        _choices = []

        if "choices" in config:
            counter = 1
            for key, value in config["choices"].iteritems():
                if key == "Transit":
                    _transition = Transit(value, "choice")
                elif key == "Jump":
                    _transition = Jump(value)

                counter += 1
                _choices.append(_transition)

        if "default_transition" in config:
            _data = config["default_transition"]

            if _data["type"] == "Transit":
                _transition = Transit(_data["destination"], "default")
            elif _data["type"] == "Jump":
                _transition = Jump(_data["destination"])
        else:
            _transition = None

        self.name = config["name"]
        self.choices = _choices
        self.default_transition = _transition

        try:
            self.enter_function = self.enter_state
        except:
            self.enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.leave_function = self.leave_state
        except:
            self.leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        for _transition in self.choices:
            try:
                exec ("_transition_function = self.transition_to_" + _transition.destination + "_" + _transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("goto_" + _transition.destination, _transition.destination, _transition_function))

        if isinstance(self.default_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.default_transition.destination + "_" + self.default_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("exit_transition", self.default_transition.destination, _transition_function))
コード例 #2
0
    def __init__(self, config):
        ablauf.APNState.__init__(self, config["name"])

        if "exit_transition" in config:
            _data = config["exit_transition"]

            if _data["type"] == "Transit":
                _transition = Transit(_data["destination"], "exit")
            elif _data["type"] == "Jump":
                _transition = Jump(_data["destination"])
        else:
            _transition = None

        self.exit_transition = _transition
        self.processed = False

        try:
            self.enter_function = self.enter_state
        except:
            self.enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.leave_function = self.leave_state
        except:
            self.leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))
        if isinstance(self.exit_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.exit_transition.destination + "_" + self.exit_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("exit_transition", self.exit_transition.destination, _transition_function))
コード例 #3
0
    def __init__(self, config):
        """
        Wait for the given amount of milliseconds
        The enter function is only processed one time. When another state return to the Loop, it is not processed again until the loop is left.
        The leaving function is only called when the test_expression is reached.

        :param name:                        the name of the State
        :type name:                         string
        :param milliseconds:                the amount of milliseconds to wait
        :type milliseconds:                 int
        :param exit_transition:             the transition if the result if false
        :type exit_transition               function
        """
        ablauf.APNState.__init__(self, config["name"])

        if "exit_transition" in config:
            _data = config["exit_transition"]

            if _data["type"] == "Transit":
                try:
                    _event = _data["event"]
                except KeyError:
                    _event = None

                _transition = Transit(_data["destination"], "exit", _event)
            elif _data["type"] == "Jump":
                _transition = Jump(_data["destination"])
        else:
            _transition = None

        self.value = config["name"] + "_counter"
        ablauf.Data.session[self.value] = None

        self.iterator = None
        self.milliseconds = config["milliseconds"]
        self.exit_transition = _transition
        self.initialized = False
        self.finalize = False
        self.enter_function = self.init_iteration
        self.leave_function = self.exit_loop

        try:
            self.additional_enter_function = self.enter_state
        except:
            self.additional_enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.effective_leave_function = self.leave_state
        except:
            self.effective_leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        if isinstance(self.exit_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.exit_transition.destination + "_" + self.exit_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("exit_transition", self.exit_transition.destination, _transition_function))
コード例 #4
0
    def __init__(self, config):
        """
        Processes a dialog and then transit to another state

        :param name:                        the name of the State
        :type name:                         string
        :param exit_transition:             the transition after the task is processed
        :type exit_transition               function
        """
        ablauf.APNState.__init__(self, config["name"])

        # check transitions
        # --------------------------------------------------------------------------------------------------------------
        if "exit_transition" in config:
            _data = config["exit_transition"]

            if _data["type"] == "Transit":
                _transition = Transit(_data["destination"], "exit")
            elif _data["type"] == "Jump":
                _transition = Jump(_data["destination"])
        else:
            _transition = None

        self.exit = False
        self.exit_transition = _transition

        try:
            self.enter_function = self.enter_state
        except:
            self.enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.leave_function = self.leave_state
        except:
            self.leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        if isinstance(self.exit_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.exit_transition.destination + "_" + self.exit_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("exit_transition", self.exit_transition.destination, _transition_function))
コード例 #5
0
    def __init__(self, config):
        """
        A decision is taken and depending on the result, the state changes.

        :param name:                        the name of the State
        :type name:                         string
        :param yes_transition:              the transition if the result is true
        :type yes_transition                function
        :param no_transition:               the transition if the result if false
        :type no_transition                function
        """
        ablauf.APNState.__init__(self, config["name"])

        if "yes_transition" in config:
            _data = config["yes_transition"]

            if _data["type"] == "Transit":
                _yes_transition = Transit(_data["destination"], "yes")
            elif _data["type"] == "Jump":
                _yes_transition = Jump(_data["destination"])
        else:
            _yes_transition = None

        if "no_transition" in config:
            _data = config["no_transition"]

            if _data["type"] == "Transit":
                _no_transition = Transit(_data["destination"], "no")
            elif _data["type"] == "Jump":
                _no_transition = Jump(_data["destination"])
        else:
            _no_transition = None

        self.yes_transition = _yes_transition
        self.no_transition = _no_transition

        try:
            self.enter_function = self.enter_state
        except:
            self.enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.leave_function = self.leave_state
        except:
            self.leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        if isinstance(self.yes_transition, Transit):
            _transition_function = None
            try:
                exec ("_transition_function = self.transition_to_" + self.yes_transition.destination + "_" + self.yes_transition.type)
            except Exception as ex:
               pass

            self.add_transition(ablauf.Transition("yes_transition", self.yes_transition.destination, _transition_function))

        if isinstance(self.no_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.no_transition.destination + "_" + self.no_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("no_transition", self.no_transition.destination, _transition_function))
コード例 #6
0
    def __init__(self, config):
        """
        A function is processed as many time as defined in the iterator function.
        The enter function is only processed one time. When another state return to the Loop, it is not processed again until the loop is left.
        The leaving function is only called when the end of the iteration is reached.

        :param name:                        the name of the State
        :type name:                         string
        :param exit_transition:             the transition if the result if false
        :type exit_transition               function
        :param loop_transition:             the transition if the result is true
        :type loop_transition               function
        """
        ablauf.APNState.__init__(self, config["name"])

        if "exit_transition" in config:
            _data = config["exit_transition"]

            if _data["type"] == "Transit":
                _exit_transition = Transit(_data["destination"], "exit")
            elif _data["type"] == "Jump":
                _exit_transition = Jump(_data["destination"])
        else:
            _exit_transition = None

        if "loop_transition" in config:
            _data = config["loop_transition"]

            if _data["type"] == "Transit":
                _loop_transition = Transit(_data["destination"], "loop")
            elif _data["type"] == "Jump":
                _loop_transition = Jump(_data["destination"])
        else:
            _loop_transition = None

        self.value = config["name"] + "_element"
        ablauf.Data.session[self.value] = None

        self.iterator = None

        self.loop_transition = _loop_transition
        self.exit_transition = _exit_transition
        self.initialized = False
        self.finalize = False

        self.enter_function = self.init_iteration
        self.leave_function = self.exit_loop

        try:
            self.additional_enter_function = self.enter_state
        except:
            self.additional_enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.effective_leave_function = self.leave_state
        except:
            self.effective_leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        if isinstance(self.loop_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.loop_transition.destination + "_" + self.loop_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("loop_transition", self.loop_transition.destination, _transition_function))

        if isinstance(self.exit_transition, Transit):
            _transition_function = None
            try:
                exec ("_transition_function = self.transition_to_" + self.exit_transition.destination + "_" + self.exit_transition.type)
            except Exception as ex:
                pass

            self.add_transition(ablauf.Transition("exit_transition", self.exit_transition.destination, _transition_function))
コード例 #7
0
    def __init__(self, config):
        """
        A function is processed as long as the test_expression is not reached.
        The enter function is only processed one time. When another state return to the Loop, it is not processed again until the loop is left.
        The leaving function is only called when the test_expression is reached.

        :param name:                        the name of the State
        :type name:                         string
        :param exit_transition:             the transition if the result if false
        :type exit_transition               function
        :param loop_transition:             the transition if the result is true
        :type loop_transition               function
        """
        ablauf.APNState.__init__(self, config["name"])

        if "exit_transition" in config:
            _data = config["exit_transition"]

            if _data["type"] == "Transit":
                _exit_transition = Transit(_data["destination"], "exit")
            elif _data["type"] == "Jump":
                _exit_transition = Jump(_data["destination"])
        else:
            _exit_transition = None

        if "loop_transition" in config:
            _data = config["loop_transition"]

            if _data["type"] == "Transit":
                _loop_transition = Transit(_data["destination"], "loop")
            elif _data["type"] == "Jump":
                _loop_transition = Jump(_data["destination"])
        else:
            _loop_transition = None

        self.test_expression = None
        try:
            exec ("self.test_expression = self.test")
#            exec ("self.test_expression = ablauf.Automate.custom_controllers[\"" + self.process_name + "\"].test_" + self.name)
        except:
            ablauf.logger.error("State: {0} has no test expression".format(self.name))
            raise Exception("Mandatory process controller function was not found")

        self.loop_transition = _loop_transition
        self.exit_transition = _exit_transition
        self.initialized = False
        self.finalize = False

        self.enter_function = self.init_iteration
        self.leave_function = self.exit_loop

        try:
            self.additional_enter_function = self.enter_state
        except:
            self.additional_enter_function = None
            ablauf.logger.debug("State: {0} has no enter function".format(self.name))

        try:
            self.effective_leave_function = self.leave_state
        except:
            self.effective_leave_function = None
            ablauf.logger.debug("State: {0} has no leave function".format(self.name))

        if isinstance(self.loop_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.loop_transition.destination + "_" + self.loop_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("loop_transition", self.loop_transition.destination, _transition_function))

        if isinstance(self.exit_transition, Transit):
            try:
                exec ("_transition_function = self.transition_to_" + self.exit_transition.destination + "_" + self.exit_transition.type)
            except:
                _transition_function = None

            self.add_transition(ablauf.Transition("exit_transition", self.exit_transition.destination, _transition_function))