-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.thingml
55 lines (42 loc) · 953 Bytes
/
base.thingml
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
import "LED.thingml"
import "pot.thingml"
import "datatypes.thingml"
thing Base includes TimerMsgs, LEDMsgs, POTmsgs {
required port timer
@sync_send "true"
{
receives timer_timeout
sends timer_start, timer_cancel
}
required port ledRed {
sends led_ON, led_OFF
}
required port pot {
receives read_value
}
statechart TrafficLights init READY {
state READY {
internal event e: pot?read_value action do
if (e.val > 50) do
ledRed!led_ON()
end
if (e.val < 50) do
ledRed!led_OFF()
end
end
}
}
}
protocol Timer;
configuration Base
{
instance Base : Base
instance pot : POT
set pot.PIN = 16
instance ledRed : LED
set ledRed.PIN = 4
connector Base.ledRed => ledRed.ctrl
connector Base.pot => pot.potValue
connector Base.timer over Timer
connector pot.clock over Timer
}