/** * Create and register an event reificator. */ public EventReificator(IOAVState state, Object agent) { this.state = state; this.agent = agent; this.observed = new HashMap(); state.addStateListener(this, false); }
public void execute(IOAVState state, IVariableAssignments assignments) { Object fn = assignments.getVariableValue("?fn"); int fncnt = ((Integer)state.getAttributeValue(fn, fibo_has_sequence)).intValue(); System.out.println("recurse for "+fncnt); Object fm = state.createRootObject(fibo_type); state.setAttributeValue(fm, fibo_has_value, Long.valueOf(-1)); state.setAttributeValue(fm, fibo_has_sequence, Integer.valueOf(fncnt-1)); } }, IPriorityEvaluator.PRIORITY_1));
/** * Add an external condition to an OAV waitabstraction. */ public static void addExternalCondition(Object wa, IExternalCondition condition, IOAVState state, Object rcapa) { Collection conditions = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_externalconditions); if(conditions==null || !conditions.contains(condition)) state.addAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_externalconditions, condition); }
/** * Remove an external condition. * @param condition The condition. */ public static void removeExternalCondition(IOAVState state, IExternalCondition condition, Object wa) { if(wa!=null) { Collection conditions = state.getAttributeValues(wa, OAVBDIRuntimeModel.waitabstraction_has_externalconditions); if(conditions!=null && conditions.contains(condition)) state.removeAttributeValue(wa, OAVBDIRuntimeModel.waitabstraction_has_externalconditions, condition); } }
/** * */ public static boolean containsFact(IOAVState state, Object handle, Object fact) { // Convert wrapped basic values to desired class (e.g. Integer to Long). Object mbel = state.getAttributeValue(handle, OAVBDIRuntimeModel.element_has_model); Class clazz = (Class)state.getAttributeValue(mbel, OAVBDIMetaModel.typedelement_has_class); Object newfact = SReflect.convertWrappedValue(fact, clazz); Collection coll = state.getAttributeValues(handle, OAVBDIRuntimeModel.beliefset_has_facts); return coll!=null && coll.contains(newfact); }
public void run() { Object caparef = getState().createObject(OAVBDIMetaModel.capabilityref_type); getState().setAttributeValue(caparef, OAVBDIMetaModel.modelelement_has_name, name); getState().setAttributeValue(caparef, OAVBDIMetaModel.capabilityref_has_file, file); getState().addAttributeValue(getHandle(), OAVBDIMetaModel.capability_has_capabilityrefs, caparef); } };
/** * Initialize the state with the given number of discs. */ protected static Object initState(int discs, IOAVState state, boolean showtowers) { // Setup Object agent = state.createRootObject(agent_type); for(int i=discs; i>0; i--) { Object disc = state.createObject(disc_type); state.setAttributeValue(disc, disc_has_size, Integer.valueOf(i)); state.addAttributeValue(agent, agent_has_tower_a, disc); } // Show Hanoi towers in JFrame. if(showtowers) showFrame(state, agent); return agent; }
OAVAttributeType to, OAVAttributeType temp, int num, RuleSystem rete, boolean showrete) Object rootgoal = state.createObject(movegoal_type); state.setAttributeValue(rootgoal, movegoal_has_from, from); state.setAttributeValue(rootgoal, movegoal_has_to, to); state.setAttributeValue(rootgoal, movegoal_has_temp, temp); state.setAttributeValue(rootgoal, movegoal_has_number, Integer.valueOf(num)); state.addAttributeValue(agent, agent_has_movegoals, rootgoal); state.notifyEventListeners(); state.expungeStaleObjects(); state.notifyEventListeners();
this.copy = state.isJavaIdentity() ? (Map)new IdentityHashMap() : new HashMap(); this.rootobjects = state.isJavaIdentity() ? (Set)new IdentityHashSet() : new HashSet(); setSynchronizator(synchronizator); this.tmodel = state.getTypeModel(); for(Iterator it=state.getDeepObjects(); it.hasNext(); ) OAVObjectType type = state.getType(id); if(!(type instanceof OAVJavaType)) for(Iterator it=state.getRootObjects(); it.hasNext(); ) state.addStateListener(listener , false);
Object b1 = state.createRootObject(block_type); Object b2 = state.createRootObject(block_type); Object b3 = state.createRootObject(block_type); Object b4 = state.createRootObject(block_type); Object b5 = state.createRootObject(block_type); state.setAttributeValue(b1, block_has_name, "B1"); state.setAttributeValue(b1, block_has_color, "red"); state.addAttributeValue(b1, block_has_on, b2); state.addAttributeValue(b1, block_has_on, b3); state.addAttributeValue(b1, block_has_on, b4); state.addAttributeValue(b1, block_has_left, b5); state.setAttributeValue(b2, block_has_name, "B2"); state.setAttributeValue(b2, block_has_color, "green"); state.addAttributeValue(b2, block_has_on, b3); state.addAttributeValue(b2, block_has_on, b4); state.addAttributeValue(b2, block_has_left, b5); state.setAttributeValue(b3, block_has_name, "B3"); state.setAttributeValue(b3, block_has_color, "blue"); state.addAttributeValue(b3, block_has_on, b4); state.addAttributeValue(b3, block_has_left, b5); state.setAttributeValue(b4, block_has_name, "B4"); state.setAttributeValue(b4, block_has_color, "yellow"); state.addAttributeValue(b4, block_has_left, b5); state.setAttributeValue(b5, block_has_name, "B5");
Collection mparamsets = state.getAttributeValues(mpe, OAVBDIMetaModel.parameterelement_has_parametersets); if(mparamsets!=null) Object evamode = state.getAttributeValue(mparamset, OAVBDIMetaModel.typedelement_has_evaluationmode); if(OAVBDIMetaModel.EVALUATIONMODE_PUSH.equals(evamode)) Object values = state.getAttributeValue(mparamset, OAVBDIMetaModel.parameterset_has_valuesexpression); if(values!=null) String varname = (String)state.getAttributeValue(values, OAVBDIMetaModel.expression_has_variable); if(varname!=null) Class clazz = (Class)state.getAttributeValue(mparamset, OAVBDIMetaModel.typedelement_has_class); var = new Variable(varname, state.getTypeModel().getJavaType(clazz)); String ptname = (String)state.getAttributeValue(mparamset, OAVBDIMetaModel.modelelement_has_name); String rulename = Rulebase.getUniqueRuleName(rb, "parameterset_dynamicvalues_"+state.getAttributeValue(mpe, OAVBDIMetaModel.modelelement_has_name)+"_"+ptname); Object[] tmp = BeliefRules.createDynamicParameterSetUserRule(mpe, ptname, var); createUserRule(model, rb, imports, mpe, values, rulename, tmp);
public void execute(IOAVState state, IVariableAssignments assignments) { Integer id = (Integer)assignments.getVariableValue("?id"); String n1 = (String)assignments.getVariableValue("?n1"); Integer s = (Integer)assignments.getVariableValue("?s"); if(Manners.print) System.out.println("Make path: "+id+" "+n1+" "+s); Object path = state.createRootObject(Manners.path_type); state.setAttributeValue(path, Manners.path_has_id, id); state.setAttributeValue(path, Manners.path_has_name, n1); state.setAttributeValue(path, Manners.path_has_seat, s); } };
/** * Get the string representation. * @return The string representation. */ public String toString() { String name = (String)state.getAttributeValue(handle, OAVBDIMetaModel.modelelement_has_name); return "OAVCapabilityModel("+name+")"; }
/** * Initialize the pattern matcher. * Called before the agenda is accessed * to perform any initialization, if necessary. */ public void init() { // Initialize initial fact node, if any. if(node.getInitialFactNode()!=null) node.getInitialFactNode().init(state, retemem, agenda); // Add initial objects. for(Iterator objects=state.getDeepObjects(); objects.hasNext(); ) { Object object = objects.next(); objectAdded(object, state.getType(object), false); // Hack!!! Should check if root? } state.addStateListener(this, true); // state.addStateListener(this, false); }
ret = root? state.createRootObject((OAVObjectType)type): state.createObject((OAVObjectType)type); OAVObjectType oavtype = state.getTypeModel().getObjectType(tag.getLocalPart()); if(oavtype!=null) ret = root? state.createRootObject(oavtype): state.createObject(oavtype);
/** * Fire all rules until quiescence. */ public void fireAllRules() { IAgenda agenda = getAgenda(); state.notifyEventListeners(); do { agenda.fireRule(); state.expungeStaleObjects(); state.notifyEventListeners(); } while(!agenda.isEmpty()); }
public void run() { Object plan = getState().getAttributeValue(getHandle(), OAVBDIRuntimeModel.mplancandidate_has_plan); if(plan==null) { Object mplan = getState().getAttributeValue(getHandle(), OAVBDIRuntimeModel.mplancandidate_has_mplan); Collection bindings = getState().getAttributeValues(getHandle(), OAVBDIRuntimeModel.mplancandidate_has_bindings); plan = PlanRules.instantiatePlan(getState(), getScope(), mplan, null, rpe, bindings, null, null); getState().setAttributeValue(getHandle(), OAVBDIRuntimeModel.mplancandidate_has_plan, plan); } object = PlanFlyweight.getPlanFlyweight(getState(), getScope(), plan); } };
/** * Load class. */ public Object postProcess(IContext context, Object object) { Map ouc = (Map)context.getUserContext(); IOAVState state = (IOAVState)ouc.get(OAVObjectReaderHandler.CONTEXT_STATE); String value = (String)state.getAttributeValue(object, classnameattr); if(value!=null) { try { Class clazz = SReflect.findClass(value, ((IModelInfo)context.getRootObject()).getAllImports(), state.getTypeModel().getClassLoader()); state.setAttributeValue(object, classattr, clazz); } catch(Exception e) { reportError(context, e.toString()); } } return null; }
public void run() { Collection coll = getState().getAttributeValues(rplan, OAVBDIRuntimeModel.plan_has_waitqueueelements); integer = coll==null? 0: coll.size(); } };
/** * Get the object type * @param object The object. * @return The object type. */ public Object getObjectType(Object object, IContext context) { return ((IOAVState)context).getType(object); }