-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1786 from lf-lang/stp-offset-parameter-test
Added test of documented STP_offset parameter
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
target C { | ||
timeout: 5 sec, | ||
coordination: decentralized | ||
} | ||
|
||
import Count from "../lib/Count.lf" | ||
|
||
/** | ||
* FIXME: inheritance not working! See issue #1733 import TestCount from | ||
* "../lib/TestCount.lf" | ||
* | ||
* reactor PrintTimer(STP_offset:time = 10 msec) extends TestCount { timer t(0, | ||
* 1 sec); reaction(t) {= lf_print("Timer ticked at (%lld, %d).", | ||
* lf_time_logical_elapsed(), lf_tag().microstep ); | ||
* =} } | ||
*/ | ||
reactor PrintTimer( | ||
STP_offset: time = 1 sec, | ||
start: int = 1, | ||
stride: int = 1, | ||
num_inputs: int = 6 | ||
) { | ||
state count: int = start | ||
state inputs_received: int = 0 | ||
input in: int | ||
|
||
timer t(0, 1 sec) | ||
|
||
reaction(in) {= | ||
lf_print("Received %d.", in->value); | ||
if (in->value != self->count) { | ||
lf_print_error_and_exit("Expected %d.", self->count); | ||
} | ||
self->count += self->stride; | ||
self->inputs_received++; | ||
=} | ||
|
||
reaction(shutdown) {= | ||
lf_print("Shutdown invoked."); | ||
if (self->inputs_received != self->num_inputs) { | ||
lf_print_error_and_exit("Expected to receive %d inputs, but got %d.", | ||
self->num_inputs, | ||
self->inputs_received | ||
); | ||
} | ||
=} | ||
|
||
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 | ||
} |