-
Notifications
You must be signed in to change notification settings - Fork 1
/
ADASModel.lf
110 lines (97 loc) · 2.15 KB
/
ADASModel.lf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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
}