Skip to content

Commit

Permalink
Reformat according to new state of formatter.
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdonovan committed Jun 21, 2023
1 parent 176bf75 commit 26638d1
Show file tree
Hide file tree
Showing 129 changed files with 4,211 additions and 4,781 deletions.
18 changes: 8 additions & 10 deletions C/src/ChatApplication/SimpleChat.lf
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/**
* This program is a simple federated chat application written in Lingua Franca
* (LF) for two users, represented by two instances of the `ChatHandler`
* reactor, `a` and `b`. Each `ChatHandler` consists of an `InputHandler` and a
* `Printer`. The `InputHandler` is responsible for receiving user input from
* the console and sending it as a message. When the user enters a message, the
* `InputHandler` reads it, prints it, and then sends it via its `out` port. The
* message then gets relayed by the `ChatHandler` via its `send` port. On the
* receiving side, the `ChatHandler` directs the incoming message through its
* `receive` port to the `Printer` reactor, which prints the received message.
* This process creates a two-way communication where `a` and `b` can send and
* This program is a simple federated chat application written in Lingua Franca (LF) for two users,
* represented by two instances of the `ChatHandler` reactor, `a` and `b`. Each `ChatHandler`
* consists of an `InputHandler` and a `Printer`. The `InputHandler` is responsible for receiving
* user input from the console and sending it as a message. When the user enters a message, the
* `InputHandler` reads it, prints it, and then sends it via its `out` port. The message then gets
* relayed by the `ChatHandler` via its `send` port. On the receiving side, the `ChatHandler`
* directs the incoming message through its `receive` port to the `Printer` reactor, which prints
* the received message. This process creates a two-way communication where `a` and `b` can send and
* receive messages from each other.
*
* @author Byeonggil Jun (junbg@hanyang.ac.kr)
Expand Down
67 changes: 31 additions & 36 deletions C/src/Delay.lf
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
/**
* This (rather trivial) example illustrates a logical action used
* to model a delay. The delay is also realized a second time
* using the `after` keyword.
*
* This (rather trivial) example illustrates a logical action used to model a delay. The delay is
* also realized a second time using the `after` keyword.
*
* @author Marten Lohstroh
* @author Edward A. Lee
*/
target C {timeout: 1 sec};
target C {
timeout: 1 sec
}

main reactor {
ramp = new Ramp();
delay = new Delay2();
print = new Print();
ramp.y -> delay.x;
delay.y -> print.x;
ramp2 = new Ramp();
print2 = new Print();
ramp2.y -> print2.x after 50 msec;
ramp = new Ramp()
delay = new Delay2()
print = new Print()
ramp.y -> delay.x
delay.y -> print.x

ramp2 = new Ramp()
print2 = new Print()
ramp2.y -> print2.x after 50 msec
}

/**
* Generate a counting sequence with outputs every 100 msec.
*/
/** Generate a counting sequence with outputs every 100 msec. */
reactor Ramp {
timer t(0, 100 msec);
output y:int;
state count:int(0);
timer t(0, 100 msec)
output y: int
state count: int = 0

reaction(t) -> y {=
lf_set(y, self->count);
self->count++;
=}
}

/**
* Realize a logical delay of 50 msec.
*/
/** Realize a logical delay of 50 msec. */
reactor Delay2 {
logical action a(50 msec):int;
input x:int;
output y:int;
reaction(a) -> y {=
lf_set(y, a->value);
=}
reaction(x) -> a {=
lf_schedule_int(a, 0, x->value);
=}
logical action a(50 msec): int
input x: int
output y: int

reaction(a) -> y {= lf_set(y, a->value); =}

reaction(x) -> a {= lf_schedule_int(a, 0, x->value); =}
}

/**
* Print the (elapsed) logical and physical times at which inputs are received.
*/
/** Print the (elapsed) logical and physical times at which inputs are received. */
reactor Print {
input x:int;
input x: int

reaction(x) {=
printf("Logical time: %lld, Physical time %lld"
", Value: %d\n",
Expand Down
28 changes: 12 additions & 16 deletions C/src/DistributedDatabase/FederatedDatabase.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Federated version of ReplicatedDatabase.
* This is identical, except that it is federated.
*
* Federated version of ReplicatedDatabase. This is identical, except that it is federated.
*
* @author Edward A. Lee
* @author Soroush Bateni
*/
Expand All @@ -12,22 +11,19 @@ target C {

import Platform from "ReplicatedDatabase.lf"

federated reactor (
query_period:time(1 sec),
num_remote_inputs:int(1)
) {
federated reactor(query_period: time = 1 sec, num_remote_inputs: int = 1) {
a = new Platform(
query_period = query_period,
query_period=query_period,
update_period = 5 sec,
update_amount = 100,
update_amount=100,
name = "San Francisco",
num_remote_inputs = num_remote_inputs);
num_remote_inputs=num_remote_inputs)
b = new Platform(
query_period = query_period,
query_period=query_period,
update_period = 1 sec,
update_amount = -20,
name = "Berkeley",
num_remote_inputs = num_remote_inputs);
b.publish -> a.update;
a.publish -> b.update;
update_amount=-20,
name="Berkeley",
num_remote_inputs=num_remote_inputs)
b.publish -> a.update
a.publish -> b.update
}
Loading

0 comments on commit 26638d1

Please sign in to comment.