Skip to content

Commit 29e6c39

Browse files
feat: allow to specify a specific target humidity for a room
1 parent b0bde52 commit 29e6c39

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/agt/humidityControl.asl

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,40 @@
1111
* in order to maintain it within the values of the user configuration.
1212
*/
1313

14+
tollerance(1).
15+
1416
!observeOperatingBlock.
1517

1618
+!observeOperatingBlock
1719
<- ?obtainObserver(OperatingBlockObserverId);
1820
focus(OperatingBlockObserverId).
1921

20-
@ventilation [atomic]
22+
// Get the humidity updates
23+
@humidity [atomic]
2124
+humidity(RoomId, RoomType, Value)
22-
: optimalHumidity(RoomType, OptimalValue) &
23-
TollerancedOptimalValue = OptimalValue + 1 &
24-
Value >= TollerancedOptimalValue
25+
<- !adjustHumidity(RoomId, RoomType, Value).
26+
27+
// Check if there is a specific value of humidity for that room id and then achieve the optimal humidity
28+
+!adjustHumidity(RoomId, RoomType, CurrentValue): specificHumidityTarget(RoomId, OptimalValue)
29+
<- !achieveOptimalHumidity(RoomId, CurrentValue, OptimalValue).
30+
31+
// If there isn't any specific value for the room id then achieve the optimal humidity based on the room type
32+
+!adjustHumidity(RoomId, RoomType, CurrentValue): not specificHumidityTarget(RoomId, X) & optimalHumidity(RoomType, OptimalValue)
33+
<- !achieveOptimalHumidity(RoomId, CurrentValue, OptimalValue).
34+
35+
// Goals to achieve optimal humidity
36+
+!achieveOptimalHumidity(RoomId, CurrentValue, OptimalValue)
37+
: tollerance(Tollerance) &
38+
TollerancedOptimalValue = OptimalValue + Tollerance &
39+
CurrentValue >= TollerancedOptimalValue
2540
<- .println(ventilation);
2641
!turnOnVentilation(RoomId).
2742

28-
@off_ventilation [atomic]
29-
+humidity(RoomId, RoomType, Value) : optimalHumidity(RoomType, OptimalValue) & Value <= TollerancedOptimalValue
43+
+!achieveOptimalHumidity(RoomId, CurrentValue, OptimalValue) : CurrentValue <= OptimalValue
3044
<- .println(off_ventilation);
3145
!turnOffVentilation(RoomId).
3246

33-
// Ventilation goal
47+
// Ventilation goals
3448
+!turnOnVentilation(RoomId) : not ventilation(RoomId)
3549
<- .concat(RoomId, "-ventilation", ResultString);
3650
makeArtifact(ResultString, "artifact.environment.roomartifact.Ventilation", [RoomId], VentilationId);

0 commit comments

Comments
 (0)