File tree 5 files changed +102
-7
lines changed
src/env/artifact/environment/roomartifact
5 files changed +102
-7
lines changed Original file line number Diff line number Diff line change 9
9
package artifact .environment .roomartifact ;
10
10
11
11
import cartago .OPERATION ;
12
+ import entity .actuator .ActuatorID ;
13
+ import entity .actuator .ActuatorType ;
14
+ import entity .room .RoomID ;
15
+ import infrastructure .digitaltwins .DigitalTwinManager ;
12
16
17
+ import java .util .Optional ;
13
18
import java .util .logging .Logger ;
14
19
15
20
/**
16
21
* CArtAgO artifact that is responsible for the communication with an ambient light inside a room of the
17
22
* Operating Block.
18
23
*/
19
24
public class AmbientLight extends AbstractRoomArtifact implements DimmableArtifact {
25
+ private ActuatorID ambientLightId ;
26
+
27
+ @ Override
28
+ protected final void init (final String roomId ) {
29
+ super .init (roomId );
30
+ final Optional <ActuatorID > actuatorID =
31
+ new DigitalTwinManager ().findActuatorInRoom (ActuatorType .AMBIENT_LIGHT , new RoomID (roomId ));
32
+ if (actuatorID .isPresent ()) {
33
+ this .ambientLightId = actuatorID .get ();
34
+ } else {
35
+ throw new IllegalArgumentException ("No Ambient Light available in room: " + roomId );
36
+ }
37
+ }
38
+
20
39
@ Override
21
40
@ OPERATION
22
41
public final void setIntensity (final int luxToSet ) {
23
42
Logger .getLogger (AmbientLight .class .toString ())
24
- .info ("[" + this .getRoomId () + "]" + " Set " + luxToSet + " LUX" );
43
+ .info ("[" + this .getRoomId () + "] " + this . ambientLightId . getId () + " Set " + luxToSet + " LUX" );
25
44
}
26
45
}
Original file line number Diff line number Diff line change 9
9
package artifact .environment .roomartifact ;
10
10
11
11
import cartago .OPERATION ;
12
+ import entity .actuator .ActuatorID ;
13
+ import entity .actuator .ActuatorType ;
14
+ import entity .room .RoomID ;
15
+ import infrastructure .digitaltwins .DigitalTwinManager ;
12
16
17
+ import java .util .Optional ;
13
18
import java .util .logging .Logger ;
14
19
15
20
/**
16
21
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
17
22
* to the cooling part.
18
23
*/
19
24
public class Cooler extends AbstractRoomArtifact implements SwitchableArtifact {
25
+ private ActuatorID coolerId ;
26
+
27
+ @ Override
28
+ protected final void init (final String roomId ) {
29
+ super .init (roomId );
30
+ final Optional <ActuatorID > actuatorID =
31
+ new DigitalTwinManager ().findActuatorInRoom (ActuatorType .COOLING , new RoomID (roomId ));
32
+ if (actuatorID .isPresent ()) {
33
+ this .coolerId = actuatorID .get ();
34
+ } else {
35
+ throw new IllegalArgumentException ("No Cooler available in room: " + roomId );
36
+ }
37
+ }
38
+
20
39
@ Override
21
40
@ OPERATION
22
41
public final void turnOn () {
23
- Logger .getLogger (Cooler .class .toString ()).info ("[" + this .getRoomId () + "]" + " ON" );
42
+ Logger .getLogger (Cooler .class .toString ()).info ("[" + this .getRoomId () + "] " + this . coolerId . getId () + " ON" );
24
43
}
25
44
26
45
@ Override
27
46
@ OPERATION
28
47
public final void turnOff () {
29
- Logger .getLogger (Cooler .class .toString ()).info ("[" + this .getRoomId () + "]" + " OFF" );
48
+ Logger .getLogger (Cooler .class .toString ()).info ("[" + this .getRoomId () + "] " + this . coolerId . getId () + " OFF" );
30
49
}
31
50
}
Original file line number Diff line number Diff line change 9
9
package artifact .environment .roomartifact ;
10
10
11
11
import cartago .OPERATION ;
12
+ import entity .actuator .ActuatorID ;
13
+ import entity .actuator .ActuatorType ;
14
+ import entity .room .RoomID ;
15
+ import infrastructure .digitaltwins .DigitalTwinManager ;
12
16
17
+ import java .util .Optional ;
13
18
import java .util .logging .Logger ;
14
19
15
20
/**
16
21
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
17
22
* to the heating part.
18
23
*/
19
24
public class Heater extends AbstractRoomArtifact implements SwitchableArtifact {
25
+ private ActuatorID heaterId ;
26
+
27
+ @ Override
28
+ protected final void init (final String roomId ) {
29
+ super .init (roomId );
30
+ final Optional <ActuatorID > actuatorID =
31
+ new DigitalTwinManager ().findActuatorInRoom (ActuatorType .HEATING , new RoomID (roomId ));
32
+ if (actuatorID .isPresent ()) {
33
+ this .heaterId = actuatorID .get ();
34
+ } else {
35
+ throw new IllegalArgumentException ("No Heater available in room: " + roomId );
36
+ }
37
+ }
38
+
20
39
@ Override
21
40
@ OPERATION
22
41
public final void turnOn () {
23
- Logger .getLogger (Heater .class .toString ()).info ("[" + this .getRoomId () + "]" + " ON" );
42
+ Logger .getLogger (Heater .class .toString ()).info ("[" + this .getRoomId () + "] " + this . heaterId . getId () + " ON" );
24
43
}
25
44
26
45
@ Override
27
46
@ OPERATION
28
47
public final void turnOff () {
29
- Logger .getLogger (Heater .class .toString ()).info ("[" + this .getRoomId () + "]" + " OFF" );
48
+ Logger .getLogger (Heater .class .toString ()).info ("[" + this .getRoomId () + "] " + this . heaterId . getId () + " OFF" );
30
49
}
31
50
}
Original file line number Diff line number Diff line change 9
9
package artifact .environment .roomartifact ;
10
10
11
11
import cartago .OPERATION ;
12
+ import entity .actuator .ActuatorID ;
13
+ import entity .actuator .ActuatorType ;
14
+ import entity .room .RoomID ;
15
+ import infrastructure .digitaltwins .DigitalTwinManager ;
12
16
17
+ import java .util .Optional ;
13
18
import java .util .logging .Logger ;
14
19
15
20
/**
16
21
* CArtAgO artifact that is responsible for the communication with a surgical light inside an operating room of the
17
22
* Operating Block.
18
23
*/
19
24
public class SurgicalLight extends AbstractRoomArtifact implements DimmableArtifact {
25
+ private ActuatorID surgicalLightId ;
26
+
27
+ @ Override
28
+ protected final void init (final String roomId ) {
29
+ super .init (roomId );
30
+ final Optional <ActuatorID > actuatorID =
31
+ new DigitalTwinManager ().findActuatorInRoom (ActuatorType .SURGICAL_LIGHT , new RoomID (roomId ));
32
+ if (actuatorID .isPresent ()) {
33
+ this .surgicalLightId = actuatorID .get ();
34
+ } else {
35
+ throw new IllegalArgumentException ("No Surgical Light available in room: " + roomId );
36
+ }
37
+ }
38
+
20
39
@ Override
21
40
@ OPERATION
22
41
public final void setIntensity (final int luxToSet ) {
23
42
Logger .getLogger (SurgicalLight .class .toString ())
24
- .info ("[" + this .getRoomId () + "]" + " Set " + luxToSet + " LUX" );
43
+ .info ("[" + this .getRoomId () + "] " + this . surgicalLightId . getId () + " Set " + luxToSet + " LUX" );
25
44
}
26
45
}
Original file line number Diff line number Diff line change 9
9
package artifact .environment .roomartifact ;
10
10
11
11
import cartago .OPERATION ;
12
+ import entity .actuator .ActuatorID ;
13
+ import entity .actuator .ActuatorType ;
14
+ import entity .room .RoomID ;
15
+ import infrastructure .digitaltwins .DigitalTwinManager ;
12
16
17
+ import java .util .Optional ;
13
18
import java .util .logging .Logger ;
14
19
15
20
/**
16
21
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
17
22
* to the ventilation part.
18
23
*/
19
24
public class Ventilation extends AbstractRoomArtifact implements DimmableArtifact {
25
+ private ActuatorID ventilationId ;
26
+
27
+ @ Override
28
+ protected final void init (final String roomId ) {
29
+ super .init (roomId );
30
+ final Optional <ActuatorID > actuatorID =
31
+ new DigitalTwinManager ().findActuatorInRoom (ActuatorType .VENTILATION , new RoomID (roomId ));
32
+ if (actuatorID .isPresent ()) {
33
+ this .ventilationId = actuatorID .get ();
34
+ } else {
35
+ throw new IllegalArgumentException ("No Ventilation available in room: " + roomId );
36
+ }
37
+ }
38
+
20
39
@ Override
21
40
@ OPERATION
22
41
public final void setIntensity (final int intensityPercentage ) {
@@ -25,6 +44,6 @@ public final void setIntensity(final int intensityPercentage) {
25
44
}
26
45
27
46
Logger .getLogger (Ventilation .class .toString ())
28
- .info ("[" + this .getRoomId () + "]" + " Set " + intensityPercentage );
47
+ .info ("[" + this .getRoomId () + "] " + this . ventilationId . getId () + " Set " + intensityPercentage );
29
48
}
30
49
}
You can’t perform that action at this time.
0 commit comments