Model Hierarchy

Structure is optional but powerful: how to organize growing models with callbacks and containers, and when a flat diagram is all you need.

A Modeloop model can be as simple as a single flat diagram: drop blocks, connect them, simulate. Nothing forces you to add structure, and small models are best left flat.

Real systems, though, grow. For those, Modeloop offers a hierarchy in which each level answers one question:

Project
└── Model                             ← what is this component?
    └── Callback                      ← what executes and when?
        └── Container                 ← how is it organized?
            └── Blocks & signals      ← what does it compute?

Every level is opt-in: you introduce it when the model needs it, not before.

Models

A model is the top-level unit of design — SensorsReading, SpeedController, ActuatorControl. Each model owns:

  • a diagram — its complete internal logic;
  • input and output interfaces for exchanging signals with the rest of the system.

Models exchange data through their declared interfaces and provide the context for code generation.

A project can contain a single model — perfectly fine for a self-contained system — or many models composed into a larger architecture.

Use separate models for functionally cohesive components you would assign to a team, review as a unit, or deploy separately.

Callbacks

A callback is an executable entry point inside a model. Its activation settings define when it runs.

Activation Trigger Typical use
Periodic Fixed period (e.g. 10 ms) Control laws, filters, signal conditioning
Event Configured Boolean activation condition Mode changes, fault reactions, on-demand computations

See Model Execution for scheduling semantics.

Each callback generates an independent function that can be invoked by the target scheduler. A task groups callbacks in the build configuration and defines their scheduling context. A callback is part of the model hierarchy; a task is part of the execution configuration.

Use separate callbacks when parts of a model need different rates (fast acquisition + slow control), different triggers (periodic control + event-driven mode logic), or independent integration on the target.

Tasks

Tasks belong to the build configuration. They group callbacks for execution and can include callbacks from more than one model. Periodic callbacks with the same period are grouped together, with their order configured in the scheduling settings. Tasks do not introduce another nested diagram level.

See Model Execution for the relationship between callback activation and task scheduling.

Containers

A container is a purely structural grouping: a named box with its own inner canvas, connected to its parent through Virtual Input / Virtual Output ports.

A Container introduces no separate period or activation condition. Its blocks execute within the owning callback. Containers help organize the model:

  • they keep large diagrams readable,
  • they name subfunctions (PIDCore, Linearization, FaultDetection),
  • they nest to any depth,
  • and they can be converted to callbacks later, when a subfunction turns out to need its own schedule.

That promotion path is the intended workflow: start structural, make it schedulable only when timing requires it.

Choosing the right level

You need to… Use
Build and simulate a small system A flat diagram — no structure needed
Define a component with a public interface, owned by a team Model
Execute logic at a specific rate or on an event Callback
Organize a diagram into readable, named subfunctions Container
Turn a subfunction into an independently scheduled unit Container → Callback conversion

Interfaces at every level

The hierarchy is only as strong as its boundaries. In Modeloop, data crosses a boundary exclusively through interface blocks:

  • Model boundary — Model Input / Model Output: the model’s contract with the system.
  • Container boundary — Virtual Input / Virtual Output: the sub-diagram’s contract with its parent.

There are no global variables and no implicit cross-references. If you can see a model’s diagram and its interface, you know everything it can possibly read or affect — which is what makes large models reviewable.

A worked structure

A typical motor control model:

Model: MotorControl
├── Inputs:  target_speed_rps, measured_speed_rps, enable
├── Outputs: pwm_duty, fault_flag
│
├── Callback: SpeedLoop (periodic, 1 ms)
│   ├── Container: ErrorShaping      (sum, filtering)
│   ├── Container: PIDCore           (gains, integral, anti-windup)
│   └── Container: OutputLimiting    (saturation, rate limit)
│
└── Callback: Supervision (periodic, 100 ms)
    ├── Container: PlausibilityChecks
    └── State chart: FaultStateMachine

Fast control runs at 1 ms; supervision runs at 100 ms; each subfunction is a named container; the model exposes three inputs and two outputs. Every level answers a different question — what is this? (model), when does it run? (callback), how is it organized? (container).

Signal names across levels

Signal names follow the producer through Virtual Input and Virtual Output bindings. Entering or leaving a container does not create a new naming authority: rename the driver to update its consumers. The editor distinguishes inherited names with angle brackets. See Naming signals for fan-out, conditional branches and unresolved interfaces.