diff --git a/versioned_docs/version-0.8.0/assets/code/.gitignore b/versioned_docs/version-0.8.0/assets/code/.gitignore new file mode 100644 index 000000000..55f4cfeb1 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/.gitignore @@ -0,0 +1,3 @@ +bin +src-gen +include diff --git a/versioned_docs/version-0.8.0/assets/code/c/.gitignore b/versioned_docs/version-0.8.0/assets/code/c/.gitignore new file mode 100644 index 000000000..dacffc6ba --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/.gitignore @@ -0,0 +1 @@ +include/ \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Alignment.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Alignment.lf new file mode 100644 index 000000000..403de2556 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Alignment.lf @@ -0,0 +1,22 @@ +target C { + timeout: 3 secs +} + +main reactor Alignment { + state s: int = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + timer t4(400 msec, 400 msec) + + reaction(t1) {= + self->s += 1; + =} + + reaction(t2) {= + self->s -= 2; + =} + + reaction(t4) {= + printf("s = %d\n", self->s); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Asynchronous.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Asynchronous.lf new file mode 100644 index 000000000..381116b8e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Asynchronous.lf @@ -0,0 +1,31 @@ +target C { + keepalive: true // Do not exit when event queue is empty. +} + +preamble {= + #include "platform.h" // Defines lf_sleep() and thread functions. +=} + +main reactor { + preamble {= + // Schedule an event roughly every 200 msec. + void* external(void* a) { + while (true) { + lf_sleep(MSEC(200)); + lf_schedule(a, 0); + } + } + =} + state thread_id: lf_thread_t = 0 + physical action a(100 msec): int + + reaction(startup) -> a {= + // Start a thread to schedule physical actions. + lf_thread_create(&self->thread_id, &external, a); + =} + + reaction(a) {= + interval_t elapsed_time = lf_time_logical_elapsed(); + printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/BankIndex.lf b/versioned_docs/version-0.8.0/assets/code/c/src/BankIndex.lf new file mode 100644 index 000000000..6a0d32cb9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/BankIndex.lf @@ -0,0 +1,12 @@ +target C; +preamble {= + int table[] = {4, 3, 2, 1}; +=} +reactor A(bank_index:int = 0, value:int = 0) { + reaction (startup) {= + printf("bank_index: %d, value: %d\n", self->bank_index, self->value); + =} +} +main reactor { + a = new[4] A(value = {= table[bank_index] =}); +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/CheckDeadline.lf b/versioned_docs/version-0.8.0/assets/code/c/src/CheckDeadline.lf new file mode 100644 index 000000000..fcb66e431 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/CheckDeadline.lf @@ -0,0 +1,21 @@ +target C; + +reactor Count { + output out:int; + reaction(startup) -> out {= + int count = 0; + while (!lf_check_deadline(self, true)) { + count++; + } + lf_set(out, count); + =} deadline (3 msec) {= + printf("Stopped counting.\n"); + =} +} + +main reactor { + c = new Count(); + reaction(c.out) {= + printf("Counted to %d\n", c.out->value); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/ChildBank.lf b/versioned_docs/version-0.8.0/assets/code/c/src/ChildBank.lf new file mode 100644 index 000000000..bbf21848c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/ChildBank.lf @@ -0,0 +1,16 @@ +target C; +reactor Child ( + bank_index:int = 0 +) { + reaction(startup) {= + printf("My bank index: %d.\n", self->bank_index); + =} +} +reactor Parent ( + bank_index:int = 0 +) { + c = new[2] Child(); +} +main reactor { + p = new[2] Parent(); +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank.lf b/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank.lf new file mode 100644 index 000000000..6e5262db9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank.lf @@ -0,0 +1,18 @@ +target C + +reactor Child(bank_index: int = 0, parent_bank_index: int = 0) { + reaction(startup) {= + printf( + "My bank index: %d. My parent's bank index: %d.\n", + self->bank_index, self->parent_bank_index + ); + =} +} + +reactor Parent(bank_index: int = 0) { + c = new[2] Child(parent_bank_index=bank_index) +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank2.lf b/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank2.lf new file mode 100644 index 000000000..094337fcf --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/ChildParentBank2.lf @@ -0,0 +1,23 @@ +target C + +reactor Child(bank_index: int = 0, parent_bank_index: int = 0) { + output out: int + + reaction(startup) -> out {= + lf_set(out, self->parent_bank_index * 2 + self->bank_index); + =} +} + +reactor Parent(bank_index: int = 0) { + c = new[2] Child(parent_bank_index=bank_index) + + reaction(c.out) {= + for (int i=0; i < c_width; i++) { + printf("Received %d from child %d.\n", c[i].out->value, i); + } + =} +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Contained.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Contained.lf new file mode 100644 index 000000000..e66ed0a15 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Contained.lf @@ -0,0 +1,13 @@ +target C + +import Overwriting from "Overwriting.lf" + +main reactor { + s = new Overwriting() + + reaction(s.y) {= + if (s.y->value != 0 && s.y->value != 1) { + lf_print_error_and_exit("Outputs should only be 0 or 1!"); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Count.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Count.lf new file mode 100644 index 000000000..a50f8c51e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Count.lf @@ -0,0 +1,11 @@ +target C + +reactor Count { + state count: int = 0 + output y: int + timer t(0, 100 msec) + + reaction(t) -> y {= + lf_set(y, self->count++); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Cycle.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Cycle.lf new file mode 100644 index 000000000..54f78f5df --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Cycle.lf @@ -0,0 +1,24 @@ +target C; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/CycleReordered.lf b/versioned_docs/version-0.8.0/assets/code/c/src/CycleReordered.lf new file mode 100644 index 000000000..a85d61110 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target C; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(startup) -> y {= + // ... something here ... + =} + reaction(x) {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/CycleWithDelay.lf b/versioned_docs/version-0.8.0/assets/code/c/src/CycleWithDelay.lf new file mode 100644 index 000000000..26f439487 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target C; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x after 0; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Deadline.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Deadline.lf new file mode 100644 index 000000000..dec5127dc --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Deadline.lf @@ -0,0 +1,11 @@ +target C; +reactor Deadline { + input x:int; + output d:int; // Produced if the deadline is violated. + reaction(x) -> d {= + printf("Normal reaction.\n"); + =} deadline(10 msec) {= + printf("Deadline violation detected.\n"); + lf_set(d, x->value); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DeadlineTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DeadlineTest.lf new file mode 100644 index 000000000..0b97d4567 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DeadlineTest.lf @@ -0,0 +1,26 @@ +target C + +import Deadline from "Deadline.lf" + +preamble {= + #include "platform.h" +=} + +main reactor { + logical action a + d = new Deadline() + + reaction(startup) -> d.x, a {= + lf_set(d.x, 0); + lf_schedule(a, 0); + =} + + reaction(a) -> d.x {= + lf_set(d.x, 0); + lf_sleep(MSEC(20)); + =} + + reaction(d.d) {= + printf("Deadline reactor produced an output.\n"); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Decentralized.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Decentralized.lf new file mode 100644 index 000000000..b7fd43e89 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Decentralized.lf @@ -0,0 +1,10 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +federated reactor { + c = new Count(); + p = new Print(); + c.out -> p.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeeback.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeeback.lf new file mode 100644 index 000000000..cda604be6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeeback.lf @@ -0,0 +1,46 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint { + input in:int; + output out:int; + state c:int(0); + timer t(0, 1 sec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STP(10 msec) {= + lf_print_warning("CountPrint: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STP(10 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSTP.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSTP.lf new file mode 100644 index 000000000..2770aaeff --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSTP.lf @@ -0,0 +1,40 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint(STP_offset:time(10 msec)) { + input in:int; + output out:int; + state c:int(0); + timer t(0, 1 sec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +reactor PrintCount(STP_offset:time(10 msec)) { + input in:int; + output out:int; + timer t(0, 1 sec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d at tag (%lld, %u)", + in->value, lf_time_logical_elapsed(), lf_tag().microstep + ); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSplit.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSplit.lf new file mode 100644 index 000000000..75e44d4a7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackSplit.lf @@ -0,0 +1,48 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +reactor Count { + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +reactor Print { + input in:int; + reaction(in) {= + lf_print("***** Print Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} STP(10 msec) {= + lf_print_warning("Print: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d", in->value); + =} STP(10 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new Count(); + pr = new Print(); + p = new PrintCount(); + c.out -> p.in; + p.out -> pr.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackWithAfter.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackWithAfter.lf new file mode 100644 index 000000000..e2ded1488 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedFeebackWithAfter.lf @@ -0,0 +1,44 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +reactor CountPrint(stp_offset:time(0)) { + input in:int; + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} STP(0 msec) {= + lf_print_warning("CountPrint: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} +} + +reactor PrintCount(stp_offset:time(0)) { + input in:int; + output out:int; + timer t(0, 999 msec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d", in->value); + =} STP(0 msec) {= + lf_print_warning("PrintCount: Safe to process violation!"); + lf_print("Intended time: %lld", in->intended_tag.time - lf_time_start()); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in after 10 msec; + p.out -> c.in after 10 msec; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimer.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimer.lf new file mode 100644 index 000000000..584038d34 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimer.lf @@ -0,0 +1,18 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +reactor PrintTimer extends Print { + timer t(0, 1 sec); + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfter.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfter.lf new file mode 100644 index 000000000..41d629cba --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfter.lf @@ -0,0 +1,22 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer extends Print { + timer t(0, 1 sec) + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.in after 10 msec +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfterHandler.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfterHandler.lf new file mode 100644 index 000000000..1c7506ea9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerAfterHandler.lf @@ -0,0 +1,35 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} + +import Count from "Federated.lf" + +reactor PrintTimer { + timer t(0, 1 sec) + input in: int + + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STP(0) {= + lf_print("****** STP violation handler invoked at (%lld, %d). " + "Intended tag was (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep, + in->intended_tag.time - lf_time_start(), in->intended_tag.microstep + ); + =} + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.in after 10 msec +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTP.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTP.lf new file mode 100644 index 000000000..68be2da3b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTP.lf @@ -0,0 +1,22 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer(STP_offset: time = 10 msec) extends Print { + timer t(0, 1 sec) + + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.in +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPDeadline.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPDeadline.lf new file mode 100644 index 000000000..22f14a765 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPDeadline.lf @@ -0,0 +1,22 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +import Count, Print from "Federated.lf" +reactor PrintTimer(STP_offset:time(10 msec)) extends Print { + timer t(0, 1 sec); + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} deadline(10 msec) {= + lf_print("**** Deadline violation at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPHandler.lf b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPHandler.lf new file mode 100644 index 000000000..3bd287016 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/DecentralizedTimerSTPHandler.lf @@ -0,0 +1,30 @@ +target C { + timeout: 5 sec, + coordination: decentralized +} +import Count from "Federated.lf" +reactor PrintTimer(STP_offset:time(10 usec)) { + timer t(0, 1 sec); + input in:int; + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} STP(0) {= + lf_print("****** STP violation handler invoked at (%lld, %d). " + "Intended tag was (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep, + in->intended_tag.time - lf_time_start(), in->intended_tag.microstep + ); + =} + reaction(t) {= + lf_print("Timer ticked at (%lld, %d).", + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} +federated reactor { + c = new Count(); + p = new PrintTimer(); + c.out -> p.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Destination.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Destination.lf new file mode 100644 index 000000000..f67592442 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Destination.lf @@ -0,0 +1,17 @@ +target C + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + int sum = 0; + if (x->is_present) { + sum += x->value; + } + if (y->is_present) { + sum += y->value; + } + printf("Received %d.\n", sum); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Double.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Double.lf new file mode 100644 index 000000000..940c37b38 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Double.lf @@ -0,0 +1,10 @@ +target C + +reactor Double { + input x: int + output y: int + + reaction(x) -> y {= + lf_set(y, x->value * 2); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Extends.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Extends.lf new file mode 100644 index 000000000..0dd925041 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Extends.lf @@ -0,0 +1,14 @@ +target C; +reactor A { + input a:int; + output out:int; + reaction(a) -> out {= + lf_set(out, a->value); + =} +} +reactor B extends A { + input b:int; + reaction(a, b) -> out {= + lf_set(out, a->value + b->value); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Federated.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Federated.lf new file mode 100644 index 000000000..064f13a4e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Federated.lf @@ -0,0 +1,27 @@ +target C + +reactor Count { + output out: int + state c: int = 0 + timer t(0, 1 sec) + + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +reactor Print { + input in: int + + reaction(in) {= + lf_print("Received: %d at (%lld, %d)", in->value, + lf_time_logical_elapsed(), lf_tag().microstep + ); + =} +} + +federated reactor { + c = new Count() + p = new Print() + c.out -> p.in +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/FederatedFeeback.lf b/versioned_docs/version-0.8.0/assets/code/c/src/FederatedFeeback.lf new file mode 100644 index 000000000..06004bda3 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/FederatedFeeback.lf @@ -0,0 +1,38 @@ +target C { + timeout: 5 sec, +} +reactor CountPrint(stp_offset:time(5 msec)) { + input in:int; + output out:int; + state c:int(0); + timer t(0, 500 msec); + reaction(t) -> out {= + lf_set(out, self->c++); + =} + reaction(in) {= + lf_print("***** CountPrint Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} +} +reactor PrintCount { + input in:int; + output out:int; + timer t(0, 1 sec); + state c:int(0); + reaction(in) {= + lf_print("***** PrintCount Received: %d at time %lld", + in->value, lf_time_logical_elapsed() + ); + =} + reaction(t) -> out {= + lf_set(out, self->c++); + =} +} + +federated reactor { + c = new CountPrint(); + p = new PrintCount(); + c.out -> p.in; + p.out -> c.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/GenericDelay.lf b/versioned_docs/version-0.8.0/assets/code/c/src/GenericDelay.lf new file mode 100644 index 000000000..b4a389e4e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/GenericDelay.lf @@ -0,0 +1,27 @@ +target C + +reactor Delay(delay: time = 0) { + input in: T + output out: T + logical action a(delay): T + + reaction(a) -> out {= + lf_set(out, a->value); + =} + + reaction(in) -> a {= + lf_schedule_copy(a, self->delay, &in->value, 1); + =} +} + +main reactor { + d = new Delay(delay = 100 ms) + + reaction(startup) -> d.in {= + lf_set(d.in, 42); + =} + + reaction(d.out) {= + printf("Received %d at time %lld.\n", d.out->value, lf_time_logical_elapsed()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/GenericString.lf b/versioned_docs/version-0.8.0/assets/code/c/src/GenericString.lf new file mode 100644 index 000000000..47224aaea --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/GenericString.lf @@ -0,0 +1,15 @@ +target C + +import Delay from "GenericDelay.lf" + +main reactor { + d = new Delay(delay = 100 ms) + + reaction(startup) -> d.in {= + lf_set(d.in, "foo"); + =} + + reaction(d.out) {= + printf("Received %s at time %lld.\n", d.out->value, lf_time_logical_elapsed()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/HelloWorld.lf b/versioned_docs/version-0.8.0/assets/code/c/src/HelloWorld.lf new file mode 100644 index 000000000..e4bb90bd5 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target C + +main reactor { + reaction(startup) {= + printf("Hello World.\n"); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Hierarchy.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Hierarchy.lf new file mode 100644 index 000000000..6a051a110 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target C + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride: int = 2) { + output y: int + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Interleaved.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Interleaved.lf new file mode 100644 index 000000000..cf9a3a61b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Interleaved.lf @@ -0,0 +1,26 @@ +target C + +reactor Node(num_nodes: size_t = 4, bank_index: int = 0) { + input[num_nodes] in: int + output[num_nodes] out: int + + reaction(startup) -> out {= + lf_set(out[1], 42); + printf("Bank index %d sent 42 on channel 1.\n", self->bank_index); + =} + + reaction(in) {= + for (int i = 0; i < in_width; i++) { + if (in[i]->is_present) { + printf("Bank index %d received %d on channel %d.\n", + self->bank_index, in[i]->value, i + ); + } + } + =} +} + +main reactor(num_nodes: size_t = 4) { + nodes = new[num_nodes] Node(num_nodes=num_nodes) + nodes.out -> interleaved(nodes.in) +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Methods.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Methods.lf new file mode 100644 index 000000000..d6ea4f795 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Methods.lf @@ -0,0 +1,19 @@ +target C + +main reactor Methods { + state foo: int = 2 + + method getFoo(): int {= + return self->foo; + =} + + method add(x: int) {= + self->foo += x; + =} + + reaction(startup) {= + lf_print("Foo is initialized to %d", getFoo()); + add(40); + lf_print("2 + 40 = %d", getFoo()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Microsteps.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Microsteps.lf new file mode 100644 index 000000000..a8484819d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Microsteps.lf @@ -0,0 +1,15 @@ +target C + +main reactor { + state count: int = 1 + logical action a + + reaction(startup, a) -> a {= + printf("%d. Logical time is %lld. Microstep is %d.\n", + self->count, lf_tag().time, lf_tag().microstep + ); + if (self->count++ < 5) { + lf_schedule(a, 0); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Multiport.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Multiport.lf new file mode 100644 index 000000000..c275ee64d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Multiport.lf @@ -0,0 +1,24 @@ +target C; +reactor Source { + output[4] out:int; + reaction(startup) -> out {= + for(int i = 0; i < out_width; i++) { + lf_set(out[i], i); + } + =} +} +reactor Destination { + input[4] in:int; + reaction(in) {= + int sum = 0; + for (int i = 0; i < in_width; i++) { + if (in[i]->is_present) sum += in[i]->value; + } + printf("Sum of received: %d.\n", sum); + =} +} +main reactor { + a = new Source(); + b = new Destination(); + a.out -> b.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/MultiportSource.lf b/versioned_docs/version-0.8.0/assets/code/c/src/MultiportSource.lf new file mode 100644 index 000000000..a023174da --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/MultiportSource.lf @@ -0,0 +1,12 @@ +target C + +reactor MultiportSource(bank_index: int = 0) { + timer t(0, 200 msec) + output out: int + state s: int = 0 + + reaction(t) -> out {= + lf_set(out, self->s); + self->s += self->bank_index; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/MultiportToBank.lf b/versioned_docs/version-0.8.0/assets/code/c/src/MultiportToBank.lf new file mode 100644 index 000000000..1a9f5eb21 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/MultiportToBank.lf @@ -0,0 +1,25 @@ +target C + +reactor Source { + output[3] out: int + + reaction(startup) -> out {= + for(int i = 0; i < out_width; i++) { + lf_set(out[i], i); + } + =} +} + +reactor Destination(bank_index: int = 0) { + input in: int + + reaction(in) {= + printf("Destination %d received %d.\n", self->bank_index, in->value); + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.in +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Overwriting.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Overwriting.lf new file mode 100644 index 000000000..c19180b36 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Overwriting.lf @@ -0,0 +1,18 @@ +target C + +reactor Overwriting { + output y: int + state s: int = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + + reaction(t1) -> y {= + self->s += 1; + lf_set(y, self->s); + =} + + reaction(t2) -> y {= + self->s -= 2; + lf_set(y, self->s); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Physical.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Physical.lf new file mode 100644 index 000000000..6aedb25d6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Physical.lf @@ -0,0 +1,12 @@ +target C; +reactor Physical { + input x:int; + physical action a; + reaction(x) -> a {= + lf_schedule(a, 0); + =} + reaction(a) {= + interval_t elapsed_time = lf_time_logical_elapsed(); + printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/RegressionTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/RegressionTest.lf new file mode 100644 index 000000000..c53d1cceb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target C { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Scale.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Scale.lf new file mode 100644 index 000000000..0560240d9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Scale.lf @@ -0,0 +1,10 @@ +target C + +reactor Scale(factor: int = 2) { + input x: int + output y: int + + reaction(x) -> y {= + lf_set(y, x->value * self->factor); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Schedule.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Schedule.lf new file mode 100644 index 000000000..6f0aca950 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Schedule.lf @@ -0,0 +1,12 @@ +target C; +reactor Schedule { + input x:int; + logical action a; + reaction(x) -> a {= + lf_schedule(a, MSEC(200)); + =} + reaction(a) {= + interval_t elapsed_time = lf_time_logical_elapsed(); + printf("Action triggered at logical time %lld nsec after start.\n", elapsed_time); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Simultaneous.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Simultaneous.lf new file mode 100644 index 000000000..09504c8ef --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Simultaneous.lf @@ -0,0 +1,30 @@ +target C + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + printf("Time since start: %lld, microstep: %d\n", + lf_time_logical_elapsed(), lf_tag().microstep + ); + if (x->is_present) { + printf(" x is present.\n"); + } + if (y->is_present) { + printf(" y is present.\n"); + } + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + lf_set(d.x, 1); + lf_schedule(repeat, 0); + =} + + reaction(repeat) -> d.y {= lf_set(d.y, 1); =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/SlowingClock.lf b/versioned_docs/version-0.8.0/assets/code/c/src/SlowingClock.lf new file mode 100644 index 000000000..c42f0aa01 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/SlowingClock.lf @@ -0,0 +1,19 @@ +target C + +main reactor SlowingClock(start: time = 100 ms, incr: time = 100 ms) { + state interval: time = start + logical action a + + reaction(startup) -> a {= + lf_schedule(a, self->start); + =} + + reaction(a) -> a {= + instant_t elapsed_logical_time = lf_time_logical_elapsed(); + printf("Logical time since start: %lld nsec.\n", + elapsed_logical_time + ); + self->interval += self->incr; + lf_schedule(a, self->interval); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Sparse.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Sparse.lf new file mode 100644 index 000000000..be8c8ade8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Sparse.lf @@ -0,0 +1,17 @@ +target C; +reactor Sparse { + @sparse + input[100] in:int; + reaction(in) {= + // Create an iterator over the input channels. + struct lf_multiport_iterator_t i = lf_multiport_iterator(in); + // Get the least index of a channel with present inputs. + int channel = lf_multiport_next(&i); + // Iterate until no more channels have present inputs. + while(channel >= 0) { + printf("Received %d on channel %d\n", in[channel]->value, channel); + // Get the next channel with a present input. + channel = lf_multiport_next(&i); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/TestCount.lf b/versioned_docs/version-0.8.0/assets/code/c/src/TestCount.lf new file mode 100644 index 000000000..f52108811 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/TestCount.lf @@ -0,0 +1,28 @@ +target C + +reactor TestCount(start: int = 0, stride: int = 1, num_inputs: int = 1) { + state count: int = start + state inputs_received: int = 0 + input x: int + + reaction(x) {= + printf("Received %d.\n", x->value); + if (x->value != self->count) { + printf("ERROR: Expected %d.\n", self->count); + exit(1); + } + self->count += self->stride; + self->inputs_received++; + =} + + reaction(shutdown) {= + printf("Shutdown invoked.\n"); + if (self->inputs_received != self->num_inputs) { + printf("ERROR: Expected to receive %d inputs, but got %d.\n", + self->num_inputs, + self->inputs_received + ); + exit(2); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/TimeElapsed.lf b/versioned_docs/version-0.8.0/assets/code/c/src/TimeElapsed.lf new file mode 100644 index 000000000..80f0e1347 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/TimeElapsed.lf @@ -0,0 +1,12 @@ +target C + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + printf( + "Elapsed logical time is %lld.\n", + lf_time_logical_elapsed() + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/TimeLag.lf b/versioned_docs/version-0.8.0/assets/code/c/src/TimeLag.lf new file mode 100644 index 000000000..ae7bc8973 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/TimeLag.lf @@ -0,0 +1,14 @@ +target C + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + interval_t t = lf_time_logical_elapsed(); + interval_t T = lf_time_physical_elapsed(); + printf( + "Elapsed logical time: %lld, physical time: %lld, lag: %lld\n", + t, T, T-t + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Timer.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Timer.lf new file mode 100644 index 000000000..8049c40d8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Timer.lf @@ -0,0 +1,9 @@ +target C + +main reactor Timer { + timer t(0, 1 sec) + + reaction(t) {= + printf("Logical time is %lld.\n", lf_time_logical()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/Triggering.lf b/versioned_docs/version-0.8.0/assets/code/c/src/Triggering.lf new file mode 100644 index 000000000..1b66e7564 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/Triggering.lf @@ -0,0 +1,13 @@ +target C +reactor Inside { + input x: int + reaction(x) {= + printf("Received %d\n", x->value); + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + lf_set(i.x, 42); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/lib/Cos.lf b/versioned_docs/version-0.8.0/assets/code/c/src/lib/Cos.lf new file mode 100644 index 000000000..ab553193e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/lib/Cos.lf @@ -0,0 +1,13 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +preamble {= + #include +=} +reactor Cos { + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/AlignmentTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/AlignmentTest.lf new file mode 100644 index 000000000..9a0819ba3 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/AlignmentTest.lf @@ -0,0 +1,20 @@ +target C { + timeout: 3 secs +} +main reactor { + state s:int(0); + timer t1(100 msec, 100 msec); + timer t2(200 msec, 200 msec); + timer t4(400 msec, 400 msec); + reaction(t1) {= + self->s += 1; + =} + reaction(t2) {= + self->s -= 2; + =} + reaction(t4) {= + if (self->s != 0) { + lf_print_error_and_exit("Value should be 0!"); + } + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/ContainedOverwriting.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/ContainedOverwriting.lf new file mode 100644 index 000000000..41bc4048b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/ContainedOverwriting.lf @@ -0,0 +1,12 @@ +target C { + timeout: 1 secs +} +import Overwriting from "../Overwriting.lf"; +main reactor { + s = new Overwriting(); + reaction(s.y) {= + printf("At logical time %lld, s = %d.\n", + lf_time_logical_elapsed(), s.y->value + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/CountDoubleDestination.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/CountDoubleDestination.lf new file mode 100644 index 000000000..f56abaacc --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/CountDoubleDestination.lf @@ -0,0 +1,23 @@ +target C { + cmake: false, + compiler: "cc", + flags: "-O3", + fast: true, + logging: log, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Double from "../Double.lf"; +import Destination from "../Destination.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Double(); + r = new Destination(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + c.y -> r.x; + d.y -> r.y; + d.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/CountScale.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/CountScale.lf new file mode 100644 index 000000000..844223036 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/CountScale.lf @@ -0,0 +1,15 @@ +target C { + fast: true, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Scale(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + d.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/ExtendsTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/ExtendsTest.lf new file mode 100644 index 000000000..f06e46134 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/ExtendsTest.lf @@ -0,0 +1,28 @@ +target C { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import TestCount from "../TestCount.lf"; + +reactor A { + input a:int; + output out:int; + reaction(a) -> out {= + lf_set(out, a->value); + =} +} +reactor B extends A { + input b:int; + reaction(a, b) -> out {= + lf_set(out, a->value + b->value); + =} +} + +main reactor { + c = new Count(); + b = new B(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + (c.y)+ -> b.a, b.b; + b.out -> t.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/HierarchyTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/HierarchyTest.lf new file mode 100644 index 000000000..d292d6d64 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/HierarchyTest.lf @@ -0,0 +1,21 @@ +target C { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +reactor Container(stride:int(2)) { + output y:int; + c = new Count(); + s = new Scale(factor = stride); + c.y -> s.x; + s.y -> y; +} + +main reactor { + c = new Container(stride = 4); + t = new TestCount(stride = 4, num_inputs = 11); + c.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/MultiportSourceTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/MultiportSourceTest.lf new file mode 100644 index 000000000..86847ce16 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/MultiportSourceTest.lf @@ -0,0 +1,33 @@ + // Check bank of reactors sending to bank of reactors. +target C { + timeout: 2 sec, + fast: true, +}; +import MultiportSource from "../MultiportSource.lf"; +reactor Destination( + bank_index:int(0) +) { + state s:int(0); + input in:int; + reaction(in) {= + printf("Destination %d received: %d.\n", self->bank_index, in->value); + if (in->value != self->s) { + printf("ERROR: Expected %d.\n", self->s); + exit(1); + } + self->s += self->bank_index; + =} + reaction(shutdown) {= + if (self->s == 0 && self->bank_index != 0) { + fprintf(stderr, "ERROR: Destination %d received no input!\n", self->bank_index); + exit(1); + } + printf("Success.\n"); + =} +} + +main reactor(width:int(4)) { + a = new[width] MultiportSource(); + b = new[width] Destination(); + a.out -> b.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PhysicalTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PhysicalTest.lf new file mode 100644 index 000000000..8b16e6bb6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PhysicalTest.lf @@ -0,0 +1,9 @@ +target C; +import Physical from "../Physical.lf"; +main reactor { + timer t(200 msec, 200 msec); + p = new Physical(); + reaction(t) -> p.x {= + lf_set(p.x, 0); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest1.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest1.lf new file mode 100644 index 000000000..3b42dc167 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest1.lf @@ -0,0 +1,13 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +main reactor { + preamble {= + #include + =} + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest2.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest2.lf new file mode 100644 index 000000000..379cdf01a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest2.lf @@ -0,0 +1,22 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +preamble {= + #include +=} +reactor Cos { + reaction(startup) {= + printf("The cosine of 1 is %f.\n", cos(1)); + =} +} +reactor Sin { + reaction(startup) {= + printf("The sine of 1 is %f.\n", sin(1)); + =} +} +main reactor { + c = new Cos() + s = new Sin() +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest3.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest3.lf new file mode 100644 index 000000000..b3347bf4d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest3.lf @@ -0,0 +1,18 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +import Cos from "../lib/Cos.lf" +preamble {= + #include +=} +reactor Sin { + reaction(startup) {= + printf("The sine of 1 is %f.\n", sin(1)); + =} +} +main reactor { + c = new Cos() + s = new Sin() +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest4.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest4.lf new file mode 100644 index 000000000..abe4969a3 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest4.lf @@ -0,0 +1,18 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +main reactor { + preamble {= + int add_42(int i) { + return i + 42; + } + =} + reaction(startup) {= + printf("42 plus 42 is %d.\n", add_42(42)); + =} + reaction(startup) {= + printf("42 plus 1 is %d.\n", add_42(1)); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest5.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest5.lf new file mode 100644 index 000000000..de4f2a4eb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest5.lf @@ -0,0 +1,27 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +preamble {= + int add_42(int i); +=} +reactor Add_42 { + reaction(startup) {= + printf("42 plus 42 is %d.\n", add_42(42)); + =} +} +reactor Add_1 { + reaction(startup) {= + printf("42 plus 1 is %d.\n", add_42(1)); + =} +} +main reactor { + preamble {= + int add_42(int i) { + return i + 42; + } + =} + a = new Add_42() + b = new Add_1() +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest6.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest6.lf new file mode 100644 index 000000000..f5e983acc --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest6.lf @@ -0,0 +1,25 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +preamble {= + extern const char shared_string[]; +=} +reactor A { + reaction(startup) {= + printf("Reactor A says %s.\n", shared_string); + =} +} +reactor B { + reaction(startup) {= + printf("Reactor B says %s.\n", shared_string); + =} +} +main reactor { + preamble {= + const char shared_string[] = "Hello"; + =} + a = new A() + b = new B() +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest7.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest7.lf new file mode 100644 index 000000000..866fd16ab --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/PreambleTest7.lf @@ -0,0 +1,14 @@ +/** + * This example is included in Preambles.md, but not automatically imported. + * Success of the test is compiling and running. + */ +target C +preamble {= + typedef int foo; +=} +main reactor { + state x:foo = 0 + reaction(startup) {= + lf_print("State is %d", self->x); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/ScheduleTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/ScheduleTest.lf new file mode 100644 index 000000000..4fbcbbedd --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/ScheduleTest.lf @@ -0,0 +1,11 @@ +target C { + timeout: 1 sec, + fast: true +} +import Schedule from "../Schedule.lf"; +import Count from "../Count.lf"; +main reactor { + c = new Count(); + d = new Schedule(); + c.y -> d.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/SlowingClockTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/SlowingClockTest.lf new file mode 100644 index 000000000..2c38b64c6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/SlowingClockTest.lf @@ -0,0 +1,42 @@ +/** + * Events are scheduled with increasing additional delays of 0, 100, 300, 600 + * msec on a logical action with a minimum delay of 100 msec. + * The use of the logical action ensures the elapsed time jumps exactly from + * 0 to 100, 300, 600, and 1000 msec. + */ +target C { + timeout: 1 sec, + fast: true, +}; +main reactor(start:time(100 msec), incr:time(100 msec)) { + logical action a; + state interval:time(start); + state expected_time:time(start); + reaction(startup) -> a {= + lf_schedule(a, self->start); + =} + reaction(a) -> a {= + instant_t elapsed_logical_time = lf_time_logical_elapsed(); + printf("Logical time since start: \%lld nsec.\n", + elapsed_logical_time + ); + if (elapsed_logical_time != self->expected_time) { + printf("ERROR: Expected time to be: \%lld nsec.\n", + self->expected_time + ); + exit(1); + } + self->interval += self->incr; + lf_schedule(a, self->interval); + self->expected_time += self->interval; + =} + reaction(shutdown) {= + if (self->expected_time != MSEC(1500)) { + printf("ERROR: Expected the next expected time to be: 1500000000 nsec.\n"); + printf("It was: \%lld nsec.\n", self->expected_time); + exit(2); + } else { + printf("Test passes.\n"); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/SparseTest.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/SparseTest.lf new file mode 100644 index 000000000..ed2465352 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/SparseTest.lf @@ -0,0 +1,8 @@ +target C +import Sparse from "../Sparse.lf" +main reactor { + s = new Sparse() + reaction(startup) -> s.in {= + lf_set(s.in[12], 42); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/c/src/test/StructParameter.lf b/versioned_docs/version-0.8.0/assets/code/c/src/test/StructParameter.lf new file mode 100644 index 000000000..0e82b87b2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/c/src/test/StructParameter.lf @@ -0,0 +1,16 @@ +target C; +main reactor(p:hello_t("Earth", 42)) { + preamble {= + typedef struct hello_t { + char* name; + int value; + } hello_t; + =} + reaction(startup) {= + printf("Parameter p.name=\"%s\", value=%d.\n", self->p.name, self->p.value); + if (self->p.value != 42) { + fprintf(stderr, "FAILED: Expected 42.\n"); + exit(1); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Alignment.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Alignment.lf new file mode 100644 index 000000000..e20a5f489 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Alignment.lf @@ -0,0 +1,22 @@ +target Cpp { + timeout: 3 s +} + +main reactor Alignment { + state s: int(0) + timer t1(100 ms, 100 ms) + timer t2(200 ms, 200 ms) + timer t4(400 ms, 400 ms) + + reaction(t1) {= + s += 1; + =} + + reaction(t2) {= + s -= 2; + =} + + reaction(t4) {= + std::cout << "s = " << std::to_string(s) << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Asynchronous.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Asynchronous.lf new file mode 100644 index 000000000..a9f7253f5 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Asynchronous.lf @@ -0,0 +1,27 @@ +target Cpp + +main reactor { + private preamble {= + #include + =} + + state thread: std::thread + physical action a: int + + reaction(startup) -> a {= + // Start a thread to schedule physical actions. + thread = std::thread([&]{ + while (true) { + std::this_thread::sleep_for(200ms); + // the value that we give it really doesn't matter + // but we the action should is scheduled for 100ms into the future + a.schedule(0, 100ms); + } + }); + =} + + reaction(a) {= + auto elapsed_time = get_physical_time(); + std::cout << "Action triggered at logical time" << elapsed_time <<"nsec after start." << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildBank.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildBank.lf new file mode 100644 index 000000000..e28721766 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildBank.lf @@ -0,0 +1,16 @@ +target Cpp; +reactor Child ( + bank_index:int = 0 +) { + reaction(startup) {= + std::cout << "My bank index:" << bank_index << std::endl; + =} +} +reactor Parent ( + bank_index:int = 0 +) { + c = new[2] Child(); +} +main reactor { + p = new[2] Parent(); +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank.lf new file mode 100644 index 000000000..5deaecdc9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank.lf @@ -0,0 +1,15 @@ +target Cpp + +reactor Child(bank_index: int(0), parent_bank_index: int(0)) { + reaction(startup) {= + std::cout <<"My bank index: " << bank_index << " My parent's bank index: " << parent_bank_index << std::endl; + =} +} + +reactor Parent(bank_index: int(0)) { + c = new[2] Child(parent_bank_index=bank_index) +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank2.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank2.lf new file mode 100644 index 000000000..143a6e375 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/ChildParentBank2.lf @@ -0,0 +1,23 @@ +target Cpp + +reactor Child(bank_index: int(0), parent_bank_index: int(0)) { + output out: int + + reaction(startup) -> out {= + out.set(parent_bank_index * 2 + bank_index); + =} +} + +reactor Parent(bank_index: int(0)) { + c = new[2] Child(parent_bank_index=bank_index) + + reaction(c.out) {= + for (auto i = 0ul; i < c.size(); i++) { + std::cout << "Received " << *c[i].out.get() <<" from child " << i << std::endl; + } + =} +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Contained.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Contained.lf new file mode 100644 index 000000000..68756747e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Contained.lf @@ -0,0 +1,17 @@ +target Cpp + +import Overwriting from "Overwriting.lf" + +main reactor { + s = new Overwriting() + + reaction(s.y) {= + auto is_correct = [](auto value){ + return value == 0 || value == 1; + }; + + if (s.y.is_present() && !is_correct(*s.y.get())) { + std::cout << "Output shoudl only be 0 or 1!" << std::endl; + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Count.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Count.lf new file mode 100644 index 000000000..194ec5102 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Count.lf @@ -0,0 +1,11 @@ +target Cpp + +reactor Count { + state count: int(0) + output y: int + timer t(0, 100 ms) + + reaction(t) -> y {= + y.set(count++); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Cycle.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Cycle.lf new file mode 100644 index 000000000..7767c626e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Cycle.lf @@ -0,0 +1,24 @@ +target Cpp; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleReordered.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleReordered.lf new file mode 100644 index 000000000..736d7c78b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target Cpp; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(startup) -> y {= + // ... something here ... + =} + reaction(x) {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleWithDelay.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleWithDelay.lf new file mode 100644 index 000000000..d306c0744 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target Cpp; +reactor A { + input x:int; + output y:int; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:int; + output y:int; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x after 0; + b.y -> a.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Deadline.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Deadline.lf new file mode 100644 index 000000000..ca1a6266c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Deadline.lf @@ -0,0 +1,12 @@ +target Cpp; + +reactor Deadline { + input x:int; + output d:int; // Produced if the deadline is violated. + reaction(x) -> d {= + std::cout << "Normal reaction." << std::endl; + =} deadline(10ms) {= + std::cout << "Deadline violation detected." << std::endl; + d.set(*x.get()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/DeadlineTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/DeadlineTest.lf new file mode 100644 index 000000000..1c57f3c06 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/DeadlineTest.lf @@ -0,0 +1,20 @@ +target Cpp; +import Deadline from "Deadline.lf"; + +main reactor { + logical action a; + d = new Deadline(); + reaction(startup) -> d.x, a {= + d.x.set(0); + a.schedule(0ms); + =} + + reaction(a) -> d.x {= + d.x.set(0); + std::this_thread::sleep_for(20ms); + =} + + reaction(d.d) {= + std::cout << "Deadline reactor produced an output." << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Destination.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Destination.lf new file mode 100644 index 000000000..c8c5adf05 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Destination.lf @@ -0,0 +1,18 @@ +target Cpp + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + int sum = 0; + if (x.is_present()) { + sum += *x.get(); + } + if (y.is_present()) { + sum += *y.get(); + } + + std::cout << "Received: " << sum << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Double.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Double.lf new file mode 100644 index 000000000..e952e7ac9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Double.lf @@ -0,0 +1,12 @@ +target Cpp + +reactor Double { + input x: int + output y: int + + reaction(x) -> y {= + if (x.is_present()){ + y.set(*x.get() * 2); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericDelay.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericDelay.lf new file mode 100644 index 000000000..b0a9c6279 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericDelay.lf @@ -0,0 +1,28 @@ +target Cpp + +reactor Delay(delay: time = 0) { + input in: T + output out: T + logical action a(delay): T + + reaction(a) -> out {= + out.set(a.get()); + =} + + reaction(in) -> a {= + a.schedule(in.get(), delay); + =} +} + +main reactor { + d = new Delay(delay = 100 ms) + + reaction(startup) -> d.in {= + d.in.set(42); + =} + + reaction(d.out) {= + std::cout << "received " << *d.out.get() << " at time " + << get_elapsed_logical_time() << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericString.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericString.lf new file mode 100644 index 000000000..340bf36eb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/GenericString.lf @@ -0,0 +1,16 @@ +target Cpp + +import Delay from "GenericDelay.lf" + +main reactor { + d = new Delay<{= std::string =}>(delay = 100 ms) + + reaction(startup) -> d.in {= + d.in.set("foo"); + =} + + reaction(d.out) {= + std::cout << "received " << *d.out.get() << " at time " + << get_elapsed_logical_time() << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/HelloWorld.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/HelloWorld.lf new file mode 100644 index 000000000..c8880fab2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target Cpp + +main reactor { + reaction(startup) {= + std::cout << "Hello World." << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Hierarchy.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Hierarchy.lf new file mode 100644 index 000000000..4ef7da3eb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target Cpp + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride: int(2)) { + output y: int + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Interleaved.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Interleaved.lf new file mode 100644 index 000000000..e238479e6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Interleaved.lf @@ -0,0 +1,25 @@ +target Cpp + +reactor Node(num_nodes: size_t(4), bank_index: int(0)) { + input[num_nodes] in: int + output[num_nodes] out: int + + reaction(startup) -> out {= + out[1].set(42); + std::cout << "Bank index " << bank_index << " sent 42 on channel 1." << std::endl; + =} + + reaction(in) {= + for (auto i = 0ul; i < in.size(); i++) { + if (in[i].is_present()) { + std::cout << "Bank index " << bank_index + << " received " << *in[i].get() << " on channel" << std::endl; + } + } + =} +} + +main reactor(num_nodes: size_t(4)) { + nodes = new[num_nodes] Node(num_nodes=num_nodes) + nodes.out -> interleaved(nodes.in) +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Methods.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Methods.lf new file mode 100644 index 000000000..4cd974704 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Methods.lf @@ -0,0 +1,19 @@ +target Cpp + +main reactor Methods { + state foo: int(2) + + const method getFoo(): int {= + return foo; + =} + + method add(x: int) {= + foo += x; + =} + + reaction(startup) {= + std::cout << "Foo is initialized to " << getFoo() << '\n'; + add(40); + std::cout << "2 + 40 = " << getFoo() << '\n'; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Microsteps.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Microsteps.lf new file mode 100644 index 000000000..f743ee278 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Microsteps.lf @@ -0,0 +1,13 @@ +target Cpp + +main reactor { + state count: int(1) + logical action a + + reaction(startup, a) -> a {= + std::cout << count << " Logical time is " << get_logical_time() << " Microstep: " << get_microstep() < out {= + for(auto i = 0ul; i < out.size(); i++) { + out[i].set(i); + } + =} +} +reactor Destination { + input[4] in:int; + reaction(in) {= + int sum = 0; + for (auto i = 0ul; i < in.size(); i++) { + if (in[i].is_present()){ + sum += *in[i].get(); + } + } + std::cout << "Sum of received: " << sum << std::endl; + =} +} +main reactor { + a = new Source(); + b = new Destination(); + a.out -> b.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportSource.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportSource.lf new file mode 100644 index 000000000..f1d8413ee --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportSource.lf @@ -0,0 +1,12 @@ +target Cpp + +reactor MultiportSource(bank_index: int(0)) { + timer t(0, 200 ms) + output out: int + state s: int(0) + + reaction(t) -> out {= + out.set(s); + s += bank_index; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportToBank.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportToBank.lf new file mode 100644 index 000000000..7eba855a5 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/MultiportToBank.lf @@ -0,0 +1,25 @@ +target Cpp + +reactor Source { + output[3] out: int + + reaction(startup) -> out {= + for(int i = 0; i < out.size(); i++) { + out[i].set(i); + } + =} +} + +reactor Destination(bank_index: int(0)) { + input in: int + + reaction(in) {= + std::cout << "Destination " << bank_index << " received " << *in.get() << std::endl; + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.in +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Overwriting.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Overwriting.lf new file mode 100644 index 000000000..3ce276570 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Overwriting.lf @@ -0,0 +1,19 @@ +target Cpp + +reactor Overwriting { + output y: int + state s: int(0) + + timer t1(100 ms, 100 ms) + timer t2(200 ms, 200 ms) + + reaction(t1) -> y {= + s += 1; + y.set(s); + =} + + reaction(t2) -> y {= + s -= 2; + y.set(s); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Physical.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Physical.lf new file mode 100644 index 000000000..238b61b8d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Physical.lf @@ -0,0 +1,15 @@ +target Cpp; + +reactor Physical { + input x:int; + physical action a; + + reaction(x) -> a {= + a.schedule(0ms); + =} + + reaction(a) {= + auto elapsed_time = get_elapsed_logical_time(); + std::cout << "Action triggered at logical time " << elapsed_time << " nsec after start." << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/RegressionTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/RegressionTest.lf new file mode 100644 index 000000000..e5efa73fa --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target Cpp { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Scale.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Scale.lf new file mode 100644 index 000000000..6c8510559 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Scale.lf @@ -0,0 +1,10 @@ +target Cpp + +reactor Scale(factor: int(2)) { + input x: int + output y: int + + reaction(x) -> y {= + y.set(factor * *x.get()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Schedule.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Schedule.lf new file mode 100644 index 000000000..d20701545 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Schedule.lf @@ -0,0 +1,13 @@ +target Cpp; + +reactor Schedule { + input x:int; + logical action a; + reaction(x) -> a {= + a.schedule(200ms); + =} + reaction(a) {= + auto elapsed_time = get_elapsed_logical_time(); + std::cout << "Action triggered at logical time " << elapsed_time << " nsec after start." << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Simultaneous.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Simultaneous.lf new file mode 100644 index 000000000..05d6bb4ab --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Simultaneous.lf @@ -0,0 +1,28 @@ +target Cpp + +reactor Destination { + input x: int + input y: int + + reaction(x, y) {= + std::cout << "Time since start: " << get_elapsed_logical_time() << " Current Microstep: " << get_microstep() << std::endl; + if (x.is_present()) { + std::cout << "x is present" << std::endl; + } + if (y.is_present()) { + std::cout << "y is present" << std::endl; + } + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + d.x.set(1); + repeat.schedule(0ms); + =} + + reaction(repeat) -> d.y {= d.y.set(1); =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/SlowingClock.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/SlowingClock.lf new file mode 100644 index 000000000..9a19aa1f7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/SlowingClock.lf @@ -0,0 +1,17 @@ +target Cpp + +main reactor SlowingClock(start: time(100 ms), incr: time(100 ms)) { + state interval: time(start) + logical action a + + reaction(startup) -> a {= + a.schedule(start); + =} + + reaction(a) -> a {= + auto elapsed_logical_time = get_elapsed_logical_time(); + std::cout << "Logical time since start: " << elapsed_logical_time << " nsec" << std::endl; + interval += incr; + a.schedule(interval); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/TestCount.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/TestCount.lf new file mode 100644 index 000000000..6d19c8bb7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/TestCount.lf @@ -0,0 +1,27 @@ +target Cpp + +reactor TestCount(start: int = 0, stride: int = 1, num_inputs: int = 1) { + state count: int = start + state inputs_received: int = 0 + input x: int + + reaction(x) {= + auto value = *x.get(); + std::cout << "Received " << value << std::endl; + if (value != count) { + std::cerr << "ERROR: Expected: "<< count << std::endl; + exit(1); + } + count += stride; + inputs_received++; + =} + + reaction(shutdown) {= + std::cout << "Shutdown invoked." << std::endl; + if (inputs_received != num_inputs) { + std::cerr << "ERROR: Expected to receive " << num_inputs + << " inputs, but got " << inputs_received << std::endl; + exit(2); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeElapsed.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeElapsed.lf new file mode 100644 index 000000000..ad1f8952f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeElapsed.lf @@ -0,0 +1,9 @@ +target Cpp + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + std::cout << "Elapsed logical time is " << get_elapsed_logical_time() << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeLag.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeLag.lf new file mode 100644 index 000000000..bb403420e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/TimeLag.lf @@ -0,0 +1,13 @@ +target Cpp + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + auto logical_time = get_elapsed_logical_time(); + auto physical_time = get_elapsed_physical_time(); + std::cout << "Elapsed logical time: " << logical_time + << " physical time: " << physical_time + << " lag: " << physical_time - logical_time << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Timer.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Timer.lf new file mode 100644 index 000000000..53ab744c8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Timer.lf @@ -0,0 +1,9 @@ +target Cpp + +main reactor Timer { + timer t(0, 1 s) + + reaction(t) {= + std::cout << "Logical time is: " << get_logical_time() << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/Triggering.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/Triggering.lf new file mode 100644 index 000000000..46a7f579d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/Triggering.lf @@ -0,0 +1,13 @@ +target Cpp +reactor Inside { + input x: int + reaction(x) {= + std::cout << "Received " << std::to_string(*x.get()) << std::endl; + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + i.x.set(42); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/AlignmentTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/AlignmentTest.lf new file mode 100644 index 000000000..099588178 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/AlignmentTest.lf @@ -0,0 +1,24 @@ +target Cpp { + timeout: 3s +} + +main reactor { + state s:int(0); + timer t1(100ms, 100ms); + timer t2(200ms, 200ms); + timer t4(400ms, 400ms); + + reaction(t1) {= + s += 1; + =} + reaction(t2) {= + s -= 2; + =} + + reaction(t4) {= + if (s != 0) { + std::cerr << "Value shoudl be 0!" << std::endl; + std::exit(1); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ContainedOverwriting.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ContainedOverwriting.lf new file mode 100644 index 000000000..606922557 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ContainedOverwriting.lf @@ -0,0 +1,13 @@ +target Cpp { + timeout: 1s +} + +import Overwriting from "../Overwriting.lf"; + +main reactor { + s = new Overwriting(); + reaction(s.y) {= + std::cout << "At logical time: " << get_elapsed_logical_time() + << "s = " << *s.y.get() << std::endl; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountDoubleDestination.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountDoubleDestination.lf new file mode 100644 index 000000000..426bbd1fd --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountDoubleDestination.lf @@ -0,0 +1,22 @@ +target Cpp { + compiler: "cxx", + fast: true, + logging: log, + timeout: 1s +}; + +import Count from "../Count.lf"; +import Double from "../Double.lf"; +import Destination from "../Destination.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Double(); + r = new Destination(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + c.y -> r.x; + d.y -> r.y; + d.y -> t.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountScale.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountScale.lf new file mode 100644 index 000000000..c1be8fb9f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/CountScale.lf @@ -0,0 +1,15 @@ +target Cpp { + fast: true, + timeout: 1s +}; +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Scale(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + d.y -> t.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/HierarchyTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/HierarchyTest.lf new file mode 100644 index 000000000..b8bca5b37 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/HierarchyTest.lf @@ -0,0 +1,22 @@ +target Cpp { + timeout: 1s, + fast: true +} + +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +reactor Container(stride:int(2)) { + output y:int; + c = new Count(); + s = new Scale(factor = stride); + c.y -> s.x; + s.y -> y; +} + +main reactor { + c = new Container(stride = 4); + t = new TestCount(stride = 4, num_inputs = 11); + c.y -> t.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/MultiportSourceTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/MultiportSourceTest.lf new file mode 100644 index 000000000..1d1af2c91 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/MultiportSourceTest.lf @@ -0,0 +1,38 @@ + // Check bank of reactors sending to bank of reactors. +target Cpp { + timeout: 2s, + fast: true, +}; + +import MultiportSource from "../MultiportSource.lf"; + +reactor Destination( + bank_index:int(0) +) { + state s:int(0); + input in:int; + + reaction(in) {= + auto value = *in.get(); + std::cout << "Destination " << bank_index << " received: " << value << std::endl; + if (value != s) { + std::cerr << "ERROR: Expected " << s << std::endl; + std::exit(1); + } + s += bank_index; + =} + + reaction(shutdown) {= + if (s == 0 && bank_index != 0) { + std::cerr << "ERROR: Destination " << bank_index << " received no input!" << std::endl; + exit(1); + } + std::cout << "Success" << std::endl; + =} +} + +main reactor(width:int(4)) { + a = new[width] MultiportSource(); + b = new[width] Destination(); + a.out -> b.in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/PhysicalTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/PhysicalTest.lf new file mode 100644 index 000000000..84b5d043c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/PhysicalTest.lf @@ -0,0 +1,12 @@ +target Cpp; + +import Physical from "../Physical.lf"; + +main reactor { + timer t(200ms, 200ms); + p = new Physical(); + + reaction(t) -> p.x {= + p.x.set(0); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ScheduleTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ScheduleTest.lf new file mode 100644 index 000000000..d41d2ab66 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/ScheduleTest.lf @@ -0,0 +1,13 @@ +target Cpp { + timeout: 1s, + fast: true +} + +import Schedule from "../Schedule.lf"; +import Count from "../Count.lf"; + +main reactor { + c = new Count(); + d = new Schedule(); + c.y -> d.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/SlowingClockTest.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/SlowingClockTest.lf new file mode 100644 index 000000000..651f88379 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/SlowingClockTest.lf @@ -0,0 +1,44 @@ +/** + * Events are scheduled with increasing additional delays of 0, 100, 300, 600 + * msec on a logical action with a minimum delay of 100 msec. + * The use of the logical action ensures the elapsed time jumps exactly from + * 0 to 100, 300, 600, and 1000 msec. + */ +target Cpp { + timeout: 1s, + fast: true, +}; + +main reactor(start:time(100 msec), incr:time(100 msec)) { + logical action a; + state interval:time(start); + state expected_time:time(start); + + reaction(startup) -> a {= + a.schedule(start); + =} + + reaction(a) -> a {= + auto elapsed_logical_time = get_elapsed_logical_time(); + std::cout << "Logical time since start: " << elapsed_logical_time << " nsec" << std::endl; + + if (elapsed_logical_time != expected_time) { + std::cerr << "ERROR: Expected time to be: " << expected_time << " nsec" << std::endl; + exit(1); + } + + interval += incr; + a.schedule(interval); + expected_time += interval; + =} + + reaction(shutdown) {= + if (expected_time != 1500ms) { + std::cerr << "ERROR: Expected the next expected time to be: 1500000000 nsec." << std::endl; + std::cerr << "It was: " << expected_time <<" nsec." << std::endl; + exit(2); + } else { + std::cout << "Test passes" << std::endl; + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/cpp/src/test/StructParameter.lf b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/StructParameter.lf new file mode 100644 index 000000000..846825afe --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/cpp/src/test/StructParameter.lf @@ -0,0 +1,37 @@ +target Cpp; + +public preamble {= + struct Hello { + std::string name; + int value; + }; + + auto operator<<(std::ostream& stream, const Hello& hello) noexcept -> std::ostream&; + auto operator>>(std::stringstream& stream, Hello& hello) noexcept -> std::stringstream&; +=} + + +private preamble {= + auto operator<<(std::ostream& stream, const Hello& hello) noexcept -> std::ostream& { + stream << "Parameter p.name= " << hello.name << ", value= " << hello.value; + return stream; + } + + auto operator>>(std::stringstream& stream, Hello& hello) noexcept -> std::stringstream& { + //stream << "Parameter p.name= " << hello.name << ", value= " << hello.value; + hello.name = std::string("Earth"); + hello.value = 42; + + return stream; + } +=} + +main reactor(p_input:Hello{"Earth", 42}) { + reaction(startup) {= + std::cout << p_input << std::endl; + if (p_input.value != 42) { + std::cerr << "ERROR: Expected 42" << std::endl; + exit(1); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/language_independent/Multicast.lf b/versioned_docs/version-0.8.0/assets/code/language_independent/Multicast.lf new file mode 100644 index 000000000..ad0fd23d1 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/language_independent/Multicast.lf @@ -0,0 +1,14 @@ +target C; +reactor A { + output y:int +} +reactor B { + input x:int +} +main reactor { + a = new A() + b1 = new B() + b2 = new B() + a.y -> b1.x + a.y -> b2.x +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/language_independent/PhysicalConnection.lf b/versioned_docs/version-0.8.0/assets/code/language_independent/PhysicalConnection.lf new file mode 100644 index 000000000..2dd204a8c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/language_independent/PhysicalConnection.lf @@ -0,0 +1,12 @@ +target C; +reactor A { + output y:int; +} +reactor B { + input x:int; +} +main reactor { + a = new A(); + b = new B(); + a.y ~> b.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Alignment.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Alignment.lf new file mode 100644 index 000000000..de1390b42 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Alignment.lf @@ -0,0 +1,22 @@ +target Python { + timeout: 3 secs +} + +main reactor Alignment { + state s = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + timer t4(400 msec, 400 msec) + + reaction(t1) {= + self.s += 1 + =} + + reaction(t2) {= + self.s -= 2 + =} + + reaction(t4) {= + print(f"s = {self.s}") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Asynchronous.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Asynchronous.lf new file mode 100644 index 000000000..e86cd0e66 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Asynchronous.lf @@ -0,0 +1,26 @@ +target Python + +main reactor { + preamble {= + import time + import threading + # Schedule an event roughly every 200 msec. + def external(self, a): + while (True): + self.time.sleep(0.2) + a.schedule(0) + =} + state thread + physical action a(100 msec) + + reaction(startup) -> a {= + # Start a thread to schedule physical actions. + self.thread = self.threading.Thread(target=self.external, args=(a,)) + self.thread.start() + =} + + reaction(a) {= + elapsed_time = lf.time.logical_elapsed() + print(f"Action triggered at logical time {elapsed_time} nsec after start.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/BankIndex.lf b/versioned_docs/version-0.8.0/assets/code/py/src/BankIndex.lf new file mode 100644 index 000000000..2c3dc2c37 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/BankIndex.lf @@ -0,0 +1,12 @@ +target Python; +preamble {= + table = [4, 3, 2, 1] +=} +reactor A(bank_index = 0, value = 0) { + reaction (startup) {= + print("bank_index: {:d}, value: {:d}".format(self.bank_index, self.value)) + =} +} +main reactor { + a = new[4] A(value = {= table[bank_index] =}) +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/ChildBank.lf b/versioned_docs/version-0.8.0/assets/code/py/src/ChildBank.lf new file mode 100644 index 000000000..f676bee08 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/ChildBank.lf @@ -0,0 +1,16 @@ +target Python; +reactor Child ( + bank_index = 0 +) { + reaction(startup) {= + print(f"My bank index: {self.bank_index}.") + =} +} +reactor Parent ( + bank_index = 0 +) { + c = new[2] Child(); +} +main reactor { + p = new[2] Parent(); +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank.lf b/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank.lf new file mode 100644 index 000000000..9f9697c88 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank.lf @@ -0,0 +1,18 @@ +target Python + +reactor Child(bank_index=0, parent_bank_index=0) { + reaction(startup) {= + print( + f"My bank index: {self.bank_index}. " + f"My parent's bank index: {self.parent_bank_index}." + ) + =} +} + +reactor Parent(bank_index=0) { + c = new[2] Child(parent_bank_index=bank_index) +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank2.lf b/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank2.lf new file mode 100644 index 000000000..7219c7cd7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/ChildParentBank2.lf @@ -0,0 +1,22 @@ +target Python + +reactor Child(bank_index=0, parent_bank_index=0) { + output out + + reaction(startup) -> out {= + out.set(self.parent_bank_index * 2 + self.bank_index) + =} +} + +reactor Parent(bank_index=0) { + c = new[2] Child(parent_bank_index=bank_index) + + reaction(c.out) {= + for i, child in enumerate(c): + print(f"Received {child.out.value} from child {i}.") + =} +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Contained.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Contained.lf new file mode 100644 index 000000000..b6a020953 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Contained.lf @@ -0,0 +1,13 @@ +target Python + +import Overwriting from "Overwriting.lf" + +main reactor { + s = new Overwriting() + + reaction(s.y) {= + if s.y.value != 0 and s.y.value != 1: + sys.stderr.write("ERROR: Outputs should only be 0 or 1!\n") + exit(1) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Count.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Count.lf new file mode 100644 index 000000000..22823d78c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Count.lf @@ -0,0 +1,12 @@ +target Python + +reactor Count { + state count = 0 + output y + timer t(0, 100 msec) + + reaction(t) -> y {= + y.set(self.count) + self.count += 1 + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Cycle.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Cycle.lf new file mode 100644 index 000000000..bad84110b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Cycle.lf @@ -0,0 +1,24 @@ +target Python; +reactor A { + input x; + output y; + reaction(x) -> y {= + # ... something here ... + =} +} +reactor B { + input x; + output y; + reaction(x) {= + # ... something here ... + =} + reaction(startup) -> y {= + # ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/CycleReordered.lf b/versioned_docs/version-0.8.0/assets/code/py/src/CycleReordered.lf new file mode 100644 index 000000000..a2315fbed --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target Python; +reactor A { + input x; + output y; + reaction(x) -> y {= + # ... something here ... + =} +} +reactor B { + input x; + output y; + reaction(startup) -> y {= + # ... something here ... + =} + reaction(x) {= + # ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/CycleWithDelay.lf b/versioned_docs/version-0.8.0/assets/code/py/src/CycleWithDelay.lf new file mode 100644 index 000000000..fc667a595 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target Python; +reactor A { + input x; + output y; + reaction(x) -> y {= + # ... something here ... + =} +} +reactor B { + input x; + output y; + reaction(x) {= + # ... something here ... + =} + reaction(startup) -> y {= + # ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x after 0; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Deadline.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Deadline.lf new file mode 100644 index 000000000..c367995f4 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Deadline.lf @@ -0,0 +1,11 @@ +target Python; +reactor Deadline { + input x; + output d; // Produced if the deadline is violated. + reaction(x) -> d {= + print("Normal reaction.") + =} deadline(10 msec) {= + print("Deadline violation detected.") + d.set(x.value) + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/DeadlineTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/DeadlineTest.lf new file mode 100644 index 000000000..9e9ad776c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/DeadlineTest.lf @@ -0,0 +1,18 @@ +target Python; +import Deadline from "Deadline.lf"; +preamble {= import time =} +main reactor { + logical action a; + d = new Deadline(); + reaction(startup) -> d.x, a {= + d.x.set(0) + a.schedule(0) + =} + reaction(a) -> d.x {= + d.x.set(0) + time.sleep(0.02) + =} + reaction(d.d) {= + print("Deadline reactor produced an output.") + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Decentralized.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Decentralized.lf new file mode 100644 index 000000000..cde1839db --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Decentralized.lf @@ -0,0 +1,23 @@ +target Python { + timeout: 0 msec, + coordination: decentralized +} + +reactor Source { + output out; + reaction(startup) -> out {= + out.set("Hello World!") + =} +} +reactor Destination { + input _in; + reaction(_in) {= + print(f"Received {_in.value}") + =} +} + +federated reactor { + s = new Source(); + d = new Destination(); + s.out -> d._in; +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfter.lf b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfter.lf new file mode 100644 index 000000000..d83b54f42 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfter.lf @@ -0,0 +1,23 @@ +target Python { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer extends Print { + timer t(0, 1 sec) + + reaction(t) {= + print( + f"Timer ticked at " + f"({lf.time.logical_elapsed()}, {lf.tag().microstep})." + ) + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.inp after 10 msec +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfterHandler.lf b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfterHandler.lf new file mode 100644 index 000000000..9544d226b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerAfterHandler.lf @@ -0,0 +1,38 @@ +target Python { + timeout: 5 sec, + coordination: decentralized +} + +import Count from "Federated.lf" + +reactor PrintTimer { + timer t(0, 1 sec) + input inp + + reaction(inp) {= + print( + f"Received: {inp.value} " + f"at ({lf.time.logical_elapsed()}, {lf.tag().microstep})" + ) + =} STP(0) {= + print( + "****** STP violation handler invoked at " + f"({lf.time.logical_elapsed()}, {lf.tag().microstep}). " + "Intended tag was " + f"({inp.intended_tag.time - lf.time.start()}, {inp.intended_tag.microstep})." + ) + =} + + reaction(t) {= + print( + "Timer ticked at " + f"({lf.time.logical_elapsed()}, {lf.tag().microstep})." + ) + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.inp after 10 msec +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerSTP.lf b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerSTP.lf new file mode 100644 index 000000000..eff575bf2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/DecentralizedTimerSTP.lf @@ -0,0 +1,23 @@ +target Python { + timeout: 5 sec, + coordination: decentralized +} + +import Count, Print from "Federated.lf" + +reactor PrintTimer(STP_offset = 10 msec) extends Print { + timer t(0, 1 sec) + + reaction(t) {= + print( + "Timer ticked at " + f"({lf.time.logical_elapsed()}, {lf.tag().microstep})." + ) + =} +} + +federated reactor { + c = new Count() + p = new PrintTimer() + c.out -> p.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Destination.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Destination.lf new file mode 100644 index 000000000..1f45cebdf --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Destination.lf @@ -0,0 +1,15 @@ +target Python + +reactor Destination { + input x + input y + + reaction(x, y) {= + sum = 0 + if x.is_present: + sum += x.value + if y.is_present: + sum += y.value + print(f"Received {sum}") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Double.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Double.lf new file mode 100644 index 000000000..0b8800f89 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Double.lf @@ -0,0 +1,10 @@ +target Python + +reactor Double { + input x + output y + + reaction(x) -> y {= + y.set(x.value * 2) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Extends.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Extends.lf new file mode 100644 index 000000000..d73ad6b76 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Extends.lf @@ -0,0 +1,14 @@ +target Python; +reactor A { + input a; + output out; + reaction(a) -> out {= + out.set(a.value) + =} +} +reactor B extends A { + input b; + reaction(a, b) -> out {= + out.set(a.value + b.value) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Federated.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Federated.lf new file mode 100644 index 000000000..96c669946 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Federated.lf @@ -0,0 +1,29 @@ +target Python + +reactor Count { + output out + state c = 0 + timer t(0, 1 sec) + + reaction(t) -> out {= + out.set(self.c) + self.c += 1 + =} +} + +reactor Print { + input inp + + reaction(inp) {= + print( + f"Received: {inp.value} " + f"at ({lf.time.logical_elapsed()}, {lf.tag().microstep})" + ) + =} +} + +federated reactor { + c = new Count() + p = new Print() + c.out -> p.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/HelloWorld.lf b/versioned_docs/version-0.8.0/assets/code/py/src/HelloWorld.lf new file mode 100644 index 000000000..1f59893a6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target Python + +main reactor { + reaction(startup) {= + print("Hello World.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Hierarchy.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Hierarchy.lf new file mode 100644 index 000000000..6750a80e8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target Python + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride=2) { + output y + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Interleaved.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Interleaved.lf new file mode 100644 index 000000000..72bd4ceb7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Interleaved.lf @@ -0,0 +1,24 @@ +target Python + +reactor Node(num_nodes=4, bank_index=0) { + input[num_nodes] inp + output[num_nodes] out + + reaction(startup) -> out {= + out[1].set(42) + print(f"Bank index {self.bank_index} sent 42 on channel 1.") + =} + + reaction(inp) {= + for i, port in enumerate(inp): + if port.is_present: + print( + f"Bank index {self.bank_index} received {port.value} on channel {i}.", + ) + =} +} + +main reactor(num_nodes=4) { + nodes = new[num_nodes] Node(num_nodes=num_nodes) + nodes.out -> interleaved(nodes.inp) +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Methods.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Methods.lf new file mode 100644 index 000000000..38db8d299 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Methods.lf @@ -0,0 +1,19 @@ +target Python + +main reactor Methods { + state foo = 2 + + method getFoo() {= + return self.foo + =} + + method add(x) {= + self.foo += x + =} + + reaction(startup) {= + print(f"Foo is initialized to {self.getFoo()}.") + self.add(40) + print(f"2 + 40 = {self.getFoo()}.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Microsteps.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Microsteps.lf new file mode 100644 index 000000000..94166aabb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Microsteps.lf @@ -0,0 +1,16 @@ +target Python + +main reactor { + state count = 1 + logical action a + + reaction(startup, a) {= + print( + f"{self.count}. Logical time is {lf.tag().time}. " + f"Microstep is {lf.tag().microstep}." + ) + if self.count < 5: + a.schedule(0) + self.count += 1 + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Multiport.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Multiport.lf new file mode 100644 index 000000000..233b639ec --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Multiport.lf @@ -0,0 +1,22 @@ +target Python; +reactor Source { + output[4] out; + reaction(startup) -> out {= + for i, port in enumerate(out): + port.set(i) + =} +} +reactor Destination { + input[4] inp; + reaction(inp) {= + sum = 0 + for port in inp: + if port.is_present: sum += port.value + print(f"Sum of received: {sum}.") + =} +} +main reactor { + a = new Source(); + b = new Destination(); + a.out -> b.inp; +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/MultiportSource.lf b/versioned_docs/version-0.8.0/assets/code/py/src/MultiportSource.lf new file mode 100644 index 000000000..6295ba0d8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/MultiportSource.lf @@ -0,0 +1,12 @@ +target Python + +reactor MultiportSource(bank_index=0) { + timer t(0, 200 msec) + output out + state s = 0 + + reaction(t) -> out {= + out.set(self.s) + self.s += self.bank_index + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/MultiportToBank.lf b/versioned_docs/version-0.8.0/assets/code/py/src/MultiportToBank.lf new file mode 100644 index 000000000..68754174f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/MultiportToBank.lf @@ -0,0 +1,24 @@ +target Python + +reactor Source { + output[3] out + + reaction(startup) -> out {= + for i, port in enumerate(out): + port.set(i) + =} +} + +reactor Destination(bank_index=0) { + input inp + + reaction(inp) {= + print(f"Destination {self.bank_index} received {inp.value}.") + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Overwriting.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Overwriting.lf new file mode 100644 index 000000000..a121a1c2c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Overwriting.lf @@ -0,0 +1,18 @@ +target Python + +reactor Overwriting { + output y + state s = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + + reaction(t1) -> y {= + self.s += 1 + y.set(self.s) + =} + + reaction(t2) -> y {= + self.s -= 2 + y.set(self.s) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Physical.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Physical.lf new file mode 100644 index 000000000..080d5bd60 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Physical.lf @@ -0,0 +1,12 @@ +target Python; +reactor Physical { + input x; + physical action a; + reaction(x) -> a {= + a.schedule(0) + =} + reaction(a) {= + elapsed_time = lf.time.logical_elapsed() + print(f"Action triggered at logical time {elapsed_time} nsec after start.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Preamble.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Preamble.lf new file mode 100644 index 000000000..d61f3dc15 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Preamble.lf @@ -0,0 +1,28 @@ +target Python +main reactor { + preamble {= + import threading + def external(self, a): + while (True): + from_user = input() # Blocking + a.schedule(0, from_user) + =} + state thread + physical action a + timer t(2 secs, 2 secs) + + reaction(startup) -> a {= + self.thread = self.threading.Thread(target=self.external, args=(a,)) + self.thread.start() + print("Type something.") + =} + + reaction(a) {= + elapsed_time = lf.time.logical_elapsed() + print(f"A time {elapsed_time} nsec after start, received: ", a.value) + =} + + reaction(t) {= + print("Waiting ...") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/RegressionTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/RegressionTest.lf new file mode 100644 index 000000000..36a8a5550 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target Python { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Scale.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Scale.lf new file mode 100644 index 000000000..36cf4e94d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Scale.lf @@ -0,0 +1,10 @@ +target Python + +reactor Scale(factor=2) { + input x + output y + + reaction(x) -> y {= + y.set(x.value * self.factor) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Schedule.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Schedule.lf new file mode 100644 index 000000000..72c71251e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Schedule.lf @@ -0,0 +1,12 @@ +target Python; +reactor Schedule { + input x; + logical action a; + reaction(x) -> a {= + a.schedule(MSEC(200)) + =} + reaction(a) {= + elapsed_time = lf.time.logical_elapsed() + print(f"Action triggered at logical time {elapsed_time} nsec after start.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Simultaneous.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Simultaneous.lf new file mode 100644 index 000000000..df48ef014 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Simultaneous.lf @@ -0,0 +1,29 @@ +target Python + +reactor Destination { + input x + input y + + reaction(x, y) {= + print( + f"Time since start: {lf.time.logical_elapsed()}, " + f"microstep: {lf.tag().microstep}" + ) + if x.is_present: + print(" x is present.") + if y.is_present: + print(" y is present.") + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + d.x.set(1) + repeat.schedule(0) + =} + + reaction(repeat) -> d.y {= d.y.set(1) =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/SlowingClock.lf b/versioned_docs/version-0.8.0/assets/code/py/src/SlowingClock.lf new file mode 100644 index 000000000..ff567f5de --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/SlowingClock.lf @@ -0,0 +1,19 @@ +target Python + +main reactor SlowingClock(start = 100 ms, incr = 100 ms) { + state interval = start + logical action a + + reaction(startup) -> a {= + a.schedule(self.start) + =} + + reaction(a) -> a {= + elapsed_logical_time = lf.time.logical_elapsed() + print( + f"Logical time since start: {elapsed_logical_time} nsec." + ) + self.interval += self.incr + a.schedule(self.interval) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/TestCount.lf b/versioned_docs/version-0.8.0/assets/code/py/src/TestCount.lf new file mode 100644 index 000000000..9ab483d36 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/TestCount.lf @@ -0,0 +1,25 @@ +target Python + +reactor TestCount(start=0, stride=1, num_inputs=1) { + state count = start + state inputs_received = 0 + input x + + reaction(x) {= + print(f"Received {x.value}.") + if x.value != self.count: + sys.stderr.write(f"ERROR: Expected {self.count}.\n") + exit(1) + self.count += self.stride + self.inputs_received += 1 + =} + + reaction(shutdown) {= + print("Shutdown invoked.") + if self.inputs_received != self.num_inputs: + sys.stderr.write( + f"ERROR: Expected to receive {self.num_inputs} inputs, but got {self.inputs_received}.\n" + ) + exit(2) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/TimeElapsed.lf b/versioned_docs/version-0.8.0/assets/code/py/src/TimeElapsed.lf new file mode 100644 index 000000000..b216301e6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/TimeElapsed.lf @@ -0,0 +1,11 @@ +target Python + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + print( + f"Elapsed logical time is {lf.time.logical_elapsed()}." + ) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/TimeLag.lf b/versioned_docs/version-0.8.0/assets/code/py/src/TimeLag.lf new file mode 100644 index 000000000..477683069 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/TimeLag.lf @@ -0,0 +1,13 @@ +target Python + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + t = lf.time.logical_elapsed() + T = lf.time.physical_elapsed() + print( + f"Elapsed logical time: {t}, physical time: {T}, lag: {T-t}" + ) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Timer.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Timer.lf new file mode 100644 index 000000000..893389eb2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Timer.lf @@ -0,0 +1,9 @@ +target Python + +main reactor Timer { + timer t(0, 1 sec) + + reaction(t) {= + print(f"Logical time is {lf.time.logical()}.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/Triggering.lf b/versioned_docs/version-0.8.0/assets/code/py/src/Triggering.lf new file mode 100644 index 000000000..402db30d8 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/Triggering.lf @@ -0,0 +1,13 @@ +target Python +reactor Inside { + input x + reaction(x) {= + print(f"Received {x.value}") + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + i.x.set(42); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/AlignmentTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/AlignmentTest.lf new file mode 100644 index 000000000..9b7484443 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/AlignmentTest.lf @@ -0,0 +1,20 @@ +target Python { + timeout: 3 secs +} +main reactor { + state s(0); + timer t1(100 msec, 100 msec); + timer t2(200 msec, 200 msec); + timer t4(400 msec, 400 msec); + reaction(t1) {= + self.s += 1 + =} + reaction(t2) {= + self.s -= 2 + =} + reaction(t4) {= + if self.s != 0: + sys.stderr.write("ERROR: Value should be 0!") + exit(1) + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/ContainedOverwriting.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/ContainedOverwriting.lf new file mode 100644 index 000000000..0e2208e4e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/ContainedOverwriting.lf @@ -0,0 +1,13 @@ +target Python { + timeout: 1 secs +} +import Overwriting from "../Overwriting.lf"; +main reactor { + s = new Overwriting(); + reaction(s.y) {= + print( + f"At logical time {lf.time.logical_elapsed()}, " + f"s = {s.y.value}." + ) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/CountDoubleDestination.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/CountDoubleDestination.lf new file mode 100644 index 000000000..13a016a39 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/CountDoubleDestination.lf @@ -0,0 +1,20 @@ +target Python { + fast: true, + logging: log, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Double from "../Double.lf"; +import Destination from "../Destination.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Double(); + r = new Destination(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + c.y -> r.x; + d.y -> r.y; + d.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/CountScale.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/CountScale.lf new file mode 100644 index 000000000..376bb7d00 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/CountScale.lf @@ -0,0 +1,15 @@ +target Python { + fast: true, + timeout: 1 secs +}; +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +main reactor { + c = new Count(); + d = new Scale(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + c.y -> d.x; + d.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/ExtendsTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/ExtendsTest.lf new file mode 100644 index 000000000..131674537 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/ExtendsTest.lf @@ -0,0 +1,28 @@ +target Python { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import TestCount from "../TestCount.lf"; + +reactor A { + input a; + output out; + reaction(a) -> out {= + out.set(a.value) + =} +} +reactor B extends A { + input b; + reaction(a, b) -> out {= + out.set(a.value + b.value) + =} +} + +main reactor { + c = new Count(); + b = new B(); + t = new TestCount(start = 0, stride = 2, num_inputs = 11); + (c.y)+ -> b.a, b.b; + b.out -> t.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/HierarchyTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/HierarchyTest.lf new file mode 100644 index 000000000..1f76c4b9a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/HierarchyTest.lf @@ -0,0 +1,21 @@ +target Python { + timeout: 1 sec, + fast: true +} +import Count from "../Count.lf"; +import Scale from "../Scale.lf"; +import TestCount from "../TestCount.lf"; + +reactor Container(stride(2)) { + output y; + c = new Count(); + s = new Scale(factor = stride); + c.y -> s.x; + s.y -> y; +} + +main reactor { + c = new Container(stride = 4); + t = new TestCount(stride = 4, num_inputs = 11); + c.y -> t.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/MultiportSourceTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/MultiportSourceTest.lf new file mode 100644 index 000000000..d34b3292c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/MultiportSourceTest.lf @@ -0,0 +1,31 @@ + // Check bank of reactors sending to bank of reactors. +target Python { + timeout: 2 sec, + fast: true, +}; +import MultiportSource from "../MultiportSource.lf"; +reactor Destination( + bank_index(0) +) { + state s(0); + input inp; + reaction(inp) {= + print(f"Destination {self.bank_index} received: {inp.value}.") + if inp.value != self.s: + sys.stderr.write(f"ERROR: Expected {self.s}.") + exit(1) + self.s += self.bank_index + =} + reaction(shutdown) {= + if self.s == 0 and self.bank_index != 0: + sys.stderr.write(f"ERROR: Destination {self.bank_index} received no input!") + exit(1) + print("Success.") + =} +} + +main reactor(width(4)) { + a = new[width] MultiportSource(); + b = new[width] Destination(); + a.out -> b.inp; +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/PhysicalTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/PhysicalTest.lf new file mode 100644 index 000000000..fa71ef3f2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/PhysicalTest.lf @@ -0,0 +1,9 @@ +target Python; +import Physical from "../Physical.lf"; +main reactor { + timer t(200 msec, 200 msec); + p = new Physical(); + reaction(t) -> p.x {= + p.x.set(0) + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/ScheduleTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/ScheduleTest.lf new file mode 100644 index 000000000..9b243ff72 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/ScheduleTest.lf @@ -0,0 +1,11 @@ +target Python { + timeout: 1 sec, + fast: true +} +import Schedule from "../Schedule.lf"; +import Count from "../Count.lf"; +main reactor { + c = new Count(); + d = new Schedule(); + c.y -> d.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/SlowingClockTest.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/SlowingClockTest.lf new file mode 100644 index 000000000..99fff4314 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/SlowingClockTest.lf @@ -0,0 +1,42 @@ +/** + * Events are scheduled with increasing additional delays of 0, 100, 300, 600 + * msec on a logical action with a minimum delay of 100 msec. + * The use of the logical action ensures the elapsed time jumps exactly from + * 0 to 100, 300, 600, and 1000 msec. + */ +target Python { + timeout: 1 sec, + fast: true, +}; +main reactor(start(100 msec), incr(100 msec)) { + logical action a; + state interval(start); + state expected_time(start); + reaction(startup) -> a {= + a.schedule(self.start) + =} + reaction(a) -> a {= + elapsed_logical_time = lf.time.logical_elapsed() + print( + f"Logical time since start: {elapsed_logical_time} nsec.", + ) + if elapsed_logical_time != self.expected_time: + sys.stderr.write( + f"ERROR: Expected time to be: {self.expected_time} nsec." + ) + exit(1) + self.interval += self.incr + a.schedule(self.interval) + self.expected_time += self.interval + =} + reaction(shutdown) {= + if self.expected_time != MSEC(1500): + sys.stderr.write( + "ERROR: Expected the next expected time to be: 1500000000 nsec.\n" + f"It was: {self.expected_time} nsec.\n" + ) + exit(2) + else: + print("Test passes.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/py/src/test/StructParameter.lf b/versioned_docs/version-0.8.0/assets/code/py/src/test/StructParameter.lf new file mode 100644 index 000000000..88dc7e8ed --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/py/src/test/StructParameter.lf @@ -0,0 +1,15 @@ +target Python; +preamble {= + class hello: + def __init__(self, name, value): + self.name = name + self.value = value +=} +main reactor(p({=hello("Earth", 42)=})) { + reaction(startup) {= + print(f"Parameter p.name=\"{self.p.name}\", value={self.p.value}.") + if self.p.value != 42: + sys.stderr.write(stderr, "FAILED: Expected 42.") + exit(1) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Alignment.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Alignment.lf new file mode 100644 index 000000000..9209af016 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Alignment.lf @@ -0,0 +1,22 @@ +target Rust { + timeout: 3 secs +} + +main reactor Alignment { + state s: u32 = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + timer t4(400 msec, 400 msec) + + reaction(t1) {= + self.s += 1; + =} + + reaction(t2) {= + self.s -= 2; + =} + + reaction(t4) {= + println!("s = {}", self.s); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Asynchronous.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Asynchronous.lf new file mode 100644 index 000000000..949beac5c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Asynchronous.lf @@ -0,0 +1,22 @@ +target Rust + +main reactor { + state start_time: Instant = {= Instant::now() =} + physical action a(100 msec): u32 + + reaction(startup) -> a {= + let phys_action = a.clone(); // clone to move it into other thread + // Start a thread to schedule physical actions. + ctx.spawn_physical_thread(move |link| { + loop { + std::thread::sleep(Duration::from_millis(200)); + link.schedule_physical(&phys_action, Asap).unwrap(); + } + }); + =} + + reaction(a) {= + let elapsed_time = self.start_time.elapsed(); + println!("Action triggered at logical time {} nsecs after start.", elapsed_time.as_nanos()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/ChildBank.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/ChildBank.lf new file mode 100644 index 000000000..d54538f05 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/ChildBank.lf @@ -0,0 +1,18 @@ +target Rust; +reactor Child ( + bank_index:usize = 0 +) { + state bank_index = bank_index; + + reaction(startup) {= + println!("My bank index: {}.", self.bank_index); + =} +} +reactor Parent ( + bank_index:usize = 0 +) { + c = new[2] Child(); +} +main reactor { + p = new[2] Parent(); +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/ChildParentBank.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/ChildParentBank.lf new file mode 100644 index 000000000..d3b0a6fce --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/ChildParentBank.lf @@ -0,0 +1,22 @@ +target Rust + +reactor Child(bank_index: usize = 0, parent_bank_index: usize = 0) { + state bank_index = bank_index + state parent_bank_index = parent_bank_index + + reaction(startup) {= + println!( + "My bank index: {}. My parent's bank index: {}.", + self.bank_index, + self.parent_bank_index, + ); + =} +} + +reactor Parent(bank_index: usize = 0) { + c = new[2] Child(parent_bank_index=bank_index) +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Contained.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Contained.lf new file mode 100644 index 000000000..e8a63b51f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Contained.lf @@ -0,0 +1,15 @@ +target Rust + +import Overwriting from "Overwriting.lf" + +main reactor { + s = new Overwriting() + + reaction(s.y) {= + let value = ctx.get(s__y).unwrap(); + if value != 0 && value != 1 { + eprintln!("Output schould only be 0 or 1!"); + ctx.request_stop(Asap); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Count.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Count.lf new file mode 100644 index 000000000..3f4e5cfdf --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Count.lf @@ -0,0 +1,12 @@ +target Rust + +reactor Count { + state count: u32 = 0 + output y: u32 + timer t(0, 100 msec) + + reaction(t) -> y {= + ctx.set(y, self.count); + self.count += 1; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Cycle.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Cycle.lf new file mode 100644 index 000000000..71d079b61 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Cycle.lf @@ -0,0 +1,24 @@ +target Rust; +reactor A { + input x:u32; + output y:u32; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:u32; + output y:u32; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/CycleReordered.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/CycleReordered.lf new file mode 100644 index 000000000..ba5bf8516 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target Rust; +reactor A { + input x:u32; + output y:u32; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:u32; + output y:u32; + reaction(startup) -> y {= + // ... something here ... + =} + reaction(x) {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/CycleWithDelay.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/CycleWithDelay.lf new file mode 100644 index 000000000..98abdd125 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target Rust; +reactor A { + input x:u32; + output y:u32; + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:u32; + output y:u32; + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A(); + b = new B(); + a.y -> b.x after 0; + b.y -> a.x; +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Destination.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Destination.lf new file mode 100644 index 000000000..610a8423a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Destination.lf @@ -0,0 +1,17 @@ +target Rust + +reactor Destination { + input x: u32 + input y: u32 + + reaction(x, y) {= + let mut sum = 0; + if let Some(x) = ctx.get(x) { + sum += x; + } + if let Some(y) = ctx.get(y) { + sum += y; + } + println!("Received {}.", sum); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Double.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Double.lf new file mode 100644 index 000000000..f5c6e62cf --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Double.lf @@ -0,0 +1,10 @@ +target Rust + +reactor Double { + input x: u32 + output y: u32 + + reaction(x) -> y {= + ctx.set(y, ctx.get(x).unwrap() * 2); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Extends.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Extends.lf new file mode 100644 index 000000000..0f366123e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Extends.lf @@ -0,0 +1,14 @@ +target Rust; +reactor A { + input a:u32; + output out:u32; + reaction(a) -> out {= + ctx.set(out, ctx.get(a).unwrap()); + =} +} +reactor B extends A { + input b:u32; + reaction(a, b) -> out {= + ctx.set(out, ctx.get(a).unwrap() + ctx.get(b).unwrap()); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/HelloWorld.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/HelloWorld.lf new file mode 100644 index 000000000..3cfd62a04 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target Rust + +main reactor { + reaction(startup) {= + println!("Hello World."); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Hierarchy.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Hierarchy.lf new file mode 100644 index 000000000..aa79cd6ef --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target Rust + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride: u32 = 2) { + output y: u32 + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Microsteps.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Microsteps.lf new file mode 100644 index 000000000..6db85539f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Microsteps.lf @@ -0,0 +1,20 @@ +target Rust + +main reactor { + state count: u32 = 1 + logical action a + + reaction(startup, a) -> a {= + let tag = ctx.get_tag(); + println!( + "{}. Logical time is {}. Microstep is {}.", + self.count, + tag.offset_from_t0.as_nanos(), + tag.microstep(), + ); + if self.count < 5 { + self.count += 1; + ctx.schedule(a, Asap); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Multiport.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Multiport.lf new file mode 100644 index 000000000..10a5b5115 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Multiport.lf @@ -0,0 +1,26 @@ +target Rust; +reactor Source { + output[4] out:usize; + reaction(startup) -> out {= + for (i, o) in out.into_iter().enumerate() { + ctx.set(o, i); + } + =} +} +reactor Destination { + input[4] inp:usize; + reaction(inp) {= + let mut sum = 0; + for i in inp { + if let Some(v) = ctx.get(&i) { + sum += v; + } + } + println!("Sum of received: {}.", sum); + =} +} +main reactor { + a = new Source(); + b = new Destination(); + a.out -> b.inp; +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportSource.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportSource.lf new file mode 100644 index 000000000..510a452e4 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportSource.lf @@ -0,0 +1,13 @@ +target Rust + +reactor MultiportSource(bank_index: u32 = 0) { + state bank_index = bank_index + timer t(0, 200 msec) + output out: u32 + state s: u32 = 0 + + reaction(t) -> out {= + ctx.set(out, self.s); + self.s += self.bank_index; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportToBank.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportToBank.lf new file mode 100644 index 000000000..143a4efcd --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/MultiportToBank.lf @@ -0,0 +1,30 @@ +target Rust + +reactor Source { + output[3] out: usize + + reaction(startup) -> out {= + for (i, o) in out.into_iter().enumerate() { + ctx.set(o, i); + } + =} +} + +reactor Destination(bank_index: usize = 0) { + state bank_index = bank_index + input inp: usize + + reaction(inp) {= + println!( + "Destination {} received {}.", + self.bank_index, + ctx.get(inp).unwrap(), + ); + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Overwriting.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Overwriting.lf new file mode 100644 index 000000000..d75aedaed --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Overwriting.lf @@ -0,0 +1,18 @@ +target Rust + +reactor Overwriting { + output y: u32 + state s: u32 = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + + reaction(t1) -> y {= + self.s += 1; + ctx.set(y, self.s); + =} + + reaction(t2) -> y {= + self.s -= 2; + ctx.set(y, self.s); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Physical.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Physical.lf new file mode 100644 index 000000000..1900ae79f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Physical.lf @@ -0,0 +1,17 @@ +target Rust; +reactor Physical { + input x:u32; + physical action a; + reaction(x) -> a {= + let phys_action = a.clone(); + ctx.spawn_physical_thread(move |link| { + link.schedule(&phys_action, Asap).unwrap(); + }); + =} + reaction(a) {= + println!( + "Action triggered at logical time {} nsec after start.", + ctx.get_elapsed_logical_time().as_nanos(), + ); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/RegressionTest.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/RegressionTest.lf new file mode 100644 index 000000000..f5131a753 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target Rust { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, num_inputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Scale.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Scale.lf new file mode 100644 index 000000000..7de10f318 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Scale.lf @@ -0,0 +1,12 @@ +target Rust + +reactor Scale(factor: u32 = 2) { + state factor = factor + input x: u32 + output y: u32 + + reaction(x) -> y {= + let x = ctx.get(x).unwrap(); + ctx.set(y, x * self.factor); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Schedule.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Schedule.lf new file mode 100644 index 000000000..439cf33f7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Schedule.lf @@ -0,0 +1,14 @@ +target Rust; +reactor Schedule { + input x:u32; + logical action a; + reaction(x) -> a {= + ctx.schedule(a, after!(200 ms)); + =} + reaction(a) {= + printf(" + Action triggered at logical time {} nsec after start.", + ctx.get_elapsed_logical_time().as_nanos(), + ); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Simultaneous.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Simultaneous.lf new file mode 100644 index 000000000..174989f5a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Simultaneous.lf @@ -0,0 +1,33 @@ +target Rust + +reactor Destination { + input x: u32 + input y: u32 + + reaction(x, y) {= + let tag = ctx.get_tag(); + println!( + "Time since start: {}, microstep: {}", + tag.offset_from_t0.as_nanos(), + tag.microstep, + ); + if ctx.is_present(x) { + println!(" x is present."); + } + if ctx.is_present(y) { + println!(" y is present."); + } + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + ctx.set(d__x, 1); + ctx.schedule(repeat, Asap); + =} + + reaction(repeat) -> d.y {= ctx.set(d__y, 1); =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/SlowingClock.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/SlowingClock.lf new file mode 100644 index 000000000..b11606817 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/SlowingClock.lf @@ -0,0 +1,23 @@ +target Rust + +main reactor SlowingClock(start: time = 100 ms, incr: time = 100 ms) { + state start = start + state incr = incr + state interval: time = start + state expected_time: time() + logical action a + + reaction(startup) -> a {= + ctx.schedule(a, After(self.start)); + =} + + reaction(a) -> a {= + println!( + "Logical time since start: {} nsec.", + ctx.get_elapsed_logical_time().as_nanos(), + ); + self.interval += self.incr; + ctx.schedule(a, After(self.interval)); + self.expected_time += self.interval; + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/TestCount.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/TestCount.lf new file mode 100644 index 000000000..bcc658c81 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/TestCount.lf @@ -0,0 +1,32 @@ +target Rust + +reactor TestCount(start: u32 = 0, stride: u32 = 1, num_inputs: u32 = 1) { + state stride = stride + state num_inputs = num_inputs + state count: u32 = start + state inputs_received: u32 = 0 + input x: u32 + + reaction(x) {= + let x = ctx.get(x).unwrap(); + println!("Received {}.", x); + if x != self.count { + println!("ERROR: Expected {}.", self.count); + std::process::exit(1); + } + self.count += self.stride; + self.inputs_received += 1; + =} + + reaction(shutdown) {= + println!("Shutdown invoked."); + if self.inputs_received != self.num_inputs { + println!( + "ERROR: Expected to receive {} inputs, but got {}.", + self.num_inputs, + self.inputs_received + ); + std::process::exit(2); + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/TimeElapsed.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/TimeElapsed.lf new file mode 100644 index 000000000..89e8ab87d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/TimeElapsed.lf @@ -0,0 +1,12 @@ +target Rust + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + println!( + "Elapsed logical time is {}.", + ctx.get_elapsed_logical_time().as_nanos(), + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/TimeLag.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/TimeLag.lf new file mode 100644 index 000000000..2803445b9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/TimeLag.lf @@ -0,0 +1,16 @@ +target Rust + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + let t = ctx.get_elapsed_logical_time(); + let T = ctx.get_elapsed_physical_time(); + println!( + "Elapsed logical time: {}, physical time: {}, lag: {}", + t.as_nanos(), + T.as_nanos(), + (T-t).as_nanos(), + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Timer.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Timer.lf new file mode 100644 index 000000000..27e0dfc05 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Timer.lf @@ -0,0 +1,12 @@ +target Rust + +main reactor Timer { + timer t(0, 1 sec) + + reaction(t) {= + println!( + "Logical time is {}.", + ctx.get_elapsed_logical_time().as_nanos(), + ); + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/rs/src/Triggering.lf b/versioned_docs/version-0.8.0/assets/code/rs/src/Triggering.lf new file mode 100644 index 000000000..6fa1da4fb --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/rs/src/Triggering.lf @@ -0,0 +1,13 @@ +target Rust +reactor Inside { + input x: u32 + reaction(x) {= + println!("Received {}", ctx.get(x).unwrap()); + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + ctx.set(i__x, 42); + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Alignment.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Alignment.lf new file mode 100644 index 000000000..86d1b5630 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Alignment.lf @@ -0,0 +1,22 @@ +target TypeScript { + timeout: 3 s +} + +main reactor Alignment { + state s: number = 0 + timer t1(100 ms, 100 ms) + timer t2(200 ms, 200 ms) + timer t4(400 ms, 400 ms) + + reaction(t1) {= + s += 1 + =} + + reaction(t2) {= + s -= 2 + =} + + reaction(t4) {= + console.log(`s = ${s}`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Asynchronous.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Asynchronous.lf new file mode 100644 index 000000000..65883df7e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Asynchronous.lf @@ -0,0 +1,16 @@ +target TypeScript + +main reactor { + physical action a(100 msec): number + + reaction(startup) -> a {= + // Have asynchronous callback schedule physical action. + setTimeout(() => { + actions.a.schedule(TimeValue.zero(), 0) + }, 200) + =} + + reaction(a) {= + console.log(`Action triggered at logical time ${util.getElapsedLogicalTime()} nsec after start.`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/ChildBank.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildBank.lf new file mode 100644 index 000000000..34772ae37 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildBank.lf @@ -0,0 +1,12 @@ +target TypeScript +reactor Child { + reaction(startup) {= + console.log(`My bank index ${this.getBankIndex()}`) + =} +} +reactor Parent { + c = new[2] Child() +} +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank.lf new file mode 100644 index 000000000..97e950415 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank.lf @@ -0,0 +1,15 @@ +target TypeScript + +reactor Child(parentBankIndex: number = 0) { + reaction(startup) {= + console.log(`My bank index: ${this.getBankIndex()} My parent's bank index: ${parentBankIndex}`) + =} +} + +reactor Parent { + c = new[2] Child(parentBankIndex = {= this.getBankIndex() =}) +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank2.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank2.lf new file mode 100644 index 000000000..ac87dd443 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/ChildParentBank2.lf @@ -0,0 +1,23 @@ +target TypeScript + +reactor Child(parentBankIndex: number = 0) { + output out: number + + reaction(startup) -> out {= + out = parentBankIndex * 2 + this.getBankIndex() + =} +} + +reactor Parent { + c = new[2] Child(parentBankIndex = {= this.getBankIndex() =}) + + reaction(c.out) {= + for (let i = 0; i < c.length; i++) { + console.log(`Received ${c[i].out} from child ${i}`) + } + =} +} + +main reactor { + p = new[2] Parent() +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Contained.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Contained.lf new file mode 100644 index 000000000..534de6be4 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Contained.lf @@ -0,0 +1,13 @@ +target TypeScript + +import Overwriting from "Overwriting.lf" + +main reactor { + s = new Overwriting() + + reaction(s.y) {= + if (s.y != 0 && s.y != 1) { + util.requestErrorStop("Outputs should only be 0 or 1!") + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Count.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Count.lf new file mode 100644 index 000000000..948755a11 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Count.lf @@ -0,0 +1,11 @@ +target TypeScript + +reactor Count { + state count: number = 0 + output y: number + timer t(0, 100 msec) + + reaction(t) -> y {= + y = count++ + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Cycle.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Cycle.lf new file mode 100644 index 000000000..8ab9728ae --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Cycle.lf @@ -0,0 +1,24 @@ +target TypeScript +reactor A { + input x:number + output y:number + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:number + output y:number + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A() + b = new B() + a.y -> b.x + b.y -> a.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/CycleReordered.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/CycleReordered.lf new file mode 100644 index 000000000..5a25db5ee --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/CycleReordered.lf @@ -0,0 +1,24 @@ +target TypeScript +reactor A { + input x:number + output y:number + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:number + output y:number + reaction(startup) -> y {= + // ... something here ... + =} + reaction(x) {= + // ... something here ... + =} +} +main reactor { + a = new A() + b = new B() + a.y -> b.x + b.y -> a.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/CycleWithDelay.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/CycleWithDelay.lf new file mode 100644 index 000000000..aa0015ff1 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/CycleWithDelay.lf @@ -0,0 +1,24 @@ +target TypeScript +reactor A { + input x:number + output y:number + reaction(x) -> y {= + // ... something here ... + =} +} +reactor B { + input x:number + output y:number + reaction(x) {= + // ... something here ... + =} + reaction(startup) -> y {= + // ... something here ... + =} +} +main reactor { + a = new A() + b = new B() + a.y -> b.x after 0 + b.y -> a.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Deadline.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Deadline.lf new file mode 100644 index 000000000..26b184461 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Deadline.lf @@ -0,0 +1,11 @@ +target TypeScript +reactor Deadline { + input x:number + output d:number // Produced if the deadline is violated. + reaction(x) -> d {= + console.log("Normal reaction.") + =} deadline(10 msec) {= + console.log("Deadline violation detected.") + d = x + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/DeadlineTest.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/DeadlineTest.lf new file mode 100644 index 000000000..9043dd490 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/DeadlineTest.lf @@ -0,0 +1,20 @@ +target TypeScript +import Deadline from "Deadline.lf" +main reactor { + logical action a + d = new Deadline() + reaction(startup) -> d.x, a {= + d.x = 0 + actions.a.schedule(TimeValue.zero(), null) + =} + reaction(a) -> d.x {= + d.x = 0 + for (const later = util.getCurrentPhysicalTime().add(TimeValue.msecs(20)); + util.getCurrentPhysicalTime() < later;) { + // Take time... + } + =} + reaction(d.d) {= + console.log("Deadline reactor produced an output.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Destination.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Destination.lf new file mode 100644 index 000000000..3ac08a15e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Destination.lf @@ -0,0 +1,17 @@ +target TypeScript + +reactor Destination { + input x: number + input y: number + + reaction(x, y) {= + let sum = 0 + if (x !== undefined) { + sum += x + } + if (y !== undefined) { + sum += y + } + console.log(`Received ${sum}.`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Double.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Double.lf new file mode 100644 index 000000000..2ca50f67a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Double.lf @@ -0,0 +1,10 @@ +target TypeScript + +reactor Double { + input x: number + output y: number + + reaction(x) -> y {= + y = value * 2 + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Extends.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Extends.lf new file mode 100644 index 000000000..501702ef2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Extends.lf @@ -0,0 +1,14 @@ +target TypeScript +reactor A { + input a:number + output out:number + reaction(a) -> out {= + out = a + =} +} +reactor B extends A { + input b:number + reaction(a, b) -> out {= + out = a + b + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Federated.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Federated.lf new file mode 100644 index 000000000..be457c298 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Federated.lf @@ -0,0 +1,25 @@ +target TypeScript { + timeout: 1 msec // FIXME: This should work with timeout: 0 msec. +} + +reactor Source { + output out: string + + reaction(startup) -> out {= + out = "Hello World!"; + =} +} + +reactor Destination { + input inp: string + + reaction(inp) {= + console.log("Received: " + inp); + =} +} + +federated reactor Federated { + s = new Source() + d = new Destination() + s.out -> d.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/HelloWorld.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/HelloWorld.lf new file mode 100644 index 000000000..4a0d6f469 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/HelloWorld.lf @@ -0,0 +1,7 @@ +target TypeScript + +main reactor { + reaction(startup) {= + console.log("Hello World.") + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Hierarchy.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Hierarchy.lf new file mode 100644 index 000000000..f86a8d3ba --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Hierarchy.lf @@ -0,0 +1,19 @@ +target TypeScript + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +reactor Container(stride: number = 2) { + output y: number + c = new Count() + s = new Scale(factor=stride) + c.y -> s.x + s.y -> y +} + +main reactor Hierarchy { + c = new Container(stride=4) + t = new TestCount(stride=4, numInputs=11) + c.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Microsteps.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Microsteps.lf new file mode 100644 index 000000000..7b29462d2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Microsteps.lf @@ -0,0 +1,13 @@ +target TypeScript + +main reactor { + state count: number = 1 + logical action a + + reaction(startup, a) -> a {= + console.log(`${count}. Logical time is ${util.getCurrentLogicalTime()}. Microstep is ${util.getCurrentTag().microstep}.`) + if (count++ < 5) { + actions.a.schedule(TimeValue.zero(), null) + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Multiport.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Multiport.lf new file mode 100644 index 000000000..8288487db --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Multiport.lf @@ -0,0 +1,25 @@ +target TypeScript +reactor Source { + output[4] out:number + reaction(startup) -> out {= + for (let i = 0 ; i < out.length; i++) { + out[i] = i + } + =} +} +reactor Destination { + input[4] inp:number + reaction(inp) {= + let sum = 0 + for (let i = 0 ; i < inp.length; i++) { + const val = inp[i] + if (val) sum += val + } + console.log(`Sum of received: ${sum}`) + =} +} +main reactor { + a = new Source() + b = new Destination() + a.out -> b.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportSource.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportSource.lf new file mode 100644 index 000000000..922b5b5a2 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportSource.lf @@ -0,0 +1,12 @@ +target TypeScript + +reactor MultiportSource { + timer t(0, 200 msec) + output out: number + state s: number = 0 + + reaction(t) -> out {= + out = s + s += this.getBankIndex() + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportToBank.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportToBank.lf new file mode 100644 index 000000000..229bbc27b --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/MultiportToBank.lf @@ -0,0 +1,25 @@ +target TypeScript + +reactor Source { + output[3] out: number + + reaction(startup) -> out {= + for (let i = 0 ; i < out.length; i++) { + out[i] = i + } + =} +} + +reactor Destination { + input inp: number + + reaction(inp) {= + console.log(`Destination ${this.getBankIndex()} received ${inp}`) + =} +} + +main reactor MultiportToBank { + a = new Source() + b = new[3] Destination() + a.out -> b.inp +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Overwriting.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Overwriting.lf new file mode 100644 index 000000000..526ecff8d --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Overwriting.lf @@ -0,0 +1,18 @@ +target TypeScript + +reactor Overwriting { + output y: number + state s: number = 0 + timer t1(100 msec, 100 msec) + timer t2(200 msec, 200 msec) + + reaction(t1) -> y {= + s += 1 + y = s + =} + + reaction(t2) -> y {= + s -= 2 + y = s + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Physical.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Physical.lf new file mode 100644 index 000000000..fa3a57e8a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Physical.lf @@ -0,0 +1,11 @@ +target TypeScript +reactor Physical { + input x:int + physical action a + reaction(x) -> a {= + actions.a.schedule(TimeValue.zero(), null) + =} + reaction(a) {= + console.log(`Action triggered at logical time ${util.getElapsedLogicalTime()} nsec after start.`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/RegressionTest.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/RegressionTest.lf new file mode 100644 index 000000000..14f71993a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/RegressionTest.lf @@ -0,0 +1,16 @@ +target TypeScript { + timeout: 1 sec, + fast: true +} + +import Count from "Count.lf" +import Scale from "Scale.lf" +import TestCount from "TestCount.lf" + +main reactor RegressionTest { + c = new Count() + s = new Scale(factor=4) + t = new TestCount(stride=4, numInputs=11) + c.y -> s.x + s.y -> t.x +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Scale.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Scale.lf new file mode 100644 index 000000000..1bdc7bbec --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Scale.lf @@ -0,0 +1,10 @@ +target TypeScript + +reactor Scale(factor: number = 2) { + input x: number + output y: number + + reaction(x) -> y {= + if (x !== undefined) y = x * factor + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Schedule.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Schedule.lf new file mode 100644 index 000000000..4b6c949ce --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Schedule.lf @@ -0,0 +1,11 @@ +target TypeScript +reactor Schedule { + input x:number + logical action a + reaction(x) -> a {= + actions.a.schedule(TimeValue.nsecs(200), null) + =} + reaction(a) {= + console.log(`Action triggered at logical time ${util.getElapsedLogicalTime()} after start.`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Simultaneous.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Simultaneous.lf new file mode 100644 index 000000000..64af3651f --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Simultaneous.lf @@ -0,0 +1,28 @@ +target TypeScript + +reactor Destination { + input x: number + input y: number + + reaction(x, y) {= + console.log(`Time since start: ${util.getElapsedLogicalTime()}, microstep: ${util.getCurrentTag().microstep}`) + if (x !== undefined) { + console.log(" x is present.") + } + if (y !== undefined) { + console.log(" y is present.") + } + =} +} + +main reactor { + logical action repeat + d = new Destination() + + reaction(startup) -> d.x, repeat {= + d.x = 1 + actions.repeat.schedule(0, null) + =} + + reaction(repeat) -> d.y {= d.y = 1 =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/SlowingClock.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/SlowingClock.lf new file mode 100644 index 000000000..7d87880c6 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/SlowingClock.lf @@ -0,0 +1,16 @@ +target TypeScript + +main reactor SlowingClock(start: time = 100 ms, incr: time = 100 ms) { + state interval: time = start + logical action a + + reaction(startup) -> a {= + actions.a.schedule(start, null); + =} + + reaction(a) -> a {= + console.log(`Logical time since start: ${util.getElapsedLogicalTime()}`) + interval = interval.add(incr) + actions.a.schedule(interval, null) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/TestCount.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/TestCount.lf new file mode 100644 index 000000000..646259730 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/TestCount.lf @@ -0,0 +1,25 @@ +target TypeScript + +reactor TestCount(start: number = 0, stride: number = 1, numInputs: number = 1) { + state count: number = start + state inputsReceived: number = 0 + input x: number + + reaction(x) {= + console.log(`Received ${x}`) + if (x != count) { + console.error(`ERROR: Expected ${count}.`) + process.exit(1) + } + count += stride; + inputsReceived++ + =} + + reaction(shutdown) {= + console.log("Shutdown invoked.") + if (inputsReceived != numInputs) { + console.error(`ERROR: Expected to receive ${numInputs}, but got ${inputsReceived}.`) + process.exit(2) + } + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/TimeElapsed.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/TimeElapsed.lf new file mode 100644 index 000000000..9032cac53 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/TimeElapsed.lf @@ -0,0 +1,9 @@ +target TypeScript + +main reactor TimeElapsed { + timer t(0, 1 s) + + reaction(t) {= + console.log(`Elapsed logical time is ${util.getElapsedLogicalTime()}`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/TimeLag.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/TimeLag.lf new file mode 100644 index 000000000..e1d5cdd1a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/TimeLag.lf @@ -0,0 +1,11 @@ +target TypeScript + +main reactor TimeLag { + timer t(0, 1 s) + + reaction(t) {= + const t = util.getElapsedLogicalTime() + const T = util.getElapsedPhysicalTime() + console.log(`Elapsed logical time: ${t}, physical time: ${T}, lag: ${T.subtract(t)}`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Timer.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Timer.lf new file mode 100644 index 000000000..59d9bc21a --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Timer.lf @@ -0,0 +1,9 @@ +target TypeScript + +main reactor Timer { + timer t(0, 1 sec) + + reaction(t) {= + console.log(`Logical time is ${util.getCurrentLogicalTime()}.`) + =} +} diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/Triggering.lf b/versioned_docs/version-0.8.0/assets/code/ts/src/Triggering.lf new file mode 100644 index 000000000..f955a1f87 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/Triggering.lf @@ -0,0 +1,13 @@ +target TypeScript +reactor Inside { + input x: number + reaction(x) {= + console.log("Received ${x}"); + =} +} +main reactor { + i = new Inside() + reaction(startup) -> i.x {= + i.x = 42 + =} +} \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/assets/code/ts/src/tsconfig.json b/versioned_docs/version-0.8.0/assets/code/ts/src/tsconfig.json new file mode 100644 index 000000000..20f8e5e45 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/code/ts/src/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "skipLibCheck": true, + "allowJs": true, + "noEmit": true, + "target": "esnext", + "esModuleInterop": true, + "isolatedModules": true, + "lib": ["esnext", "dom"], + "sourceMap": true, + "strict": true, + "moduleResolution": "node", + "strictBindCallApply": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + }, + "include": [ + "src/**/*", + ] +} diff --git a/versioned_docs/version-0.8.0/assets/images/ExternalToolsConfiguration.png b/versioned_docs/version-0.8.0/assets/images/ExternalToolsConfiguration.png new file mode 100644 index 000000000..c22e2f21e Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/ExternalToolsConfiguration.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/Lingua_Franca.png b/versioned_docs/version-0.8.0/assets/images/Lingua_Franca.png new file mode 100644 index 000000000..108a2c662 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/Lingua_Franca.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/debugging/cmake-debug.png b/versioned_docs/version-0.8.0/assets/images/debugging/cmake-debug.png new file mode 100644 index 000000000..39d94eee4 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/debugging/cmake-debug.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/debugging/cmake-tools.png b/versioned_docs/version-0.8.0/assets/images/debugging/cmake-tools.png new file mode 100644 index 000000000..b1c6baaa7 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/debugging/cmake-tools.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/debugging/wrong-debug.png b/versioned_docs/version-0.8.0/assets/images/debugging/wrong-debug.png new file mode 100644 index 000000000..e08e0f6f9 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/debugging/wrong-debug.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableDesugared.png b/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableDesugared.png new file mode 100644 index 000000000..86ddc9129 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableDesugared.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableNaiveDesugared.png b/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableNaiveDesugared.png new file mode 100644 index 000000000..44e10dec2 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/diagrams/AddressableNaiveDesugared.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Asynchronous.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Asynchronous.svg new file mode 100644 index 000000000..94b948068 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Asynchronous.svg @@ -0,0 +1,99 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 9, 2022 at 5:42:00 PM Pacific Daylight Time + + + + + + + + + + + + Asynchronous + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + P + + + min delay: 100 msec + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/BankToBankMultiport.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/BankToBankMultiport.svg new file mode 100644 index 000000000..d237deff4 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/BankToBankMultiport.svg @@ -0,0 +1,200 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 1:32:34 PM Pacific Daylight Time + + + + + + + + + + + + Multiport + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Source + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + + + out[4] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Destination + + + + + + + + + + + + + + + + + + 4 + + + in[4] + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/ChildBank.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/ChildBank.svg new file mode 100644 index 000000000..cba5b05c1 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/ChildBank.svg @@ -0,0 +1,109 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 11:29:37 AM Pacific Daylight Time + + + + + + + + + + + + ChildBank + + + + + + + + + + + + + + + + + + + + + + + Parent + + + + + + + + + + + + + + + + + + + + + + + Child + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + 2 + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/ChildParentBank2.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/ChildParentBank2.svg new file mode 100644 index 000000000..a25d5be52 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/ChildParentBank2.svg @@ -0,0 +1,142 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 11:41:56 AM Pacific Daylight Time + + + + + + + + + + + + ChildParentBank2 + + + + + + + + + + + + + + + + + + + + + + + Parent + + + + + + + + + + + + + + + + + + + + + + + Child + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + out + + + + + + + + + + + + + + + + + + 2 + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Contained.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Contained.svg new file mode 100644 index 000000000..4acd639a9 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Contained.svg @@ -0,0 +1,165 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Tuesday, March 29, 2022 at 4:36:03 PM Pacific Daylight Time + + + + + + + + + + + + Contained + + + + + + + + + + + + + s : Overwriting + + + + + + + + + + + + + + + + + + (100 msec, 100 msec) + + + + + + + + + + + + + + + + + + (200 msec, 200 msec) + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Cycle.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Cycle.svg new file mode 100644 index 000000000..271c7fc9c --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Cycle.svg @@ -0,0 +1,244 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 1:46:50 PM Pacific Daylight Time + + + + + + + + + + + + + + + + Reactor contains cyclic dependencies! + + + + + + + + Show Cycle + + + + + + + + Filter Cycle + + + + + + + + + + + + + Cycle + + + + + + + + + + + + + A + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + B + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/CycleReordered.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/CycleReordered.svg new file mode 100644 index 000000000..0476ea0bf --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/CycleReordered.svg @@ -0,0 +1,191 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 1:59:04 PM Pacific Daylight Time + + + + + + + + + + + + CycleReordered + + + + + + + + + + + + + A + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + B + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/CycleWithDelay.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/CycleWithDelay.svg new file mode 100644 index 000000000..07aa4f3d0 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/CycleWithDelay.svg @@ -0,0 +1,214 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 1:54:07 PM Pacific Daylight Time + + + + + + + + + + + + CycleWithDelay + + + + + + + + + + + + + A + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + B + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/DeadlineTest.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/DeadlineTest.svg new file mode 100644 index 000000000..0f1744bf5 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/DeadlineTest.svg @@ -0,0 +1,216 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 10:03:56 AM Pacific Daylight Time + + + + + + + + + + + + DeadlineTest + + + + + + + + + + + + + + + + + + + + + + + Deadline + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10 msec + + + + + + + + + + + + + x + + + + + + + + + + + + + d + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + L + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Extends.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Extends.svg new file mode 100644 index 000000000..183f31e63 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Extends.svg @@ -0,0 +1,219 @@ + + + + + + Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 2, 2022 at 6:03:55 PM Pacific Daylight Time + + + + + + + + + + + + + + A + + + + + + + + + + + + + + + + + + + + + + + + a + + + + + + + + + + + + + + out + + + + + + + + + + + + + + + + + + + + + + + + B + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + b + + + + + + + + + + + + + + a + + + + + + + + + + + + + + out + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Hierarchy.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Hierarchy.svg new file mode 100644 index 000000000..d0f2f36de --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Hierarchy.svg @@ -0,0 +1,268 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Tuesday, March 29, 2022 at 10:10:43 AM Pacific Daylight Time + + + + + + + + + + + + Hierarchy + + + + + + + + + + + + + t : TestCount + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + c : Container + + + + + + + + + + + + + s : Scale + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + c : Count + + + + + + + + + + + + + + + + + + (0, 100 msec) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + y + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Interleaved.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Interleaved.svg new file mode 100644 index 000000000..d7c450cce --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Interleaved.svg @@ -0,0 +1,160 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 1:10:16 PM Pacific Daylight Time + + + + + + + + + + + + Interleaved + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Node + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + 4 + + + in[4] + + + + + + + + + + + + + out[4] + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Microsteps.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Microsteps.svg new file mode 100644 index 000000000..4273f53df --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Microsteps.svg @@ -0,0 +1,75 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 9:19:33 AM Pacific Daylight Time + + + + + + + + + + + + Microsteps + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + L + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Multicast.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Multicast.svg new file mode 100644 index 000000000..fcd42b5a5 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Multicast.svg @@ -0,0 +1,130 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 2, 2022 at 5:45:26 PM Pacific Daylight Time + + + + + + + + + + + + Multicast1 + + + + + + + + + + + + + a : A + + + y + + + + + + + + + + + + + + + + + + + + + + + b2 : B + + + + + + + + + + + + + x + + + + + + + + + + + + + b1 : B + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Multiport.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Multiport.svg new file mode 100644 index 000000000..ef6022ec7 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Multiport.svg @@ -0,0 +1,134 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 11:08:08 AM Pacific Daylight Time + + + + + + + + + + + + Multiport + + + + + + + + + + + + + Source + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + out[4] + + + + + + + + + + + + + + + + + + + + + + + Destination + + + + + + + + + + + + + + + + + + in[4] + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/MultiportToBank.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/MultiportToBank.svg new file mode 100644 index 000000000..69cbd71d1 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/MultiportToBank.svg @@ -0,0 +1,157 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 11:48:50 AM Pacific Daylight Time + + + + + + + + + + + + MultiportToBank + + + + + + + + + + + + + Source + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + out[3] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Destination + + + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + in + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Physical.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Physical.svg new file mode 100644 index 000000000..d5f727a60 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Physical.svg @@ -0,0 +1,103 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 9, 2022 at 4:44:58 PM Pacific Daylight Time + + + + + + + + + + + + + + + + Physical + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + P + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalConnection.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalConnection.svg new file mode 100644 index 000000000..eb64da41e --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalConnection.svg @@ -0,0 +1,104 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 2, 2022 at 5:07:16 PM Pacific Daylight Time + + + + + + + + + + + + PhysicalConnection + + + + + + + + + + + + + b : B + + + + + + + + + + + + + x + + + + + + + + + + + + + a : A + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalTest.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalTest.svg new file mode 100644 index 000000000..211a1d400 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/PhysicalTest.svg @@ -0,0 +1,150 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 8:15:55 AM Pacific Daylight Time + + + + + + + + + + + + PhysicalTest + + + + + + + + + + + + + Physical + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + P + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + + + + + + (200 msec, 200 msec) + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/RegressionTest.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/RegressionTest.svg new file mode 100644 index 000000000..d0e52be69 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/RegressionTest.svg @@ -0,0 +1,237 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, March 27, 2022 at 4:32:52 PM Pacific Daylight Time + + + + + + + + + + + + RegressionTest + + + + + + + + + + + + + t : TestCount + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + s : Scale + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + c : Count + + + + + + + + + + + + + + + + + + (0, 100 msec) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + y + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Schedule.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Schedule.svg new file mode 100644 index 000000000..0586f34f3 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Schedule.svg @@ -0,0 +1,103 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Saturday, April 9, 2022 at 3:59:14 PM Pacific Daylight Time + + + + + + + + + + + + + + + + Schedule + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + L + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + + + diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/ScheduleDiagram.png b/versioned_docs/version-0.8.0/assets/images/diagrams/ScheduleDiagram.png new file mode 100644 index 000000000..206e1e540 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/diagrams/ScheduleDiagram.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/diagrams/Simultaneous.svg b/versioned_docs/version-0.8.0/assets/images/diagrams/Simultaneous.svg new file mode 100644 index 000000000..4878f6704 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/diagrams/Simultaneous.svg @@ -0,0 +1,165 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Sunday, April 10, 2022 at 9:31:53 AM Pacific Daylight Time + + + + + + + + + + + + Simultaneous + + + + + + + + + + + + + + + + + + + + + + + Destination + + + + + + + + + + + + + + + + + + + + + + + y + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + L + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/footer_logo.svg b/versioned_docs/version-0.8.0/assets/images/footer_logo.svg new file mode 100644 index 000000000..817d25977 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/footer_logo.svg @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/header_logo.svg b/versioned_docs/version-0.8.0/assets/images/header_logo.svg new file mode 100644 index 000000000..bd72f23d4 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/header_logo.svg @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/debugger_screen.png b/versioned_docs/version-0.8.0/assets/images/intellij/debugger_screen.png new file mode 100644 index 000000000..0c8483da2 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/debugger_screen.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/expand_gradle_tab.png b/versioned_docs/version-0.8.0/assets/images/intellij/expand_gradle_tab.png new file mode 100644 index 000000000..525660873 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/expand_gradle_tab.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/gradle_import.png b/versioned_docs/version-0.8.0/assets/images/intellij/gradle_import.png new file mode 100644 index 000000000..43349b0e6 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/gradle_import.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/modify_run_config.png b/versioned_docs/version-0.8.0/assets/images/intellij/modify_run_config.png new file mode 100644 index 000000000..448728620 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/modify_run_config.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/new_runlfc_config.png b/versioned_docs/version-0.8.0/assets/images/intellij/new_runlfc_config.png new file mode 100644 index 000000000..788b0daad Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/new_runlfc_config.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/run_config_language_server.png b/versioned_docs/version-0.8.0/assets/images/intellij/run_config_language_server.png new file mode 100644 index 000000000..e3b456c9c Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/run_config_language_server.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/run_config_lf_program.png b/versioned_docs/version-0.8.0/assets/images/intellij/run_config_lf_program.png new file mode 100644 index 000000000..2400a0187 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/run_config_lf_program.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/run_debug_buttons.png b/versioned_docs/version-0.8.0/assets/images/intellij/run_debug_buttons.png new file mode 100644 index 000000000..3b26c588a Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/run_debug_buttons.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/skip_maven_build.png b/versioned_docs/version-0.8.0/assets/images/intellij/skip_maven_build.png new file mode 100644 index 000000000..878f7c4ae Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/skip_maven_build.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/intellij/trust_gradle_project.png b/versioned_docs/version-0.8.0/assets/images/intellij/trust_gradle_project.png new file mode 100644 index 000000000..1c196f036 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/intellij/trust_gradle_project.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/modal_models/local_time.svg b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time.svg new file mode 100644 index 000000000..6f9c403fd --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time.svg @@ -0,0 +1,743 @@ + + + + + + Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Monday, March 21, 2022 at 5:38:14 PM Central European Standard Time + + + TimingExample + + + Modal + + + One + + + 2 + + + L + min delay: 500 msec + + + + (100 msec, 750 msec) + + + T1 + + + 1 + + + 3 + + + out + + + next + + + + + + + + + Two + + + T2 + + + + (100 msec, 750 msec) + + + 6 + + + L + min delay: 500 msec + + + 5 + + + 4 + + + next + + + out + + + + + + + + + + + + + + + + + + next + + + out + + + + (1 sec, 1 sec) + + + T + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_plot.svg b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_plot.svg new file mode 100644 index 000000000..d013afbea --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_plot.svg @@ -0,0 +1,993 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gnuplot + Produced by GNUPLOT 5.2 patchlevel 8 + + + + + + + + 0 + + 500 + 850 + + 1000 + + 1500 + + 2000 + + 2500 + + 3000 + + 3500 + + 4000 + One + One + Two + Two + + 0 + + 500 + + 1000 + + 1500 + + 2000 + + 2500 + + 3000 + + 3500 + + 4000 + + + + + + + + + + + + + + + + + + + + + + + + Localized Time (msec) + Global Time (msec) + Mode + Timing Example (T) + + One (T1) + + Two (T2) + + + + + + Gnuplot + + + + + 100 + + 1600 + + + + + + + Leave One + Leave Two + ContinueOne + + Leave One + + Start Two + + + Reset Two + + diff --git a/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_trace.svg b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_trace.svg new file mode 100644 index 000000000..17efb8ddd --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/modal_models/local_time_trace.svg @@ -0,0 +1,2998 @@ + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +01000100 +logicaltime(msec) + + + + + +600 850 + + + +T1outmodeOne + + + + + + + + + + + + + + + + + + + + +1100200016001850260023503000OneTwoTwo1outout2T1action suspends1Taction is discardedtimer restarts withinitial offsettimer resumesremainingperiod time3LL2LLT11LT245T24T6T3LLL3100400036003850T245T24T6LLLaction resumesaction suspendsout diff --git a/versioned_docs/version-0.8.0/assets/images/oomph/product_selection.png b/versioned_docs/version-0.8.0/assets/images/oomph/product_selection.png new file mode 100644 index 000000000..05cc0fdb1 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/oomph/product_selection.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/oomph/project_configuration.png b/versioned_docs/version-0.8.0/assets/images/oomph/project_configuration.png new file mode 100644 index 000000000..52a107fd8 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/oomph/project_configuration.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/oomph/project_selection.png b/versioned_docs/version-0.8.0/assets/images/oomph/project_selection.png new file mode 100644 index 000000000..eed09360b Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/oomph/project_selection.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/oomph/run_configurations.png b/versioned_docs/version-0.8.0/assets/images/oomph/run_configurations.png new file mode 100644 index 000000000..813b824a8 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/oomph/run_configurations.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/oomph/simple_view.png b/versioned_docs/version-0.8.0/assets/images/oomph/simple_view.png new file mode 100644 index 000000000..ce409ab9f Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/oomph/simple_view.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/remote-ssh/helloworld.png b/versioned_docs/version-0.8.0/assets/images/remote-ssh/helloworld.png new file mode 100644 index 000000000..b81431861 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/remote-ssh/helloworld.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/remote-ssh/remote-status-bar.png b/versioned_docs/version-0.8.0/assets/images/remote-ssh/remote-status-bar.png new file mode 100644 index 000000000..4f4faa53c Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/remote-ssh/remote-status-bar.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/remote-ssh/ssh-status-bar.png b/versioned_docs/version-0.8.0/assets/images/remote-ssh/ssh-status-bar.png new file mode 100644 index 000000000..8d53b84cd Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/remote-ssh/ssh-status-bar.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/small_logo.svg b/versioned_docs/version-0.8.0/assets/images/small_logo.svg new file mode 100644 index 000000000..64b28fd19 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/small_logo.svg @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC.png b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC.png new file mode 100644 index 000000000..13656bcc1 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC2.png b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC2.png new file mode 100644 index 000000000..665d2560d Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC2.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC3.png b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC3.png new file mode 100644 index 000000000..1bb652133 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/ChromeTracingInC3.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.png b/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.png new file mode 100644 index 000000000..a0e794ad4 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.svg b/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.svg new file mode 100644 index 000000000..9e7b88b85 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/tracing/Feedback.svg @@ -0,0 +1,303 @@ + + + + +Creator: FreeHEP Graphics2D Driver Producer: de.cau.cs.kieler.klighd.piccolo.freehep.SemanticSVGGraphics2D Revision Source: Date: Friday, March 24, 2023 at 7:39:05 PM Central European Standard Time + + + + + + + + + + + + Feedback + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + f1 : Fed1 + + + + + + + + + + + + + + + + + + (10 msec) + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + + + + + + + + f2 : Fed2 + + + + + + + + + + + + + 1 + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + z + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + f3 : Fed3 + + + + + + + + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + y + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/Messages.png b/versioned_docs/version-0.8.0/assets/images/tracing/Messages.png new file mode 100644 index 000000000..811f70a08 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/Messages.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tracing/SDstartup.png b/versioned_docs/version-0.8.0/assets/images/tracing/SDstartup.png new file mode 100644 index 000000000..5d1f0b9b4 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tracing/SDstartup.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tutorial/contributor.png b/versioned_docs/version-0.8.0/assets/images/tutorial/contributor.png new file mode 100644 index 000000000..aace88df6 Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tutorial/contributor.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/tutorial/vm.png b/versioned_docs/version-0.8.0/assets/images/tutorial/vm.png new file mode 100644 index 000000000..48e82e40d Binary files /dev/null and b/versioned_docs/version-0.8.0/assets/images/tutorial/vm.png differ diff --git a/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-dark-mode.svg b/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-dark-mode.svg new file mode 100644 index 000000000..13766a5dc --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-dark-mode.svg @@ -0,0 +1,3 @@ + + + diff --git a/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-light-mode.svg b/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-light-mode.svg new file mode 100644 index 000000000..2b8c0d953 --- /dev/null +++ b/versioned_docs/version-0.8.0/assets/images/vs_code/diagram-icon-light-mode.svg @@ -0,0 +1,3 @@ + + + diff --git a/versioned_docs/version-0.8.0/developer/_category_.yml b/versioned_docs/version-0.8.0/developer/_category_.yml new file mode 100644 index 000000000..6c97c272b --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/_category_.yml @@ -0,0 +1,4 @@ +position: 50 +label: Developer +collapsible: true +collapsed: true \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/developer/contributing.mdx b/versioned_docs/version-0.8.0/developer/contributing.mdx new file mode 100644 index 000000000..278f03ccc --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/contributing.mdx @@ -0,0 +1,7 @@ +--- +title: Contributing +description: Contribute to Lingua Franca. +--- + +The preferred way to contribute to Lingua Franca is to issue pull requests through [GitHub](https://github.com/lf-lang/lingua-franca). +See the [Contributing](https://github.com/lf-lang/lingua-franca/blob/master/CONTRIBUTING.md) document for more details. diff --git a/versioned_docs/version-0.8.0/developer/debugging-generated-code.mdx b/versioned_docs/version-0.8.0/developer/debugging-generated-code.mdx new file mode 100644 index 000000000..2d6d8ec8b --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/debugging-generated-code.mdx @@ -0,0 +1,63 @@ +--- +title: Debugging Generated Code +description: Using VS Code to debug generated code. +--- + +## Prerequisites + +This page assumes you are using Visual Studio Code (VS Code). +Lingua Franca files are compiled using CMake, so you should install Microsoft's +[CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). +The instructions here will work with the C, Cpp, and CCpp targets. +They may work with other targets as well, but will probably require additional VS Code extensions. + +## Getting Started + +When you run `lfc` to compile a Lingua Franca program, the generated code goes into a directory +called `src-gen` that will be created next to the `src` directory that contains your `.lf` files +(see [Structure of an LF project](<../writing-reactors/a-first-reactor.mdx#structure-of-an-lf-project>)). +You can directly edit, compile, run, and debug the generated code using VS Code. +To do this, start VS Code in the directory where the generated code is. +For example, if your program is `src/Foo.lf`, the following steps will get you into the generated code: + +``` + lfc src/Foo.lf + cd src-gen/Foo + code . +``` + +The structure of the generated code depends on the target you are using, but in all cases, the project includes +everything needed to build and run the code. +You can use VS Code's convenient Search functionality to find your reaction bodies and set breakpoints. +You can also modify the code directly and recompile it using CMake, but be careful to save any changes that you +want to preserve somewhere else because the next time you run `lfc`, the `src-gen` directory will be overwritten. + +## Running and Debugging Generated Code + +First note that you have to ignore the built-in VS Code run and debug menu items, which are not designed to work with CMake. +That is, ignore the following menu items: + +![Wrong debug menu items](./../assets/images/debugging/wrong-debug.png) + +If you have installed the CMake Tools extension, then you should see its icon in the left sidebar, +as shown at the lower left here: + +![CMake tools sidebar icon](./../assets/images/debugging/cmake-tools.png) + +In the Configure menu, select the compiler to use. +Above the selection is Clang for an Apple silicon Mac. +Then, instead of using the menu items to build, run, and debug, +use the buttons at the _bottom_ of the screen, which look like this: + +![CMake tools build, run, and debug buttons](./../assets/images/debugging/cmake-debug.png) + +The Build button will compile the code. +To the right of that button are buttons for debugging and running the code. + +## Debugging Federated Programs + +For federated programs, the layout of the generated files is a bit different. +If, for example, your federated program is in `src/Foo.lf` and it has a top-level reactor named `bar`, +then you will find the generated code for the `bar` federate in `fed-gen/Foo/src-gen/federate__bar`. +You can then run and debug that individual federate from within VS Code, but you will also have +to manually run the RTI and the other federates in order for the code to start executing. diff --git a/versioned_docs/version-0.8.0/developer/developer-eclipse-setup-with-oomph.mdx b/versioned_docs/version-0.8.0/developer/developer-eclipse-setup-with-oomph.mdx new file mode 100644 index 000000000..d88abcb2c --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/developer-eclipse-setup-with-oomph.mdx @@ -0,0 +1,131 @@ +--- +title: Developer Eclipse Setup +description: Developer Eclipse setup with Oomph. +--- + +:::warning +Eclipse does not currently support Kotlin, the language used for some of the target code generators. If you plan to develop Kotlin code, we recommend using [IntelliJ](../developer/developer-intellij-setup.mdx) instead of Eclipse. +::: + +## Prerequisites + +- Java 17 ([download from Oracle](https://www.oracle.com/java/technologies/downloads/)) +- Each target language may have additional requirements. See the [Target Language Details](<../reference/target-language-details.mdx#requirements>) page and select your target language. + +## Oomph Setup + +The Eclipse setup with Oomph allows to automatically create a fully configured Eclipse IDE for the development of Lingua Franca. Note that we recommend installing a new instance of Eclipse even if you already have one for other purposes. There is no problem having multiple Eclipse installations on the same machine, and separate installations help prevent cross-project problems. + +1. If you have previously installed Eclipse and you want to start fresh, then remove or move a hidden directory called `.p2` in your home directory. I do this: + +```sh +mv ~/.p2 ~/.p2.bak +``` + +2. Go to the [Eclipse download site](https://www.eclipse.org/downloads/index.php) (https://www.eclipse.org/downloads/index.php) and download the Eclipse Installer for your platform. The site does not advertise that it ships the Oomph Eclipse Installer but downloading Eclipse with the orange download button will give you the installer.\ + **You can skip this step if you already have the installer available on your system.** + +3. Starting the installer for the first time will open a window that looks like the following (**if you have previously followed these steps, skip to step 4**):\ + ![](./../assets/images/oomph/simple_view.png) + +4. Click the Hamburger button at the top right corner and switch to "Advanced Mode". + +5. Oomph now wants you to select the base Eclipse distribution for your development. We recommend to use "Eclipse IDE for Java and DSL Developers". As product version we recommend to use "Latest Release (...)". \ + **Important**: Lingua Franca tools require Java 17. Under Java VM, please select Java 17.\ + Then press Next to continue with the project section.\ + ![](./../assets/images/oomph/product_selection.png) + +6. Next, we need to register the Lingua Franca specific setup in Oomph **(only the first time you use the installer)**. Click the green Plus button at the top right corner. Select "GitHub Projects" as catalog and paste the following URL into the "Resource URI" field: + `https://raw.githubusercontent.com/icyphy/lingua-franca/master/oomph/LinguaFranca.setup`. + Then press OK. + NOTE: to check out another branch instead, adjust the URL above accordingly. For instance, in order to install the setup from `foo-bar` branch, change the URL to `https://raw.githubusercontent.com/icyphy/lingua-franca/foo-bar/oomph/LinguaFranca.setup`. Also, in the subsequent screen in the wizard, select the particular branch of interest instead of default, which is `master`. + +7. Now Oomph lists the Lingua Franca setup in the "\" directory of the "GitHub Projects" catalog. Check the Lingua Franca entry. A new entry for Lingua Franca will appear in the table at the bottom of the window. Select Lingua Franca and click Next.\ + ![](./../assets/images/oomph/project_selection.png) + +8. Now you can further configure where and how your development Eclipse should be created. Check "Show all variables" to enable all possible configuration options. You can hover over the field labels to get a more detailed explanation of their effects. + +- If you already have cloned the LF repository and you want Eclipse to use this location instead of cloning it into the new IDE environment, you should adjust the "Git clone location rule". +- Preferably, you have a GitHub account with an SSH key uploaded to GitHub. Otherwise, you should adjust the "Lingua Franca GitHub repository" entry to use the https option in the drop-down menu. See [adding an SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account). +- If the "JRE 17 location" is empty, you need to install and/or locate a JDK that has at least version 17. + ![](./../assets/images/oomph/project_configuration.png) + +9. Click Next to get a summary of what will happen during installation. Click Finish to start. + +10. Once the basic installation is complete, your new Eclipse will start. If it fails to clone the GitHub repository, then you should use the back button in the Oomph dialog and change the way you are accessing the repo (ssh or https). See above. \ + The setup may also fail to clone the repository via SHH if Eclipse cannot find the private ssh key that matches the public key you uploaded to GitHub. You can configure the location of your private key in Eclipse as follows. In the Eclipse IDE, click the menu entry Window -> Preferences (on Mac Apple-Menu -> Preferences) and navigate to General -> Network Connections -> SSH2 in the tree view on the left and configure the SSH home directory and key names according to your computer. After the repo has been cloned, you can safely close the initial Oomph dialog (if not dismissed automatically). You will see a Welcome page that you can close. + +11. In the new Eclipse, it may automatically start building the project, or it may pop up an "Eclipse Updater" dialog. If neither happens, you can click the button with the yellow and blue cycling arrows in the status bar at the bottom. Oomph will perform various operations to configure the Eclipse environment, including the initial code generation for the LF language. This may take some time. Wait until the setup is finished. + +12. If you get compile errors, make sure Eclipse is using Java 17. If you skipped the first step above (removing your `~/.p2` directory), then you may have legacy configuration information that causes Eclipse to mysteriously use an earlier version of Java. Lingua Franca requires Java 17, and will get compiler errors if it uses an earlier version. To fix this, go to the menu `Project->Properties` and select `Java Build Path`. Remove the entry for `JRE System Library [JRE for JavaSE-8]` (or similar). Choose `Add Library` on the right, and choose `JRE System Library`. You should now be able to choose `Workspace default JRE (JRE for JavaSE-17)`. A resulting rebuild should then compile correctly. + +13. When the setup dialog is closed, your LF development IDE is ready. Probably, Eclipse is still compiling some code but when this is finished as well, all error markers on the project should have disappeared. Now, you can start a runtime Eclipse to test the actual Lingua Franca end-user IDE. In the toolbar, click on the small arrow next to the green Start button. There may already be an entry named "Launch Runtime Eclipse", but probably not. To create it, click on "Run Configurations...". Expand the "Eclipse Application" entry, select "Launch Runtime Eclipse", as follows: + +![](./../assets/images/oomph/run_configurations.png) + +Make sure that the Execution Environment shows a version of Java that is at least Java 17. The click on "Run" at the bottom. + +14. A new Eclipse starts where you can write LF programs and also get a diagram representation (but you fist need to open the diagram view by clicking on Window -> Show View -> Other and selecting Diagram in the "KIELER Lightweight Diagrams" folder). You can close the welcome window in the new Eclipse and proceed to creating a new project, as below. + +### Using the Lingua Franca IDE + +Start the Lingua Franca IDE, create a project, and create your first LF program: + +- Select File->New->Project (a General Project is adequate). +- Give the project a name, like "test". +- You may want to uncheck `Use default location` and specify a location that you can remember. +- Close the Eclipse welcome window, if it is open. It obscures the project. +- Right click on the project name and select New->File. +- Give the new a name like "HelloWorld.lf" (with .lf extension). +- **IMPORTANT:** A dialog appears: Do you want to convert 'test' to an Xtext Project? Say YES. +- Start typing in Lingua-Franca! Try this: + +```lf + target C; + main reactor HelloWorld { + timer t; + reaction(t) {= + printf("Hello World.\n"); + =} + } +``` + +When you save, generated code goes into your project directory, e.g. `/Users/yourname/test`. That directory now has two directories inside it, `src-gen` and `bin`. The first contains the generated C code and the second contains the resulting executable program. Run the program: + +```sh + cd ~/lingua-franca-master/runtime-EclipseXtext/test + bin/HelloWorld +``` + +The above directory assumes you chose default locations for everything. This should produce output that looks something like this: + +``` +---- Start execution at time Sun Mar 28 10:19:24 2021 +---- plus 769212000 nanoseconds. +Hello World. +---- Elapsed logical time (in nsec): 0 +---- Elapsed physical time (in nsec): 562,000 +``` + +This should print "Hello World". + +We strongly recommend browsing the system tests, which provide a concise overview of the capabilities of Lingua Franca. You can set up a project in the IDE for this using [these instructions](<../developer/regression-tests.mdx#browsing-and-editing-examples-in-the-lf-ide>). + +## Working on the Lingua-Franca Compiler + +The source code for the compiler is in the package `org.icyphy.linguafranca`. + +- The grammar is in `src/org.icyphy/LinguaFranca.xtext` +- The code generator for the C target is in `src/org.icyphy.generator/CGenerator.xtend` +- The code generator for the TypeScript target is in `src/org.icyphy.generator/TypeScriptGenerator.xtend` +- The code generator for the C++ target is in `src/org.icyphy.generator/CppGenerator.xtend` +- The code generator for the Python target is in `src/org.icyphy.generator/PythonGenerator.xtend` + +## Troubleshooting + +- GitHub uses port `443` for its ssh connections. In some systems, the default expected port by `git` can be 22, causing a timeout when cloning the repo. This can be fixed by adding the following to `~/.ssh/config`: + ``` + Host github.com + Hostname ssh.github.com + Port 443 + ``` diff --git a/versioned_docs/version-0.8.0/developer/developer-intellij-setup.mdx b/versioned_docs/version-0.8.0/developer/developer-intellij-setup.mdx new file mode 100644 index 000000000..397c710c9 --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/developer-intellij-setup.mdx @@ -0,0 +1,90 @@ +--- +title: Developer IntelliJ Setup +description: Developer IntelliJ Setup. +--- + +## Prerequisites + +- Java 17 ([download from Oracle](https://www.oracle.com/java/technologies/downloads/)) +- IntelliJ IDEA Community Edition ([download from Jetbrains](https://www.jetbrains.com/idea/download/)) + +## Cloning lingua-franca repository + +If you have not done so already, clone the lingua-franca repository into your working directory. + +```sh +git clone git@github.com:lf-lang/lingua-franca.git lingua-franca +cd lingua-franca +git submodule update --init --recursive +``` + +## Opening lingua-franca as IntelliJ Project + +To import the Lingua Franca repository as a project, simply run `./gradlew openIdea`. +This will create some project files and then open the project in IntelliJ. + +When you open the project for the first time, you will see a small pop-up in the lower right corner. + +![](./../assets/images/intellij/gradle_import.png) + +Click on Load Gradle Project to import the Gradle configurations. + +If you are prompted to a pop-up window asking if you trust the Gradle project, click Trust Project. + +![](./../assets/images/intellij/trust_gradle_project.png) + +Once the repository is imported as a Gradle project, you will see a Gradle tab on the right. + +Once the indexing finishes, you can expand the Gradle project and see the set of Tasks. + +![](./../assets/images/intellij/expand_gradle_tab.png) + +You can run any Gradle command from IntelliJ simply by clicking on the Execute Gradle Task icon in the Gradle tab. You are then prompted for the precise command to run. + +## Setting up run configurations + +You can set up a run configuration for running and debugging various Gradle tasks from the Gradle tab, including the code generation through `lfc`. +To set up a run configuration for the run task of `lfc`, expand the application task group under org.lflang \> Tasks, right-click on ⚙️ run, and select Modify Run Configuration.... +This will create a custom run/debug configuration for you. + +In the Create Run Configuration dialog, click on the text box next to Run, select `cli:lfc:run` from the drop-down menu, and append arguments to be passed to `lfc` using the `--args` flag. For instance, to invoke `lfc` on `test/Cpp/src/HelloWorld.lf`, enter `cli:lfc:run --args 'test/Cpp/src/HelloWorld.lf'` Then click OK. + +![](./../assets/images/intellij/run_config_lf_program.png) + +You will see a new run/debug config added to the top-level menu bar, as shown below. +You can always change the config, for example, changing the `--args`, by clicking Edit Configurations via a drop-down menu. + +![](./../assets/images/intellij/new_runlfc_config.png) + +## Running and Debugging + +Using the newly added config, you can run and debug the code generator by clicking the play button and the debug button. + +![](./../assets/images/intellij/run_debug_buttons.png) + +Set up breakpoints before starting the debugger by clicking the space right next to the line numbers. +While debugging, you can run code step-by-step by using the debugger tools. + +![](./../assets/images/intellij/debugger_screen.png) + +By clicking the play button, `lfc` will be invoked, and if compilation is successful, its output can be found, relative to package root of the file under compilation, in `bin` if the target is a compiled language (e.g., C) or in `src-gen` if the target is an interpreted language (e.g., TypeScript). For the `HelloWorld.lf` example above, the binary can be found in `test/Cpp/bin/HelloWorld` and can be executed in the terminal. + +## Starting and Debugging the Language Server + +There should a predefined run configuration called LanguageDiagramServer available, which executes the main method the `LanguageDiagramServer` class, which, as a result, starts the language server. + +![](./../assets/images/intellij/run_config_language_server.png) + +Per default it uses the port `7670`. This port should be the same as the port specified by the vscode-lingua-franca extension in its [launch configuration](https://github.com/lf-lang/vscode-lingua-franca/blob/38515b4aa0de68383a88a0d4daf56cdb8c5b9b4c/.vscode/launch.json#L25). + +After start-up it should output the following: + +``` +Connection to: localhost:7670 +Starting language server socket +Language Server Socket ready! +``` + +## Integration Tests + +You can also run the integration test from IntelliJ. You will find the targetTest and singleTest tasks in the Gradle tab under org.lflang \> Tasks \> other. Make sure to add a run configuration as shown above and append `-Ptarget=...'` to the `targetTest` command or `-DsingleTest=...` to your `singleTest` command to specify the target (e.g., `C`) or the specific test that you would like to run. diff --git a/versioned_docs/version-0.8.0/developer/downloading-and-building.mdx b/versioned_docs/version-0.8.0/developer/downloading-and-building.mdx new file mode 100644 index 000000000..4497f95a0 --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/downloading-and-building.mdx @@ -0,0 +1,59 @@ +--- +title: Building from Source Code +description: Instruction for downloading and building the Lingua Franca source code. +--- + +## Prerequisites + +- Java 17 ([download from Oracle](https://www.oracle.com/java/technologies/downloads/)) + +## Cloning the Repository + +Please run the following commands to clone the repository and its submodules. + +```sh +git clone git@github.com:lf-lang/lingua-franca.git +cd lingua-franca +git submodule update --init --recursive +``` + +Submodules are checked out over HTTPS by default. In case you want to commit to a submodule and use SSH instead, you can simply change the remote. For example, to change the remote of the `reactor-c` submodule, you can do this: + +```sh +cd core/src/main/resources/lib/c/reactor-c +git remote remove origin +git remote add origin git@github.com:lf-lang/reactor-c.git +``` + +## Building the command line tools + +We use [Gradle](https://docs.gradle.org/current/userguide/userguide.html) for building the code within our repository. + +For an easy start, the `bin/` directory contains scripts for building and running our command line tools, including the compiler lfc. +Try to run `./bin/lfc-dev --version`. +This will first build `lfc` and then execute it through Gradle. + +To build the entire repository, you can simply run `./gradlew build`. +This will build all tools and also run all formatting checks and unit tests. +Note that this does not run our integration tests. +For more details on our testing infrastructure, please refer to the [Regression Test](../developer/regression-tests.mdx) section. + +If you only want to build without running any tests, you can use `./gradlew assemble` instead. +Both the assemble and the build task will create a distribution package containing our command line tools in `build/distribution`. +There is also an installed version of this package in `build/install/lf-cli/`. +If you run `build/install/lf-cli/bin/lfc` this will run lfc as it was last build. +Thus, you can choose if you want to use `bin/lfc-dev`, which first builds `lfc` using the latest code and then runs it, or if you prefer to run `./gradlew build` and then separately invoke `build/install/lf-cli/bin/lfc`. + +## IDE Integration + +You can use any editor or IDE that you like to work with the code base. +However, we would suggest to choose an IDE that comes with good Java (and +ideally Kotlin) support and that integrates well with Gradle. +We recommend to use our [IntelliJ setup](../developer/developer-intellij-setup.mdx). + +## Building IDEs + +Currently, we provide two IDEs that support Lingua Franca programs. +Their source code is located in external repositories. +We have a [Lingua Franca extension](https://github.com/lf-lang/vscode-lingua-franca) for VS code and an Eclipse based IDE called [Epoch](https://github.com/lf-lang/epoch). +Please refer to the READMEs for build instructions. diff --git a/versioned_docs/version-0.8.0/developer/on-target-development.mdx b/versioned_docs/version-0.8.0/developer/on-target-development.mdx new file mode 100644 index 000000000..1f6679360 --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/on-target-development.mdx @@ -0,0 +1,75 @@ +--- +title: On-target Development +description: Using VS Code for "on-target" development. +--- + +# Develop Lingua Franca on Remote Targets +Microsoft Visual Studio Code can be used to connect to a remote target or a virtual machine, which provides a convenient way of developing Lingua Franca applications "on target". The steps here are an alternative to cross-compilation or installing local toolchains, as the tools run natively on a remote target or virtual machine. + +

+ +

+ +## Configure your Target + +You may [manually install Lingua Franca](./../installation), or, if you want to use a provisioning tool, see [xronos-inc/xronos_lfc_ansible](https://github.com/xronos-inc/xronos_lfc_ansible) for an Ansible script to install Lingua Franca tools on a remote target. + +If you would like to configure a virtual machine, see [xronos-inc/lfc-multipass](https://github.com/xronos-inc/lfc-multipass) for a cloud-init script to install Lingua Franca tools using multipass. + +Once you have your remote target, be it a virtual machine or a machine accessible over a network, you can connect to it using Visual Studio Code and the Remote SSH extension. + +## Install the Microsoft Remote-SSH extension + +Open VS Code, launch Quick Open (Ctrl + P) and enter: + +`ext install ms-vscode-remote.remote-ssh` + +After installation is complete you'll see the Remote SSH status bar icon: + +![remote status bar](./../assets/images/remote-ssh/remote-status-bar.png) + +## Connect VS Code to your remote system via SSH + +In VS Code, click on the "Remote SSH" status bar icon and select "Connect to Host..." then "Add New SSH Host". When prompted for the host, enter + +`ssh ubuntu@[remotehost]` + +where `remotehost` is the hostname or IP address of your remote target. + +A new VS Code window will open, and the address of your remote target should appear in the Remote SSH status bar: + +![remote status bar](./../assets/images/remote-ssh/ssh-status-bar.png) + +## Install the Lingua Franca VS Code extension + +open VS Code, launch Quick Open (Ctrl + P) and enter: + +`ext install lf-lang.vscode-lingua-franca` + +## Run the Hello World Application + +In VS Code, create the folder `helloworld` on your remote target, then create a file within that folder called `helloworld.lf` with the following contents: + +```lf-cpp +target Cpp + +main reactor { + reaction(startup) {= + std::cout << "Hello World." << std::endl; + =} +} +``` + +Similar hello world programs can be created for any of the supported target languages. + +Open `helloworld.lf`. You should see the visual rendering of the application on the right pane of Visual Studio. On remote targets with slow internet connections, or slower processors, this may take a few seconds for the first rendering. + +Build by pressing Ctrl + Shift + P followed by `Lingua Franca: Build and Run`. The program will be compiled and executed on your remote target with build output and terminal output visible within VS Code. + +![hello world example](./../assets/images/remote-ssh/helloworld.png) + +## References + +- [How to set up Lingua Franca](./../installation) +- [How to create a VSCode Linux remote environment](https://ubuntu.com/blog/how-to-create-a-vscode-linux-remote-environment) +- [Remote development over SSH](https://code.visualstudio.com/docs/remote/ssh-tutorial) \ No newline at end of file diff --git a/versioned_docs/version-0.8.0/developer/regression-tests.mdx b/versioned_docs/version-0.8.0/developer/regression-tests.mdx new file mode 100644 index 000000000..84e175146 --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/regression-tests.mdx @@ -0,0 +1,107 @@ +--- +title: Regression Tests +description: Regression Tests for Lingua Franca. +--- + +Lingua Franca comes with an extensive set of regression tests that are executed on various platforms automatically whenever an update is pushed to the LF repository. There are two categories of tests: + +- **Unit tests** are Java or Kotlin methods in our code base that are labeled with the `@Test` directive. These tests check individual functions of the code generation infrastructure. These are located in the `src/test` directory of each subroject within the repository. +- **Integration tests** are complete Lingua Franca programs that are compiled and executed automatically. A test passes if it successfully compiles and runs to completion with normal termination (return code 0). These tests are located in the `test` directory at the root of the LF repo, with one subdirectory per target language. +Their implementation can be found in the `core/src/integrationTest` directory. +The integration tests are also executed through JUnit using methods with `@Test` directives, but they are executed separately. + +## Running the Tests From the Command Line + +To run all unit tests, simply run `./gradlew test`. Note that also the normal build tasks `./gradlew build` runs all the unit tests. + + +The integration tests can be run using the `integrationTest` task. However, typically it is not desired to run all tests for all targets locally as it will need the right target tooling and will take a long time. + +To run only the integration tests for one target, we provide the `targetTest` gradle task. For instance, you can use the following command to run all Rust tests: +``` +./gradlew targetTest -Ptarget=Rust +``` +You can specify any valid target. If you run the task without specifying the target property `./gradlew targetTest` it will produce an error message and list all available targets. + + +The `targetTest` task is essentially a convenient shortcut for the following: +``` +./gradew core:integrationTest --test org.lflang.tests.runtime.Test.* +``` +If you prefer have more control over which tests are executed, you can also use this more verbose version. + +It is also possible to run a subset of the tests. For example, the C tests are organized into the following categories: + +* **generic** tests are `.lf` files located in `$LF/test/C/src`. +* **concurrent** tests are `.lf` files located in `$LF/test/C/src/concurrent`. +* **federated** tests are `.lf` files located in `$LF/test/C/src/federated`. +* **multiport** tests are `.lf` files located in `$LF/test/C/src/multiport`. + +To invoke only the C tests in the `concurrent` category, for example, run this: +``` +./gradlew core:integrationTest --tests org.lflang.tests.runtime.CTest.runConcurrentTests +``` + +Sometimes it is convenient to only run a single specific test case. This can be done with the `singleTest` task. For instance: +``` +./gradlew singleTest -DsingleTest=test/C/src/Minimal.lf +``` + +## Reporting Bugs + +If you encounter a bug or add some enhancement to Lingua Franca, then you should create a regression test either as a system test or a unit test and issue a pull request. System tests are particularly easy to create since they are simply Lingua Franca programs that either compile and execute successfully (the test passes) or fail either to compile or execute. + +## Testing Architecture + +System tests can be put in any subdirectory of `$LF/test` or `$LF/example`. +Any `.lf` file within these directories will be treated as a system test unless they are within a directory named `failing`, in which case they will be ignored. +The tests are automatically indexed by our JUnit-based test infrastructure, which is located in the package `core/src/integrationTest`. Each target has its own class in the `runtime` package, with a number of test methods that correspond to particular test categories, such as `generic`, `concurrent`, `federated`, etc. A test can be associated with a particular category by placing it in a directory that matches its name. For instance, we can create a test (e.g., `Foo.lf`) in `test/C/src/concurrent`, which will then get indexed under the target `C` in the category `concurrent`. Files placed directly in `test/C/src` will be considered `generic` `C` tests, and a file in a directory `concurrent/federated` will be indexed as `federated` (corresponding to the nearest containing directory). + +**Caution**: adding a _new_ category requires updating an enum in `TestRegistry.java` and adding a `@Test`-labeled method to `TestBase`. + +### Known Failures + +Sometimes it is useful to retain tests that have a known failure that should be addressed at a later point. Such tests can simply be put in a directory called `failing`, which will tell our test indexing code to exclude it. + +### Test Output + +Tests are grouped by target and category. It is also reported when, for a given category, there are other targets that feature tests that are missing for the target under test. Tests that either do not have a main reactor or are marked as known failures are reported as "ignored." For all the tests that were successfully indexed, it is reported how many passed. For each failing test, diagnostics are reported that should help explain the failure. Here is some sample output for `Ctest.runConcurrentTests`, which runs tests categorized as `concurrent` for the `C` target: + +``` +CTest > runConcurrentTests() STANDARD_OUT + ============================================================================== + Target: C + Description: Run concurrent tests. + ============================================================================== + + ============================================================================== + Category: CONCURRENT + ============================================================================== + ------------------------------------------------------------------------------ + Ignored: 0 + ------------------------------------------------------------------------------ + + ------------------------------------------------------------------------------ + Covered: 29/33 + ------------------------------------------------------------------------------ + Missing: src/concurrent/BankToBank.lf + Missing: src/concurrent/BankToBankMultiport.lf + Missing: src/concurrent/BankToBankMultiportAfter.lf + Missing: src/concurrent/BankToMultiport.lf + + ------------------------------------------------------------------------------ + Passing: 29/29 + ------------------------------------------------------------------------------ + +``` + +## Code Coverage + +Code coverage is automatically recorded when running tests. +A combined report for each subproject can be created by running `./gradlew jacocoTestReport`. +For the `core` subproject, the html report will be located in `build/reports/html/index.html`. +Note that this report will only reflect the coverage of the test that have actually executed. + +## Continuous Integration + +Each push or pull request will trigger all tests to be run on GitHub Actions. It's configuration can be found [here](https://github.com/lf-lang/lingua-franca/tree/master/.github/workflows). diff --git a/versioned_docs/version-0.8.0/developer/running-benchmarks.mdx b/versioned_docs/version-0.8.0/developer/running-benchmarks.mdx new file mode 100644 index 000000000..d43f2d97c --- /dev/null +++ b/versioned_docs/version-0.8.0/developer/running-benchmarks.mdx @@ -0,0 +1,251 @@ +--- +title: Running Benchmarks +description: Running Benchmarks. +--- + +# Running Benchmarks + +The LF repository contains a series of benchmarks in the `benchmark` directory. There is also a flexible benchmark runner that automates the process of running benchmarks for various settings and collecting results from those benchmarks. It is located in `benchmark/runner`. +The runner is written in python and is based on [hydra](https://hydra.cc/docs/intro), a tool for dynamically creating hierarchical configurations by composition + +## Prerequisites + +### Install Python dependencies + +The benchmark runner is written in Python and requires a working Python3 installation. It also requires a few python packages to be installed. Namely, `hydra-core`, `cogapp` and `pandas`. + +It is recommended to install the dependencies and execute the benchmark runner in a virtual environment. For instance, this can be done with `virtualenv`: + +```sh +virtualenv ~/virtualenvs/lfrunner -p python3 +source ~/virtualenvs/lfrunner/bin/activate +``` + +Then the dependencies can be installed by running: + +```sh +pip install -r benchmark/runner/requirements.txt +``` + +### Compile lfc + +For running LF benchmarks, the command-line compiler `lfc` needs to be built. Simply run + +```sh +bin/build-lfc +``` + +in the root directory of the LF repository. + +Also, the environment variable `LF_PATH` needs to be set and point to the location of the LF repository. This needs to be an absolute path. + +```sh +export LF_PATH=/path/to/lf +``` + +### Setup Savina + +Currently all of our benchmarks are ported from the [Savina actor benchmark suite](https://doi.org/10.1145/2687357.2687368). In order to compare our LF implementations with actor based implementation, the Savina benchmark suite needs to be downloaded and compiled. Note that we require a modified version of the Savina suite, that adds support for specifying the number of worker threads and that includes CAF implementations of most benchmarks. + +To download and build Savina, run the following commands: + +```sh +git clone https://github.com/lf-lang/savina.git +cd savina +mvn install +``` + +Building Savina requires a Java 8 JDK. Depending on the local setup, `JAVA_HOME` might need to be adjusted before running `mvn` in order to point to the correct JDK. + +```sh +export JAVA_HOME=/path/to/jdk8 +``` + +Before invoking the benchmark runner, the environment variable `SAVINA_PATH` needs to be set and point to the location of the Savina repository using an absolute path. + +```sh +export SAVINA_PATH=/path/to/savina +``` + +#### CAF + +To further build the CAF benchmarks, CAF 0.16.5 needs to be downloaded, compiled and installed first: + +```sh +git clone --branch "0.16.5" git@github.com:actor-framework/actor-framework.git +mkdir actor-framework/build && cd actor-framework/build +cmake -DCMAKE_INSTALL_PREFIX= .. +make install +``` + +Then, from within the Savina directory, the CAF benchmarks can be build: + +```sh +cmake -DCAF_ROOT_DIR= .. +make +``` + +The CAF benchmarks are used in these two publications: + +- ["Reducing Message Latency and CPU Utilization in the CAF Actor Framework"](https://www.researchgate.net/publication/322519252_Reducing_Message_Latency_and_CPU_Utilization_in_the_CAF_Actor_Framework) +- ["Improving the Performance of Actors on Multi-cores with Parallel Patterns"](https://link.springer.com/article/10.1007/s10766-020-00663-1) + +## Running a benchmark + +A benchmark can simply be run by specifying a benchmark and a target. For instance + +```sh +cd benchmark/runner +./run_benchmark.py benchmark=savina_micro_pingpong target=lf-c +``` + +runs the Ping Pong benchmark from the Savina suite using the C-target of LF. Currently, supported targets are `lf-c`, `lf-cpp`, `akka`, and `caf` where `akka` corresponds to the Akka implementation in the original Savina suite and `caf` corresponds to a implementation using the [C++ Actor Framework](https://www.actor-framework.org/) . + +The benchmarks can also be configured. The `threads` and `iterations` parameters apply to every benchmark and specify the number of worker threads as well as how many times the benchmark should be run. Most benchmarks allow additional parameters. For instance, the Ping Pong benchmark sends a configurable number of pings that be set via the `benchmark.params.messages` configuration key. Running the Akka version of the Ping Pong benchmark for 1000 messages, 1 thread and 12 iterations could be done like this: + +```sh +./run_benchmark.py benchmark=savina_micro_pingpong target=akka threads=1 iterations=12 benchmark.params.messages=1000 +``` + +Each benchmark run produces an output directory in the scheme `outputs//