You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
An atomic state is a [state](state.html){:.glossary} that has no _substates_.States that have substates are either [compound states](compound-state.html){:.glossary} or [parallel states](parallel-state.html){:.glossary}.
An atomic state is a [state](state.html){:.glossary} that has no _substates_. States that have substates are either [compound states](compound-state.html){:.glossary} or [parallel states](parallel-state.html){:.glossary}.
Atomic states do not define "initial" states either.
Expand All
@@ -29,7 +29,7 @@ For atomic states that have no actions, and are otherwise empty, a very small, r
In SCXML, an atomic state is any state that has no _state_ children:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
oneliner:a transition that happens immediately upon entering a state or immediately after a condition arises
oneliner:A transition that happens immediately upon entering a state or immediately after a condition arises
breadcrumbs:
- id: transition
name: Transition
Expand All
@@ -18,9 +18,9 @@ Automatic transitions are [transitions](transition.html){:.glossary} that are tr
Automatic transitions don't have an associated [event](event.html){:.glossary}, as the mere being in the state implies that the transition should be taken.
Automatic transitions are usually [guarded](guard.html){:.glossary}.Such a guarded automatic transition is checked immediately after the state is entered.If the condition doesn't hold then the machine remains in the state, with this automatic transition in play _for as long as the state is active_.Every time the statechart handles an event, the guard condition for these automatic transitions are checked.If the guard condition ever succeeds, then the transition happens.
Automatic transitions are usually [guarded](guard.html){:.glossary}. Such a guarded automatic transition is checked immediately after the state is entered. If the condition doesn't hold then the machine remains in the state, with this automatic transition in play _for as long as the state is active_. Every time the statechart handles an event, the guard condition for these automatic transitions are checked. Ifeverthe guard condition ever succeeds, then the transition happens.
If there are many automatic transitions in play, they are all checked.In some statechart systems, only one guard is allowed to be true at any point in time; in others, the transitions are ordered, and the guards are checked until a one of them succeeds.
If there are many automatic transitions in play, they are all checked. In some statechart systems, only one guard is allowed to be true at any point in time; in others, the transitions are ordered, and the guards are checked until a one of them succeeds.
## Notation
Expand All
@@ -31,16 +31,15 @@ A transition arrow, but without the name of an event, only guards and/or actions
---------------------->
```
## Usage
Guarded transitions can be used to cause a machine to "wait" in a certain state, _until_ some condition holds, regardless of what else is happening in the form of events.For example, a machine could be in the 'filling' state until some threshold is reached, by defining an automatic transition from the 'filling' state with a guard `contents >= capacity`. Immediately after the contents reach the capacity, it would exit from this 'filling' state.
Guarded transitions can be used to cause a machine to "wait" in a certain state, _until_ some condition holds, regardless of what else is happening in the form of events. For example, a machine could be in the 'filling' state until some threshold is reached, by defining an automatic transition from the 'filling' state with a guard `contents >= capacity`. Immediately after the contents reach the capacity, it would exit from this 'filling' state.
By using an _in_ guard, it is possible to coordinate different parts of a [parallel state](parallel-state.html){:.glossary}.When the one region ends up on a certain state, it can wait until another region enters a specific state.
By using an _in_ guard, it is possible to coordinate different parts of a [parallel state](parallel-state.html){:.glossary}. When the one region ends up on a certain state, it can wait until another region enters a specific state.
If a machine is in a state with a guarded automatic transition, then that guard is checked as often as possible.Being eventdriven, the guards are effectively only checked whenever an event has been processed, but also after other automatic transitions have fired, or other internal events (such as [raised events](raised-event.html){:.glossary} are fired.
If a machine is in a state with a guarded automatic transition, then that guard is checked as often as possible. Being event–driven, the guards are effectively only checked whenever an event has been processed, but also after other automatic transitions have fired, or other internal events (such as [raised events](raised-event.html){:.glossary}) are fired.
Automatic transitions can be used to implement a [condition states](condition-state.html){:.glossary}, in other words, a state that only has automatic transitions.This is done by creating a state that only declares guarded automatic transitions, in such a way that it is guaranteed that the machine will always pick a transition upon entry, never _resting_ in that state.
Automatic transitions can be used to implement a [condition states](condition-state.html){:.glossary}, in other words, a state that only has automatic transitions. This is done by creating a state that only declares guarded automatic transitions, in such a way that it is guaranteed that the machine will always pick a transition upon entry, never _resting_ in that state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
_Also known as **Composite state** and **Or state**_
A compound state is a [state](state.html){:.glossary} that includes one or more substates.It is the main differentiating factor between traditional state machines and statecharts. A compound state can be thought of as _containing its own state machine_.
A compound state is a [state](state.html){:.glossary} that includes one or more substates. It is the main differentiating factor between traditional state machines and statecharts. A compound state can be thought of as _containing its own state machine_.
## Notation
A compound state is a normal state with its substates depicted _inside_ the borders of the state itself:

Here, the state called **Off** is a compound state.It has two states **A** and **B** as its substates. Note how the substates constitute their own state machine, even with an [initial state](initial-state.html){:.glossary}.
Here, the state called **Off** is a compound state. It has two states **A** and **B** as its substates. Note how the substates constitute their own state machine, even with an [initial state](initial-state.html){:.glossary}.
## Description
If there are more than one substates, one of them is usually designated as the [initial](initial-state.html){:.glossary} state of that compound state.
When a compound state is active, its substates behave as though they were an active state machine:Exactly one child state must also be active. This means that:
When a compound state is active, its substates behave as though they were an active state machine: Exactly one child state must also be active. This means that:
* When a compound state is [entered](enter.html){:.glossary}, it must also enter exactly one of its substates, usually its initial state.
* When an [event](event.html){:.glossary} happens, the _substates_ have priority when it comes to selecting which transition to follow. If a substate happens to handles an event, the event is consumed, it isn't passed to the parent compound state.
* When a substate [transitions](transition.html){:.glossary} to another substate, both "inside" the compound state, the compound state does _not_ exit or enter; it remains active.
* When a compound state [exits](exit.html){:.glossary}, its substate is simultaneously exited too. (Ttechnically, the substate exits first, _then_ its parent.)
- When a compound state is [entered](enter.html){:.glossary}, it must also enter exactly one of its substates, usually its initial state.
- When an [event](event.html){:.glossary} happens, the _substates_ have priority when it comes to selecting which transition to follow. If a substate happens to handles an event, the event is consumed, it isn't passed to the parent compound state.
- When a substate [transitions](transition.html){:.glossary} to another substate, both "inside" the compound state, the compound state does _not_ exit or enter; it remains active.
- When a compound state [exits](exit.html){:.glossary}, its substate is simultaneously exited too. (Technically, the substate exits first, _then_ its parent.)
Compound states may be nested, or include [parallel](parallel-state.html){:.glossary} states.
The opposite of a compound state is an [atomic state](atomic-state.html){:.glossary}, which is a state with no substates.
A compound state is allowed to define transitions to its child states. Normally, when a transition leads from a state, it causes that state to be exited.For transitions from a compound state to one of its descendantes, it is possible to define a transition that avoids exiting and entering the compound state itself, such transitions are called [local transitions](local-transition.html){:.glossary}.
A compound state is allowed to define transitions to its child states. Normally, when a transition leads from a state, it causes that state to be exited. For transitions from a compound state to one of its descendantes, it is possible to define a transition that avoids exiting and entering the compound state itself, such transitions are called [local transitions](local-transition.html){:.glossary}.
## Usage
An atomic state is often converted to a compound state in order to change its behaviour slightly.The newly introduced substates get a chance to override the behaviour by defining how to react to different events.The substates only need to define the differences in behaviour. The (now) compound state defines the general behaviour, and substates define deviations from this behaviour.
An atomic state is often converted to a compound state in order to change its behaviour slightly. The newly introduced substates get a chance to override the behaviour by defining how to react to different events. The substates only need to define the differences in behaviour. The (now) compound state defines the general behaviour, and substates define deviations from this behaviour.
The act of changing an atomic state into a compound state (by introducing a substate or two) is called _refining_ the state.The refinement alludes to the different behaviour encoded in the substates as being a _refinement_, or _specialization_ of the general behavour of the compound state.
The act of changing an atomic state into a compound state (by introducing a substate or two) is called _refining_ the state. The refinement alludes to the different behaviour encoded in the substates as being a _refinement_, or _specialization_ of the general behavour of the compound state.
A group of states can be collected into a compound state to factor out _common transitions_.For example, if five sibling states all have the same transitions to a particular target, it can be beneficial to move those five states into a single compound state, and then move the individual transitions to the compound state.
A group of states can be collected into a compound state to factor out _common transitions_. For example, if five sibling states all have the same transitions to a particular target, it can be beneficial to move those five states into a single compound state, and then move the individual transitions to the compound state.
The act of grouping states with commonalities into a compound state is called _clustering_.
Technically a statechart itself is usually (at the top level) a compound state itself. Some systems allow the machine to be a parallel state.
Technically a statechart itself is usually (at the top level) a compound state itself. Some systems allow the machine to be a parallel state.
### Zooming in and out
The nesting of states in a hierarchy can lead to complicated charts when it is visualized.It is possible to conceal the internals of a compound state by excluding substates from the visualization.This technique is called _zooming out_. Zooming _in_ would then reveal the details.
The nesting of states in a hierarchy can lead to complicated charts when it is visualized. It is possible to conceal the internals of a compound state by excluding substates from the visualization. This technique is called _zooming out_. Zooming _in_ would then reveal the details.
## SCXML
In Statechart XML, a compound state is any state with nested state elements as direct children; this includes `<parallel>`, `<initial>` elements too, as these are also state elements.
```xml
```xml
<state id="off">
<transition event="flick" target="on" />
<state id="A"/>
<state id="B"/>
<state id="A"/>
<state id="B"/>
</state>
```
A compound state's initial state is either identified by the `initial` attribute of the compound state, or the `<initial>` state, and if none of these is specified, the first state in document order.
## XState
An XState [compound state](https://xstate.js.org/docs/guides/hierarchical.html) is declared using the `states` property of the state, holding an object containing substates.Each key value pair declares the name and definition of the state, respectively.
An XState [compound state](https://xstate.js.org/docs/guides/hierarchical.html) is declared using the `states` property of the state, holding an object containing substates. Each key value pair declares the name and definition of the state, respectively.
```javascript
"off": {
Expand All
@@ -109,7 +108,7 @@ The `initial` property must specify the initial state.
In SCION-CORE, a compound state is declared by specifying the `states` property of the state in question, containing an array of state objects.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.