Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Python path

You chose the Python target. Work from this directory for all eight labs:

cd Python

Each lab lives in src/labN/ and has its own README with instructions. Compile and run every program from this directory, for example:

lfc src/lab1/ReadySetReact.lf
bin/ReadySetReact

lfc places a launcher script in bin/ (named after the program) and the generated Python sources in src-gen/. Lab 8 additionally generates fed-gen/ for its federated build. All three directories are generated and ignored by Git.

Python-target cheat sheet

Inside reaction bodies you write plain Python (indented consistently). The most used APIs in these labs:

Purpose API
Print print(f"count {x}")
Read an input value inp.value (guard with inp.is_present if needed)
Write an output out.set(value)
Read/write state self.count
Read a parameter self.period
Elapsed logical time (ns) lf.time.logical_elapsed()
Elapsed physical time (ns) lf.time.physical_elapsed()
Current tag lf.tag().time, lf.tag().microstep
Schedule an action a.schedule(delay) or a.schedule(delay, value)
Time literals in Python code MSEC(250), SEC(1), ...
Request a clean stop lf.request_stop()

Time values are integer nanosecond counts. Modules imported in a preamble are accessed through self (for example, self.time.sleep(...) after import time in the preamble). One naming note: in is a Python keyword, so these labs name input ports inp.

Labs

  1. Ready, set, react
  2. Building a reactor pipeline
  3. Tags, delays, and lag
  4. Predictable ordering
  5. Reacting to the outside world
  6. Changing behavior with modes
  7. Useful work under a time budget
  8. One model, multiple processes