/** * Wait for ever (is aborted on goal success/failure). */ public void waitForEver() { checkNotInAtomic(); Future<Void> ret = new Future<Void>(); ret.get(); }
/** * Dispatch a new top-level goal. * @param goal The new goal. */ public void dispatchSubgoalAndWait(IGoal goal) { dispatchSubgoalAndWait(goal, -1); }
/** * Get the current time. * The time unit depends on the currently running clock implementation. * For the default system clock, the time value adheres to the time * representation as used by {@link System#currentTimeMillis()}, i.e., * the value of milliseconds passed since 0:00 'o clock, January 1st, 1970, UTC. * For custom simulation clocks, arbitrary representations can be used. * @return The current time. */ public long getTime() { return getClock().getTime(); }
checkNotInAtomic(); : bdif.getBDIModel().getCapability().getResolvedMessageEvent(getRPlan().getModelElement().getCapabilityName(), type);
checkNotInAtomic(); final IParsedExpression exp = SJavaParser.parseExpression(mcond.getExpression(), getAgent().getModel().getAllImports(), getAgent().getClassLoader()); try nowait = ((Boolean)exp.getValue(CapabilityWrapper.getFetcher(getAgent(), mcond.getExpression().getLanguage(), values))).booleanValue();
/** * Get the uncatched exception that occurred in the body (if any). * Method should only be called when in failed() method. * @return The exception. */ public Exception getException() { return getRPlan().getException(); }
/** * Dispatch a new top-level goal. * @param goal The new goal. */ public void dispatchSubgoalAndWait(IGoal goal, long timeout) { checkNotInAtomic(); dispatchSubgoal(goal); RGoal rgoal = (RGoal)goal; Future<Void> ret = new Future<Void>(); rgoal.addListener(new DelegationResultListener<Void>(ret)); try { ret.get(timeout); } catch(BDIFailureException e) { throw e; } catch(TimeoutException e) { throw e; } catch(Exception e) { throw new GoalFailureException(null, e); } }
/** * 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) { checkNotInAtomic(); IInternalBDIAgentFeature bdif = agent.getComponentFeature(IInternalBDIAgentFeature.class); WaitAbstraction wa = new WaitAbstraction(); wa.addReply((RMessageEvent)me, null); rplan.setWaitAbstraction(wa); sendMessage(me); Future<IMessageEvent> ret = new Future<IMessageEvent>(); try { agent.getComponentFeature(IInternalBDIXMessageFeature.class).registerMessageEvent((RMessageEvent)me); return ret.get(timeout); } finally { agent.getComponentFeature(IInternalBDIXMessageFeature.class).deregisterMessageEvent((RMessageEvent)me); } }
/** * Send a message and wait until it is sent. * @param me The message event. */ public IFuture<Void> sendMessage(IMessageEvent me) { return getEventbase().sendMessage(me); }
/** * Get an expression by name. * @name The expression name. * @return The expression. */ public IExpression createExpression(String exp) { return getExpressionbase().createExpression(exp); }
/** * Create a goal from a template goal. * To be processed, the goal has to be dispatched as subgoal * or adopted as top-level goal. * @param type The template goal name as specified in the ADF. * @return The created goal. */ public IGoal createGoal(String type) { return getGoalbase().createGoal(type); }
public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { UnparsedExpression uexp = mcond.getExpression(); Boolean ret = (Boolean)SJavaParser.parseExpression(uexp, getAgent().getModel().getAllImports(), getAgent().getClassLoader()).getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage(), values)); return new Future<Tuple2<Boolean, Object>>(ret!=null && ret.booleanValue()? TRUE: FALSE); } }, new IAction<Void>()
/** * Get the agent name. * @return The agent name. */ public String getComponentName() { return getComponentIdentifier().getLocalName(); }
checkNotInAtomic(); getRPlan().getModelElement().getCapabilityName(), type); WaitAbstraction wa = new WaitAbstraction(); wa.addModelElement(mevent);
checkNotInAtomic(); final IParsedExpression exp = SJavaParser.parseExpression(uexp, getAgent().getModel().getAllImports(), getAgent().getClassLoader()); List<EventType> events = new ArrayList<EventType>(); BDIAgentFeature.addExpressionEvents(uexp, events, (MParameterElement)rplan.getModelElement());
/** * Get the scope. * @return The scope. */ public ICapability getScope() { return new CapabilityWrapper(agent, getRPlan().getModelElement().getCapabilityName()); }
/** * Create a new intenal event. * @return The new intenal event. */ public IInternalEvent createInternalEvent(String type) { return getEventbase().createInternalEvent(type); }
/** * Get an expression by name. * @name The expression name. * @return The expression. */ public IExpression getExpression(String name) { return getExpressionbase().getExpression(name); }
/** * Dispatch a new top-level goal. * @param goal The new goal. * Note: plan step is interrupted after call. */ public void dispatchTopLevelGoal(IGoal goal) { getGoalbase().dispatchTopLevelGoal(goal); }
public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { Boolean ret = (Boolean)exp.getValue(CapabilityWrapper.getFetcher(getAgent(), uexp.getLanguage())); return new Future<Tuple2<Boolean, Object>>(ret!=null && ret.booleanValue()? TRUE: FALSE); } }, new IAction<Void>()