メインコンテンツまでスキップ
バージョン: DAI 6.5

Setting Preconditions for Actions

You can set preconditions on model actions in Eggplant DAI so that the action can't be called during a model run unless specific conditions are met. For instance, you might have a button in your application that becomes active only if you enter text in a field first. In this case, you could use a precondition on the button action to ensure the model couldn't call it unless the field text was entered first. Another use case might be if you have a global action that shouldn't be called from a certain state.

Setting an action precondition involves three steps:

Create a Parameter

Parameters for preconditions are created the same as any other parameter. The parameter can be a state parameter or a global parameter. Your choice will be based on the condition you want the model execution to meet before performing the action.

If the precondition is based on another action within the same state, you'll use a state parameter. For instance, you might have a login screen where a username and password must be entered before you can click the OK button. If you build your model such that each of those is a separate action, then both the username action and the password action could be set as preconditions to the OK action, using state parameters.

An Eggplant AI model state for a login screen An Eggplant DAI model state for a login screen

You could use a global parameter as a precondition for something that happens at one point in your model but could block the actions in multiple other places. For instance, you might need a user to log in to the system to access some features but not others. In this case, you would set the global parameter when the log in action takes place, then use that as the precondition for each action elsewhere in the model that requires a logged in user.

ヒント

The currentState parameter is a special predefined global parameter that contains the name of the current state. You can use this parameter to prevent a global action from being called from a specific state. For instance, if you have a global action for Quit, you might want to block that action from being called from your Initial state.

For information about creating parameters, see State Parameters Section.

Set the Evaluation Condition

To meet a precondition before accessing an action, you set an evaluation condition for a parameter. If the value for the parameter isn't correct, the given action can't be called by the model execution.

You set the evaluation condition on the Action Properties tab in the Preconditions for this Action to Execute section. Follow these steps to set an evaluation condition:

  1. Select the action in the Model tab that you want to apply a precondition to. In the right pane, the Action Properties tab should become the focus. In the Preconditions for this Action to Execute section, you'll see a listing of all the state parameters and global parameters available to the selected action.

    Set the evaluation condition for an action

  2. For the parameter you want to evaluate against, select the evaluation condition from the Condition list menu.

  3. In the Value field, enter or select the value to evaluate against. The value you enter should be consistent with the parameter type, which is shown in the Type field.

Note that you can set a precondition on multiple parameters for a single action.

For more information about the Preconditions section on the Action Properties tab, see Preconditions for this Action to Execute Section.

Set or Change Parameter Value

A precondition evaluation is based on a parameter having a specified value. You can change the value of a parameter when it encounters a specific action in the model by using the Set and Generate Parameter Values section on the Action Properties tab. Follow these steps to set or change a parameter value during model execution:

  1. Select the action in the Model workspace that you want to use to trigger a parameter value change. In the right pane, the Action Properties tab should be visible. In the Set and Generate Parameter Values section, you'll see a listing of all the state parameters and global parameters available to the selected action.

    Configure Action Parameters

  2. For the parameter you want to change, select the change type from the Operation list menu:

    • set: Use this option to select a specific value. When you're using this capability for preconditions, this option will mostly likely be the right choice.
    • generate: Use this option if you want to generate a value based on criteria appropriate to the parameter type.
  3. In the Value field, enter or select the value to set for the parameter. The value you enter should be consistent with the parameter type, which is shown in the Type field.

In addition to using the Set and Generate Parameter Values section to change parameter values, you can pass parameters to SenseTalk snippets to affect their values, then use those parameters as preconditions for actions.

For more information about the Generate Parameter section of the Action Properties tab, see Set and Generate Parameter Values.