Skip to content

Commit

Permalink
Merge branch 'main' into tomacs
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj authored Jan 27, 2025
2 parents 3ccf8a9 + 080de05 commit ac199e3
Show file tree
Hide file tree
Showing 33 changed files with 1,197 additions and 959 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Quick start:
2. Open with [VS Code](https://code.visualstudio.com) (`code playground-lingua-franca`)
3. Install the [Lingua Franca extension](https://github.com/lf-lang/vscode-lingua-franca) (<kbd>Ctrl</kbd>+<kbd>P</kbd> and enter `ext install lf-lang.vscode-lingua-franca`).

Once in VSCode, navigate to [./examples](./examples) and click on any of the `.lf` files to open them into your editor. To build and run, use <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> and select `Lingua Franca: Build and Run`. Note: You might need not install additional dependencies in order to successfully build some of the code you find in this repository. For more information, see the [setup-env.bash](./utils/scripts/setup-env.bash) script that we use to configure our Docker-based environments.
Once in VSCode, navigate to [./examples](./examples) and click on any of the `.lf` files to open them into your editor. To build and run, use <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> and select `Lingua Franca: Build and Run`. Note: You might need to install additional dependencies in order to successfully build some of the code you find in this repository. For more information, see the [setup-env.bash](./utils/scripts/setup-env.bash) script that we use to configure our Docker-based environments.


## :rocket: Running in the Cloud
Expand Down
3 changes: 2 additions & 1 deletion examples/C/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* [Furuta Pendulum](src/modal_models/FurutaPendulum/README.md): A controller and simulation illustrating a modal reactor.
* [Keyboard](src/keyboard/README.md): Responding to keyboard input using ncurses.
* [Leader Election](src/leader-election/README.md): Federated fault-tolerant system with leader election.
* [MQTT](src/mqtt/README.md): Interacting with MQTT-based services.
* [MQTT](https://github.com/lf-lang/mqtt-c): Interacting with MQTT publish-and-subscribed (moved to a library repo).
* [Patterns](src/patterns/README.md): Common communication patterns.
* [Rhythm](src/rhythm/README.md): Sound generation and terminal user interface demos.
* [Rosace](src/rosace/README.md): Aircraft controller illustrating periodic systems with multiple periods.
Expand All @@ -19,3 +19,4 @@
* [Train Door](src/train-door/README.md): Train door controller from a verification paper.
* [Low Code](src/low-code/LowCode.lf): Using ChatGPT to generate reaction bodies.
* [Watchdog](src/watchdog/README.md): Federated illustration of watchdogs.
* [Zero-delay Cycles](src/zero-delay-cycles/README.md): Federated patterns with zero-delay cycles.
37 changes: 37 additions & 0 deletions examples/C/src/leader-election/NRP_FD_NobodyFails.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* This version of NRP_FD simply has the primary (node1) failing after 5 seconds and the backup
* (node2) failing at at 15s. The backup detects simultaneous loss of the heartbeat on both networks
* and hence assumes that the primary has failed rather than there being a network failure. Switch 1
* remains the NRP.
*
* @author Edward A. Lee
* @author Marjan Sirjani
*/
target C {
coordination: decentralized,
timeout: 1000 hours
}

import Switch, Node from "NRP_FD.lf"

federated reactor(heartbeat_period: time = 1 s, delay: time = 10 ms) {
node1 = new Node(heartbeat_period=heartbeat_period, id=1)
node2 = new Node(heartbeat_period=heartbeat_period, id=2)

switch1 = new Switch(id=1)
switch2 = new Switch(id=2)
switch3 = new Switch(id=3)
switch4 = new Switch(id=4)

node1.out -> switch1.in1, switch3.in1 after delay
switch1.out1, switch3.out1 -> node1.in after delay

switch1.out2 -> switch2.in2 after delay
switch2.out2 -> switch1.in2 after delay

switch2.out1, switch4.out1 -> node2.in after delay
node2.out -> switch2.in1, switch4.in1 after delay

switch3.out2 -> switch4.in2 after delay
switch4.out2 -> switch3.in2 after delay
}
Loading

0 comments on commit ac199e3

Please sign in to comment.