The objective of this workshop is to get familiar with basic features of Lingua Franca. We will go a step further to discuss how it can be applied for the development of time critical software applications.
We recommend visiting the Lingua Franca project page for more details.
We have created two development environments for you to try the workshop examples. Gitpod and Codespaces allow you to launch the containerized environment and support editing in VS Code (Browser based or Desktop version).
You are responsible for the costs incurred for working on both these environments. Kindly review the pricing and make sure you maximize your free credits as an individual user.
If you are not comfortable with the above environments, please follow the links below to build the development environment on your compute machine.
Your environment can take up to a few minutes to build the container image and load the editor. Once you pass this step, you are ready for the LF programming experience!
Make sure you have the compiler built in the previous step by bringing up the terminal in the editor and typing in lfc
. By default, the terminal points to 'lf-workshop' directory. To run an example, use the command lfc src/<example>.lf
to build and run the generated binary bin/<example>
.
$lfc src/HelloWorld.lf
$bin/HelloWorld
You can also use the features of the in-built editor by pressing ctrl+shift+p
and selecting Lingua Franca: Build and Run
option which builds and runs the program for you. To render the diagram view of your Lingua Franca code, click the icon on the top right corner of the editor window in which the .lf
program is opened.
Running a simplest LF application to familiarize with concepts of the meta language
- Open
src/HelloLF.lf
in editor.
- Go through the syntax and key words
- Diagrammatic view of the LF program
- Observe generated code and compare with equivalent non-LF code (
artifacts/HelloWorld.c
) - Polyglot test in CPP/Python (
src/HelloLFPy.lf
andsrc/HelloLFCpp.lf
)
- Trigger reaction with periodic timer
- Print logical and physical time at each trigger
- Explore target properties (eg:
timeout
) - Include preamble code
- State variables
Building composite reactors
- Open
src/Composition.lf
in editor. - Multiple reactors
- Import mechanism
- Banks of reactors
- A note on Determinism using
src/Determinism.lf
- Open
src/Modal.lf
for Modal models - Add a third mode with
Understanding LF time syntax
- Open
src/PhyLogTimes.lf
in editor.
- Understand that logical time advances only on an event while physical time advances irrespective
- Open
src/Logical.lf
in editor and observe multisource pattern. - Deadline handling mechanism using
src/SimpleDeadline.lf
- Logical and physical actions (Optional)
- Physical connection (Optional)
Developing distributed applications
- Open
src/HelloWorldFederated.lf
in editor. - Explore centralized vs distributed coordination
- Containerized execution
A real life application - door lock example
- Open
src/DoorLock/DoorLock.lf
in editor. - Detect cases of non-determinism
When you are done with the workshop, cleanup unused/stopped instances you may have created during the event to avoid being billed.
We extend our sincere thanks to Prof. Edward Lee and to the amazing Lingua Franca community. The scripts used for containerized development environments have been borrowed with permission from Lingua Franca playground repository.