/** * Has the element a parameter set element. * @param name The name. * @return True, if it has the parameter set. */ public boolean hasParameterSet(String name) { boolean ret = state.containsKey(rplan, OAVBDIRuntimeModel.parameterelement_has_parametersets, name); if(!ret) { Object mplan = state.getAttributeValue(rplan, OAVBDIRuntimeModel.element_has_model); ret = state.containsKey(mplan, OAVBDIMetaModel.parameterelement_has_parametersets, name); } return ret; }
/** * Has the element a parameter element. * @param name The name. * @return True, if it has the parameter. */ public boolean hasParameter(String name) { boolean ret = state.containsKey(rplan, OAVBDIRuntimeModel.parameterelement_has_parameters, name); if(!ret) { Object mplan = state.getAttributeValue(rplan, OAVBDIRuntimeModel.element_has_model); ret = state.containsKey(mplan, OAVBDIMetaModel.parameterelement_has_parameters, name); } return ret; }
public void run() { bool = getState().containsKey(getHandle(), OAVBDIRuntimeModel.parameterelement_has_parameters, name); } };
public void run() { bool = getState().containsKey(getHandle(), OAVBDIRuntimeModel.parameterelement_has_parametersets, name); } };
/** * Create a goal of a given type. * Uses method instantiateGoal(). */ public static Object createGoal(IOAVState state, Object rcapa, String type) { Object mcap = state.getAttributeValue(rcapa, OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcap, OAVBDIMetaModel.capability_has_goals, type)) throw new RuntimeException("Unknown goal: "+type); Object mgoal = state.getAttributeValue(mcap, OAVBDIMetaModel.capability_has_goals, type); Object rgoal = GoalLifecycleRules.instantiateGoal(state, rcapa, mgoal, null, null, null, null); return rgoal; }
/** * Create an expression of a given type but does not add to state. * @param state The state. * @param rcapa The scope. * @param type The type. * @param rplan The plan (if created from plan). */ public static Object createExpression(IOAVState state, Object rcapa, String type) { Object mcapa = state.getAttributeValue(rcapa, OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_expressions, type)) throw new RuntimeException("Unknown expression: "+type); Object mexp = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_expressions, type); return ExpressionFlyweight.getExpressionFlyweight(state, rcapa, mexp); }
/** * Create an internal event of a given type but does not add to state. * @param state The state. * @param rcapa The scope. * @param type The type. * @param rplan The plan (if created from plan). */ public static Object createInternalEvent(IOAVState state, Object rcapa, String type) { Object mcapa = state.getAttributeValue(rcapa, OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_internalevents, type)) throw new RuntimeException("Unknown internal event: "+type); Object mevent = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_internalevents, type); Object revent = instantiateInternalEvent(state, rcapa, mevent, null, null, null, null); return revent; }
/** * Add a message event type to an OAV waitabstraction. */ public static void addMessageEvent(Object wa, String type, IOAVState state, Object rcapa) { Collection mevents = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_messageeventtypes); Object[] scope = AgentRules.resolveCapability(type, OAVBDIMetaModel.messageevent_type, rcapa, state); Object mcapa = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_messageevents, scope[0])) throw new RuntimeException("Unknown message event: "+type); Object mevent = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_messageevents, scope[0]); if(mevents==null || !mevents.contains(mevent)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_messageeventtypes, mevent); }
/** * Add a condition type to an OAV waitabstraction. */ public static void addCondition(Object wa, String condition, IOAVState state, Object rcapa) { Collection mconds = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_conditiontypes); Object[] scope = AgentRules.resolveCapability(condition, OAVBDIMetaModel.condition_type, rcapa, state); Object mcapa = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_conditions, scope[0])) throw new RuntimeException("Unknown condition: "+condition); Object mcond = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_conditions, scope[0]); if(mconds==null || !mconds.contains(mcond)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_conditiontypes, mcond); }
/** * Add an internal event type to an OAV waitabstraction. */ public static void addInternalEvent(Object wa, String type, IOAVState state, Object rcapa) { Object[] scope = AgentRules.resolveCapability(type, OAVBDIMetaModel.internalevent_type, rcapa, state); Object mcapa = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_internalevents, scope[0])) throw new RuntimeException("Unknown internal event: "+type); Object mevent = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_internalevents, scope[0]); Collection ievents = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_internaleventtypes); if(ievents==null || !ievents.contains(mevent)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_internaleventtypes, mevent); }
/** * Remove an internal event. * @param type The type. */ public static void removeInternalEvent(IOAVState state, Object scope, String type, Object wa) { if(wa!=null) { Collection mevents = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_internaleventtypes); Object[] rscope = AgentRules.resolveCapability(type, OAVBDIMetaModel.internalevent_type, scope, state); Object mcapa = state.getAttributeValue(rscope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_internalevents, rscope[0])) throw new RuntimeException("Unknown internal event: "+type); Object mevent = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_internalevents, rscope[0]); if(mevents!=null && mevents.contains(mevent)) state.removeAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_internaleventtypes, mevent); } }
/** * Remove a condition. * @param type The condition. */ public static void removeCondition(IOAVState state, Object scope, String type, Object wa) { if(wa!=null) { Collection mconds = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_conditiontypes); Object[] rscope = AgentRules.resolveCapability(type, OAVBDIMetaModel.condition_type, scope, state); Object mcapa = state.getAttributeValue(rscope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_conditions, rscope[0])) throw new RuntimeException("Unknown condition: "+type); Object mcond = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_conditions, rscope[0]); if(mconds!=null && mconds.contains(mcond)) state.removeAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_conditiontypes, mconds); } }
/** * */ public static void removeMessageEvent(IOAVState state, Object scope, String type, Object wa) { if(wa!=null) { Collection mevents = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_messageeventtypes); Object[] rscope = AgentRules.resolveCapability(type, OAVBDIMetaModel.messageevent_type, scope, state); Object mcapa = state.getAttributeValue(rscope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_messageevents, rscope[0])) throw new RuntimeException("Unknown message event: "+type); Object mevent = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_messageevents, rscope[0]); if(mevents!=null && mevents.contains(mevent)) state.removeAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_messageeventtypes, mevent); } }
/** * Add a goal type to an OAV waitabstraction. */ public static void addGoal(Object wa, String type, IOAVState state, Object rcapa) { Collection mgoals = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_goalfinisheds); Object[] scope = AgentRules.resolveCapability(type, OAVBDIMetaModel.goal_type, rcapa, state); Object mcapa = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.element_has_model); if(!state.containsKey(mcapa, OAVBDIMetaModel.capability_has_goals, scope[0])) throw new RuntimeException("Unknown goal: "+type); Object mgoal = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_goals, scope[0]); if(mgoals==null || !mgoals.contains(mgoal)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_goalfinisheds, mgoal); BDIInterpreter.getInterpreter(state).getEventReificator().addObservedElement(mgoal); }
public void run() { Collection vals = null; if(!hasHandle() && getState().containsKey(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)) { setHandle(getState().getAttributeValue(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)); } if(hasHandle()) { vals = getState().getAttributeValues(getHandle(), OAVBDIRuntimeModel.parameterset_has_values); } Object[] ret = (Object[])Array.newInstance(resolveClazz(), vals!=null ? vals.size() : 0); oarray = vals!=null ? vals.toArray(ret) : ret; } };
/** * Add a fact added event to an OAV waitabstraction. */ public static void addFactAdded(Object wa, String type, IOAVState state, Object rcapa) { Object[] scope = AgentRules.resolveCapability(type, OAVBDIMetaModel.beliefset_type, rcapa, state); Object rbel; Object mcapa = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.element_has_model); if(state.containsKey(mcapa, OAVBDIMetaModel.capability_has_beliefsets, scope[0])) { Object mbel = state.getAttributeValue(mcapa, OAVBDIMetaModel.capability_has_beliefsets, scope[0]); rbel = state.getAttributeValue(scope[1], OAVBDIRuntimeModel.capability_has_beliefsets, mbel); } else throw new RuntimeException("Unknown beliefset: "+type); Collection rbels = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_factaddeds); if(rbels==null || !rbels.contains(rbel)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_factaddeds, rbel); BDIInterpreter.getInterpreter(state).getEventReificator().addObservedElement(rbel); }
public void run() { if(!hasHandle() && getState().containsKey(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)) { setHandle(getState().getAttributeValue(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)); } String direction = resolveDirection(); if(OAVBDIMetaModel.PARAMETER_DIRECTION_FIXED.equals(direction) || OAVBDIMetaModel.PARAMETER_DIRECTION_IN.equals(direction) && ParameterFlyweight.inprocess(getState(), pe, getScope()) || OAVBDIMetaModel.PARAMETER_DIRECTION_OUT.equals(direction) && !ParameterFlyweight.inprocess(getState(), pe, getScope())) throw new RuntimeException("Write access not allowed to parameter set: " +direction+" "+getName()); if(!hasHandle()) throw new RuntimeException("Value not contained: "+value); BeliefRules.removeParameterSetValue(getState(), getHandle(), value); } };
public void run() { integer = 0; if(!hasHandle() && getState().containsKey(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)) { setHandle(getState().getAttributeValue(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)); } if(hasHandle()) { Collection coll = getState().getAttributeValues(getHandle(), OAVBDIRuntimeModel.parameterset_has_values); if(coll!=null) integer = coll.size(); } } };
public void run() { if(!hasHandle() && getState().containsKey(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)) { setHandle(getState().getAttributeValue(pe, OAVBDIRuntimeModel.parameterelement_has_parametersets, name)); } Collection vals = null; Object newval = value; if(hasHandle()) { // Class clazz = (Class)getState().getAttributeValue(getHandle(), OAVBDIMetaModel.typedelement_has_class); newval = SReflect.convertWrappedValue(value, resolveClazz()); vals = getState().getAttributeValues(getHandle(), OAVBDIRuntimeModel.parameterset_has_values); } bool = vals!=null && vals.contains(newval); } };
public void run() { if(!hasHandle() && getState().containsKey(parameterelement, OAVBDIRuntimeModel.parameterelement_has_parameters, name)) { setHandle(getState().getAttributeValue(parameterelement, OAVBDIRuntimeModel.parameterelement_has_parameters, name)); } if(hasHandle()) { object = getState().getAttributeValue(getHandle(), OAVBDIRuntimeModel.parameter_has_value); } } };