Skip to content

Behaviors

mikolaj-milewski edited this page Sep 18, 2024 · 10 revisions

Overview

Core concept of Stateflows framework is Behavior: piece of executable logic which is addressable, has its own persistent state and can be interacted with by Events sent to it and received from it.

Stateflows provides two types of Behaviors:

  1. State Machine (designed to manage processes),
  2. Activity (more suited for data processing).

Definition of Behavior (f.e. State Machine structure) is called Behavior Class.

For each Behavior Class there can be multiple addressable entities called Behavior Instances, distinguished by string-based Instance ID.

Lifecycle

Each Behavior Instance has its own lifecycle:

  1. Before any interaction with it, it has status NotInitialized.

Actually, before any interaction with Behavior Instance, it exist only virtually. Behavior Instance represents virtual actor in Stateflows framework.

  1. By default, first interaction (first Event sent to it) initializes Behavior Instance and enables it to consume next incoming Events.

Initialization can be customized, so developer can decide whether it should happen or not. Refer to Custom initialization for more details.

  1. Behavior Instance can also finish its work and be marked as Finalized, which means that no further Events will be consumed by it (with exception of some System Events).
Clone this wiki locally