Skip to content

Commit 709fbe4

Browse files
feat: search for actuator id in actuator artifacts
1 parent 0f9badf commit 709fbe4

File tree

5 files changed

+102
-7
lines changed

5 files changed

+102
-7
lines changed

src/env/artifact/environment/roomartifact/AmbientLight.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,37 @@
99
package artifact.environment.roomartifact;
1010

1111
import cartago.OPERATION;
12+
import entity.actuator.ActuatorID;
13+
import entity.actuator.ActuatorType;
14+
import entity.room.RoomID;
15+
import infrastructure.digitaltwins.DigitalTwinManager;
1216

17+
import java.util.Optional;
1318
import java.util.logging.Logger;
1419

1520
/**
1621
* CArtAgO artifact that is responsible for the communication with an ambient light inside a room of the
1722
* Operating Block.
1823
*/
1924
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+
2039
@Override
2140
@OPERATION
2241
public final void setIntensity(final int luxToSet) {
2342
Logger.getLogger(AmbientLight.class.toString())
24-
.info("[" + this.getRoomId() + "]" + " Set " + luxToSet + " LUX");
43+
.info("[" + this.getRoomId() + "] " + this.ambientLightId.getId() + " Set " + luxToSet + " LUX");
2544
}
2645
}

src/env/artifact/environment/roomartifact/Cooler.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,42 @@
99
package artifact.environment.roomartifact;
1010

1111
import cartago.OPERATION;
12+
import entity.actuator.ActuatorID;
13+
import entity.actuator.ActuatorType;
14+
import entity.room.RoomID;
15+
import infrastructure.digitaltwins.DigitalTwinManager;
1216

17+
import java.util.Optional;
1318
import java.util.logging.Logger;
1419

1520
/**
1621
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
1722
* to the cooling part.
1823
*/
1924
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+
2039
@Override
2140
@OPERATION
2241
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");
2443
}
2544

2645
@Override
2746
@OPERATION
2847
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");
3049
}
3150
}

src/env/artifact/environment/roomartifact/Heater.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,42 @@
99
package artifact.environment.roomartifact;
1010

1111
import cartago.OPERATION;
12+
import entity.actuator.ActuatorID;
13+
import entity.actuator.ActuatorType;
14+
import entity.room.RoomID;
15+
import infrastructure.digitaltwins.DigitalTwinManager;
1216

17+
import java.util.Optional;
1318
import java.util.logging.Logger;
1419

1520
/**
1621
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
1722
* to the heating part.
1823
*/
1924
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+
2039
@Override
2140
@OPERATION
2241
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");
2443
}
2544

2645
@Override
2746
@OPERATION
2847
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");
3049
}
3150
}

src/env/artifact/environment/roomartifact/SurgicalLight.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,37 @@
99
package artifact.environment.roomartifact;
1010

1111
import cartago.OPERATION;
12+
import entity.actuator.ActuatorID;
13+
import entity.actuator.ActuatorType;
14+
import entity.room.RoomID;
15+
import infrastructure.digitaltwins.DigitalTwinManager;
1216

17+
import java.util.Optional;
1318
import java.util.logging.Logger;
1419

1520
/**
1621
* CArtAgO artifact that is responsible for the communication with a surgical light inside an operating room of the
1722
* Operating Block.
1823
*/
1924
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+
2039
@Override
2140
@OPERATION
2241
public final void setIntensity(final int luxToSet) {
2342
Logger.getLogger(SurgicalLight.class.toString())
24-
.info("[" + this.getRoomId() + "]" + " Set " + luxToSet + " LUX");
43+
.info("[" + this.getRoomId() + "] " + this.surgicalLightId.getId() + " Set " + luxToSet + " LUX");
2544
}
2645
}

src/env/artifact/environment/roomartifact/Ventilation.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,33 @@
99
package artifact.environment.roomartifact;
1010

1111
import cartago.OPERATION;
12+
import entity.actuator.ActuatorID;
13+
import entity.actuator.ActuatorType;
14+
import entity.room.RoomID;
15+
import infrastructure.digitaltwins.DigitalTwinManager;
1216

17+
import java.util.Optional;
1318
import java.util.logging.Logger;
1419

1520
/**
1621
* CArtAgO artifact that is responsible for the communication with the hvac system of the operating block respect
1722
* to the ventilation part.
1823
*/
1924
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+
2039
@Override
2140
@OPERATION
2241
public final void setIntensity(final int intensityPercentage) {
@@ -25,6 +44,6 @@ public final void setIntensity(final int intensityPercentage) {
2544
}
2645

2746
Logger.getLogger(Ventilation.class.toString())
28-
.info("[" + this.getRoomId() + "]" + " Set " + intensityPercentage);
47+
.info("[" + this.getRoomId() + "] " + this.ventilationId.getId() + " Set " + intensityPercentage);
2948
}
3049
}

0 commit comments

Comments
 (0)