-
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.
Added test for reactor-c modes-with-microsteps
- Loading branch information
1 parent
4cb65ff
commit 1b3b567
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
Submodule reactor-c
updated
3 files
+1 −1 | core/modal_models/modes.c | |
+8 −2 | core/utils/pqueue_tag.c | |
+0 −8 | include/core/utils/pqueue_base.h |
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,46 @@ | ||
/** | ||
* When in the Primary mode, the watchdog is sure to trigger, causing the reaction to watcher | ||
* to be executed one microstep later. Previously, after a mode transition, the microstep was | ||
* hardwired to 1, which caused a fatal error after the mode transition when the runtime tried | ||
* to advance to microstep 1 and found that it was already at microstep 1. This program tests | ||
* that this is fixed. Success is simply running to completion without error. | ||
*/ | ||
target C { | ||
keepalive: true, | ||
timeout: 1 s | ||
} | ||
|
||
reactor Arbitrator(timeout: time = 100 ms) { | ||
input in1: double | ||
input in2: double | ||
|
||
watchdog watcher(timeout) {= lf_print("watchdog timeout."); =} | ||
|
||
initial mode Primary { | ||
reaction(in1) -> watcher {= | ||
lf_watchdog_start(watcher, 0); | ||
=} | ||
|
||
reaction(watcher) -> reset(Backup) {= | ||
lf_print("watchdog reaction."); | ||
lf_set_mode(Backup); | ||
=} | ||
} | ||
|
||
mode Backup { | ||
reaction(in2) -> watcher {= | ||
lf_watchdog_start(watcher, 0); | ||
=} | ||
} | ||
} | ||
|
||
main reactor { | ||
timer t(0, 100 ms) | ||
|
||
ar = new Arbitrator() | ||
|
||
reaction(t) -> ar.in1, ar.in2 {= | ||
lf_set(ar.in1, 0.0); | ||
lf_set(ar.in2, 0.0); | ||
=} | ||
} |