/** * Get all plans of a specified type (=model element name). * @param type The plan type. * @return All plans of the specified type. */ public IPlan[] getPlans(String type) { return planbase.getPlans(prefix + type); }
/** * Create a plan instance. */ public IPlan createPlan(MPlan mplan) { return planbase.createPlan(mplan); } }
/** * Get the model element. * @return The model element. */ public MElement getModelElement() { return planbase.getModelElement(); }
/** * Get all running plans of this planbase. * @return The plans. */ public IPlan[] getPlans() { List<IPlan> ret = new ArrayList<IPlan>(); for(IPlan plan: planbase.getPlans()) { if(plan.getModelElement().getName().startsWith(prefix)) { ret.add(plan); } } return ret.toArray(new IPlan[ret.size()]); }
/** * The plan body. */ public void body() { waitFor(3000); getBeliefbase().getBelief("mycontext").setFact(Boolean.FALSE); if(getPlanbase().getPlans().length==1) { getLogger().info("Success. Plan has been removed."); } else { getLogger().info("Failure! Plan with invalid context still alive."); } killAgent(); } }
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { waitFor(300); TestReport tr = new TestReport("#1", "Test plan context condition."); if(getPlanbase().getPlans().length==1) { tr.setSucceeded(true); } else { tr.setReason("Plan was not terminated on invalid context."); } getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
getLogger().info("\nTesting atomic step. There are 3 conditions a, b, and(a,b) that should trigger after the plan step has finished."); getLogger().info("Plan: Setting a to true."); int plan_cnt1 = getPlanbase().getPlans().length; getBeliefbase().getBelief("a").setFact(Boolean.TRUE); int plan_cnt2 = getPlanbase().getPlans().length; getLogger().info("Plan: a is now true."); getLogger().info("Plan: Setting b to true."); getBeliefbase().getBelief("b").setFact(Boolean.TRUE); int plan_cnt3 = getPlanbase().getPlans().length; getLogger().info("Plan: b is now true."); getLogger().info("Step 3 finished.");
IPlan[] plans = getPlanbase().getPlans("testplan"); if(plans!=null && plans.length==1)
IPlan[] plans = getPlanbase().getPlans("testplan"); if(plans!=null && plans.length==1)