IBehaviourModel (ITF)ΒΆ

INTERFACE IBehaviourModel EXTENDS __SYSTEM.IQueryInterface

Implemented by the function block BehaviourModel.

This interface provides all methods and properties which are necessary for controlling a BehaviourModel instance via interface reference variables.

When operating via an interface reference variable it should be possible to decide exactly when the state machine is called. For this the methods StartModel, AbortModel, ResetModel and GetModelState has a parameter xCommit. Calling one of these methods with the value xCommit:=FALSE will only prepare the state changes and will not trigger the state machine to execute the related actions for changing the state. Calling one of these methods with the value xCommit:=TRUE will prepare the state changes and will then trigger the state machine to execute the necessary action to reach the next stable state. It is important to know, that the state machine sometimes needs more than one invocation to transit from on state to the next stable state. With this in mind the following code example might be useful for handling a common behaviour model via an interface reference variable.

A code example for handling a common behaviour model via an interface reference variable

 1VAR
 2    itfBehaviourModel : CBML.IBehaviourModel;
 3    eState : CBML.STATE;
 4    /// Some variable to trigger the abort of the behaviour model
 5    xSignal : BOOL;
 6END_VAR
 7
 8CASE eState OF
 9    CBML.STATE.DORMANT:
10        (* Prepare execting *)
11        itfBehaviourModel.StartModel(xCommit:=FALSE);
12
13    CBML.STATE.DONE:
14        (* Handle the ``Done`` state *)
15        itfBehaviourModel.ResetModel(xCommit:=FALSE);
16
17    CBML.STATE.ABORTED:
18        (* Handle the ``Aborted`` state *)
19        itfBehaviourModel.ResetModel(xCommit:=FALSE);
20
21    CBML.STATE.ERROR:
22        (* Handle the ``Error`` state *)
23        itfBehaviourModel.ResetModel(xCommit:=FALSE);
24END_CASE
25
26IF xSignal AND
27   eState = CBML.STATE.STARTING OR
28   eState = CBML.STATE.EXECUTING
29THEN
30    itfBehaviourModel.AbortModel(xCommit:=FALSE);
31END_IF
32
33itfBehaviourModel.GetModelState(xCommit:=TRUE, eState=>eState);

There is a very important aspect of this code example: The state machine should definitely be called/triggered only once in a PLC cycle!

Properties:

Methods:

Structure: