/** * End an atomic transaction. * Side-effects (i.e. triggered conditions) * of all internal changes (e.g. belief changes) * performed after the last call to startAtomic() * will now be evaluated and performed. * @see #startAtomic() */ public void endAtomic() { interpreter.endAtomic(); interpreter.endMonitorConsequences(); }
/** * Kill this agent. */ public void killAgent() { // capability.killAgent(); // Problem: duplicate functionality here and in capability flyweight :-( // state.setAttributeValue(ragent, OAVBDIRuntimeModel.agent_has_state, // OAVBDIRuntimeModel.AGENTLIFECYCLESTATE_TERMINATING); interpreter.startMonitorConsequences(); getInterpreter().killComponent(); interpreter.endMonitorConsequences(); }
/** * Dispatch a new top-level goal. * @param goal The new goal. * Note: plan step is interrupted after call. */ public void dispatchTopLevelGoal(IGoal goal) { Object rgoal = ((GoalFlyweight)goal).getHandle(); interpreter.startMonitorConsequences(); GoalLifecycleRules.adoptGoal(state, ((GoalFlyweight)goal).getScope(), rgoal); interpreter.endMonitorConsequences(); }
/** * Dispatch an internal event. * @param event The event. * Note: plan step is interrupted after call. */ public void dispatchInternalEvent(IInternalEvent event) { Object revent = ((InternalEventFlyweight)event).getHandle(); Object rcapa = ((InternalEventFlyweight)event).getScope(); interpreter.startMonitorConsequences(); InternalEventRules.adoptInternalEvent(state, rcapa, revent); interpreter.endMonitorConsequences(); }
/** * Send a message after some delay. * @param me The message event. * @return The filter to wait for an answer. */ public IFuture sendMessage(IMessageEvent me, byte[] codecids) { Object revent = ((MessageEventFlyweight)me).getHandle(); Object rcapa = ((MessageEventFlyweight)me).getScope(); interpreter.startMonitorConsequences(); IFuture ret = MessageEventRules.sendMessage(state, rcapa, revent, codecids); interpreter.endMonitorConsequences(); return ret; }
/** * Dispatch a new subgoal. * @param subgoal The new subgoal. * Note: plan step is interrupted after call. */ public void dispatchSubgoal(IGoal subgoal) { Object rgoal = ((GoalFlyweight)subgoal).getHandle(); Object scope = ((GoalFlyweight)subgoal).getScope(); interpreter.startMonitorConsequences(); GoalLifecycleRules.adoptGoal(state, scope, rgoal); state.addAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_subgoals, rgoal); state.setAttributeValue(rgoal, OAVBDIRuntimeModel.goal_has_parentplan, rplan); // Protect goal, if necessary. Object planstate = state.getAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_lifecyclestate); Object reason = state.getAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_reason); boolean protectgoal = OAVBDIRuntimeModel.PLANLIFECYCLESTATE_PASSED.equals(planstate) || OAVBDIRuntimeModel.PLANLIFECYCLESTATE_FAILED.equals(planstate) || OAVBDIRuntimeModel.PLANLIFECYCLESTATE_ABORTED.equals(planstate); if(!protectgoal && reason!=null && state.getType(reason).isSubtype(OAVBDIRuntimeModel.goal_type)) { protectgoal = ((Boolean)state.getAttributeValue(reason, OAVBDIRuntimeModel.goal_has_protected)).booleanValue(); } if(protectgoal) { state.setAttributeValue(rgoal, OAVBDIRuntimeModel.goal_has_protected, Boolean.TRUE); } interpreter.endMonitorConsequences(); }
getInterpreter().endMonitorConsequences();
/** * Drop this goal. * Causes all associated process goals * and subgoals to be dropped. */ public void drop() { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { GoalLifecycleRules.dropGoal(getState(), getHandle()); } }; } else { getInterpreter().startMonitorConsequences(); GoalLifecycleRules.dropGoal(getState(), getHandle()); getInterpreter().endMonitorConsequences(); } }
/** * Remove a fact to a belief. * @param fact The new fact. */ public void removeFact(final Object fact) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { SFlyweightFunctionality.removeFact(getState(), getHandle(), fact, getScope()); } }; } else { getInterpreter().startMonitorConsequences(); SFlyweightFunctionality.removeFact(getState(), getHandle(), fact, getScope()); getInterpreter().endMonitorConsequences(); } }
/** * Dispatch a new top-level goal. * @param goal The new goal. */ public void dispatchTopLevelGoal(final IGoal goal) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { GoalLifecycleRules.adoptGoal(getState(), ((ElementFlyweight)goal).getScope(), ((ElementFlyweight)goal).getHandle()); } }; } else { getInterpreter().startMonitorConsequences(); GoalLifecycleRules.adoptGoal(getState(), ((ElementFlyweight)goal).getScope(), ((ElementFlyweight)goal).getHandle()); getInterpreter().endMonitorConsequences(); } }
getInterpreter().endMonitorConsequences();
/** * Dispatch an event. * @param event The event. */ // changed signature for javaflow, removed final public void dispatchInternalEvent(IInternalEvent event) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation(event) { public void run() { InternalEventRules.adoptInternalEvent(getState(), getScope(), ((InternalEventFlyweight)arg).getHandle()); } }; } else { getInterpreter().startMonitorConsequences(); InternalEventRules.adoptInternalEvent(getState(), getScope(), ((InternalEventFlyweight)event).getHandle()); getInterpreter().endMonitorConsequences(); } }
/** * Set a fact of a belief. * @param fact The new fact. */ public void setFact(final Object fact) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { SFlyweightFunctionality.setFact(getState(), getHandle(), fact, getScope()); } }; } else { getInterpreter().startMonitorConsequences(); SFlyweightFunctionality.setFact(getState(), getHandle(), fact, getScope()); getInterpreter().endMonitorConsequences(); } }
/** * Indicate that the fact of this belief was modified. * Calling this method causes an internal fact changed * event that might cause dependent actions. */ public void modified() { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { SFlyweightFunctionality.modified(getState(), getHandle(), getInterpreter()); } }; } else { getInterpreter().startMonitorConsequences(); SFlyweightFunctionality.modified(getState(), getHandle(), getInterpreter()); getInterpreter().endMonitorConsequences(); } }
/** * Add a fact to a belief. * @param fact The new fact. */ public void addFact(final Object fact) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { BeliefRules.addBeliefSetValue(getState(), getHandle(), fact, getScope()); } }; } else { getInterpreter().startMonitorConsequences(); BeliefRules.addBeliefSetValue(getState(), getHandle(), fact, getScope()); getInterpreter().endMonitorConsequences(); } }
/** * Add facts to a parameter set. * @param facts The facts. */ public void addFacts(final Object[] facts) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { SFlyweightFunctionality.addFacts(getState(), getHandle(), facts, getScope()); } }; } else { getInterpreter().startMonitorConsequences(); SFlyweightFunctionality.addFacts(getState(), getHandle(), facts, getScope()); getInterpreter().endMonitorConsequences(); } }
/** * Update a fact to a new fact. Searches the old * value with equals, removes it and stores the new fact. * @param newfact The new fact. */ public void updateFact(final Object newfact) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { SFlyweightFunctionality.updateFact(getState(), getHandle(), newfact, getScope()); } }; } else { getInterpreter().startMonitorConsequences(); SFlyweightFunctionality.updateFact(getState(), getHandle(), newfact, getScope()); getInterpreter().endMonitorConsequences(); } }
/** * Indicate that a fact of this belief set was modified. * Calling this method causes an internal facts changed * event that might cause dependent actions. */ public void modified(final Object fact) { if(getInterpreter().getComponentAdapter().isExternalThread()) { new AgentInvocation() { public void run() { getInterpreter().getEventReificator().objectModified(getHandle(), getState().getType(getHandle()), OAVBDIRuntimeModel.beliefset_has_facts, fact, fact); } }; } else { getInterpreter().startMonitorConsequences(); getInterpreter().getEventReificator().objectModified(getHandle(), getState().getType(getHandle()), OAVBDIRuntimeModel.beliefset_has_facts, fact, fact); getInterpreter().endMonitorConsequences(); } }
getInterpreter().endMonitorConsequences();
getInterpreter().endMonitorConsequences();