/** * Get the resolved host name. */ public String getHostName() { if(hostnamefut!=null) { this.hostname = hostnamefut.get(new ThreadSuspendable()); this.hostnamefut = null; } return hostname; }
@Plan protected void wait(IPlan plan) { System.out.println("waiting for notification"); plan.waitForFactChanged("mybean").get(); System.out.println("received notification"); }
/** * Plan that prints out goal text and passes. */ @Plan protected void printHello(IPlan plan) { System.out.println("Hello World."); plan.waitFor(1000).get(); System.out.println("Good bye."); } }
public void intermediateResultAvailable(String item) { // System.out.println("Item offered: "+item); System.out.println(agent.getComponentIdentifier()+": "+(ls.claimItem(item).get()? "I won item: ": "I did not win item: ")+item); }
/** * The agent body. */ @AgentBody public void body() { String eword = "dog"; String gword = (String)bdiFeature.dispatchTopLevelGoal(capa.new Translate(eword)).get(); System.out.println("Translated: "+eword+" "+gword); List<String> syns = (List<String>)bdiFeature.adoptPlan("findSynonyms", new Object[]{eword}).get(); System.out.println("Found synonyms: "+eword+" "+syns); }
@AgentCreated public void init() { System.out.println("Agent created"); IFuture<Collection<ITestService>> fut = agent.getComponentFeature(IRequiredServicesFeature.class).getRequiredServices("testService"); Collection<ITestService> sers = fut.get(); System.out.println("fetched all available services: "+sers.size()); }
/** * 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."); } }
@PlanBody protected void takeTrain(IPlan plan) { System.out.println("Trying to take train to Uni."); plan.dispatchSubgoal(new TakeXGoal(TakeXGoal.Type.TRAIN)).get(); System.out.println("Took train to Uni."); } }
/** * Test method. */ public IFuture<String> test() { System.out.println("invoked service: "+sid.getProviderId()+" cnt="+(++cnt)+" wait="+wait); comp.waitForDelay(wait).get(); return new Future<String>(sid.toString()); } }
@Plan(trigger=@Trigger(goals=TestGoal.class)) public String p2(IPlan plan) { plan.waitFor(200).get(); return "p2"; }
/** * Get the current time. */ protected long getTime() { IClockService cs = (IClockService)agent.getComponentFeature(IRequiredServicesFeature.class).getRequiredService("clockser").get(); return cs.getTime(); }
/** * The agent body. */ @AgentBody public void body() { agent.getComponentFeature(IBDIAgentFeature.class).adoptPlan("printHello").get(); }
@Plan(trigger=@Trigger(goals=TestGoal.class)) public String p1(IPlan plan) { plan.waitFor(200).get(); return "p1"; }
/** * Execute a plan. */ public void body() { IComponentIdentifier cid = (IComponentIdentifier)getParameter("componentidentifier").getValue(); IFuture ret =((IComponentManagementService)getServiceContainer().getRequiredService("cms").get(this)).suspendComponent(cid); IComponentDescription desc = (IComponentDescription)ret.get(this); getParameter("componentdescription").setValue(desc); } }
/** * The agent body. */ @AgentBody public void body() { bdi.adoptPlan(new TranslatePlan("dog")); agent.getComponentFeature(IExecutionFeature.class).waitForDelay(1000).get(); context = false; System.out.println("context set to false"); }
/** * The agent body. */ @AgentBody public void body() { agent.getComponentFeature(IBDIAgentFeature.class).dispatchTopLevelGoal(new HelloGoal("Hello BDI agent V3.")).get(); // System.out.println("body end: "+getClass().getName()); }
@Classname("stop") public IFuture<Void> execute(IInternalAccess ia) { IComponentManagementService cms = ia.getComponentFeature(IRequiredServicesFeature.class) .searchService(IComponentManagementService.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); cms.destroyComponent(player.getAgentID()); return IFuture.DONE; } });
/** * The agent body. */ @AgentBody public void body(IInternalAccess agent) { agent.getComponentFeature(IExecutionFeature.class).waitForDelay(1000).get(); tr.setFailed("Plan was not triggered."); agent.killComponent(); }
@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"); }