Skip to content

Commit abd0672

Browse files
committed
Updated federated docs
1 parent 15e80dc commit abd0672

12 files changed

+1469
-897
lines changed

docs/assets/code/c/src/DecentralizedFeeback.lf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target C {
55
reactor CountPrint {
66
input in:int;
77
output out:int;
8-
state c:int(0);
8+
state c:int = 0;
99
timer t(0, 1 sec);
1010
reaction(t) -> out {=
1111
lf_set(out, self->c++);
@@ -14,7 +14,7 @@ reactor CountPrint {
1414
lf_print("***** CountPrint Received: %d at tag (%lld, %u)",
1515
in->value, lf_time_logical_elapsed(), lf_tag().microstep
1616
);
17-
=} STP(10 msec) {=
17+
=} STAA(10 msec) {=
1818
lf_print_warning("CountPrint: Safe to process violation!");
1919
lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start());
2020
=}
@@ -24,12 +24,12 @@ reactor PrintCount {
2424
input in:int;
2525
output out:int;
2626
timer t(0, 999 msec);
27-
state c:int(0);
27+
state c:int = 0;
2828
reaction(in) {=
2929
lf_print("***** PrintCount Received: %d at tag (%lld, %u)",
3030
in->value, lf_time_logical_elapsed(), lf_tag().microstep
3131
);
32-
=} STP(10 msec) {=
32+
=} STAA(10 msec) {=
3333
lf_print_warning("PrintCount: Safe to process violation!");
3434
lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start());
3535
=}

docs/assets/code/c/src/DecentralizedFeebackSTP.lf renamed to docs/assets/code/c/src/DecentralizedFeebackSTA.lf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ target C {
22
timeout: 5 sec,
33
coordination: decentralized
44
}
5-
reactor CountPrint(STP_offset:time(10 msec)) {
5+
reactor CountPrint(STA:time = 10 ms) {
66
input in:int;
77
output out:int;
8-
state c:int(0);
8+
state c:int = 0;
99
timer t(0, 1 sec);
1010
reaction(t) -> out {=
1111
lf_set(out, self->c++);
@@ -17,11 +17,11 @@ reactor CountPrint(STP_offset:time(10 msec)) {
1717
=}
1818
}
1919

20-
reactor PrintCount(STP_offset:time(10 msec)) {
20+
reactor PrintCount(STA:time = 10 ms) {
2121
input in:int;
2222
output out:int;
2323
timer t(0, 1 sec);
24-
state c:int(0);
24+
state c:int = 0;
2525
reaction(in) {=
2626
lf_print("***** PrintCount Received: %d at tag (%lld, %u)",
2727
in->value, lf_time_logical_elapsed(), lf_tag().microstep
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
target C {
2+
coordination: decentralized
3+
}
4+
5+
reactor CountPrint {
6+
input in: int
7+
output out: int
8+
state c: int = 0
9+
timer t(0, 100 ms)
10+
11+
reaction(t) -> out {=
12+
lf_set(out, self->c++);
13+
=}
14+
15+
reaction(in) {=
16+
lf_print("***** CountPrint Received: %d at tag (%lld, %u)",
17+
in->value, lf_time_logical_elapsed(), lf_tag().microstep
18+
);
19+
=} STAA(forever) {=
20+
// This should never happen, but it is here to demonstrate the STAA violation handler.
21+
lf_print_warning("CountPrint: Safe to process violation!");
22+
lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start());
23+
=}
24+
}
25+
26+
reactor Double(STA: time = forever) {
27+
input in: int
28+
output out: int
29+
30+
reaction(in) -> out {=
31+
lf_set(out, in->value * 2);
32+
=}
33+
}
34+
35+
federated reactor {
36+
c = new CountPrint()
37+
p = new Double()
38+
c.out -> p.in
39+
p.out -> c.in
40+
}

docs/assets/code/c/src/DecentralizedTimerAfterHandler.lf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ reactor PrintTimer {
1313
lf_print("Received: %d at (%lld, %d)", in->value,
1414
lf_time_logical_elapsed(), lf_tag().microstep
1515
);
16-
=} STP(0) {=
17-
lf_print("****** STP violation handler invoked at (%lld, %d). "
16+
=} STAA(0) {=
17+
lf_print("****** Violation handler invoked at (%lld, %d). "
1818
"Intended tag was (%lld, %d).",
1919
lf_time_logical_elapsed(), lf_tag().microstep,
2020
in->intended_tag.time - lf_time_start(), in->intended_tag.microstep

docs/assets/code/c/src/DecentralizedTimerSTP.lf renamed to docs/assets/code/c/src/DecentralizedTimerSTA.lf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target C {
55

66
import Count, Print from "Federated.lf"
77

8-
reactor PrintTimer(STP_offset: time = 10 msec) extends Print {
8+
reactor PrintTimer(STA: time = 10 ms) extends Print {
99
timer t(0, 1 sec)
1010

1111
reaction(t) {=
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
target Python {
2+
coordination: decentralized
3+
}
4+
5+
reactor CountPrint {
6+
input inp
7+
output out
8+
state c = 0
9+
timer t(0, 100 ms)
10+
11+
reaction(t) -> out {=
12+
self.c += 1
13+
out.set(self.c)
14+
=}
15+
16+
reaction(inp) {=
17+
print(f"***** CountPrint Received: {inp.value} at tag ({lf.time.logical_elapsed()}, {lf.tag().microstep})")
18+
=} STAA(forever) {=
19+
# This should never happen, but it is here to demonstrate the STAA violation handler.
20+
print("CountPrint: Safe to process violation!")
21+
print(f"Intended time: {inp.intended_tag.time - lf.time.start()}")
22+
=}
23+
}
24+
25+
reactor Double(STA = forever) {
26+
input inp
27+
output out
28+
29+
reaction(inp) -> out {=
30+
out.set(inp.value * 2)
31+
=}
32+
}
33+
34+
federated reactor {
35+
c = new CountPrint()
36+
p = new Double()
37+
c.out -> p.inp
38+
p.out -> c.inp
39+
}

docs/assets/code/py/src/DecentralizedTimerAfterHandler.lf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ reactor PrintTimer {
1414
f"Received: {inp.value} "
1515
f"at ({lf.time.logical_elapsed()}, {lf.tag().microstep})"
1616
)
17-
=} STP(0) {=
17+
=} STAA(0) {=
1818
print(
19-
"****** STP violation handler invoked at "
19+
"****** Violation handler invoked at "
2020
f"({lf.time.logical_elapsed()}, {lf.tag().microstep}). "
2121
"Intended tag was "
2222
f"({inp.intended_tag.time - lf.time.start()}, {inp.intended_tag.microstep})."

docs/assets/code/py/src/DecentralizedTimerSTP.lf renamed to docs/assets/code/py/src/DecentralizedTimerSTA.lf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ target Python {
55

66
import Count, Print from "Federated.lf"
77

8-
reactor PrintTimer(STP_offset = 10 msec) extends Print {
8+
reactor PrintTimer(STA = 10 ms) extends Print {
99
timer t(0, 1 sec)
1010

1111
reaction(t) {=

docs/assets/images/diagrams/DecentralizedFeedbackSTAA.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)