/** * Translate an English word to German. */ @Plan public String[] translateEnglishGerman() { String eword = "dog"; String gword = wordtable.get(eword); return new String[]{eword, gword}; } }
/** * The plans responds to the goal being violated and shows a dialog, * that asks the user to move the mouse. */ @Plan(trigger=@Trigger(goals=InUpperLeftCorner.class)) void moveToCorner() { JOptionPane.showMessageDialog(null, "Please move the mouse to the upper left corner."); }
/** * Plan reacts to the automatically created * translation goal. * @param tg The translation goal. */ @Plan(trigger=@Trigger(goals=TranslationGoal.class)) public String translatePlan(String eword) { return wordtable.get(eword); }
/** * Inline plan method that reacts on count goal. */ @Plan(trigger=@Trigger(goals=CountGoal.class)) protected IFuture<Void> inc(CountGoal goal) { counter++; System.out.println("counter is: "+counter); return IFuture.DONE; }
/** * Translate a word. */ @Plan(trigger=@Trigger(goals=Translate.class)) protected String translate(String eword) { return wordtable.get(eword); } }
@Plan protected void notify(IPlan plan) { System.out.println("notify using bean"); mybean.setAlive(true); }
/** * */ @Plan(trigger=@Trigger(goals=ExternalPlanBDI.MyGoal.class)) public class ExternalPlan { @PlanBody public void body() { System.out.println("body"); } }
/** * Plan that prints the time. */ @Plan(trigger=@Trigger(factchangeds="time")) protected void printTime() { System.out.println(formatter.format(getTime())); }
@Plan protected void wait(IPlan plan) { System.out.println("waiting for notification"); plan.waitForFactChanged("mybean").get(); System.out.println("received notification"); }
/** * Translate a word. */ @Plan(trigger=@Trigger(goals=Translate.class)) protected String translate(String eword) { return getWordtable().get(eword); }
/** * Plan that prints out goal text and passes. */ @Plan(trigger=@Trigger(goals=HelloGoal.class)) protected void printHello(String text, IPlan plan) { System.out.println(text); plan.waitFor(1000).get(); System.out.println("Good bye."); } }
/** * Plan reacting on test goal. */ @Plan(trigger=@Trigger(goals=TestGoal.class)) public IFuture<Void> testPlan(TestGoal goal) { goal.setCnt(goal.getCnt()+1); System.out.println("Capa plan: "+this); return new Future<Void>(new RuntimeException()); } }
@Plan(trigger=@Trigger(factchangeds={"byte", "short", "int", "long", "float", "double", "char", "boolean", "string", "array"})) public void beliefChanged(ChangeEvent event) { TestReport tr = results.get(event.getSource()); tr.setSucceeded(true); } }
/** * Prints out goal text and passes. */ @Plan(trigger=@Trigger(goals=HelloGoal.class)) protected IFuture<Void> printHello2(HelloGoal goal) { System.out.println("Plan body: "+goal.getText()); agent.killComponent(); return IFuture.DONE; } }
@Plan(trigger=@Trigger(factaddeds="names")) protected void printAddedFact(ChangeEvent event, RPlan rplan) { System.out.println("fact added: "+event.getValue()+" "+event.getSource()+" "+rplan); tr[0].setSucceeded(true); }
@Plan(trigger=@Trigger(goals=TestGoal.class)) public String p2(IPlan plan) { plan.waitFor(200).get(); return "p2"; }
@Plan(trigger=@Trigger(factaddeds="names")) protected void printAddedFact(ChangeEvent event, RPlan rplan) { System.out.println("fact added: "+event.getValue()+" "+event.getSource()+" "+rplan); tr[0].setSucceeded(true); }
@Plan(trigger=@Trigger(goals=SomeGoal.class)) protected IFuture<Void> planB() { System.out.println("Plan B"); res += "B"; return new Future<Void>(new PlanFailureException()); // return IFuture.DONE; }
@Plan(trigger=@Trigger(goals=TestGoal.class)) public String p1(IPlan plan) { plan.waitFor(200).get(); return "p1"; }
@Plan(trigger=@Trigger(goals=TestGoal.class)) public void inc(TestGoal g, IPlan plan) { g.inc(); // plan.waitFor(200).get(); agent.getComponentFeature(IExecutionFeature.class).waitForDelay(200).get(); // System.out.println("plan end"); }