@Override protected void executeOnEnded() throws CoreException { getNode().selectDefaultNextTarget(); }
@Override protected void executeOnStarted() throws CoreException { if(getNode().getExecution().getChildExecutions().isEmpty()) { //when the fastest child execution finished log.finest("End of exclusive behaviour."); this.state = State.ACTIVITY_ENDED; } }
@Override protected void executeOnInactive() throws CoreException { this.state = State.ACTIVITY_STARTED; alreadyNotified = false; if(triggeringNodes==null || triggeringNodes.isEmpty()) { this.state = State.ACTIVITY_ENDED; return; } try{ SCAHelper.getSCAHelper().startComponentAndSubComponents(getNode().getExecution().getParentScope().getComponent()); } catch(SCAException e) { throw new CoreException(e); } List<Node> nodes = new ArrayList<Node>(); for(Node child : getNode().getChildNodes()) { for(Node triggeringNode : triggeringNodes) { if(triggeringNode.getName().equals(child.getName())) { nodes.add(child); break; } } } getNode().getExecution().setNextExecutableElements(this, nodes); }
@Override public synchronized void onChildBehaviourNotification(Behaviour childBehaviour) throws CoreException { if(alreadyNotified) { return; } alreadyNotified = true; log.finest("Notification received from "+childBehaviour.getName()); //cancel all the other child executions String execName = childBehaviour.getNode().getExecution().getName(); for(Execution childExec : getNode().getExecution().getChildExecutions()) { if(!execName.equals(childExec.getName())) { log.finest(childExec.getName()+" has been cancelled"); childExec.setState(Execution.State.CANCELLED); getNode().getExecution().removeChildExecution(childExec); } } }