1
+ /*
2
+ * Copyright (c) 2023. Smart Operating Block
3
+ *
4
+ * Use of this source code is governed by an MIT-style
5
+ * license that can be found in the LICENSE file or at
6
+ * https://opensource.org/licenses/MIT.
7
+ */
8
+
9
+ /*
10
+ * This agent is responsible to monitor the humidity inside the Operating Block
11
+ * in order to maintain it within the values of the user configuration.
12
+ */
13
+
14
+ !observeOperatingBlock.
15
+
16
+ +!observeOperatingBlock
17
+ <- ?obtainObserver(OperatingBlockObserverId);
18
+ focus(OperatingBlockObserverId).
19
+
20
+ @ventilation [atomic]
21
+ +humidity(RoomId, RoomType, Value)
22
+ : optimalHumidity(RoomType, OptimalValue) &
23
+ TollerancedOptimalValue = OptimalValue + 1 &
24
+ Value >= TollerancedOptimalValue
25
+ <- .println(ventilation);
26
+ !turnOnVentilation(RoomId).
27
+
28
+ @off_ventilation [atomic]
29
+ +humidity(RoomId, RoomType, Value) : optimalHumidity(RoomType, OptimalValue) & Value <= TollerancedOptimalValue
30
+ <- .println(off_ventilation);
31
+ !turnOffVentilation(RoomId).
32
+
33
+ // Ventilation goal
34
+ +!turnOnVentilation(RoomId) : not ventilation(RoomId)
35
+ <- .concat(RoomId, "-ventilation" , ResultString);
36
+ makeArtifact(ResultString, "artifact.environment.roomartifact.Ventilation" , [RoomId], VentilationId);
37
+ setIntensity(100) [aid(VentilationId)];
38
+ +ventilation(RoomId); // add mental note to not re-turn on
39
+ disposeArtifact(VentilationId).
40
+ -!turnOnVentilation(RoomId)
41
+ <- true.
42
+
43
+ +!turnOffVentilation(RoomId) : ventilation(RoomId)
44
+ <- .concat(RoomId, "-ventilation" , ResultString);
45
+ makeArtifact(ResultString, "artifact.environment.roomartifact.Ventilation" , [RoomId], VentilationId);
46
+ setIntensity(0 ) [aid(VentilationId)];
47
+ -ventilation(RoomId); // add mental note to not re-turn off
48
+ disposeArtifact(VentilationId).
49
+ -!turnOffVentilation(RoomId)
50
+ <- true.
51
+
52
+
53
+ // Obtain the operating block observer
54
+ +?obtainObserver(OperatingBlockObserverId)
55
+ <- lookupArtifact("operating_block_observer" , OperatingBlockObserverId).
56
+
57
+ -?obtainObserver(OperatingBlockObserverId)
58
+ <- .wait(100);
59
+ ?obtainObserver(OperatingBlockObserverId).
60
+
61
+ { include("$jacamoJar/templates/common-cartago.asl" ) }
62
+ { include("$jacamoJar/templates/common-moise.asl" ) }
0 commit comments