Main Content

Describe System Behavior Using Activity Diagrams

An activity diagram is a type of diagram within System Composer™ to model a dynamic workflow, process, or system behavior through a controlled sequence of activities. You can use activity diagrams to visualize how data moves and how decisions are made within a system. An activity diagram model enables a deeper understanding of what the system is and how it behaves over time.

Suppose you are designing a software algorithm. You can use an activity diagram to create a clear, visual representation of the workflow like a dynamic flow chart before you write any code. You can map each step and decision to help stakeholders understand the logic, identify edge cases, and spot ambiguities early in the design phase. You can attach requirements to each part of the workflow and test whether the implementation meets those requirements. For example, if the code you build is for a robot controller with a defined system architecture, you can allocate specific controller components to the activity diagram. This approach enables you to link requirements and architecture and improve traceability throughout the development process.

You can use activity diagrams to model many kinds of processes and workflows, for example:

  • Model a shopping process, including adding items to a cart, authorizing payment, and placing an order.

  • Test UAV mission workflows, such as takeoff, maneuvering, and landing.

  • Analyze business processes such as employee onboarding and to identify and address potential improvements.

A basic activity diagram model contains action nodes with pins connected by flow lines. This activity diagram illustrates a simple algorithm that reads a value and processes it only if the value is greater than or equal to 5.

These concepts are relevant for authoring activity diagrams:

  • Tokens are objects that flow in the activity diagram. A token can represent data such as structures and integers, or a token can simply pass on the control. An object token represents an object, such as a piece of data. A control token represents a control or a triggering event that does not carry any data.

  • A flow in an activity diagram connects two nodes. A dashed line represents a control flow. A solid line represents an object flow. Tokens in an object flow contains token data on which actions operate. You can use object flows to route input or output tokens to carry information or physical items between object nodes. Tokens in a control flow trigger the execution of actions. You can use control flows to model transfer of control from one Action Node to another.

  • An action node is a key building block in an activity diagram. An action node represents an action to be executed. Action nodes consume input tokens and produce output tokens on pins. Use a MATLAB® function or a nested activity diagram to describe the behavior of an action node.

  • A control node routes a logical flow of tokens through the system. Use control nodes and flows to route tokens. Control nodes can be used to initialize, split, merge, and terminate token flows.

    These are the various types of control nodes in an activity:

    • Initial Node — Dispatches a control token at the beginning of an activity.

    • Decision or Merge Node — A decision node routes an input token to an output flow based on the evaluation of guard expressions. A merge node routes tokens from multiple input flows to a single output flow. A merge decision node routes tokens from multiple input flows to certain output flows based on the evaluation of guard expressions.

    • Join or Fork Node — A join node consolidates multiple input tokens to one output flow given that a token is available at each input pin. A fork node replicates one input token on each output flow.

    • Flow Final Node — Terminates one object or control flow but not the entire activity.

    • Activity Final Node — Terminates the incoming token and the entire activity.

  • A pin acts as a buffer for object tokens and directs tokens into or out of an action node. The directionality of the pin represents input or output. You can connect pins by object flows. Use pins to route an object token to or from an Action Node. Pins are also used to store object tokens before or during execution. You can use pins only for object flows.

  • A type defines the contents of a token that flows through a pin. A type has dimension, unit, complexity, minimum, maximum and description. A value type token is a type assigned to a single value. A composite type token is equivalent to a bus structure that contains field of different values and data types. A MATLAB class type token references a MATLAB class on the path that defines a complex object with properties and methods. You can use a built-in MATLAB class or define your own MATLAB class.

  • A parameter node routes tokens into or out of a nested activity diagram. When a pin is created, a corresponding parameter node will be created inside the nested activity. Use a parameter node to define how tokens enter or leave a nested activity. There are two types of parameter nodes input and output.

Create New Activity Diagram

Create an activity diagram by launching the System Composer Start Page. Enter this command in the MATLAB Command Window.

systemcomposer

From the dialog box that opens, select Activity Diagram.

Activity Diagram from Simulink Start menu

Alternatively, you can use the systemcomposer.createActivity function to create a new activity diagram.

Author, Simulate, and Visualize Activity Diagrams

Activity diagrams are integrated with architecture models in System Composer. When designing a system, you can use an activity diagram to conceptualize a system and visualize the flow of actions or decisions. Activity diagrams help you to understand how the elements of your system interact with each other. In System Composer, you can also simulate and visualize activity diagrams to validate system behavior.

TopicDescription
Author a Simple Activity DiagramInteractively create and edit an activity diagram and learn terminology.
Simulate, Visualize, and Validate Activity DiagramsSimulate and visualize an activity diagram to validate system behavior.

Tip

To learn more about how System Composer concepts apply to systems engineering design, see System Composer Concepts.

See Also

Functions

Objects

Tools

Blocks

Topics