|
25 | 25 | setFrequency(1) [aid(ClockId)]; // 1 tick per second
|
26 | 26 | start [aid(ClockId)].
|
27 | 27 |
|
| 28 | +// No presence event |
28 | 29 | @no_presence
|
29 | 30 | +presence(RoomId, RoomType, PresenceDetected)
|
30 | 31 | : PresenceDetected == false &
|
|
33 | 34 | not no_presence(RoomId, RoomType, X, Y) // Check that it isn't already known
|
34 | 35 | <- +no_presence(RoomId, RoomType, CurrentMillisecond, MinutesToStandby * 60 * 1000).
|
35 | 36 |
|
36 |
| -@presence [atomic] |
| 37 | +// If presence is detected again in a room that is in standby send request to disable it. |
| 38 | +@presence_in_standby [atomic] |
| 39 | ++presence(RoomId, RoomType, PresenceDetected) |
| 40 | + : PresenceDetected == true & |
| 41 | + requestedStandby(RoomId) |
| 42 | + <- out(stopStandby, RoomId); |
| 43 | + -requestedStandby(RoomId). |
| 44 | + |
| 45 | +// If presence is detected again in a room which is not in standby mode then only delete the no presence event. |
| 46 | +@presence_not_in_standby [atomic] |
37 | 47 | +presence(RoomId, RoomType, PresenceDetected) : PresenceDetected == true
|
38 | 48 | <- -no_presence(RoomId, RoomType, X, Y).
|
39 | 49 |
|
| 50 | + |
| 51 | +// At each tick check the need to set room in the standby mode |
40 | 52 | +tick: nticks(CurrentMillisecond)
|
41 | 53 | <- !checkNeedStandbyMode(CurrentMillisecond).
|
42 | 54 |
|
43 | 55 | +!checkNeedStandbyMode(CurrentMillisecond)
|
44 | 56 | : no_presence(RoomId, RoomType, Instant, Limit) &
|
45 | 57 | CurrentMillisecond - Instant > Limit
|
46 |
| - //todo: obtain configuration considering the type of the room |
47 |
| - <- //todo: write on tuple space the configuration to reach |
| 58 | + <- !setStandbyMode(RoomId, RoomType); |
| 59 | + +requestedStandby(RoomId); // mental note to save for which room I have requested the standby mode. |
48 | 60 | -no_presence(RoomId, RoomType, Instant, Limit);
|
49 | 61 | !!checkNeedStandbyMode(CurrentMillisecond). // Continue to check until there are match
|
50 | 62 |
|
51 | 63 | -!checkNeedStandbyMode(CurrentMillisecond). // No more match found
|
52 | 64 |
|
| 65 | +// Set Standby mode Operating Room |
| 66 | ++!setStandbyMode(RoomId, RoomType) |
| 67 | + : standbyEnvironmentConfig(RoomType, Temperature, Humidity, AmbientLight, SurgicalLight) |
| 68 | + <- out(requestStandby, RoomId, Temperature, Humidity, AmbientLight, SurgicalLight). // propose specific configuration to director |
| 69 | + |
| 70 | +// Set Standby mode Pre/Post Operating Room |
| 71 | ++!setStandbyMode(RoomId, RoomType) |
| 72 | + : standbyEnvironmentConfig(RoomType, Temperature, Humidity, AmbientLight) |
| 73 | + <- out(requestStandby, RoomId, Temperature, Humidity, AmbientLight). // propose specific configuration to director |
| 74 | + |
53 | 75 | // Obtain the operating block observer
|
54 | 76 | +?obtainObserver(OperatingBlockObserverId)
|
55 | 77 | <- lookupArtifact("operating_block_observer", OperatingBlockObserverId).
|
|
0 commit comments