In essence, a condition is a monitored boolean expression, what means that whenever
some of the referenced entities (e.g., beliefs) change the expression of the condition is
evaluated. Associated with a condition is an action, that gets executed whenever the
condition is triggered. Context-specific conditions as defined in the ADF have special
associated actions (e.g., for activating goals). For custom conditions created by plans
the default action is to generate an internal event of type
jadex.model.IMEventbase.TYPE_CONDITION_TRIGGERED
.
The behavior of a custom condition can be adjusted with the trigger attribute. Note, that the trigger types of predefined conditions such as goal or plan creation conditions cannot be changed. Several trigger types are available: A condition can be triggered, e.g., whenever it is evaluated to true, or only triggered when its value first changes to true, but not when it stays true for some time. The list of available trigger types is given in Table 11.1, “Condition Trigger Types”. The default trigger type of a predefined condition depends on the context, for example the maintain condition of a maintain goal is triggered when the expression value changes to false, because the goal should be processed whenever the maintain condition is violated.
Table 11.1. Condition Trigger Types
Name | Description |
---|---|
changes_to_true | Execute action when expression value changes to true |
changes_to_false | Execute action when expression value changes to false |
changes | Execute action when the expression value changes |
is_true | Execute action whenever expression evaluates to true |
is_false | Execute action whenever expression evaluates to false |
always | Execute action whenever expression is evaluated (regardless of value) |
When programming plans, it is also possible to explicitly wait for
certain conditions using the waitForCondition(ICondition cond)
method. Conditions are obtained in a similar fashion to expressions,
either by instantiating a predefined condition from the ADF (see Figure 11.1, “The Jadex conditions XML schema part”),
or by creating a new condition from an expression string. When waiting for a condition,
the plan will be blocked until the condition triggers, which by default means that its
value changes to true. The condition is monitored automatically
by the agent, by considering all internal state changes that may affect
the condition value, e.g., when some other plan changes a belief.
The following example uses the "timer" belief from Section 6.3, “Dynamically Evaluated Beliefs”
to execute some action when the alarmtime has reached (belief not shown here).