diff --git a/bdi-jade-test/src/bdi4jade/examples/undo/ManagementCapability.java b/bdi-jade-test/src/bdi4jade/examples/undo/ManagementCapability.java
index 5be9d24..f85ea48 100644
--- a/bdi-jade-test/src/bdi4jade/examples/undo/ManagementCapability.java
+++ b/bdi-jade-test/src/bdi4jade/examples/undo/ManagementCapability.java
@@ -3,45 +3,26 @@ package bdi4jade.examples.undo;
import bdi4jade.annotation.Belief;
import bdi4jade.belief.PredicateBelief;
import bdi4jade.belief.TransientPredicate;
-import bdi4jade.examples.undo.domain.Alarm;
import bdi4jade.examples.undo.domain.CO;
-import bdi4jade.examples.undo.domain.Door;
-import bdi4jade.examples.undo.domain.Fan;
-import bdi4jade.examples.undo.domain.Light;
-import bdi4jade.examples.undo.domain.Valve;
-import bdi4jade.examples.undo.domain.WaterHeater;
-import bdi4jade.examples.undo.domain.Window;
+import bdi4jade.examples.undo.domain.House;
import bdi4jade.examples.undo.domain.predicate.Abnormal;
import bdi4jade.examples.undo.domain.predicate.Leak;
import bdi4jade.examples.undo.domain.predicate.Locked;
import bdi4jade.examples.undo.domain.predicate.On;
import bdi4jade.examples.undo.domain.predicate.Open;
import bdi4jade.examples.undo.domain.predicate.TakeOff;
-import bdi4jade.examples.undo.goal.AlarmShutdownGoal;
-import bdi4jade.examples.undo.goal.AlarmTakeOffGoal;
-import bdi4jade.examples.undo.goal.DoorsLockGoal;
-import bdi4jade.examples.undo.goal.DoorsUnlockGoal;
-import bdi4jade.examples.undo.goal.FansOffGoal;
-import bdi4jade.examples.undo.goal.FansOnGoal;
-import bdi4jade.examples.undo.goal.LightsOffGoal;
-import bdi4jade.examples.undo.goal.LightsOnGoal;
import bdi4jade.examples.undo.goal.NormalizeCOGoal;
-import bdi4jade.examples.undo.goal.ValveCloseGoal;
-import bdi4jade.examples.undo.goal.WindowsCloseGoal;
-import bdi4jade.examples.undo.goal.WindowsOpenGoal;
import bdi4jade.examples.undo.plan.EvacuateAndVentilatePlanBody;
-import bdi4jade.examples.undo.plan.request.RequestAlarmShutdownPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestAlarmTakeOffPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestDoorsLockPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestDoorsUnlockPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestFansOffPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestFansOnPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestLightsOffPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestLightsOnPlanBody;
-import bdi4jade.examples.undo.plan.request.RequestValveClosePlanBody;
-import bdi4jade.examples.undo.plan.request.RequestWindowsClosePlanBody;
-import bdi4jade.examples.undo.plan.request.RequestWindowsOpenPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceClosePlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceLockPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceOffPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceOnPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceOpenPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceShutdownPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceTakeOffPlanBody;
+import bdi4jade.examples.undo.plan.request.RequestDeviceUnlockPlanBody;
import bdi4jade.extension.undo.RevertingCapability;
+import bdi4jade.goal.GoalTemplateFactory;
import bdi4jade.plan.DefaultPlan;
import bdi4jade.plan.Plan;
@@ -53,15 +34,6 @@ public class ManagementCapability extends RevertingCapability {
private static final long serialVersionUID = -1971498055603790248L;
- // Devices
- public static final Alarm ALARM = new Alarm("ALARM");
- public static final Door DOORS = new Door("DOORS");
- public static final Fan FANS = new Fan("FANS");
- public static final Light LIGHTS = new Light("LIGHTS");
- public static final Valve VALVE = new Valve("VALVE");
- public static final WaterHeater WATER_HEATER = new WaterHeater("WATER_HEATER");
- public static final Window WINDOWS = new Window("WINDOWS");
-
// Neighbours
@Belief
String alarmAgent;
@@ -77,40 +49,35 @@ public class ManagementCapability extends RevertingCapability {
String windowsAgent;
// Device Predicates
- PredicateBelief<TakeOff> alarmTakeOff = new TransientPredicate<>(new TakeOff(ALARM), false);
- PredicateBelief<Locked> doorsUnlock = new TransientPredicate<>(new Locked(DOORS), true);
- PredicateBelief<On> fansOn = new TransientPredicate<On>(new On(FANS), false);
- PredicateBelief<Leak> leakingWaterHeater = new TransientPredicate<Leak>(new Leak(WATER_HEATER), false);
- PredicateBelief<On> lightsOn = new TransientPredicate<>(new On(LIGHTS), false);
- PredicateBelief<Open> valveClose = new TransientPredicate<Open>(new Open(VALVE), false);
- PredicateBelief<Open> windowsOpen = new TransientPredicate<Open>(new Open(WINDOWS), false);
+ PredicateBelief<TakeOff> alarmTakeOff = new TransientPredicate<>(new TakeOff(House.ALARM), false);
+ PredicateBelief<Locked> doorsUnlock = new TransientPredicate<>(new Locked(House.DOORS), true);
+ PredicateBelief<On> fansOn = new TransientPredicate<On>(new On(House.FANS), false);
+ PredicateBelief<Leak> leakingWaterHeater = new TransientPredicate<Leak>(new Leak(House.WATER_HEATER), false);
+ PredicateBelief<On> lightsOn = new TransientPredicate<>(new On(House.LIGHTS), false);
+ PredicateBelief<Open> valveOpen = new TransientPredicate<Open>(new Open(House.VALVE), false);
+ PredicateBelief<Open> windowsOpen = new TransientPredicate<Open>(new Open(House.WINDOWS), false);
PredicateBelief<Abnormal> abnormalCO = new TransientPredicate<Abnormal>(new Abnormal(CO.getInstance()), false);
// Plans
@bdi4jade.annotation.Plan
- private Plan lightsOnPlan;
- @bdi4jade.annotation.Plan
- private Plan lightsOffPlan;
- @bdi4jade.annotation.Plan
- private Plan alarmTakeOffPlan;
- @bdi4jade.annotation.Plan
- private Plan alarmShutdownPlan;
+ private Plan evacuateAndVentilatePlan;
+
@bdi4jade.annotation.Plan
- private Plan doorsUnlockPlan;
+ private Plan requestDeviceTakeOffPlan;
@bdi4jade.annotation.Plan
- private Plan doorsLockPlan;
+ private Plan requestDeviceShutdownPlan;
@bdi4jade.annotation.Plan
- private Plan fansOnPlan;
+ private Plan requestDeviceOnPlan;
@bdi4jade.annotation.Plan
- private Plan fansOffPlan;
+ private Plan requestDeviceOffPlan;
@bdi4jade.annotation.Plan
- private Plan windowsOpenPlan;
+ private Plan requestDeviceUnlockPlan;
@bdi4jade.annotation.Plan
- private Plan windowsClosePlan;
+ private Plan requestDeviceLockPlan;
@bdi4jade.annotation.Plan
- private Plan valveClosePlan;
+ private Plan requestDeviceOpenPlan;
@bdi4jade.annotation.Plan
- private Plan evacuateAndVentilatePlan;
+ private Plan requestDeviceClosePlan;
public ManagementCapability(String alarmAgent, String valveAgent, String doorsAgent, String fansAgent,
String lightsAgent, String windowsAgent) {
@@ -126,21 +93,31 @@ public class ManagementCapability extends RevertingCapability {
}
private void initializePlans() {
- this.lightsOnPlan = new DefaultPlan(LightsOnGoal.class, RequestLightsOnPlanBody.class);
- this.lightsOffPlan = new DefaultPlan(LightsOffGoal.class, RequestLightsOffPlanBody.class);
- this.alarmTakeOffPlan = new DefaultPlan(AlarmTakeOffGoal.class, RequestAlarmTakeOffPlanBody.class);
- this.alarmShutdownPlan = new DefaultPlan(AlarmShutdownGoal.class, RequestAlarmShutdownPlanBody.class);
- this.doorsUnlockPlan = new DefaultPlan(DoorsUnlockGoal.class, RequestDoorsUnlockPlanBody.class);
- this.doorsLockPlan = new DefaultPlan(DoorsLockGoal.class, RequestDoorsLockPlanBody.class);
- this.fansOnPlan = new DefaultPlan(FansOnGoal.class, RequestFansOnPlanBody.class);
- this.fansOffPlan = new DefaultPlan(FansOffGoal.class, RequestFansOffPlanBody.class);
- this.windowsOpenPlan = new DefaultPlan(WindowsOpenGoal.class, RequestWindowsOpenPlanBody.class);
- this.windowsClosePlan = new DefaultPlan(WindowsCloseGoal.class, RequestWindowsClosePlanBody.class);
- this.valveClosePlan = new DefaultPlan(ValveCloseGoal.class, RequestValveClosePlanBody.class);
+
+ this.requestDeviceTakeOffPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(TakeOff.class, true), RequestDeviceTakeOffPlanBody.class);
+ this.requestDeviceShutdownPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(TakeOff.class, false), RequestDeviceShutdownPlanBody.class);
+
+ this.requestDeviceOnPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(On.class, true), RequestDeviceOnPlanBody.class);
+ this.requestDeviceOffPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(On.class, false), RequestDeviceOffPlanBody.class);
+
+ this.requestDeviceUnlockPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(Locked.class, false), RequestDeviceUnlockPlanBody.class);
+ this.requestDeviceLockPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(Locked.class, true), RequestDeviceLockPlanBody.class);
+
+ this.requestDeviceOpenPlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(Open.class, true), RequestDeviceOpenPlanBody.class);
+ this.requestDeviceClosePlan = new DefaultPlan(
+ GoalTemplateFactory.hasBeliefOfTypeWithValue(Open.class, false), RequestDeviceClosePlanBody.class);
+
this.evacuateAndVentilatePlan = new DefaultPlan(NormalizeCOGoal.class, EvacuateAndVentilatePlanBody.class);
}
private void initializeCauseEffectRelationship() {
-
+
}
}