Skip to content

Commit b0bde52

Browse files
feat: allow to specify a specific target temperature for a room
1 parent 9bde8b3 commit b0bde52

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

src/agt/temperatureControl.asl

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

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

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

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

29-
@heating [atomic]
30-
+temperature(RoomId, RoomType, Value)
31-
: optimalTemperature(RoomType, OptimalValue) &
32-
TollerancedOptimalValue = OptimalValue - 0.5 &
33-
Value < TollerancedOptimalValue
44+
+!achieveOptimalTemperature(RoomId, CurrentValue, OptimalValue)
45+
: tollerance(Tollerance) &
46+
TollerancedOptimalValue = OptimalValue - Tollerance &
47+
CurrentValue < TollerancedOptimalValue
3448
<- .println(heating);
3549
!turnOffCooling(RoomId);
3650
!turnOnHeating(RoomId).
3751

38-
@off_temperature [atomic]
39-
+temperature(RoomId, RoomType, Value) : optimalTemperature(RoomType, OptimalValue) & Value == OptimalValue
52+
+!achieveOptimalTemperature(RoomId, CurrentValue, OptimalValue) : CurrentValue == OptimalValue
4053
<- .println(off_temperature);
4154
!turnOffCooling(RoomId);
4255
!turnOffHeating(RoomId).
4356

44-
// Cooling goal
57+
// Cooling goals
4558
+!turnOnCooling(RoomId) : not cooling(RoomId)
4659
<- .concat(RoomId, "-cooler", ResultString);
4760
makeArtifact(ResultString, "artifact.environment.roomartifact.Cooler", [RoomId], CoolerId);
@@ -60,7 +73,7 @@
6073
-!turnOffCooling(RoomId)
6174
<- true.
6275

63-
// Heating goal
76+
// Heating goals
6477
+!turnOnHeating(RoomId) : not heating(RoomId)
6578
<- .concat(RoomId, "-heater", ResultString);
6679
makeArtifact(ResultString, "artifact.environment.roomartifact.Heater", [RoomId], HeaterId);

0 commit comments

Comments
 (0)