Skip to content

Commit

Permalink
Merge pull request #1786 from lf-lang/stp-offset-parameter-test
Browse files Browse the repository at this point in the history
Added test of documented STP_offset parameter
  • Loading branch information
lhstrh authored May 28, 2023
2 parents aa170d7 + 5719ab4 commit e835ee3
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/C/src/federated/STPParameter.lf
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
}

0 comments on commit e835ee3

Please # to comment.