Skip to content

DNDEMoto/lf-workshop

 
 

Repository files navigation

Lingua Franca Workshop

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.

Development Environment

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.

Launching your development environment

Open in GitHub Codespaces

Open in Gitpod

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!

Getting started with the exercises

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 diagram-image icon on the top right corner of the editor window in which the .lf program is opened.

Tutorial

Exercise 1

Running a simplest LF application to familiarize with concepts of the meta language

  1. 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 and src/HelloLFCpp.lf)
  1. Trigger reaction with periodic timer
  2. Print logical and physical time at each trigger
  3. Explore target properties (eg: timeout)
  4. Include preamble code
  5. State variables

Exercise 2

Building composite reactors

  1. Open src/Composition.lf in editor.
  2. Multiple reactors
  3. Import mechanism
  4. Banks of reactors
  5. A note on Determinism using src/Determinism.lf
  6. Open src/Modal.lf for Modal models
  7. Add a third mode with

Exercise 3

Understanding LF time syntax

  1. Open src/PhyLogTimes.lf in editor.
  • Understand that logical time advances only on an event while physical time advances irrespective
  1. Open src/Logical.lf in editor and observe multisource pattern.
  2. Deadline handling mechanism using src/SimpleDeadline.lf
  3. Logical and physical actions (Optional)
  4. Physical connection (Optional)

Exercise 4

Developing distributed applications

  1. Open src/HelloWorldFederated.lf in editor.
  2. Explore centralized vs distributed coordination
  3. Containerized execution

Exercise 5

A real life application - door lock example

  1. Open src/DoorLock/DoorLock.lf in editor.
  2. Detect cases of non-determinism

Before you leave

When you are done with the workshop, cleanup unused/stopped instances you may have created during the event to avoid being billed.

Acknowledgements

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 61.1%
  • Python 30.6%
  • Dockerfile 5.5%
  • C 2.8%