public void goalFinished(AgentEvent ae) { IGoal goal = (IGoal)ae.getSource(); if(goal.isSucceeded()) { goalcnt++; if(goalcnt==agoalnames.length) lis.resultAvailable(null); } else { lis.exceptionOccurred(goal.getException()); } }
/** * Wait for the result. * @return The result. */ public Object waitForResult() { return waitForResult(-1); }
/** * Wait for a condition to be satisfied. * @param condition The condition. */ public void waitForCondition(String condition) { waitForCondition(condition, -1); }
public void body() { IMessageEvent updateMsg = (IMessageEvent) getReason(); IGoal handleUpdate = createGoal("sp_handle_update"); handleUpdate.getParameter("subscription_id").setValue(updateMsg.getParameter(SFipa.CONVERSATION_ID).getValue()); handleUpdate.getParameter("update").setValue(updateMsg.getParameter(SFipa.CONTENT).getValue()); dispatchTopLevelGoal(handleUpdate); } }
@Classname("addTarget") public IFuture<Void> execute(IInternalAccess ia) { IBDIInternalAccess bia = (IBDIInternalAccess)ia; if(!bia.getBeliefbase().getBeliefSet("my_targets").containsFact(so)) { bia.getBeliefbase().getBeliefSet("my_targets").addFact(so); } return IFuture.DONE; } });
/** * Get the monitor for waiting. * @return The monitor. */ public Object getMonitor() { BDIInterpreter pi = BDIInterpreter.getInterpreter(getState()); IPlanExecutor exe = pi==null? null: pi.getPlanExecutor(getRPlan()); return exe==null? null: exe.getMonitor(getRPlan()); }
/** * Let a plan fail. */ public void fail() { throw new PlanFailureException(); }
/** * Send a message and wait for the answer. * @param me The message event. * @return The result event. */ public IMessageEvent sendMessageAndWait(IMessageEvent me) { return sendMessageAndWait(me, -1); }
/** * Wait for a belief (set) fact change. * @param belief The belief (set) type. * @return The changed fact value. */ public Object waitForFactChanged(String belief) { return waitForFactChanged(belief, -1); }
/** * Wait for a message event. * @param type The message event type. */ public IMessageEvent waitForMessageEvent(String type) { return waitForMessageEvent(type, -1); }
/** * Wait for a goal. * @param goal The goal. */ public void waitForGoal(IGoal goal) { waitForGoal(goal, -1); }
/** * Wait for a message. * @param msgevent The message event. */ public IMessageEvent waitForReply(IMessageEvent msgevent) { return waitForReply(msgevent, -1); }
/** * Wait for a belief set fact addition or removal. * @param beliefset The belief set type. * @return The added fact value. */ public Object waitForFactAddedOrRemoved(String beliefset) { return waitForFactAddedOrRemoved(beliefset, -1); }
public void body() { IMessageEvent msg = (IMessageEvent) getReason(); IMessageEvent reply = getEventbase().createReply(msg, "sp_agree"); sendMessage(reply); IGoal startSub = createGoal("sp_start_subscription"); startSub.getParameter("initiator").setValue(msg.getParameter(SFipa.SENDER).getValue()); startSub.getParameter("subscription_id").setValue(msg); startSub.getParameter("subscription").setValue(msg.getParameter(SFipa.CONTENT).getValue()); dispatchSubgoalAndWait(startSub); } }
/** * Let a plan fail. * @param message The message. * @param cause The cause. */ public void fail(String message, Throwable cause) { throw new PlanFailureException(message, cause); }
/** * Send a message and wait for the answer. * Adds a reply_with entry if not present, for tracking the conversation. * @param me The message event. * @param timeout The timeout. * @return The result event. */ public IMessageEvent sendMessageAndWait(IMessageEvent me, long timeout) { return sendMessageAndWait(me, timeout, null); }
/** * Execute the plan. */ public void body() { IMessageEvent rep = getEventbase().createReply((IMessageEvent)getReason(), "not_understood"); rep.getParameter(SFipa.CONTENT).setValue(((IParameterElement)getReason()).getParameter(SFipa.CONTENT).getValue()); sendMessage(rep); // sendMessage(((IMessageEvent)getReason()).createReply( // "not_understood", getReason().getParameter(SFipa.CONTENT).getValue())); } }
/** * Let a plan fail. * @param cause The cause. */ public void fail(Throwable cause) { throw new PlanFailureException(null, cause); }
/** * */ public void body() { IMessageEvent msg = (IMessageEvent) getParameter("message").getValue(); IMessageEvent update = getEventbase().createReply(msg, "sp_inform"); update.getParameter(SFipa.CONTENT).setValue(getParameter("update").getValue()); sendMessage(update); } }