Skip to content

Examples

Three complete programs, each showing one thing.

  • Connecting to a link


    The smallest useful Frost program: three components register with a FrostLink and report when they are connected.

    Connecting to a link

  • Invoking a method


    A caller invokes a method on another component's data model and checks the result that comes back.

    Invoking a method

  • Subscribing to a variable


    A subscriber asks to be told when another component's variable changes, and receives updates.

    Subscribing to a variable

Where these come from

These examples are adapted from Frost's own test suite, on the dev branch — test/src/TestFrostLink.lf, test/src/TestMethodInvoke.lf and test/src/TestSubscription.lf. Frost's CI builds and runs them on every push, so they are known to work against the code they document.

Adaptations are limited to trimming the assertions that make them tests, and naming files as you would in a project of your own.

Running them

Each example needs three files:

your-project/
├── src/
│   └── Main.lf                       the program
└── resources/
    ├── frost_config.yml              logging, data model paths, parameters
    └── data_model/
        ├── link.yml                  the FrostLink's data model
        └── ...                       one per component

Build and run with the Lingua Franca compiler:

lfc src/Main.lf
FROST_CONFIG=resources/frost_config.yml bin/Main

FROST_CONFIG defaults to resources/frost_config.yml, so if you keep that path you can leave the variable out. See Configuration.

Start from the template

frost-template is a GitHub template with this layout, Frost as a submodule, and a main reactor already in place.

Other examples

frost-playground collects larger examples — publisher/subscriber, sensor/alarm, a stock-market toy and a production scheduler.

The playground targets Frost v1.0.0

Its Frost submodule is pinned to the main branch, so its examples use the v1.0.0 component names (FrostMachine, FrostBus, FrostDataModel) rather than the ones documented here. They do not compile against dev unchanged. See Versions.