/** * */ public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { boolean res = !capa.getGoals(mgoal).isEmpty(); // return res? ICondition.TRUE: ICondition.FALSE; return new Future<Tuple2<Boolean,Object>>(res? ICondition.TRUE: ICondition.FALSE); } }
/** * Get the current goals as api representation. * @return All currently instantiated goals. */ public Collection<IGoal> getGoals() { return (Collection)getCapability().getGoals(); }
/** * */ public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { boolean res = !capa.getGoals(mgoal).isEmpty(); // return res? ICondition.TRUE: ICondition.FALSE; return new Future<Tuple2<Boolean,Object>>(res? ICondition.TRUE: ICondition.FALSE); } }
/** * */ public IFuture<Tuple2<Boolean, Object>> evaluate(IEvent event) { boolean res = !capa.getGoals(mgoal).isEmpty(); // return res? ICondition.TRUE: ICondition.FALSE; return new Future<Tuple2<Boolean,Object>>(res? ICondition.TRUE: ICondition.FALSE); } }
/** * Get the rGoal for a pojogoal. */ public RGoal getRGoal(Object pojogoal) { RGoal ret = null; Collection<RGoal> rgoals = getGoals(pojogoal.getClass()); if(rgoals!=null) { for(RGoal rgoal: rgoals) { if(rgoal.getPojoElement().equals(pojogoal)) { ret = rgoal; break; } } } return ret; }
/** * Get the rGoal for a pojogoal. */ public RGoal getRGoal(Object pojogoal) { RGoal ret = null; Collection<RGoal> rgoals = getGoals(pojogoal.getClass()); if(rgoals!=null) { for(RGoal rgoal: rgoals) { if(rgoal.getPojoElement().equals(pojogoal)) { ret = rgoal; break; } } } return ret; }
/** * Get the goals of a given type as pojos. * @param clazz The pojo goal class. * @return The currently instantiated goals of that type. */ public <T> Collection<T> getGoals(Class<T> clazz) { Collection<RGoal> rgoals = getCapability().getGoals(clazz); List<T> ret = new ArrayList<T>(); for(RProcessableElement rgoal: rgoals) { ret.add((T)rgoal.getPojoElement()); } return ret; }
/** * Get the current goals. */ public Collection<IGoal> getGoals() { return (Collection)((BDIAgentInterpreter)getInterpreter()).getCapability().getGoals(); }
/** * Drop a pojo goal. */ public void dropGoal(Object goal) { for(RGoal rgoal: getCapability().getGoals(goal.getClass())) { if(goal.equals(rgoal.getPojoElement())) { rgoal.drop(); } } }
/** * Get the goals of a given type. */ public <T> Collection<T> getGoals(Class<T> clazz) { Collection<RGoal> rgoals = ((BDIAgentInterpreter)getInterpreter()).getCapability().getGoals(clazz); List<T> ret = new ArrayList<T>(); for(RProcessableElement rgoal: rgoals) { ret.add((T)rgoal.getPojoElement()); } return ret; }
/** * Get all the adopted goals in this scope (including subgoals). * @return All goals and subgoals. */ public IGoal[] getGoals() { List<IGoal> ret = new ArrayList<IGoal>(); for(IGoal goal: getCapability().getGoals()) { if(SUtil.equals(goal.getModelElement().getCapabilityName(), scope)) { ret.add(goal); } } return ret.toArray(new IGoal[ret.size()]); }
/** * Drop a pojo goal. * @param goal The pojo goal. */ public void dropGoal(Object goal) { for(RGoal rgoal: getCapability().getGoals(goal.getClass())) { if(goal.equals(rgoal.getPojoElement())) { rgoal.drop(); break; } } }
/** * Get all proprietary goals of a specified type (=model element name). * @param type The goal type. * @return All proprietary goals of the specified type. */ public IGoal[] getGoals(String type) { MGoal mgoal = getCapability().getMCapability().getResolvedGoal(scope, type); Collection<RGoal> ret = getCapability().getGoals(mgoal); return ret.toArray(new IGoal[ret.size()]); }
public IFuture<Void> execute(final IEvent event, final IRule<Void> rule, final Object context, Object condresult) { for(final RGoal goal: getCapability().getGoals(mgoal)) { executeGoalMethod(m, goal, event) .addResultListener(new IResultListener<Boolean>() { public void resultAvailable(Boolean result) { if(result.booleanValue()) { goal.targetConditionTriggered(getInternalAccess(), event, rule, context); } } public void exceptionOccurred(Exception exception) { } }); } return IFuture.DONE; } });
public IFuture<Void> execute(final IEvent event, final IRule<Void> rule, final Object context, Object condresult) { for(final RGoal goal: getCapability().getGoals(mgoal)) { executeGoalMethod(m, goal, event) .addResultListener(new IResultListener<Boolean>() { public void resultAvailable(Boolean result) { if(result.booleanValue()) { goal.targetConditionTriggered(getInternalAccess(), event, rule, context); } } public void exceptionOccurred(Exception exception) { } }); } return IFuture.DONE; } });
/** * Called when a goal has been adopted. * @param goal The goal. */ public IFuture<Void> goalIsAdopted(RGoal goal) { // System.out.println(inhibitions.size()+" "+inhibitions); Collection<RGoal> others = getCapability().getGoals(); for(RGoal other: others) { // if(other.getLifecycleState().equals(RGoal.GOALLIFECYCLESTATE_ACTIVE) // && other.getProcessingState().equals(RGoal.GOALPROCESSINGSTATE_INPROCESS) // if(goal!=other && other.getModelElement().equals(goal.getModelElement()) && goal.getModelElement().getName().toLowerCase().indexOf("achievecleanup")!=-1) // System.out.println("achievecleanup"); if(!isInhibitedBy(other, goal) && inhibits(other, goal)) { // if(goal.getModelElement().getName().indexOf("achievecleanup")!=-1) // System.out.println("inhibit"); addInhibitor(goal, other); } } return IFuture.DONE; }
public IFuture<Void> execute(IEvent event, IRule<Void> rule, Object context, Object condresult) { for(final RGoal goal: getCapability().getGoals(mgoal)) { if(RGoal.GoalLifecycleState.SUSPENDED.equals(goal.getLifecycleState())) { executeGoalMethod(m, goal, event) .addResultListener(new IResultListener<Boolean>() { public void resultAvailable(Boolean result) { if(result.booleanValue()) { // if(goal.getMGoal().getName().indexOf("AchieveCleanup")!=-1) // System.out.println("Goal made option: "+goal); goal.setLifecycleState(getInternalAccess(), RGoal.GoalLifecycleState.OPTION); // setState(ia, PROCESSABLEELEMENT_INITIAL); } } public void exceptionOccurred(Exception exception) { } }); } } return IFuture.DONE; } });
public IFuture<Void> execute(IEvent event, IRule<Void> rule, Object context, Object condresult) { // create the complete inhibitorset for a newly adopted goal RGoal goal = (RGoal)event.getContent(); for(RGoal other: getCapability().getGoals()) { // if(other.getLifecycleState().equals(RGoal.GOALLIFECYCLESTATE_ACTIVE) // && other.getProcessingState().equals(RGoal.GOALPROCESSINGSTATE_INPROCESS) if(!other.isInhibitedBy(goal) && other.inhibits(goal, getInternalAccess())) { goal.addInhibitor(other, getInternalAccess()); } } return IFuture.DONE; } });
public IFuture<Void> execute(IEvent event, IRule<Void> rule, Object context, Object condresult) { for(final RGoal goal: getCapability().getGoals(mgoal)) { if(RGoal.GoalLifecycleState.ACTIVE.equals(goal.getLifecycleState()) && RGoal.GoalProcessingState.IDLE.equals(goal.getProcessingState())) { executeGoalMethod(m, goal, event) .addResultListener(new IResultListener<Boolean>() { public void resultAvailable(Boolean result) { if(!result.booleanValue()) { // System.out.println("Goal maintain triggered: "+goal); // System.out.println("state was: "+goal.getProcessingState()); goal.setProcessingState(getInternalAccess(), RGoal.GoalProcessingState.INPROCESS); } } public void exceptionOccurred(Exception exception) { } }); } } return IFuture.DONE; } });
public IFuture<Void> execute(IEvent event, IRule<Void> rule, Object context, Object condresult) { // System.out.println("parameter update: "+event); RCapability capa = BDIAgentFeature.getCapability(component); for(RGoal goal: SUtil.safeCollection(capa.getGoals(mgoal))) { if(!mparam.isMulti(component.getClassLoader())) { ((RParameter)goal.getParameter(mparam.getName())).updateDynamicValue(); } else { ((RParameterSet)goal.getParameterSet(mparam.getName())).updateDynamicValues(); } } return IFuture.DONE; } });