public void CanRegisterAnInterrupter() { var executor = new BTExecutor(new ModelSuccess(null)); var modelInterrupter = new ModelInterrupter(null, new ModelSuccess(null)); executor.RegisterInterrupter((ExecutionInterrupter)modelInterrupter.CreateExecutor(executor, null)); Assert.NotNull(executor.GetExecutionInterrupter(modelInterrupter)); }
public void TicksTheInterruptBranchTheSpecifiedNumberOfTimes() { var model = new ModelInterrupter(null, new ModelSuccess(null) { Interrupter = new InterrupterBranchTask(null) }) { NumInterrupterBranchTicks = 10 }; var context = new BasicContext(); var executor = new ExecutionInterrupter(model, new BTExecutor(model, context), null); executor.Spawn(context); executor.Interrupt(Status.Success); Assert.AreEqual(10, TestInterrupterExecutor.RecordedTicks); }
/** * Returns the ExecutionInterrupter that is currently active and registered in the BTExecutor ( * {@link #registerInterrupter(ExecutionInterrupter)}) whose associated ModelInterrupter is * <code>modelInterrupter</code>. Returns null if there is no such an ExecutionInterrupter. * * @param modelInterrupter * the ModelInterrupter associated to the ExecutionInterrupter to retrieve. * @return the ExecutionInterrupter whose associated ModelInterrupter is * <code>modelInterrupter</code>. */ public ExecutionInterrupter GetExecutionInterrupter(ModelInterrupter modelInterrupter) { return(_interrupters.ContainsKey(modelInterrupter) ? _interrupters[modelInterrupter] : null); }
///Creates an ExecutionInterrupter that is able to run a ModelInterrupter ///task and that is managed by a BTExecutor. /// ///@param modelTask the ModelInterrupter that this ExecutionInterrupter is going to run. ///@param executor the BTExecutor in charge of running this ExecutionInterrupter. ///@param parent the parent ExecutionTask of this task. public ExecutionInterrupter(ModelInterrupter modelTask, IBTExecutor executor, ExecutionTask parent) : base(modelTask, executor, parent) { _interrupted = false; }