Skip to content

Tutorial on building a traffic light controller in Lingua Franca

Notifications You must be signed in to change notification settings

lf-lang/lf-traffic-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LF Traffic Light Controller

Build a Lingua Franca based traffic light controller! Go directly to the exercises here

Prerequisites

  • Linux, macOS or Windows Subsystem for Linux (WSL).
  • A Ubuntu VM with everything installed can also be downloaded here
  • git
  • A C compiler such as gcc or clang
  • A recent version of cmake
  • GNU make
  • Java 17 (or greater)

For more information on the prerequisites, see https://www.lf-lang.org/docs/installation

Getting started

1. Clone this repo

git clone [email protected]:erlingrj/lf-traffic-light.git

or

git clone https://github.com/erlingrj/lf-traffic-light.git

2. VSCode extension (recommended)

Install Microsoft VSCode (https://code.visualstudio.com/).

Open the cloned repo in VSCode, e.g. in the same terminal as you ran the git clone command, do:

code lf-traffic-light

Navigate to the Extension Marketplace:

Extension

Find and install the Lingua Franca extension:

Open HelloWorld.lf

Inspect the auto-generated diagram by pressing this button:

And run the program by pressing the Play button

The program output is printed to the integrated terminal.

2. Command-line tools (optional)

If you have installed VSCode and the extension, you can skip this section.

If you wish to use another code editor, or just want to interact directly with the command line tools, they can be installed by our convenience install script:

curl -Ls https://install.lf-lang.org | bash -s cli

This will install lfc to $HOME/.local/bin, make sure this is on your system path, e.g. by adding the following to the end of your ~/.bashrc

export PATH=$PATH:$HOME/.local/bin

Now you can manually compile the HelloWorld.lf from the command line with:

lfc src/HelloWorld.lf

Run the resulting binary with

bin/HelloWorld

Generate the diagram by:

lfd src/HelloWorld.lf

This will produce an SVG called HelloWorld.svg.

Finally, you can verify that everything is correctly installed with:

make all

2. Ubuntu VM (If nothing else works)

Download a preconfigured Ubuntu VM here The username and password are both ubuntu.

After logging in, fetch the most recent changes to the tutorial and verify the setup.

cd ~/lf-traffic-light
git pull
make all

VScode will be installed with the Lingua Franca extension so you can interact with the auto-synthesized diagrams.

Exercises

Now that your setup is done and verified you can move on to the actual exercises

About

Tutorial on building a traffic light controller in Lingua Franca

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published