Overview
User-Interface
Finite-State Machine
The CBA ItemBuilder’s user-interface for Finite-State Machines consists of two editors: The State Machine Tree View and the State Machine Rules Editor (open both with menu Project > Edit State Machine).


Events: and Rules:How to Create States?

Machine VERSION_01_01.New Child > State. <not set>. State Type
START: Each FSM needs one Start-state (required).NORMAL: Regular states are Normal-states.END: State-machines end in an End-state (not required).State Name
Page to Open
A minimal configuration should have at least two States:
ST_START)ST_RUNNING)
Make sure to not accidentally nest the states: 
Siblings are not required for a simple configuration: 
Regions are not required for a simple configuration: 
Configuration of states is also possible in the Properties-view, but avoid typos in Page-names!
Minimal Syntax:
Line 1 (Events:)
Events: followed by a list of events.EV_Placeholder)., (comma) as separator.; (semicolon).Line 2 (Rules:)
Rules: is required for the 2nd part.ST_Start) to the Normal-state (ST_Running) is required.{true}).A few notes in advance …
Ctrl/Strg + Space).
Changes in the State Machine Rules Editor and in the State Machine Tree View are confirmed by closing the editor. After defining States or Events, close both editors to make sure the model is updated!
When closing one of the two editors (either State Machine Rules Editor or State Machine Tree View), close also the other before request the editors again!
/* ... */ or //) to document syntax or to remove syntax temporary.It’s about the ?-Button:
Two States
State_Hint_Visible: Test-taker not yet used drag-and-drop (a hint might be required)State_Hint_Invisible: Drag-and-drop observed (no hint required)Rules1
User-Defined FSM-Events1
Definition of FSM-Rules3
->) vs. Regular Rules (=>){})|)internal): [Cond])entry and -exit rulesThe CBA ItemBulider’s Finite-State Machine syntax is not complicated.
But be careful with the different characters (e.g., -> vs. =>), as they have an explicit meaning.
Start Rule (->)
StartState) must be a state of type START.StateA) must be a state of type NORMAL.{true} is always fulfilled (i.e., the transition is executed).Regular Rule (=>)
StateA) must be a state of type NORMAL.true) must be a state of type NORMAL.{TriggerEvent} occurs in StateA.How to read the syntax? A transition is defined from StateA to StateB for TriggerEvent.
Finite-State Machines are mainly used to trigger Operators (i.e., to change the item) either due to user-interactions (i.e. Events linked to components) or (internal) Timers.
Regular Rule with Operator (|)
Operator() is executed, when the Transition defined in this Rule is executed.Operator() is executed when the FSM is in StateA and the TriggerEvent occurs.CBA ItemBuilder Syntax defines various Operators for FSMs to
CBA ItemBuilder Syntax defines various Operators1 for FSM-Rules …
next_task, back_task, cancel_taskcalcOp, calcOpnd, calcSettingsExternalPageFrames: callExternalPageFrameopenDialog, closeDialogInputfields: focus, insertTextraiseset, resetscrollEmbeddedPage, scrollTopLevelPagePageAreas: setEmbeddedPagesetActive / unsetActive, setFrozen / unsetFrozensetHidden / unsetHiddenAudio/ Video components: initMediaPlayer, setMediaPlayer, setMediaPlayerVolume…
…
setGlobalPropertyinitFSM, setFSMEvent, setFSMStateImageMaps: setValueDisplayModeTextFields: setHighlightable / unsetHighlightableFrameSelectGroups: setMultiselect / unsetMultiselect, setNoDeselect / unsetNoDeselect, setSelectable / unsetSelectabletrace_snapshot, trace_text, trace_typed_snapshot, trace_typed_texttree_copy, tree_moveFinite-State Machines differentiate a finite number of States. However, in practice, this restriction is circumvented by the use of Conditions (i.e., Guards) that can incorporate Variables in Boolean expressions.
Possible Scenarios:
StateFrom: Nothing will happen if EventName occurs. Condition.)StateFrom:
EventName occurs, if Condition is not met.StateTo, if EventName occurs and if the specified Condition is fulfilled.Rules for transitions between regular States with Condition and Operators can be defined.
Combination of [] and |:
How to read the syntax? A transition is defined from StateFrom to StateTo is defined for EventName. If the Condition is fulfilled when EventName occurs and the FSM is in State StateFrom, the FSM will change to StateTo and execute the Operators OperatorA() and OperatorB().
Conditions can be complex Boolean expressions, but Bracketing need to be considered!
Single Condition
A complete Finite-State Machine definition in the CBA ItemBuilder usually includes more than the minimum required two rules.
Idea
internal).Pragmatic Approach
->)In most cases, the rule that defines the Transition between a Start-state and a Normal-state is defined with a condition that is always fulfilled (i.e., using the default {true}).
For Project Files with several Tasks, the Start-rule (->) allow conditions:
Possible Conditions
Task-Name (T1 or T2):
 S -> N1 {isCurrentTask(T1)}
 S -> N2 {isCurrentTask(T2)}
Page-Name (P1 or P2):1
 S -> N1 {current_page(P1)}
 S -> N2 {current_page(P2)}
Default
S -> N {true}If identical operators should be executed when a FSM enters a particular State (i.e., entry) or leaves pa particular State (i.e., exit).
Don’t repeat syntax for operators, if possible.
Operators executed when a FSM changes to a particular State:
entry:Self-Transitions (i.e., Identical From- and To-States)
StateA is left and re-entered.The transition StateA => StateA means that StateA is re-entered:
entry and State-exit are executed.CBA ItemBuilder FSMs use User-Defined States:
internal is not used).The Required FSM-Events:
Asign Raised Event or similar in the Page Editor).It is impossible / very unlikely to define a valid Finite-State Machine syntax using trial & error.
Helpful to remember
NORMAL (multiple) vs. START (one).->, =>, {}, |, [] and keyword internalEvents: EV1, EV2; Rules: S->N1{true}N1=>N2{EV1}Strg/Ctrl + MGeneral idea