Skip to main content

Components in State Machine

Description

The

AState stateMachine machineis consistscreated inby combining components such as “State” and “Transition”. These elements are used to construct rules that define a setseries of states, a setseries of possible inputsinputs, and rules to trigger transitions to another state or transition to itself forin anyresponse to the input. 

The following eight types of elements can be used as components of a State Machine in the Scene Composer. These can be selected from the toolbar at the top of the possibleState inputs.Machine Editor panel and placed on the diagram.

States

    Initial State State Transition Subchart Entry/Exit Point History State Note Choice

    A 

    Initial State

    The Initial State is a special state denotesthat a given logical status. Each state machine shall have an initial state, which isindicates the entrystarting point forof the state machine. WhenThere ais always one of these in each state machine, and when the state machine is executedexecuted, itprocessing always starts alwaysfrom this Initial State.

    drawing-4-1737960437.png

     

    State

    A State represents a specific logical state. It indicates the current operation and conditions within a State Machine, and specific actions can be performed when a State starts or ends. All actions associated with a State are executed sequentially when a State starts (OnEntry) or ends (OnExit). These actions can be set in the initialproperties state.panel or Fusion editor after selecting the target State.

    drawing-5-1708091541.pngdrawing-4-1737960451.png

     


    Transition

    A stateTransition can haverepresents a setconnection ofbetween actionstwo associated when the state is activated (On Entry)States and when deactivated (On Exit). All actions defined for the state changes are executed when enteringspecific orconditions leavingare met. Transitions aggregate the state.

    drawing-5-1725607559.png

    Transitions

    One or more transitions can be defined between two states. A transition is executed when the associated condition is met.

    A transition aggregates a sendersending object, a conditioncondition, and an action. If the condition is evaluatedevaluates to true, the action is executed. Transitions are evaluated based on theirthe logical order according to their definition.defined.

    drawing-5-1725608029.png

    In

    addition,

    CGI Studio provides a large number of standard events for its controls and a predefined set of conditions to choose from.

    drawing-5-1725608246.png

    Set Transition Priority

    Whenif multiple transitions are connected to the same state, you can set the priority of the transitionstransitions. For details, see here.

    drawing-4-1737960481.png

     

    Subchart

    A Subchart is a structure that groups one or more States and Transitions. The lower right corner of a Subchart in the diagram is marked with an “S” to distinguish it from a normal State.

    drawing-4-1737960507.png

    Subcharts can be setconnected into twoother ways. Transitions are checked in order of priority,States and theSubcharts transitions that matchon the conditionsdiagram, areallowing executed.you Thisto featyrecreate isflexible usefulflow whenstructures. Double-clicking on a Subchart will display the conditionsdetails forwithin theit. occurrenceAs of multiple transitions are the same.

      Setting Transition Priority in State Machine Editor tree
      Transitions are displayed in the tree view in the upper left corner of State Machine Editor. Transitionsthey can be reorderededited independently of the main diagram, they can be used to organize complex logic in an easy-to-understand way.
      drawing-4-1737960576.png

       

      Entry/Exit Point

      A Entry Point and a Exit Point are pseudo-states that enable controlled entry and exit to and from a Subchart. They function as clear starting and ending points for entering a Subchart. By setting multiple Entry Points, you can start a Subchart from different points depending on the conditions. Similarly, by draggingsetting multiple Exit Points, you can provide different exits depending on the conditions.

      drawing-4-1737960601.png

      Example of Subchart Configuration Using Entry/Exit Point

      The following is a simple example of a configuration using a Subchart and droppingEntry/Exit themPoints.

      with
      drawing-4-1737694084.png
      the mouse.

      In the figure below,above, Transition_1the Subchart "SubChartState_1" is placed on the diagram.

        The state machine starts the transition from the Initial State on the diagram, and then moves to Subchart "SubChartState_1" and transitions to the Initial State in the Subchart (see diagram 1 above). A mouse click causes a transition to State_1 of the Subchart (2 in the above figure). Subsequently, mouse click operation causes a sequential transition to State and Exit Point of Subchart (3 and 4 in the above figure). As a result, the state machine transitions from Subchart to State_1 of the diagram (5 in the previous figure). Subsequent mouse clicks will transition to the diagram State (previous figure 6). A mouse click on this State triggers Transition_3, which is connected to the State, and thus re-enters the Subchart via the Entry Point (orange frame area in the above left diagram) again and returns to the State in the Subchart (above diagram 2).

         

        History State

        A History State is a special State that is placed within a Subchart, and it has the highestrole priorityof and Transition_3 hasremembering the lowest priority.

        drawing-5-1725608529.png

        Setting Transition Prioritystate in Propertieswhich Panel
        Transitionsthe Subchart was last active. This makes it possible to resume processing from the State immediately before exiting when transitioning back to the Subchart. Subcharts that contain a History State are displayedmarked with an “H” in Propertiesthe Paneltop underright [corner. Transitions
        drawing-4-1737960626.png
        >

        Example Exitof TransitionsHistory ].State TransitionsConfiguration

        are

        The orderedfollowing fromis highesta prioritysimple toexample lowestof priority,a andconfiguration canwith bea reorderedHistory usingState placed in the [Subchart.

        Move
        drawing-4-1737959821.png
        Item Down ] and [ Move Item Up ] icons.

        In the figure below, ExitTransitions 0 (= Transition_1) hasabove, the highestSubchart priority"Media" andwith ExitTransitionsHistory 2State (=is Transition_3)placed hason the lowestdiagram.

        priority.
        drawing-5-1725608658.png

        State Machine Behavior

        The state machine behaviorstarts isits atransition standardfrom CGIthe StudioInitial behaviorState whichon allowsthe diagram, and then moves to configureSubchart a"Media" state(see machinediagram instance.1 above). It first passes through the History State (orange boxed area in the above figure) and enters the State loop (red boxed area in the above figure) starting with State "Bluetooth".
          The associated state machine will receiveremain allin this Subchart as long as transitions between Bluetooth, Radio, and USB are triggered. When Transition_1 on the eventsdiagram (2 in the diagram above) is triggered, this Subchart will exit. When the Subchart ends, History State remembers the State in the Subchart immediately before the exit. If the state machine transitions again to Subchart "Media" via Transition_3 (Figure 3 above), it transitions to Subchart "Media" again.
            History State remembers the State of the associatedlast nodetransitioned andSubchart could"Media". triggerTherefore, furtherthe actionstransition asis theyrestarted arefrom definedthe last transitioned State in the Subchart "Media".

            When exiting the Media state machine.and transitioning to the Navigation state, not only the OnExit of the Media state is called, but also the OnExit of the last selected meMedia device state (Bluetooth/USB/Radio).

            When entering the Media state as well as when exiting the Media state, OnEnter of the Media state as well as OnEnter of the stored most recently selected Media device state (Bluetooth/USB/Radio) will be called.

            See State Machine Solution for a sample state machine solution using History State.

             

            Note

            In a State Machine Editor, you can add Note to the diagram to supplement the information. This helps you to visually organize the design content and notes.

            drawing-5-1733494680.pngdrawing-4-1737960773.png

             

            Choice

            Choice allows you to branch Transitions. This makes it easy to edit state machines that define different behaviors based on multiple conditions.

            Example of Choice Usage

            In the State Machine diagram below, the transition starts from the Initial State on the diagram and transitions to the Evaluate State.

            drawing-4-1737693957.png
              When the button is clicked in the Evaluate State, Transition (1 in the above figure) is executed, and the transition moves to Choice (orange frame section in the above figure), where the Transition branches. In the Transition "Transition_too_high" (2 in the above figure), the processed value is checked to see if it exceeds a specific threshold value.
                If the condition is met: Transition to "Red State" if the value is too large (2 in the above figure). If the condition is not met: If the value is below the threshold, Transition_okClicked is executed and a transition to the "Blue State" is made (3 in the above figure).

                The priority of a Transition (Exit Transition) connected to a Choice is the same as the normal Transition priority change procedure.

                By utilizing Choice, multiple conditions can be clearly organized within the state machine, making it easier to visually grasp the branching structure. This makes it possible to design complex logic in a simple manner.