Skip to content
Mikołaj Milewski edited this page Apr 5, 2025 · 1 revision

# Overview

Activity Nodes represent the building blocks of Activities in the Stateflows framework.

In general, an Activity Node consists of:

  • Name, uniquely identifying the Node within the Activity,
  • Type, specifying the kind of Activity Node (e.g., Action, Decision, Merge, Fork, Join, etc.),
  • Incoming Flows, passing input Tokens into the node,
  • Outgoing Flows, passing output Tokens outside the node,
  • Logic, code that is invoked when the node is executed (Action Nodes only).

Types of Activity Nodes

There are several types of Activity nodes:

  1. Action Node: Represents a single step or action in the Activity.
  2. Decision Node: Represents a branching point where one of several outgoing flows is selected based on a condition.
  3. Merge Node: Combines multiple incoming flows into a single outgoing flow.
  4. Fork Node: Splits a single incoming flow into multiple outgoing flows, enabling parallel execution.
  5. Join Node: Combines multiple incoming flows into a single outgoing flow, synchronizing parallel flows.

Definition

UML notation of two Activity nodes connected by a flow:

flowchart

initial@{ shape: circle, label: " " }
initial --> generator
generator(IntGenerator)
generator -->|int| decision
decision@{ shape: diamond, label: " " }
decision -->|token.Value < 100| small
decision -->|else| big
small(SmallIntProcessor)
big(BigIntProcessor)
join@{ shape: join, label: " " }
small --> join
big --> join
join --> finish
finish@{ shape: double-circle, label: " " }
Loading

Equivalent Stateflows notation of Activity Nodes:

Lambda style

    /* fragment of Activity definition */
    .AddInitial(b => b
        .AddControlFlow("IntGenerator")
    )
    .AddAction("IntGenerator",
        async c => { /* logic that generates ints */ },
        b => b.AddFlow<int>(DecisionNode.Name)
    )
    .AddDecision(b => b
        .AddFlow("SmallIntProcessor", b => b
            .AddGuard(async c => c.Token.Value < 100)
        )
        .AddElseFlow("BigIntProcessor")
    )
    .AddAction("SmallIntProcessor",
        async c => { /* logic that processes small ints */ },
        b => b.AddControlFlow(JoinNode.Name)
    )
    .AddAction("BigIntProcessor",
        async c => { /* logic that processes big ints */ },
        b => b.AddControlFlow(JoinNode.Name)
    )
    .AddJoin(b => b
        .AddControlFlow(FinalNode.Name)
    )
    .AddFinal()

Using lambda style means that Activity nodes are represented by string names passed as parameters to AddAction methods.

Typed style

    /* fragment of Activity definition */
    .AddAction<IntGenerator>(b => b
        .AddFlow<int>(DecisionNode.Name)
    )
    .AddDecision(b => b
        .AddFlow<SmallIntProcessor>(b => b
            .AddGuard(async c => c.Token.Value < 100)
        )
        .AddElseFlow<BigIntProcessor>()
    )
    .AddAction<SmallIntProcessor>(b => b
        .AddControlFlow<Join>()
    )
    .AddAction<BigIntProcessor>(b => b
        .AddControlFlow<Join>()
    )
    .AddJoin(b => b
        .AddControlFlow<FinalNode>()
    )
    .AddFinal()

Using typed style means that Activity nodes are represented by classes that are referenced in typed overloads of AddAction methods. Such classes must implement proper interfaces - refer to detailed descriptions of Action Node, Decision Node, etc.

Overview
Installation
Behaviors
   State Machines
       Building blocks
           States
               State
               Composite State
               Orthogonal State
               Final State
           Pseudostates
               Choice
               Junction
               Fork
               Join
           Transitions
               Transition
               Default Transition
               Internal Transition
       Concepts
           Evaluation of Transitions
   Activities
       Building blocks
           Nodes
               Action Node
               Decision Node
               Merge Node
               Initial Node
               Final Node
               Input Node
               Output Node
               Fork Node
               Join Node
               Accept Event Action Node
               Send Event Action Node
               Data Store Node
               Structured Activity Node
               Iterative Activity Node
               Parallel Activity Node
           Flows
               Data Flow
               Control Flow
       Concepts
           Implicit fork and join
   Actions

Clone this wiki locally