-
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.
- Loading branch information
1 parent
863401e
commit 27ef659
Showing
6 changed files
with
137 additions
and
13 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
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,110 @@ | ||
/** FIXME: Turn this program into a test case. */ | ||
target C { | ||
timeout: 1 sec, | ||
scheduler: STATIC, | ||
build-type: Debug, | ||
single-threaded: true | ||
} | ||
|
||
preamble {= | ||
typedef int c_frame_t; | ||
typedef int l_frame_t; | ||
=} | ||
|
||
realtime reactor Camera { | ||
output out: {= c_frame_t =} | ||
state frame: {= c_frame_t =} | ||
timer t(0, 17 msec) // 60 fps | ||
|
||
@wcet("93572 nsec") // RPI4 | ||
reaction(t) -> out {= | ||
// Capture a frame. | ||
//lf_print("Camera reaction"); | ||
self->frame = 1; | ||
lf_set(out, self->frame); | ||
=} | ||
} | ||
|
||
realtime reactor LiDAR { | ||
output out: {= l_frame_t =} | ||
state frame: {= l_frame_t =} | ||
timer t(0, 34 msec) // 30 fps | ||
|
||
@wcet("97942 nsec") // RPI4 | ||
reaction(t) -> out {= | ||
// Capture a frame. | ||
// lf_print("LiDAR Reaction"); | ||
self->frame = 2; | ||
lf_set(out, self->frame); | ||
=} | ||
} | ||
|
||
realtime reactor Brakes { | ||
input inADAS: int | ||
state brakesApplied: int = 0 | ||
|
||
// RPI4 | ||
@wcet("5037 nsec") | ||
reaction(inADAS) {= | ||
// Actuate brakes. | ||
// lf_print("Brakes reaction"); | ||
self->brakesApplied = 1; | ||
=} | ||
} | ||
|
||
reactor ADASProcessor { | ||
input in1: {= l_frame_t =} | ||
input in2: {= c_frame_t =} | ||
input a_in: int | ||
output out1: int | ||
output out2: int | ||
output a_out: int | ||
state requestStop: int | ||
|
||
// RPI4 | ||
@wcet("5592 nsec") | ||
reaction(in1, in2) -> a_out {= | ||
// ... Detect danger | ||
// and request stop. | ||
// lf_print("ADASProcessor reaction 1"); | ||
lf_set_present(a_out); | ||
self->requestStop = 1; | ||
=} | ||
|
||
// RPI4 | ||
@wcet("6741 nsec") | ||
reaction(a_in) -> out1, out2 {= | ||
// lf_print("ADASProcessor reaction 2"); | ||
if (self->requestStop == 1) { | ||
lf_set_present(out1); | ||
lf_set_present(out2); | ||
} | ||
=} deadline(20 msec) {= | ||
// lf_print("Deadline reaction"); | ||
=} | ||
} | ||
|
||
reactor Dashboard { | ||
input in: int | ||
state received: int | ||
|
||
// RPI4 | ||
@wcet("4815 nsec") | ||
reaction(in) {= | ||
// lf_print("Dashboard reaction"); | ||
self->received = 1; | ||
=} | ||
} | ||
|
||
main reactor ADASModel { | ||
c = new Camera() | ||
l = new LiDAR() | ||
p = new ADASProcessor() | ||
b = new Brakes() | ||
d = new Dashboard() | ||
l.out -> p.in1 | ||
c.out -> p.in2 | ||
p.out2 -> d.in | ||
p.out1 -> b.inADAS after 5 msec | ||
p.a_out -> p.a_in after 50 msec | ||
} |
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
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
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
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