/** * Test if two activations are equal. * @param o The object to test. */ public boolean equals(Object o) { if(o==this) return true; boolean ret = false; if(o instanceof Activation) { Activation act = (Activation)o; ret = rule.equals(act.getRule()) && values.equals(act.values); } return ret; }
/** * Remove an activation * @param act The activation. */ public void removeActivation(Activation act) { this.activations.remove(act); if(act.equals(next)) next = null; state++; notifyListeners(); }
/** * Fire one activated rule. */ public void fireRule() { last = getNextActivation(); if(last!=null) { if(history!=null) history.add(last.toString()); // System.err.println("++++++++ executing: "+last); // if(last.toString().indexOf("listener_belief_changed")!=-1) // System.out.println("hhhhh"); last.execute(); // Hack!!! Shouldn't remove executed activations? removeActivation(last); } }
agenda.removeActivation(new Activation(rule, oldass, state)); agenda.addActivation(new Activation(rule, newass, state));
public int compare(Object arg0, Object arg1) { Activation act0 = (Activation)arg0; Activation act1 = (Activation)arg1; // if(act0==null || act1==null) // System.out.println("test"); int ret = act0.getPriority()-act1.getPriority(); if(ret==0) { Long tmp0 = (Long)counts.get(act0); Long tmp1 = (Long)counts.get(act1); long cnt0 = tmp0==null? 0: tmp0.longValue(); long cnt1 = tmp1==null? 0: tmp1.longValue(); // FIFO ret = (int)(cnt1-cnt0); } return ret; } });
agenda.removeActivation(new Activation(rule, oldass, state)); agenda.addActivation(new Activation(rule, newass, state));
public int compare(Object arg0, Object arg1) { Activation act0 = (Activation)arg0; Activation act1 = (Activation)arg1; // if(act0==null || act1==null) // System.out.println("test"); int ret = act0.getPriority()-act1.getPriority(); if(ret==0) { Long tmp0 = (Long)counts.get(act0); Long tmp1 = (Long)counts.get(act1); long cnt0 = tmp0==null? 0: tmp0.longValue(); long cnt1 = tmp1==null? 0: tmp1.longValue(); // FIFO ret = (int)(cnt1-cnt0); } return ret; } });
/** * Test if two activations are equal. * @param o The object to test. */ public boolean equals(Object o) { if(o==this) return true; boolean ret = false; if(o instanceof Activation) { Activation act = (Activation)o; ret = rule.equals(act.getRule()) && values.equals(act.values); } return ret; }
/** * Fire one activated rule. */ public void fireRule() { last = getNextActivation(); if(last!=null) { if(history!=null) history.add(last.toString()); // System.err.println("++++++++ executing: "+last); // if(last.toString().indexOf("listener_belief_changed")!=-1) // System.out.println("hhhhh"); last.execute(); // Hack!!! Shouldn't remove executed activations? removeActivation(last); } }
/** * Send an tuple to this node. * @param tuple The tuple. */ public void addTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Add Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); // Store variable assignments. Map nodemem = (Map)mem.getNodeMemory(this); Map vars = new HashMap(); for(Iterator it=extractors.keySet().iterator(); it.hasNext(); ) { Object variable = it.next(); vars.put(variable, ((IValueExtractor)extractors.get(variable)).getValue(tuple, null, null, state)); } ReteVariableAssignments assignments = new ReteVariableAssignments(vars, rule); nodemem.put(tuple, assignments); // Create activation for tuple. // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.addActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove an activation * @param act The activation. */ public void removeActivation(Activation act) { this.activations.remove(act); if(act.equals(next)) next = null; state++; notifyListeners(); }
/** * Execute the activation. */ public void execute() { getRule().getAction().execute(state, values); }
/** * Send an tuple to this node. * @param tuple The tuple. */ public void addTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Add Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); // Store variable assignments. Map nodemem = (Map)mem.getNodeMemory(this); Map vars = new HashMap(); for(Iterator it=extractors.keySet().iterator(); it.hasNext(); ) { Object variable = it.next(); vars.put(variable, ((IValueExtractor)extractors.get(variable)).getValue(tuple, null, null, state)); } ReteVariableAssignments assignments = new ReteVariableAssignments(vars, rule); nodemem.put(tuple, assignments); // Create activation for tuple. // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.addActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove an activation * @param act The activation. */ public void removeActivation(Activation act) { this.activations.remove(act); if(act.equals(next)) next = null; state++; notifyListeners(); }
/** * Execute the activation. */ public void execute() { getRule().getAction().execute(state, values); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Remove Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); // Get old assignments. Map nodemem = (Map)mem.getNodeMemory(this); ReteVariableAssignments assignments = (ReteVariableAssignments)nodemem.remove(tuple); // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.removeActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove an activation * @param act The activation. */ public void removeActivation(Activation act) { this.activations.remove(act); if(act.equals(next)) next = null; state++; notifyListeners(); }
public void actionPerformed(ActionEvent e) { if(followact.isSelected()) { Activation act = system.getAgenda().getNextActivation(); if(act!=null && followact.isSelected()) { rulebasepanel.setSelectedBreakpoints(new String[]{act.getRule().getName()}); } } else { rulebasepanel.setSelectedBreakpoints(new String[0]); } } });
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Remove Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); // Get old assignments. Map nodemem = (Map)mem.getNodeMemory(this); ReteVariableAssignments assignments = (ReteVariableAssignments)nodemem.remove(tuple); // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.removeActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Test if the component's execution is currently at one of the * given breakpoints. If yes, the component will be suspended by * the platform. * @param breakpoints An array of breakpoints. * @return True, when some breakpoint is triggered. */ public boolean isAtBreakpoint(String[] breakpoints) { // assert isAgentThread(); assert !getAgentAdapter().isExternalThread(); boolean isatbreakpoint = false; Object cs = state.getAttributeValue(ragent, OAVBDIRuntimeModel.agent_has_state); if(cs!=null && !OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_TERMINATED.equals(cs)) { Set bps = new HashSet(Arrays.asList(breakpoints)); // Todo: cache set across invocations for speed? Iterator it = getRuleSystem().getAgenda().getActivations().iterator(); while(!isatbreakpoint && it.hasNext()) { IRule rule = ((Activation)it.next()).getRule(); isatbreakpoint = bps.contains(rule.getName()); } } // else still in init return isatbreakpoint; }