|
11 | 11 | * in order to maintain it within the values of the user configuration.
|
12 | 12 | */
|
13 | 13 |
|
| 14 | +tollerance(0.5). |
| 15 | + |
14 | 16 | !observeOperatingBlock.
|
15 | 17 |
|
16 | 18 | +!observeOperatingBlock
|
17 | 19 | <- ?obtainObserver(OperatingBlockObserverId);
|
18 | 20 | focus(OperatingBlockObserverId).
|
19 | 21 |
|
20 |
| -@cooling [atomic] |
| 22 | +// Get the temperature updates |
| 23 | +@temperature [atomic] |
21 | 24 | +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 |
25 | 40 | <- .println(cooling);
|
26 | 41 | !turnOffHeating(RoomId);
|
27 | 42 | !turnOnCooling(RoomId).
|
28 | 43 |
|
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 |
34 | 48 | <- .println(heating);
|
35 | 49 | !turnOffCooling(RoomId);
|
36 | 50 | !turnOnHeating(RoomId).
|
37 | 51 |
|
38 |
| -@off_temperature [atomic] |
39 |
| -+temperature(RoomId, RoomType, Value) : optimalTemperature(RoomType, OptimalValue) & Value == OptimalValue |
| 52 | ++!achieveOptimalTemperature(RoomId, CurrentValue, OptimalValue) : CurrentValue == OptimalValue |
40 | 53 | <- .println(off_temperature);
|
41 | 54 | !turnOffCooling(RoomId);
|
42 | 55 | !turnOffHeating(RoomId).
|
43 | 56 |
|
44 |
| -// Cooling goal |
| 57 | +// Cooling goals |
45 | 58 | +!turnOnCooling(RoomId) : not cooling(RoomId)
|
46 | 59 | <- .concat(RoomId, "-cooler", ResultString);
|
47 | 60 | makeArtifact(ResultString, "artifact.environment.roomartifact.Cooler", [RoomId], CoolerId);
|
|
60 | 73 | -!turnOffCooling(RoomId)
|
61 | 74 | <- true.
|
62 | 75 |
|
63 |
| -// Heating goal |
| 76 | +// Heating goals |
64 | 77 | +!turnOnHeating(RoomId) : not heating(RoomId)
|
65 | 78 | <- .concat(RoomId, "-heater", ResultString);
|
66 | 79 | makeArtifact(ResultString, "artifact.environment.roomartifact.Heater", [RoomId], HeaterId);
|
|
0 commit comments