From 6bb7ddf10544056684bb83913b73ed913d15ff45 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Wed, 13 Sep 2023 14:13:10 -0700 Subject: [PATCH] Apply formatter --- examples/C/src/ChatApplication/SimpleChat.lf | 12 +++++++--- examples/C/src/Delay.lf | 8 +++++-- .../DistributedDatabase/ReplicatedDatabase.lf | 9 ++++--- .../ResourceManagement.lf | 4 +++- examples/C/src/ReflexGame/ReflexGame.lf | 4 +++- examples/C/src/RockPaperScissors.lf | 8 +++++-- examples/C/src/browser-ui/BrowserUI.lf | 4 +++- examples/C/src/car-brake/CarBrake.lf | 4 +++- examples/C/src/deadlines/AnytimePrime.lf | 8 +++++-- examples/C/src/deadlines/PeriodicDeadline.lf | 4 +++- examples/C/src/keyboard/Keyboard.lf | 8 +++++-- examples/C/src/leader-election/Election.lf | 8 +++++-- examples/C/src/lib/PrintToFile.lf | 4 +++- examples/C/src/lib/Random.lf | 4 +++- examples/C/src/lib/RandomDelay.lf | 4 +++- examples/C/src/lib/ServerUI.lf | 4 +++- examples/C/src/lib/WebSocketServer.lf | 12 +++++++--- .../FurutaPendulumDisturbance.lf | 4 +++- .../FurutaPendulum/PendulumSimulation.lf | 4 +++- .../src/modal_models/FurutaPendulum/Print.lf | 4 +++- examples/C/src/patterns/Simultaneity.lf | 4 +++- .../C/src/patterns/lib/SendersAndReceivers.lf | 24 ++++++++++++++----- examples/C/src/rhythm/PlayWaveform.lf | 8 +++++-- examples/C/src/rhythm/Rhythm.lf | 4 +++- .../C/src/rhythm/RhythmDistributedNoUI.lf | 4 +++- examples/C/src/rhythm/SensorSimulator.lf | 4 +++- examples/C/src/rhythm/Sound.lf | 4 +++- examples/C/src/robot/CompositeRobot.lf | 12 +++++++--- examples/C/src/rosace/AircraftSimulator.lf | 8 +++++-- examples/C/src/rosace/Rosace.lf | 4 +++- examples/C/src/rosace/RosaceController.lf | 8 +++++-- examples/C/src/sdv/ParkingAssist.lf | 10 ++++++-- examples/C/src/simulation/MemoryHierarchy.lf | 16 +++++++++---- .../src/train-door/TrainDoorWithDeadlines.lf | 8 +++++-- examples/CCpp/DoorLock/src/DoorLock.lf | 20 ++++++++++++---- examples/Cpp/AlarmClock/src/AlarmClock.lf | 4 +++- examples/Cpp/AlarmClock/src/Clock.lf | 4 +++- examples/Cpp/AlarmClock/src/Network.lf | 8 +++++-- examples/Cpp/CarBrake/src/CarBrake.lf | 4 +++- examples/Cpp/CarBrake/src/CarBrake2.lf | 4 +++- examples/Cpp/ROS2/src/MinimalPublisher.lf | 4 +++- examples/Cpp/ROS2/src/MinimalSubscriber.lf | 4 +++- examples/Cpp/ReflexGame/src/ReflexGame.lf | 4 +++- examples/Cpp/RequestResponse/src/Add.lf | 4 +++- .../DoubleUnlock/DoubleUnlockDemo.lf | 8 +++++-- examples/Python/src/ReflexGame/ReflexGame.lf | 12 +++++++--- examples/Python/src/YOLOv5/YOLOv5_Webcam.lf | 12 +++++++--- .../Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf | 8 +++++-- .../Python/src/acas/lib/ACASController.lf | 4 +++- examples/Python/src/acas/lib/Aircraft.lf | 8 +++++-- examples/Rust/src/Snake/Snake.lf | 5 +++- .../ChatApplication/src/SimpleChat.lf | 16 +++++++++---- .../SimpleWebserver/src/SimpleWebserver.lf | 4 +++- 53 files changed, 282 insertions(+), 94 deletions(-) diff --git a/examples/C/src/ChatApplication/SimpleChat.lf b/examples/C/src/ChatApplication/SimpleChat.lf index ee7940df..f0d0f5d3 100644 --- a/examples/C/src/ChatApplication/SimpleChat.lf +++ b/examples/C/src/ChatApplication/SimpleChat.lf @@ -72,7 +72,9 @@ reactor InputHandler { reactor Printer { input in: string - reaction(in) {= printf("Received: %s\n", in->value); =} + reaction(in) {= + printf("Received: %s\n", in->value); + =} } reactor ChatHandler { @@ -81,9 +83,13 @@ reactor ChatHandler { u = new InputHandler() r = new Printer() - reaction(u.out) -> send {= lf_set(send, u.out->value); =} + reaction(u.out) -> send {= + lf_set(send, u.out->value); + =} - reaction(receive) -> r.in {= lf_set(r.in, receive->value); =} + reaction(receive) -> r.in {= + lf_set(r.in, receive->value); + =} } federated reactor SimpleChat { diff --git a/examples/C/src/Delay.lf b/examples/C/src/Delay.lf index 69f55614..dc6ade8b 100644 --- a/examples/C/src/Delay.lf +++ b/examples/C/src/Delay.lf @@ -39,9 +39,13 @@ reactor Delay2 { input x: int output y: int - reaction(a) -> y {= lf_set(y, a->value); =} + reaction(a) -> y {= + lf_set(y, a->value); + =} - reaction(x) -> a {= lf_schedule_int(a, 0, x->value); =} + reaction(x) -> a {= + lf_schedule_int(a, 0, x->value); + =} } /** Print the (elapsed) logical and physical times at which inputs are received. */ diff --git a/examples/C/src/DistributedDatabase/ReplicatedDatabase.lf b/examples/C/src/DistributedDatabase/ReplicatedDatabase.lf index 4b9b1730..df9b859d 100644 --- a/examples/C/src/DistributedDatabase/ReplicatedDatabase.lf +++ b/examples/C/src/DistributedDatabase/ReplicatedDatabase.lf @@ -72,8 +72,9 @@ reactor Server( self->queries_outstanding++; =} - reaction(update_trigger) -> update {= lf_set(update, self->update_amount); =} deadline( - update_deadline) {= + reaction(update_trigger) -> update {= + lf_set(update, self->update_amount); + =} deadline(update_deadline) {= tag_t tag = lf_tag(); lf_print_error("At tag (%lld, %u), deadline missed at database \"%s\". Rejecting update.\n" " Elapsed physical time is %lld.", @@ -186,7 +187,9 @@ reactor Database(name: char* = "unnamed database", num_remote_inputs: int = 1) { #endif =} - reaction(query) -> balance {= lf_set(balance, self->record); =} + reaction(query) -> balance {= + lf_set(balance, self->record); + =} } /** diff --git a/examples/C/src/DistributedResourceManagement/ResourceManagement.lf b/examples/C/src/DistributedResourceManagement/ResourceManagement.lf index e9d2ac25..6e173d37 100644 --- a/examples/C/src/DistributedResourceManagement/ResourceManagement.lf +++ b/examples/C/src/DistributedResourceManagement/ResourceManagement.lf @@ -358,7 +358,9 @@ reactor ResourceManager( } =} - reaction(shutdown) {= free(self->queue.queue); =} + reaction(shutdown) {= + free(self->queue.queue); + =} } /** diff --git a/examples/C/src/ReflexGame/ReflexGame.lf b/examples/C/src/ReflexGame/ReflexGame.lf index 2746f114..78ef6c3d 100644 --- a/examples/C/src/ReflexGame/ReflexGame.lf +++ b/examples/C/src/ReflexGame/ReflexGame.lf @@ -100,7 +100,9 @@ reactor GetUserInput { lf_thread_create(&thread_id, &read_input, user_response); =} - reaction(prompt) {= self->prompt_time = lf_time_logical(); =} + reaction(prompt) {= + self->prompt_time = lf_time_logical(); + =} reaction(user_response) -> another {= if (user_response->value == EOF) { diff --git a/examples/C/src/RockPaperScissors.lf b/examples/C/src/RockPaperScissors.lf index fce8375b..31375150 100644 --- a/examples/C/src/RockPaperScissors.lf +++ b/examples/C/src/RockPaperScissors.lf @@ -8,7 +8,9 @@ */ target C -preamble {= typedef enum {paper=0, rock=1, scissors=2} symbol_t; =} +preamble {= + typedef enum {paper=0, rock=1, scissors=2} symbol_t; +=} main reactor RockPaperScissors { player1 = new Player(id=1) @@ -19,7 +21,9 @@ main reactor RockPaperScissors { } reactor Player(id: char = 0) { - preamble {= const char* symbol_names[] = {"paper", "rock", "scissors"}; =} + preamble {= + const char* symbol_names[] = {"paper", "rock", "scissors"}; + =} input observe: symbol_t output reveal: symbol_t diff --git a/examples/C/src/browser-ui/BrowserUI.lf b/examples/C/src/browser-ui/BrowserUI.lf index ef461486..cb7d42c7 100644 --- a/examples/C/src/browser-ui/BrowserUI.lf +++ b/examples/C/src/browser-ui/BrowserUI.lf @@ -25,7 +25,9 @@ main reactor { state count: int = 0 s = new ServerUI() - reaction(s.initialized) {= self->count = 0; =} + reaction(s.initialized) {= + self->count = 0; + =} reaction(s.request) -> s.response {= char* response; diff --git a/examples/C/src/car-brake/CarBrake.lf b/examples/C/src/car-brake/CarBrake.lf index 3fa21c25..ec618428 100644 --- a/examples/C/src/car-brake/CarBrake.lf +++ b/examples/C/src/car-brake/CarBrake.lf @@ -64,7 +64,9 @@ reactor Braking { state thread: lf_thread_t - reaction(startup) -> pedal {= lf_thread_create(&self->thread, &press_pedal, pedal); =} + reaction(startup) -> pedal {= + lf_thread_create(&self->thread, &press_pedal, pedal); + =} reaction(shutdown) {= stop_thread = true; diff --git a/examples/C/src/deadlines/AnytimePrime.lf b/examples/C/src/deadlines/AnytimePrime.lf index c2a6c4a1..e1fba6e3 100644 --- a/examples/C/src/deadlines/AnytimePrime.lf +++ b/examples/C/src/deadlines/AnytimePrime.lf @@ -49,13 +49,17 @@ reactor Prime { // Output the largest prime found. lf_set(out, (long long)primes.start[num_primes - 1]); - =} deadline(3 sec) {= lf_print("Deadline handler called!"); =} + =} deadline(3 sec) {= + lf_print("Deadline handler called!"); + =} } reactor Print { input in: {= long long =} - reaction(in) {= printf("Largest prime found within the deadline: %lld\n", in->value); =} + reaction(in) {= + printf("Largest prime found within the deadline: %lld\n", in->value); + =} } main reactor AnytimePrime { diff --git a/examples/C/src/deadlines/PeriodicDeadline.lf b/examples/C/src/deadlines/PeriodicDeadline.lf index 38c23829..f05f9174 100644 --- a/examples/C/src/deadlines/PeriodicDeadline.lf +++ b/examples/C/src/deadlines/PeriodicDeadline.lf @@ -39,7 +39,9 @@ reactor OffsetSensor(offset: time = 0) extends Sensor { lf_sleep(SEC(2)); =} - reaction(t) -> y {= lf_set(y, self->count++); =} + reaction(t) -> y {= + lf_set(y, self->count++); + =} } reactor StartupSensor extends Sensor { diff --git a/examples/C/src/keyboard/Keyboard.lf b/examples/C/src/keyboard/Keyboard.lf index 25e199ea..2b8d8031 100644 --- a/examples/C/src/keyboard/Keyboard.lf +++ b/examples/C/src/keyboard/Keyboard.lf @@ -87,7 +87,9 @@ reactor KeyboardInput(exit_key: int = 0) { lf_thread_create(&thread_id, &read_input, &keyboard_input); =} - reaction(keypress) -> key {= lf_set(key, keypress->value); =} + reaction(keypress) -> key {= + lf_set(key, keypress->value); + =} reaction(shutdown) {= endwin(); @@ -98,5 +100,7 @@ reactor KeyboardInput(exit_key: int = 0) { main reactor { k = new KeyboardInput(exit_key=120) - reaction(k.key) {= lf_print("You typed %c (keycode %d).", k.key->value, k.key->value); =} + reaction(k.key) {= + lf_print("You typed %c (keycode %d).", k.key->value, k.key->value); + =} } diff --git a/examples/C/src/leader-election/Election.lf b/examples/C/src/leader-election/Election.lf index 9f2e90ca..1a34bba7 100644 --- a/examples/C/src/leader-election/Election.lf +++ b/examples/C/src/leader-election/Election.lf @@ -21,9 +21,13 @@ reactor Node(id: int = 0) { logical action a: int initial mode NotElected { - reaction(startup) -> out {= lf_set(out, self->id); =} + reaction(startup) -> out {= + lf_set(out, self->id); + =} - reaction(a) -> out {= lf_set(out, a->value); =} + reaction(a) -> out {= + lf_set(out, a->value); + =} reaction(in) -> a, reset(Elected) {= if (in->value > self->id) { diff --git a/examples/C/src/lib/PrintToFile.lf b/examples/C/src/lib/PrintToFile.lf index 5a0a80a4..32fe84f7 100644 --- a/examples/C/src/lib/PrintToFile.lf +++ b/examples/C/src/lib/PrintToFile.lf @@ -17,5 +17,7 @@ reactor PrintToFile(filename: string = "output.data") { fprintf(self->file, "%f %f\n", t, y->value); =} - reaction(shutdown) {= fclose(self->file); =} + reaction(shutdown) {= + fclose(self->file); + =} } diff --git a/examples/C/src/lib/Random.lf b/examples/C/src/lib/Random.lf index b7bb897a..9899cac0 100644 --- a/examples/C/src/lib/Random.lf +++ b/examples/C/src/lib/Random.lf @@ -27,7 +27,9 @@ reactor Random(seed: {= unsigned int =} = 0) { } =} - method random(): int {= return rand_r(&self->seed); =} + method random(): int {= + return rand_r(&self->seed); + =} method exponential(lambda: double): double {= double u = random() / (RAND_MAX + 1.0); diff --git a/examples/C/src/lib/RandomDelay.lf b/examples/C/src/lib/RandomDelay.lf index 59d9c5d4..ff8d77cd 100644 --- a/examples/C/src/lib/RandomDelay.lf +++ b/examples/C/src/lib/RandomDelay.lf @@ -14,7 +14,9 @@ reactor RandomDelay(average: time = 1 sec) extends Random { output out: time logical action a: time - reaction(a) -> out {= lf_set(out, a->value); =} + reaction(a) -> out {= + lf_set(out, a->value); + =} reaction(in) -> a {= double lambda = SEC(1) / ((double)self->average); diff --git a/examples/C/src/lib/ServerUI.lf b/examples/C/src/lib/ServerUI.lf index ef4315ed..2264d618 100644 --- a/examples/C/src/lib/ServerUI.lf +++ b/examples/C/src/lib/ServerUI.lf @@ -158,7 +158,9 @@ reactor ServerUI(initial_file: string = "page.html", hostport: uint16_t = 8080) * with its contents. The caller is responsible for freeing the pointer returned. * @param path File path relative to the source .lf file. */ - method read_file(path: {= const char* =}): char* {= + method read_file(path: {= + const char* + =}): char* {= // Construct the path to the file to be read char* file_path = (char *) malloc(strlen(LF_SOURCE_DIRECTORY) + strlen(path) + 2); if (file_path == NULL) lf_print_error_and_exit("Out of memory."); diff --git a/examples/C/src/lib/WebSocketServer.lf b/examples/C/src/lib/WebSocketServer.lf index 637443ea..b96db945 100644 --- a/examples/C/src/lib/WebSocketServer.lf +++ b/examples/C/src/lib/WebSocketServer.lf @@ -270,7 +270,9 @@ reactor WebSocketServer(hostport: int = 8000, max_clients: int = 0) { self->status.running = true; =} - reaction(received_action) -> received {= lf_set_token(received, received_action->token); =} + reaction(received_action) -> received {= + lf_set_token(received, received_action->token); + =} reaction(send) {= // NOTE: This send must be before the reaction to connected_action @@ -290,7 +292,11 @@ reactor WebSocketServer(hostport: int = 8000, max_clients: int = 0) { } =} - reaction(connected_action) -> connected {= lf_set(connected, connected_action->value); =} + reaction(connected_action) -> connected {= + lf_set(connected, connected_action->value); + =} - reaction(shutdown) {= self->status.running = false; =} + reaction(shutdown) {= + self->status.running = false; + =} } diff --git a/examples/C/src/modal_models/FurutaPendulum/FurutaPendulumDisturbance.lf b/examples/C/src/modal_models/FurutaPendulum/FurutaPendulumDisturbance.lf index 48c24c6b..873cb013 100644 --- a/examples/C/src/modal_models/FurutaPendulum/FurutaPendulumDisturbance.lf +++ b/examples/C/src/modal_models/FurutaPendulum/FurutaPendulumDisturbance.lf @@ -33,5 +33,7 @@ main reactor { s.theta -> p.theta s.phi -> p.phi - reaction(disturb) -> s.d {= lf_set(s.d, 0.5); =} + reaction(disturb) -> s.d {= + lf_set(s.d, 0.5); + =} } diff --git a/examples/C/src/modal_models/FurutaPendulum/PendulumSimulation.lf b/examples/C/src/modal_models/FurutaPendulum/PendulumSimulation.lf index c8b1e7e0..de0111fa 100644 --- a/examples/C/src/modal_models/FurutaPendulum/PendulumSimulation.lf +++ b/examples/C/src/modal_models/FurutaPendulum/PendulumSimulation.lf @@ -156,5 +156,7 @@ reactor PendulumSimulation( self->x[1] += d->value; =} - reaction(u) {= self->latest_u = u->value; =} + reaction(u) {= + self->latest_u = u->value; + =} } diff --git a/examples/C/src/modal_models/FurutaPendulum/Print.lf b/examples/C/src/modal_models/FurutaPendulum/Print.lf index 0c36d602..f2ec8133 100644 --- a/examples/C/src/modal_models/FurutaPendulum/Print.lf +++ b/examples/C/src/modal_models/FurutaPendulum/Print.lf @@ -37,5 +37,7 @@ reactor Print(filename: string = "pendulum.csv") { ); =} - reaction(shutdown) {= fclose(self->file); =} + reaction(shutdown) {= + fclose(self->file); + =} } diff --git a/examples/C/src/patterns/Simultaneity.lf b/examples/C/src/patterns/Simultaneity.lf index f326abfb..5f58cf3a 100644 --- a/examples/C/src/patterns/Simultaneity.lf +++ b/examples/C/src/patterns/Simultaneity.lf @@ -7,7 +7,9 @@ reactor Source(period: time = 100 ms) { output out: int state count: int = 0 - reaction(t) -> out {= lf_set(out, self->count++); =} + reaction(t) -> out {= + lf_set(out, self->count++); + =} } reactor Sink { diff --git a/examples/C/src/patterns/lib/SendersAndReceivers.lf b/examples/C/src/patterns/lib/SendersAndReceivers.lf index bc706b13..9a7c49f1 100644 --- a/examples/C/src/patterns/lib/SendersAndReceivers.lf +++ b/examples/C/src/patterns/lib/SendersAndReceivers.lf @@ -9,7 +9,9 @@ target C reactor SendOnce { output out: int - reaction(startup) -> out {= lf_set(out, 42); =} + reaction(startup) -> out {= + lf_set(out, 42); + =} } /** @@ -47,14 +49,18 @@ reactor ReceiveAndSend { input in: int output out: int - reaction(in) -> out {= lf_set(out, in->value); =} + reaction(in) -> out {= + lf_set(out, in->value); + =} } reactor SendOnceAndReceive { input in: int output out: int - reaction(startup) -> out {= lf_set(out, 42); =} + reaction(startup) -> out {= + lf_set(out, 42); + =} reaction(in) {= lf_print("At tag (%lld, %d), received %d.", @@ -164,7 +170,9 @@ reactor SendAndReceiveWithLocalQuery(query_offset: time = 0, query_period: time extends LocalRemoteUpdates { local_query = new SendPeriodicallyAndReceive(offset=query_offset, period=query_period) - reaction(local_query.out) -> local_query.in {= lf_set(local_query.in, self->count); =} + reaction(local_query.out) -> local_query.in {= + lf_set(local_query.in, self->count); + =} } // @label Accumulate local/remote increments, delayed query. @@ -175,7 +183,11 @@ reactor SendAndReceiveWithDelayedQuery( local_query = new SendPeriodicallyAndReceive(offset=query_offset, period=query_period) logical action a(query_delay) - reaction(local_query.out) -> a {= lf_schedule(a, 0); =} + reaction(local_query.out) -> a {= + lf_schedule(a, 0); + =} - reaction(a) -> local_query.in {= lf_set(local_query.in, self->count); =} + reaction(a) -> local_query.in {= + lf_set(local_query.in, self->count); + =} } diff --git a/examples/C/src/rhythm/PlayWaveform.lf b/examples/C/src/rhythm/PlayWaveform.lf index 4840e4b7..6238c436 100644 --- a/examples/C/src/rhythm/PlayWaveform.lf +++ b/examples/C/src/rhythm/PlayWaveform.lf @@ -86,7 +86,9 @@ reactor PlayWaveform( lf_start_audio_loop(lf_time_logical()); =} - reaction(waveform) {= self->waveform_id = waveform->value; =} + reaction(waveform) {= + self->waveform_id = waveform->value; + =} reaction(note) {= if (self->waveform_id < 0 || self->waveform_id > NUM_WAVEFORMS) { @@ -96,5 +98,7 @@ reactor PlayWaveform( } =} - reaction(shutdown) {= lf_stop_audio_loop(); =} + reaction(shutdown) {= + lf_stop_audio_loop(); + =} } diff --git a/examples/C/src/rhythm/Rhythm.lf b/examples/C/src/rhythm/Rhythm.lf index c0fc1c1f..3db74e21 100644 --- a/examples/C/src/rhythm/Rhythm.lf +++ b/examples/C/src/rhythm/Rhythm.lf @@ -284,7 +284,9 @@ reactor RhythmSource( lf_schedule(tick, self->tick_duration); =} - reaction(shutdown) {= end_sensor_simulator(); =} + reaction(shutdown) {= + end_sensor_simulator(); + =} } main reactor { diff --git a/examples/C/src/rhythm/RhythmDistributedNoUI.lf b/examples/C/src/rhythm/RhythmDistributedNoUI.lf index 96a60794..44f7ca53 100644 --- a/examples/C/src/rhythm/RhythmDistributedNoUI.lf +++ b/examples/C/src/rhythm/RhythmDistributedNoUI.lf @@ -45,7 +45,9 @@ reactor BeatSource(period: time = 1600 msec) { timer tick(0, period) - reaction(tick) -> note {= lf_set(note, 1.0f); =} + reaction(tick) -> note {= + lf_set(note, 1.0f); + =} } reactor RhythmPlayer { diff --git a/examples/C/src/rhythm/SensorSimulator.lf b/examples/C/src/rhythm/SensorSimulator.lf index 197cee8b..50269216 100644 --- a/examples/C/src/rhythm/SensorSimulator.lf +++ b/examples/C/src/rhythm/SensorSimulator.lf @@ -24,7 +24,9 @@ main reactor { register_sensor_key('\0', key); =} - reaction(t) {= show_tick("*"); =} + reaction(t) {= + show_tick("*"); + =} reaction(r) {= lf_print("Elapsed logical time: %lld.", lf_time_logical_elapsed()); diff --git a/examples/C/src/rhythm/Sound.lf b/examples/C/src/rhythm/Sound.lf index 02dc5f3c..c95291ec 100644 --- a/examples/C/src/rhythm/Sound.lf +++ b/examples/C/src/rhythm/Sound.lf @@ -45,7 +45,9 @@ reactor RhythmSource( state count: int = 0 // Count of sixteenth notes. - reaction(startup) -> note, tick {= lf_schedule(tick, self->sixteenth); =} + reaction(startup) -> note, tick {= + lf_schedule(tick, self->sixteenth); + =} reaction(tick) -> note, tick {= int position = 1 << self->count; diff --git a/examples/C/src/robot/CompositeRobot.lf b/examples/C/src/robot/CompositeRobot.lf index 394f8308..4be4f16a 100644 --- a/examples/C/src/robot/CompositeRobot.lf +++ b/examples/C/src/robot/CompositeRobot.lf @@ -32,9 +32,13 @@ reactor Handler { } mode HANDLING { - reaction(arm_status, agv_status, gripper_status) -> reset(IDLE) {= lf_set_mode(IDLE); =} + reaction(arm_status, agv_status, gripper_status) -> reset(IDLE) {= + lf_set_mode(IDLE); + =} - reaction(job) {= lf_print("Job rejected at %lld ns. Busy.", lf_time_logical_elapsed()); =} + reaction(job) {= + lf_print("Job rejected at %lld ns. Busy.", lf_time_logical_elapsed()); + =} } } @@ -44,7 +48,9 @@ reactor Jobs { p = new PoissonClock() - reaction(p.event) -> job {= lf_set(job, self->job_count++); =} + reaction(p.event) -> job {= + lf_set(job, self->job_count++); + =} } reactor ManualControl { diff --git a/examples/C/src/rosace/AircraftSimulator.lf b/examples/C/src/rosace/AircraftSimulator.lf index 5d6baa18..e1309764 100644 --- a/examples/C/src/rosace/AircraftSimulator.lf +++ b/examples/C/src/rosace/AircraftSimulator.lf @@ -140,7 +140,9 @@ reactor Engine(period: time = 5 ms, scale: double = 26350.0, tau: double = 0.75) state x1: double = {= delta_th_eq =} - reaction(t) -> T {= lf_set(T, self->scale * self->x1); =} + reaction(t) -> T {= + lf_set(T, self->scale * self->x1); + =} reaction(t) delta_thc {= const double dt = ((double)self->period)/1e9; // Period in seconds. (1.0/200.0) @@ -161,7 +163,9 @@ reactor Elevator(period: time = 5 ms, omega: double = 25.0, xi: double = 0.85) { state x1: double = {= delta_e_eq =} state x2: double = 0.0 - reaction(t) -> delta_e {= lf_set(delta_e, self->x1); =} + reaction(t) -> delta_e {= + lf_set(delta_e, self->x1); + =} reaction(t) delta_ec {= const double dt = ((double)self->period)/1e9; // Period in seconds. (1.0/200.0) diff --git a/examples/C/src/rosace/Rosace.lf b/examples/C/src/rosace/Rosace.lf index 127efcd4..246f55cd 100644 --- a/examples/C/src/rosace/Rosace.lf +++ b/examples/C/src/rosace/Rosace.lf @@ -72,7 +72,9 @@ reactor Command(period: time = 100 ms, value: double = 0.0) { timer t(0, period) output c: double - reaction(t) -> c {= lf_set(c, self->value); =} + reaction(t) -> c {= + lf_set(c, self->value); + =} } main reactor(filter_period: time = 10 ms) { diff --git a/examples/C/src/rosace/RosaceController.lf b/examples/C/src/rosace/RosaceController.lf index eb7a45d2..a9237d1b 100644 --- a/examples/C/src/rosace/RosaceController.lf +++ b/examples/C/src/rosace/RosaceController.lf @@ -61,7 +61,9 @@ reactor Filter( self->x2 = self->init_x2; =} - reaction(t) -> y {= lf_set(y, self->x2); =} + reaction(t) -> y {= + lf_set(y, self->x2); + =} reaction(t) x {= double x1_tmp = - self->a[0] * self->x2 + self->b[0] * x->value; @@ -76,7 +78,9 @@ reactor Command(period: time = 100 ms, value: double = 0.0) { timer t(0, period) output c: double - reaction(t) -> c {= lf_set(c, self->value); =} + reaction(t) -> c {= + lf_set(c, self->value); + =} } reactor Hold( diff --git a/examples/C/src/sdv/ParkingAssist.lf b/examples/C/src/sdv/ParkingAssist.lf index c6f6c47b..b8c4a1fb 100644 --- a/examples/C/src/sdv/ParkingAssist.lf +++ b/examples/C/src/sdv/ParkingAssist.lf @@ -71,7 +71,11 @@ reactor Sensors( * into the result and return 0. Otherwise, return -1 if the key is not present, -2 if the value * is not an int, and -3 if the JSON string does not have the expected form. */ - method json_to_int(json: {= const char* =}, key: {= const char* =}, result: int*): int {= + method json_to_int(json: {= + const char* + =}, key: {= + const char* + =}, result: int*): int {= char* key_position = strstr(json, key); if (key_position == NULL) return -1; // Check that the next character is closing quotation mark. @@ -144,7 +148,9 @@ reactor Dashboard { =} // Make sure disconnections occur after messages are sent. - reaction(s.connected) {= self->connection = s.connected->value; =} + reaction(s.connected) {= + self->connection = s.connected->value; + =} } reactor SoundAlert { diff --git a/examples/C/src/simulation/MemoryHierarchy.lf b/examples/C/src/simulation/MemoryHierarchy.lf index 8522dc77..7e8c70fa 100644 --- a/examples/C/src/simulation/MemoryHierarchy.lf +++ b/examples/C/src/simulation/MemoryHierarchy.lf @@ -44,7 +44,9 @@ reactor Client(seed: int = 0, lambda: double = 10000000.0) { #include "platform.h" // Defines PRINTF_TIME =} - reaction(p.event) -> request {= lf_set(request, lf_time_logical_elapsed()); =} + reaction(p.event) -> request {= + lf_set(request, lf_time_logical_elapsed()); + =} reaction(response) {= if (response->value > 0) { @@ -74,7 +76,9 @@ reactor Cache(miss_probability: double = 0.1, hit_delay: time = 10 ns) extends R state pending: bool = false logical action a: time - reaction(a) -> response {= lf_set(response, a->value); =} + reaction(a) -> response {= + lf_set(response, a->value); + =} reaction(request) -> a, response, miss {= bool hit = random() >= (int)(self->miss_probability * RAND_MAX); @@ -101,7 +105,11 @@ reactor Memory(seed: int = 0, average_delay: time = 100 ns) { output response: time delay = new RandomDelay(average=average_delay) - reaction(request) -> delay.in {= lf_set(delay.in, request->value); =} + reaction(request) -> delay.in {= + lf_set(delay.in, request->value); + =} - reaction(delay.out) -> response {= lf_set(response, delay.out->value); =} + reaction(delay.out) -> response {= + lf_set(response, delay.out->value); + =} } diff --git a/examples/C/src/train-door/TrainDoorWithDeadlines.lf b/examples/C/src/train-door/TrainDoorWithDeadlines.lf index 1a8b6b02..bb1a6e05 100644 --- a/examples/C/src/train-door/TrainDoorWithDeadlines.lf +++ b/examples/C/src/train-door/TrainDoorWithDeadlines.lf @@ -21,12 +21,16 @@ realtime reactor Train { reaction(stop) {= self->moving = false; lf_print("Train stopped."); - =} deadline(50 msec) {= lf_print_warning("Deadline violated! Ignoring stop command."); =} + =} deadline(50 msec) {= + lf_print_warning("Deadline violated! Ignoring stop command."); + =} reaction(move) {= self->moving = true; lf_print("Train moving."); - =} deadline(48 msec) {= lf_print_warning("Deadline violated! Ignoring move command."); =} + =} deadline(48 msec) {= + lf_print_warning("Deadline violated! Ignoring move command."); + =} } realtime reactor Door { diff --git a/examples/CCpp/DoorLock/src/DoorLock.lf b/examples/CCpp/DoorLock/src/DoorLock.lf index 4872dc20..040d1c63 100644 --- a/examples/CCpp/DoorLock/src/DoorLock.lf +++ b/examples/CCpp/DoorLock/src/DoorLock.lf @@ -35,7 +35,9 @@ reactor DoorLockController { output actuate: LockCommand initial mode ClosedLocked { - reaction(reset) {= lf_print("*** Door is closed and has been locked."); =} + reaction(reset) {= + lf_print("*** Door is closed and has been locked."); + =} reaction(button, fob, mobile) -> reset(ClosedUnlocked), actuate {= if ( @@ -50,11 +52,15 @@ reactor DoorLockController { } =} - reaction(door) {= lf_print("Door is closed and locked."); =} + reaction(door) {= + lf_print("Door is closed and locked."); + =} } mode ClosedUnlocked { - reaction(reset) {= lf_print("*** Door has been closed and is unlocked."); =} + reaction(reset) {= + lf_print("*** Door has been closed and is unlocked."); + =} reaction(button, fob, mobile) -> reset(ClosedLocked), actuate {= if ( @@ -76,14 +82,18 @@ reactor DoorLockController { } mode Open { - reaction(reset) {= lf_print("*** Door has been opened."); =} + reaction(reset) {= + lf_print("*** Door has been opened."); + =} reaction(door) -> reset(ClosedUnlocked) {= if (door->value == CLOSE) lf_set_mode(ClosedUnlocked); else lf_print("Door is already open."); =} - reaction(button, fob, mobile) {= lf_print("Door is open."); =} + reaction(button, fob, mobile) {= + lf_print("Door is open."); + =} } } diff --git a/examples/Cpp/AlarmClock/src/AlarmClock.lf b/examples/Cpp/AlarmClock/src/AlarmClock.lf index 113186a5..27992705 100644 --- a/examples/Cpp/AlarmClock/src/AlarmClock.lf +++ b/examples/Cpp/AlarmClock/src/AlarmClock.lf @@ -27,5 +27,7 @@ main reactor AlarmClock { network.delete_index -> clock.cancel_by_index clock.event_dump -> network.updated_events - reaction(startup) {= std::cout << "Starting Lingua Franca AlarmClock" << std::endl; =} + reaction(startup) {= + std::cout << "Starting Lingua Franca AlarmClock" << std::endl; + =} } diff --git a/examples/Cpp/AlarmClock/src/Clock.lf b/examples/Cpp/AlarmClock/src/Clock.lf index 196d1d49..7eef961d 100644 --- a/examples/Cpp/AlarmClock/src/Clock.lf +++ b/examples/Cpp/AlarmClock/src/Clock.lf @@ -71,7 +71,9 @@ reactor Trigger { ignore_flag = false; =} - reaction(interrupt) {= ignore_flag = true; =} + reaction(interrupt) {= + ignore_flag = true; + =} } reactor Clock { diff --git a/examples/Cpp/AlarmClock/src/Network.lf b/examples/Cpp/AlarmClock/src/Network.lf index 45aa78cc..2455d30d 100644 --- a/examples/Cpp/AlarmClock/src/Network.lf +++ b/examples/Cpp/AlarmClock/src/Network.lf @@ -213,7 +213,11 @@ reactor Network { }); =} - reaction(updated_events) {= events = std::move(*updated_events.get()); =} + reaction(updated_events) {= + events = std::move(*updated_events.get()); + =} - reaction(shutdown) {= thread.join(); =} + reaction(shutdown) {= + thread.join(); + =} } diff --git a/examples/Cpp/CarBrake/src/CarBrake.lf b/examples/Cpp/CarBrake/src/CarBrake.lf index a1f3957a..84e235c4 100644 --- a/examples/Cpp/CarBrake/src/CarBrake.lf +++ b/examples/Cpp/CarBrake/src/CarBrake.lf @@ -63,7 +63,9 @@ reactor BrakePedal { trigger_brake.set(); =} - reaction(shutdown) {= thread.join(); =} + reaction(shutdown) {= + thread.join(); + =} } reactor Brake { diff --git a/examples/Cpp/CarBrake/src/CarBrake2.lf b/examples/Cpp/CarBrake/src/CarBrake2.lf index d3ede35a..d943c92c 100644 --- a/examples/Cpp/CarBrake/src/CarBrake2.lf +++ b/examples/Cpp/CarBrake/src/CarBrake2.lf @@ -57,7 +57,9 @@ reactor BrakePedal { trigger_brake.set(); =} - reaction(shutdown) {= thread.join(); =} + reaction(shutdown) {= + thread.join(); + =} } reactor Brake { diff --git a/examples/Cpp/ROS2/src/MinimalPublisher.lf b/examples/Cpp/ROS2/src/MinimalPublisher.lf index 18fe48a1..1aaceac8 100644 --- a/examples/Cpp/ROS2/src/MinimalPublisher.lf +++ b/examples/Cpp/ROS2/src/MinimalPublisher.lf @@ -27,7 +27,9 @@ main reactor { timer t(0, 500 ms) - reaction(startup) {= publisher = lf_node->create_publisher("topic", 10); =} + reaction(startup) {= + publisher = lf_node->create_publisher("topic", 10); + =} reaction(t) {= auto message = std_msgs::msg::String(); diff --git a/examples/Cpp/ROS2/src/MinimalSubscriber.lf b/examples/Cpp/ROS2/src/MinimalSubscriber.lf index 406fc07a..5cd82f4e 100644 --- a/examples/Cpp/ROS2/src/MinimalSubscriber.lf +++ b/examples/Cpp/ROS2/src/MinimalSubscriber.lf @@ -35,5 +35,7 @@ main reactor { // const std_msgs::msg::String::SharedPtr& msg =} - reaction(message) {= reactor::log::Info() << "I heard: " << *message.get(); =} + reaction(message) {= + reactor::log::Info() << "I heard: " << *message.get(); + =} } diff --git a/examples/Cpp/ReflexGame/src/ReflexGame.lf b/examples/Cpp/ReflexGame/src/ReflexGame.lf index 4f5074da..a68f94cd 100644 --- a/examples/Cpp/ReflexGame/src/ReflexGame.lf +++ b/examples/Cpp/ReflexGame/src/ReflexGame.lf @@ -90,7 +90,9 @@ reactor GetUserInput { }); =} - reaction(prompt) {= prompt_time = get_physical_time(); =} + reaction(prompt) {= + prompt_time = get_physical_time(); + =} reaction(user_response) -> another {= auto c = user_response.get(); diff --git a/examples/Cpp/RequestResponse/src/Add.lf b/examples/Cpp/RequestResponse/src/Add.lf index 16d0f6f6..7a174d2e 100644 --- a/examples/Cpp/RequestResponse/src/Add.lf +++ b/examples/Cpp/RequestResponse/src/Add.lf @@ -26,7 +26,9 @@ reactor Client { counter++; =} - reaction(add_response) {= reactor::log::Info() << "It is " << add_response.get()->data(); =} + reaction(add_response) {= + reactor::log::Info() << "It is " << add_response.get()->data(); + =} } main reactor { diff --git a/examples/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf b/examples/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf index a110e132..fb638277 100644 --- a/examples/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf +++ b/examples/Python/src/DigitalTwin/DoubleUnlock/DoubleUnlockDemo.lf @@ -131,9 +131,13 @@ reactor DoubleUnlockKeyFob(auto_lock_duration=5) { t.start() =} - reaction(press_lock) -> handle_press_lock {= handle_press_lock.schedule(0) =} + reaction(press_lock) -> handle_press_lock {= + handle_press_lock.schedule(0) + =} - reaction(press_unlock) -> handle_press_unlock {= handle_press_unlock.schedule(0) =} + reaction(press_unlock) -> handle_press_unlock {= + handle_press_unlock.schedule(0) + =} reaction(handle_press_lock) -> do_lock, send_lock_action {= self.append_log(auto=False, remote=False, do_lock=True) diff --git a/examples/Python/src/ReflexGame/ReflexGame.lf b/examples/Python/src/ReflexGame/ReflexGame.lf index d75acd51..f74f7102 100644 --- a/examples/Python/src/ReflexGame/ReflexGame.lf +++ b/examples/Python/src/ReflexGame/ReflexGame.lf @@ -24,7 +24,9 @@ reactor RandomSource(min_time = 2 sec, max_time = 8 sec) { logical action prompt(min_time) state count = 0 - reaction(startup) {= self.random.seed() =} + reaction(startup) {= + self.random.seed() + =} reaction(prompt) -> out {= self.count += 1 @@ -67,7 +69,9 @@ reactor GetUserInput { t.start() =} - reaction(user_response) -> user_input {= user_input.set(user_response.value) =} + reaction(user_response) -> user_input {= + user_input.set(user_response.value) + =} } /** Sends graphics updates to the pygame process. */ @@ -154,7 +158,9 @@ reactor UpdateGraphics { * and UpdateGraphics */ reactor StartGui { - preamble {= import gui =} + preamble {= + import gui + =} output user_input_pipe output update_graphics_pipe diff --git a/examples/Python/src/YOLOv5/YOLOv5_Webcam.lf b/examples/Python/src/YOLOv5/YOLOv5_Webcam.lf index f91e703a..e0e9ad66 100644 --- a/examples/Python/src/YOLOv5/YOLOv5_Webcam.lf +++ b/examples/Python/src/YOLOv5/YOLOv5_Webcam.lf @@ -5,7 +5,9 @@ */ target Python -preamble {= BILLION = 1_000_000_000 =} +preamble {= + BILLION = 1_000_000_000 +=} /** * Use OpenCV2 to read from the user webcam. @@ -50,7 +52,9 @@ reactor WebCam(webcam_id=0) { self.video_capture_thread.start() =} - reaction(frame_action) -> camera_frame {= camera_frame.set(frame_action.value) =} + reaction(frame_action) -> camera_frame {= + camera_frame.set(frame_action.value) + =} reaction(shutdown) {= self.thread_should_be_running.clear() @@ -110,7 +114,9 @@ reactor Plotter(label_deadline = 100 msec) { state _model # Keep the model state _prev_time = 0 - preamble {= from cv2 import cv2 =} + preamble {= + from cv2 import cv2 + =} /** Receive the DNN model */ reaction(model) {= diff --git a/examples/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf b/examples/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf index bf0db6b0..60535db1 100644 --- a/examples/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf +++ b/examples/Python/src/YOLOv5/YOLOv5_Webcam_Timer.lf @@ -21,7 +21,9 @@ reactor WebCam { state video_capture_thread state thread_should_be_running - preamble {= import cv2 =} + preamble {= + import cv2 + =} timer camera_tick(3 sec, 100 msec) @@ -40,7 +42,9 @@ reactor WebCam { camera_frame.set((lf.time.physical_elapsed(), frame)) =} - reaction(shutdown) {= self.stream.release() =} + reaction(shutdown) {= + self.stream.release() + =} } main reactor { diff --git a/examples/Python/src/acas/lib/ACASController.lf b/examples/Python/src/acas/lib/ACASController.lf index 0b282e7c..b2b6314c 100644 --- a/examples/Python/src/acas/lib/ACASController.lf +++ b/examples/Python/src/acas/lib/ACASController.lf @@ -105,7 +105,9 @@ reactor PostProcessor( command.set(self.available_commands[next.value] * math.pi/180.0) =} - reaction(score) -> next {= next.schedule(0, np.argmin(score.value)) =} + reaction(score) -> next {= + next.schedule(0, np.argmin(score.value)) + =} } reactor ACASController(period = 1 s) { diff --git a/examples/Python/src/acas/lib/Aircraft.lf b/examples/Python/src/acas/lib/Aircraft.lf index c73b806b..34b3a3f2 100644 --- a/examples/Python/src/acas/lib/Aircraft.lf +++ b/examples/Python/src/acas/lib/Aircraft.lf @@ -24,7 +24,9 @@ */ target Python -preamble {= import math =} +preamble {= + import math +=} reactor Aircraft( x_init=0.0, # Initial x position in feet. @@ -53,7 +55,9 @@ reactor Aircraft( v.set(self.v_init) =} - reaction(turn) {= self.latest_turn = turn.value =} + reaction(turn) {= + self.latest_turn = turn.value + =} reaction(t) -> x, y, psi, v {= delta_t = self.period / 1e9 # Period is seconds diff --git a/examples/Rust/src/Snake/Snake.lf b/examples/Rust/src/Snake/Snake.lf index 95042599..02606097 100644 --- a/examples/Rust/src/Snake/Snake.lf +++ b/examples/Rust/src/Snake/Snake.lf @@ -125,5 +125,8 @@ main reactor Snake(grid_side: usize = 32, tempo_step: time = 40 msec, food_limit } =} - reaction(shutdown) {= println!("New high score: {}", self.snake.len()); =} // @label shutdown + // @label shutdown + reaction(shutdown) {= + println!("New high score: {}", self.snake.len()); + =} } diff --git a/examples/TypeScript/ChatApplication/src/SimpleChat.lf b/examples/TypeScript/ChatApplication/src/SimpleChat.lf index d1d3a362..be57f7e5 100644 --- a/examples/TypeScript/ChatApplication/src/SimpleChat.lf +++ b/examples/TypeScript/ChatApplication/src/SimpleChat.lf @@ -14,7 +14,9 @@ reactor InputHandler { output out: string physical action response - preamble {= import * as readline from "readline"; =} + preamble {= + import * as readline from "readline"; + =} reaction(startup, response) -> out, response {= const rl = readline.createInterface({ @@ -36,7 +38,9 @@ reactor InputHandler { reactor Printer { input inp: string - reaction(inp) {= console.log("Received: " + inp); =} + reaction(inp) {= + console.log("Received: " + inp); + =} } reactor ChatHandler { @@ -45,9 +49,13 @@ reactor ChatHandler { u = new InputHandler() p = new Printer() - reaction(u.out) -> send {= send = u.out; =} + reaction(u.out) -> send {= + send = u.out; + =} - reaction(receive) -> p.inp {= p.inp = receive; =} + reaction(receive) -> p.inp {= + p.inp = receive; + =} } federated reactor SimpleChat { diff --git a/examples/TypeScript/SimpleWebserver/src/SimpleWebserver.lf b/examples/TypeScript/SimpleWebserver/src/SimpleWebserver.lf index 5e781015..e60ec860 100644 --- a/examples/TypeScript/SimpleWebserver/src/SimpleWebserver.lf +++ b/examples/TypeScript/SimpleWebserver/src/SimpleWebserver.lf @@ -11,7 +11,9 @@ target TypeScript { } main reactor { - preamble {= import * as http from "http" =} + preamble {= + import * as http from "http" + =} state server: {= http.Server | undefined =} = {= undefined =} physical action serverRequest: {= [http.IncomingMessage, http.ServerResponse] =}