Skip to content

Commit b0eaba7

Browse files
feat: powerSaver agent is now capable of request the start and the stop of the standby mode to the director through the tuple space
1 parent c985d61 commit b0eaba7

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/agt/powerSaver.asl

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
setFrequency(1) [aid(ClockId)]; // 1 tick per second
2626
start [aid(ClockId)].
2727

28+
// No presence event
2829
@no_presence
2930
+presence(RoomId, RoomType, PresenceDetected)
3031
: PresenceDetected == false &
@@ -33,23 +34,44 @@
3334
not no_presence(RoomId, RoomType, X, Y) // Check that it isn't already known
3435
<- +no_presence(RoomId, RoomType, CurrentMillisecond, MinutesToStandby * 60 * 1000).
3536

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]
3747
+presence(RoomId, RoomType, PresenceDetected) : PresenceDetected == true
3848
<- -no_presence(RoomId, RoomType, X, Y).
3949

50+
51+
// At each tick check the need to set room in the standby mode
4052
+tick: nticks(CurrentMillisecond)
4153
<- !checkNeedStandbyMode(CurrentMillisecond).
4254

4355
+!checkNeedStandbyMode(CurrentMillisecond)
4456
: no_presence(RoomId, RoomType, Instant, Limit) &
4557
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.
4860
-no_presence(RoomId, RoomType, Instant, Limit);
4961
!!checkNeedStandbyMode(CurrentMillisecond). // Continue to check until there are match
5062

5163
-!checkNeedStandbyMode(CurrentMillisecond). // No more match found
5264

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+
5375
// Obtain the operating block observer
5476
+?obtainObserver(OperatingBlockObserverId)
5577
<- lookupArtifact("operating_block_observer", OperatingBlockObserverId).

0 commit comments

Comments
 (0)