The Configure the state machine page allows you to configure a state machine in a single page. This page consists of three main areas:
The Accordion -- On the left side of the page is a pane called the Accordion that provides two views, States and Applies To. When you display this page for a new State Machine, the States view is displayed ("on top"). When you display this page for an existing State Machine, the view that was last displayed on top of the Accordion is displayed.
States view -- From this view you can add new states to the State Machine, edit the names of states, change the order in which states are processed, move expression rules from one state to another, remove expression rules from states, and remove states and all their expression rules. Note that you cannot control the order in which the expression rules within a state are processed from this view.
Note: if you see the violation icon () next to the name of a State, expand the State so that you can see which expression rule has been disabled due to recursion or execution policy violation. To re-enable the state machine, you need to edit the expression rule(s) for the State so that recursion or execution policy violations are prevented. For details about recursion, refer to Recursive Expression Rules; for details about execution policy violations, see Expression Rules that violate execution policies.
Applies To view -- From this view, you can apply the state machine to models and assets so that the state machine runs only for all assets of the selected models. Further, you can include and exclude assets of a particular model, such that the state machine runs for included assets but not for excluded assets. Once state machines have been applied to models and assets, the Accordion displays them in the following groupings: All assets of these Models, Plus the following Assets, and But never to these Assets.
To add or change the models and assets for a state machine, click the pencil icon (). The page Apply this state machine to models and assets appears on top of this page.
State Machine general information - The fields under the title, State Machine, provide the general information for the State Machine: its Name, a Description of what it does, and the Enabled flag, The Enabled check box is selected by default, which means that by default the State Machine, its states and expression rules will be processed for the models and assets to which the state machine has been applied. Below the Expression Rule for state area are the buttons that apply to the entire State Machine configuration: Validate, Save and New, Save, and Cancel.
Expression Rule for state -- Below the general information is a form for adding and editing expression rules for a selected state of the State Machine. This form lets you choose the State to which you want to apply the expression rule and then add/edit the expression rule in much the same ways as you add/edit expression rules for models and assets:
On the left side of the Expression Rule form is the Expression Tree, which displays lists of available objects for an expression rule in three categories: Variables, Functions, and Actions. A message, or trigger, serves as the Type for an expression rule. Each Type has a set of associated Variables (including namespaces), Functions, and Actions that you can use to create expressions. When creating an expression rule, you select the Type of trigger and then select the objects for the If, Then, and Else expressions of the rule.
On the right side of the Expression Rule for state form are the general fields for the expression rule, a dropdown list of states that have been added to the State Machine, the If, Then, and Else expression fields, and the buttons that are strictly for validating and saving the expression rule for the state.
1. In the Name field, type a unique identifier for the state machine. This information is required and can be edited. You can use up to 50 alphanumeric and special characters. The state machine appears by this name in the pages of the Axeda® Connected Product Management Applications.
2. Optional - in the Description field, type a brief explanation of the purpose and actions of the state machine. You can use up to 2000 characters (no limitations). For example, you may want to list the states and transitions for the state machine.
3. In the Accordion, if the States view is not currently displayed, select States.
4. Depending on whether you are adding or editing a state, this step varies:
§ To add a new state, select Add State. Continue to the next step.
§ If you want to change the name of an existing state, double-click the state name in the Accordion and once the current name is highlighted, type a new name. Press ENTER to save the change. Continue to step 6 if you want to add or edit an expression rule for the state. If you have finished editing the state machine, continue to step 18.
5. In
the States view, [EDIT ME] appears.
Double-click this entry and then type a name for the new state and press
ENTER. You can use up to 50 alphanumeric and special characters for a
state name.
Next, you will create an expression rule for the state.
6. On the Expression Rule form, make sure that the name of the state for which you want to add (or edit) an expression rule is displayed in the State field. When editing a state machine, you can select the state in the States view of the Accordion or click the arrow in this field to display the list of the states configured for the state machine.
7. Depending on whether you are adding or editing an expression rule, this step varies:
§ Adding an expression rule - In the Name field for the expression rule, type a unique identifier for the expression rule. You can use up to 50 alphanumeric and special characters in this field.
Note: While you can use a Name that is the same as an expression rule in another state or that was created outside of state machines, Axeda recommends that you keep the names of expression rules unique as much as possible. You cannot use the same name for two expression rules within the same state.
§ Editing an expression rule - In the Accordion, expand the node for the State and then click the name of the expression rule you want to edit. If you want to edit the Name of the expression rule, you can do so. You can use up to 50 alphanumeric and special characters in this field. Otherwise, continue to the step for the component of the expression rule that you want to change.
8. Optional: Type a Description of the expression rule. This description is not displayed anywhere else, except in this configuration page for the rule. You can use up to 2000 characters (no limitations on types of characters).
9. From the Type list in the Expression Rule for state form, select the type of message, or trigger, for this expression rule. This selection is required and specifies what condition in the Platform causes this rule to execute. For complete details about the available events, refer to the topic, Triggers for Expression Rules.
10. By default, a new expression rule is enabled (the check box is selected). If you want to disable the rule, clear the check box next to Enabled.
11. If
the actions for this expression rule are to be executed each time the
rule evaluates, select the check box next to Execute
action each time rule evaluates to true (selected by default).
If you do not select this option, the actions for this rule (defined in
the Then
and Else
expressions) will be executed upon the first evaluation to a Boolean value
(true or false). Then, the If expression
must evaluate to the opposite Boolean value and back again for actions
to execute.
For example, a rule that creates an alarm when the expression, If temp
> 82, evaluates to true (the temperature exceeds 82 degrees),
would create an alarm every time the value of temp is over the limit when
this option is selected. If this option is not selected, one alarm will
be created when temp exceeds 82, then the temp must go below 82 (the temp
> 82 expression must evaluate to false) and then rise above it again
(that is, the temp > 82 expression must evaluate to true again) before
another alarm is created.
Next you will create the expressions
for the rule. You can create the If, Then, Else expressions in any order.
The remaining steps assume you are creating the If
expression first.
12. Use the Expression Tree to create the If, Then, and Else expressions:
§ Click the icon next to Variables, Functions, or Actions to display the list of objects that are available for the event Type selected.
§ To see details for an object, click the name of the object once. A definition and information about what the variable returns are displayed in the Details pane below the expressions.
§ To insert an object in the If, Then, or Else field, click in the field and then double-click the name of the object.
§ To collapse a list of objects, click .
For details on the syntax for the expressions, refer to the following topics:
§ General information about the syntax - Expression Rule Syntax. and Syntax rules for Expression Rules
§ Variables - Namespaces in Expression Rules
§ Functions - Functions reference for expression rules
§ Operators - Supported Operators for Expression Rules
§ Actions - Actions Reference for Expression Rules
13. Position the cursor in the If expression field. Then double-click the names of objects (Variables, Functions) in the Expression Tree to insert them in the If expression and type any appropriate operators or parameters in the If expression field. (Actions are not valid in the If expression.) The If expression MUST evaluate to true or false.
14. To create the Then and Else expressions, position the cursor in the appropriate field. Review the available objects (Variables, Functions, and Actions) in the Expression Tree to find the ones you need, and then double-click the names of the objects to insert them in the fields. For the Then expression, choose the actions that the Platform will run when the If expression evaluates to true. For the Else expression, choose the actions that the Platform will run when the If expression evaluates to false. Use variables and functions to complete these expressions.
15. At any point you can validate your expressions and verify that the structure, syntax, and defined parameter values are correct. To validate your expression without saving it to the Platform, click Validate. This action will check the syntax and format of your expression; it will NOT validate the Variable objects. If invalid syntax is found, the field containing the invalid syntax is shaded in red. If the syntax is valid, the fields are shaded in green. For assistance with the error, move the cursor into the red field; a popup message from the parser displays possible causes for the error. For details about valid syntax, refer to Syntax rules for expression rules.
Note: Validation is important to ensure that your state machine runs the way you expect. Since you may have other configuration tasks to perform before validation of a rule or state machine will be successful (turn the fields green), the Platform allows you to save an expression rule or a state machine without validating. However, it is recommended that you take advantage of the validation, sometime before enabling the state machine in a production environment.
16. When you are ready to save your expression rule, click Save. This action saves the expression rule with the state. The name of the expression rule appears under the selected state in the States view of the Accordion.
17. Continue adding states and expression rules for your state machine.
18. When
ready, click Validate to verify
the state machine, and then click one of the following buttons:
Save to save the state machine
and return to the View and manage
state machines page.
Save and New to save the state
machine and refresh the form so that you can create another state machine.
Cancel to discard all your changes
and return to the View and manage state machines page.