Beispiel #1
0
    def __init__(self, agent, sense_name, value = None, predicate = None):
        """Picks the given sense or sense-act from the given agent.

        The method uses the agent's behaviour dictionary to get the
        sense / sense-act method.
        
        The log domain is set to "[AgentName].Sense.[sense_name]".

        The sense name is set to "[BehaviourName].[sense_name]".
        
        @param agent: The agent that can use the sense.
        @type agent: L{SPOSH.Agent}
        @param sense_name: The name of the sense
        @type sense_name: string
        @param value: The value to compare it to. This is given as a string,
            but will be converted to an integer or float or boolean, or
            left as a string, whatever is possible. If None is given
            then the sense has to evaluate to 1.
        @type value: string
        @param predicate: "==", "!=", "<", ">", "<=", ">=". If None is
            given, then "==" is assumed.
        @type predicate: string
        """
        ElementBase.__init__(self, agent, "Sense.%s" % sense_name)
        beh_dict = agent.getBehaviourDict()
        self._sense = beh_dict.getSense(sense_name)
        behaviour = beh_dict.getSenseBehaviour(sense_name)
        self._name = "%s.%s" % (behaviour.getName(), sense_name)
        self._value = self._convertValue(value)
        if not predicate:
            self._pred = "=="
        else:
            self._pred = predicate
        self.debug("Created")
Beispiel #2
0
    def __init__(self, agent, sense_name, value=None, predicate=None):
        """Picks the given sense or sense-act from the given agent.

        The method uses the agent's behaviour dictionary to get the
        sense / sense-act method.
        
        The log domain is set to "[AgentId].Sense.[sense_name]".

        The sense name is set to "[BehaviourName].[sense_name]".
        
        @param agent: The agent that can use the sense.
        @type agent: L{POSH.strict.Agent}
        @param sense_name: The name of the sense
        @type sense_name: string
        @param value: The value to compare it to. This is given as a string,
            but will be converted to an integer or float or boolean, or
            left as a string, whatever is possible. If None is given
            then the sense has to evaluate to True.
        @type value: string
        @param predicate: "==", "!=", "<", ">", "<=", ">=". If None is
            given, then "==" is assumed.
        @type predicate: string
        """
        ElementBase.__init__(self, agent, "Sense.%s" % sense_name)
        beh_dict = agent.getBehaviourDict()
        self._sense = beh_dict.getSense(sense_name)
        self.behaviour = beh_dict.getSenseBehaviour(sense_name)
        self._name = "%s.%s" % (self.behaviour.getName(), sense_name)
        self._value = self._convertValue(value)
        if not predicate:
            self._pred = "=="
        else:
            self._pred = predicate
        self.log.debug("Created")
Beispiel #3
0
    def __init__(self, agent, senses):
        """Initialises the trigger.

        The log domain is set to [Agent].T.[senseName1+senseName2+...]

        @param agent: The agent that uses the trigger.
        @type agent: L{SPOSH.Agent}
        @param senses: The list of senses and sense-acts for the trigger.
        @type senses: Sequence of L{SPOSH.Sense}
        """
        ElementBase.__init__(self, agent, "T.%s" % \
                             '+'.join(map(Sense.getName, senses)))
        self._senses = senses
        self.debug("Created")
Beispiel #4
0
    def __init__(self, agent, senses):
        """Initialises the trigger.

        The log domain is set to [Agent].T.[senseName1+senseName2+...]

        @param agent: The agent that uses the trigger.
        @type agent: L{POSH.strict.Agent}
        @param senses: The list of senses and sense-acts for the trigger.
        @type senses: Sequence of L{POSH.strict.Sense}
        """
        ElementBase.__init__(self, agent, "T.%s" % \
                             '+'.join(map(Sense.getName, senses)))
        self._senses = senses
        self.log.debug("Created")