|
11 | 11 | * in order to maintain it within the values of the user configuration.
|
12 | 12 | */
|
13 | 13 |
|
| 14 | +tollerance(1). |
| 15 | + |
14 | 16 | !observeOperatingBlock.
|
15 | 17 |
|
16 | 18 | +!observeOperatingBlock
|
17 | 19 | <- ?obtainObserver(OperatingBlockObserverId);
|
18 | 20 | focus(OperatingBlockObserverId).
|
19 | 21 |
|
20 |
| -@ventilation [atomic] |
| 22 | +// Get the humidity updates |
| 23 | +@humidity [atomic] |
21 | 24 | +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 |
25 | 40 | <- .println(ventilation);
|
26 | 41 | !turnOnVentilation(RoomId).
|
27 | 42 |
|
28 |
| -@off_ventilation [atomic] |
29 |
| -+humidity(RoomId, RoomType, Value) : optimalHumidity(RoomType, OptimalValue) & Value <= TollerancedOptimalValue |
| 43 | ++!achieveOptimalHumidity(RoomId, CurrentValue, OptimalValue) : CurrentValue <= OptimalValue |
30 | 44 | <- .println(off_ventilation);
|
31 | 45 | !turnOffVentilation(RoomId).
|
32 | 46 |
|
33 |
| -// Ventilation goal |
| 47 | +// Ventilation goals |
34 | 48 | +!turnOnVentilation(RoomId) : not ventilation(RoomId)
|
35 | 49 | <- .concat(RoomId, "-ventilation", ResultString);
|
36 | 50 | makeArtifact(ResultString, "artifact.environment.roomartifact.Ventilation", [RoomId], VentilationId);
|
|
0 commit comments