public void factAdded(ChangeInfo<Object> info) { if(info.getValue().equals(Integer.valueOf(1))) { reports.addFact(new TestReport("#1", "Adding first fact.", true, null)); } else if(info.getValue().equals(Integer.valueOf(2))) { reports.addFact(new TestReport("#2", "Adding second fact.", true, null)); } else { reports.addFact(new TestReport("??", "Adding ??? fact.", false, "Unexpected event for: "+info.getValue())); } }
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { int i=0; while(true) { waitFor(100); getBeliefbase().getBeliefSet("some_numbers").addFact(Integer.valueOf(i++)); //getBeliefbase().getBeliefSet("some_numbers").removeFact(Integer.valueOf(i++)); } } }
/** * Called on plan abortion. */ public void aborted() { tr.setSucceeded(true); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); getLogger().info("Plan aborted."); } }
/** * The plan body. */ public void body() { System.out.println("started: "+this); TestReport tr = new TestReport("#1", "Test if plan can be started manually."); tr.setSucceeded(true); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
/** * Called when plan failed. */ public void failed() { tr.setSucceeded(true); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
/** * Called when the plan is aborted. */ public void aborted() { getLogger().info("Plan aborting..."); tr.setSucceeded(true); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
/** * The plan body. */ public void body() { // System.out.println("reports: "+getBeliefbase().getBeliefSet("testcap.reports").size()); this.report = (TestReport)getParameter("report").getValue(); if(report==null) throw new RuntimeException("Report must not null."); getLogger().info("Storing report: "+report); getBeliefbase().getBeliefSet("testcap.reports").addFact(report); } }
/** * Called on plan failure. */ public void failed() { getLogger().info("No belief set update detected. Plan failed."); if(tr==null) tr = new TestReport("", "Plan failure occurred before test was created."); tr.setReason("No belief set update detected"); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); }
/** * Called on plan failure. */ public void failed() { getLogger().info("No belief update detected. Plan failed."); if(tr==null) tr = new TestReport("", "Plan failure occurred before test was created."); tr.setReason("No belief update detected"); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
/** * When move to location or eat food finally failed, * add food to forbidden food. */ public void failed() { getBeliefbase().getBeliefSet("forbidden_food") .addFact(getParameter("food").getValue()); } }
@Classname("addAlarm") public IFuture<Void> execute(IInternalAccess ia) { IBDIXAgentFeature bia = ia.getComponentFeature(IBDIXAgentFeature.class); bia.getBeliefbase().getBeliefSet("alarms").addFact(alarm); return IFuture.DONE; } });
/** * Test if a short waitFor(...) succeeds. */ protected void testWait(long wait, TestReport tr) { getLogger().info("Now waiting for " + wait + " ms"); waitFor(wait); getLogger().info("Finished waiting"); if(tr!=null) { tr.setSucceeded(true); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } } }
/** * The plan body. */ public void body() { tr = new TestReport("#1", "Tests plan abortion due to invalid context."); getLogger().info("Waiting: "+this); waitFor(1000); getLogger().info("Continued: "+this); tr.setReason("Plan was not aborted."); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); }
/** * The body method is called on the * instantiated plan instance from the scheduler. */ public void body() { tr = new TestReport("#1", "Test plan termination."); getLogger().info("Plan started, waiting for context."); // Waits internally on the same condition as the plan context. // This means the plan is immediately aborted when both conditions trigger. waitForCondition("plan_context"); getLogger().info("Plan after condition??"); tr.setReason("Plan is executed even though plan context is not valid."); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); }
public void body() { String instancename = (String)getParameter("instance").getValue(); waitFor(100); // wait for the listening plan to start for(int i=0; i < 5; i++) { String fact = instancename + " " + i; getBeliefbase().getBeliefSet("beliefSetToAddFacts").addFact(fact); getLogger().info("added fact: " + fact); waitFor(50); } } }
/** * The plan body. */ public void body() { String test = (String)((IParameterElement)getReason()).getParameter("param").getValue(); boolean success = ((Boolean)getParameter("success").getValue()).booleanValue(); TestReport report = new TestReport(test, "Test reaction to an initial event"); if(success) report.setSucceeded(true); else report.setFailed("Event did not match"); getBeliefbase().getBeliefSet("testcap.reports").addFact(report); } }
/** * The body method. */ public void body() { TestReport tr = new TestReport("#1", "Testing waitForResult()."); Future<Object> listener = new Future<Object>(); getBeliefbase().getBelief("listener").setFact(listener); Object result = listener.get(); if("success".equals(result)) tr.setSucceeded(true); else tr.setFailed("Wrong result received: "+result); getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
public void body() { TestReport report = new TestReport("test_inline", "Dispatch a goal handled by the inline plan"); try { IGoal agoal = createGoal("testgoal"); dispatchSubgoalAndWait(agoal); report.setSucceeded(true); } catch(GoalFailureException gfe) { report.setReason(gfe.toString()); } getBeliefbase().getBeliefSet("testcap.reports").addFact(report); } }
/** * The plan body. */ public void body() { // Substract both sets. Target[] ts = (Target[])getBeliefbase().getBeliefSet("move.my_targets").getFacts(); Target[] fts = (Target[])getBeliefbase().getBeliefSet("finished_targets").getFacts(); Target[] res = (Target[])SUtil.substractArrays(ts, fts); for(int i=0; i<res.length; i++) { //System.out.println("Infoming sentry about a new target!!!"); informSentryAgents(res[i]); getBeliefbase().getBeliefSet("finished_targets").addFact(res[i]); } }