From f0ba141df0e839649aa3ceb38d495b0d6d9bfa7f Mon Sep 17 00:00:00 2001 From: Andrea Giulianelli Date: Sun, 23 Apr 2023 16:44:26 +0200 Subject: [PATCH] feat: implement light automation supporter agent --- src/agt/lightAutomationSupporter.asl | 71 ++++++++++++++++++++++++++ src/agt/medicalTechnologySupporter.asl | 36 ------------- 2 files changed, 71 insertions(+), 36 deletions(-) create mode 100644 src/agt/lightAutomationSupporter.asl delete mode 100644 src/agt/medicalTechnologySupporter.asl diff --git a/src/agt/lightAutomationSupporter.asl b/src/agt/lightAutomationSupporter.asl new file mode 100644 index 0000000..4a57e43 --- /dev/null +++ b/src/agt/lightAutomationSupporter.asl @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2023. Smart Operating Block + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + */ + +/* + * The agent is responsible to handle the automation scenarios that support the usage + * of medical technologies and custom light settings inside the operating rooms. + */ + +!observeOperatingBlock. +!createOperatingBlockSender. + ++!observeOperatingBlock + <- ?obtainObserver(OperatingBlockObserverId); + focus(OperatingBlockObserverId). + ++!createOperatingBlockSender + <- makeArtifact("operating_room_proposer", "artifact.environment.OperatingRoomProposerArtifact", [], OperatingRoomSenderId). + +// Medical technology usage events ++medicalTechnologyUsage(Type, true, RoomId) // Usage of a medical technology + : scenario(Type, AmbientLight, SurgicalLight) & + not medicalTechnologyInUse(Type, R) // Check that the medical technology is not know to be already in use + <- +medicalTechnologyInUse(Type, RoomId); + lookupArtifact("operating_room_proposer", OperatingRoomSenderId); + sendMedicalTechnologyAutomationProposal(RoomId, Type, AmbientLight, SurgicalLight) [aid(OperatingRoomSenderId)]. + ++medicalTechnologyUsage(Type, false, RoomId) // Stop usage of a medical technology that isn't currently supported + : medicalTechnologyInUse(Type, RoomId) & // Check that the medical technology was in use + not medicalTechnologySupported(Type, RoomId) // This plan cover the case in which the doctor chose to not use the support + <- -medicalTechnologyInUse(Type, RoomId). + ++medicalTechnologyUsage(Type, false, RoomId) // Stop usage of a medical technology that is currently supported + : medicalTechnologySupported(Type, RoomId) // This plan cover the case in which the doctor use the support + <- -medicalTechnologyInUse(Type, RoomId); + -medicalTechnologySupported(Type, RoomId); + out(lightSupportStop, RoomId). + +// Medical technology automation scenario request from operating room. ++medicalTechnologyRequestScenario(RoomId, MedicalTechnologyType) + : medicalTechnologyInUse(MedicalTechnologyType, RoomId) & + scenario(MedicalTechnologyType, AmbientLight, SurgicalLight) & + not customLight(RoomId) // check that there isn't any other automation scenario in that room + <- +medicalTechnologySupported(MedicalTechnologyType, RoomId); + out(lightSupportStart, RoomId, AmbientLight, SurgicalLight). + +// Custom light setup request from operating room. ++customLightSetupRequest(RoomId, AmbientLight, SurgicalLight) + : not medicalTechnologySupported(X, RoomId) // check that there isn't any other automation in that room. + <- +customLight(RoomId); + out(lightSupportStart, RoomId, AmbientLight, SurgicalLight). + ++customLightStopRequest(RoomId) + <- -customLight(RoomId); + out(lightSupportStop, RoomId). + +// Obtain the operating block observer ++?obtainObserver(OperatingBlockObserverId) + <- lookupArtifact("operating_block_observer", OperatingBlockObserverId). + +-?obtainObserver(OperatingBlockObserverId) + <- .wait(100); + ?obtainObserver(OperatingBlockObserverId). + + +{ include("$jacamoJar/templates/common-cartago.asl") } +{ include("$jacamoJar/templates/common-moise.asl") } \ No newline at end of file diff --git a/src/agt/medicalTechnologySupporter.asl b/src/agt/medicalTechnologySupporter.asl deleted file mode 100644 index 04d02f6..0000000 --- a/src/agt/medicalTechnologySupporter.asl +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2023. Smart Operating Block - * - * Use of this source code is governed by an MIT-style - * license that can be found in the LICENSE file or at - * https://opensource.org/licenses/MIT. - */ - -/* - * The agent is responsible to handle the automation scenarios that support the usage - * of medical technologies inside the operating rooms. - */ - -!observeOperatingBlock. - -+!observeOperatingBlock - <- ?obtainObserver(OperatingBlockObserverId); - focus(OperatingBlockObserverId). - -+medicalTechnologyUsage(Type, true, RoomId) // Usage of a medical technology - <- true. - -+medicalTechnologyUsage(Type, false, RoomId) // Stop usage of a medical technology - <- true. - -// Obtain the operating block observer -+?obtainObserver(OperatingBlockObserverId) - <- lookupArtifact("operating_block_observer", OperatingBlockObserverId). - --?obtainObserver(OperatingBlockObserverId) - <- .wait(100); - ?obtainObserver(OperatingBlockObserverId). - - -{ include("$jacamoJar/templates/common-cartago.asl") } -{ include("$jacamoJar/templates/common-moise.asl") } \ No newline at end of file