-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.raku
57 lines (54 loc) · 2.08 KB
/
test.raku
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
[
[
{
cmd => "query",
query => %( :type("==" => "temperature"), :value(">" => 40) ),
id => "#temp",
store => < value area >,
}, {
cmd => "query",
query => %( :type("==" => "humidity"), :value("<" => 20), :area("==" => -> %state { %state<#temp><area> }) ),
id => "#hum",
store => < value area >,
}, {
cmd => "dispatch",
dispatch => "fire-risk",
data => -> %state --> Hash() { :temperature(%state<#temp>.value), :humidity(%state<#hum>.value) },
}
], [
{
cmd => "query",
query => %( :type("==" => "humidity"), :value("<" => 20) ),
id => "#hum",
store => < value area >,
}, {
cmd => "query",
query => %( :type("==" => "temperature"), :value(">" => 40), :area("==" => -> %state { %state<#hum><area> }) ),
id => "#temp",
store => < value area >,
}, {
cmd => "dispatch",
dispatch => "fire-risk",
data => -> %state --> Hash() { :temperature(%state<#temp>.value), :humidity(%state<#hum>.value) },
}
]
]
# BEGIN
$storage.add:
%( :type("==" => "temperature"), :value(">" => 40) ),
%(:id<#temp>, :track<fire-risk>, :sub-track(0), :pos(0), :store< value area >, :state(%()))
;
$storage.add:
%( :type("==" => "humidity"), :value("<" => 20) ),
%(:id<#hum>, :track<fire-risk>, :sub-track(1), :pos(0), :store< value area >, :state(%()))
;
# ON temperature
$storage.add:
%( :type("==" => "humidity"), :value("<" => 20), :area(-> %state { %state<#temp><area> }) ),
%(:id<#hum>, :track<fire-risk>, :sub-track(0), :pos(1), :store< value area >, :state(%()))
;
# ON humidity
$storage.add:
%( :type("==" => "temperature"), :value(">" => 40), :area(-> %state { %state<#hum><area> }) ),
%(:id<#temp>, :track<fire-risk>, :sub-track(1), :pos(1), :store< value area >, :state(%()))
;