// OLD - use Default RP instead? ///// <summary> ///// If null, throw an exception when trying to run a child with no IHasStatusRecurranceParameters ///// </summary> //TimeSpan? DefaultInterval = null; protected override void OnChildStatusChanged(IBehavior child, BehaviorStatus oldStatus, BehaviorStatus newStatus) { if (child.IsFinished) { var finishedChildrenCopy = finishedChildren; if (finishedChildrenCopy != null) { finishedChildrenCopy.Add(child); } this.children.Remove(child); #if LOG_TASK_FINISHED l.Info("Task finished: " + child.ToString()); #endif } switch (newStatus) { case BehaviorStatus.Uninitialized: break; case BehaviorStatus.Initialized: break; case BehaviorStatus.Running: break; case BehaviorStatus.Failed: break; case BehaviorStatus.Succeeded: break; case BehaviorStatus.Disposed: break; default: break; } }
protected override void OnSelectedStatusChangedForTo(IBehavior child, BehaviorStatus oldStatus, BehaviorStatus status) { #if SanityChecks if (child != SelectedChild) { l.Warn("child != SelectedChild"); return; } #endif switch (status) { //case BehaviorStatus.Uninitialized: // break; //case BehaviorStatus.Initialized: // break; case BehaviorStatus.Running: // It is running as expected break; case BehaviorStatus.Failed: Fail(child.StatusMessage); break; case BehaviorStatus.Succeeded: if (Advance() == BehaviorStatus.Succeeded) { Succeed(); } break; //case BehaviorStatus.Disposed: // break; default: l.Warn("UNEXPECTED Sequencer child state: " + child.ToString()); break; } }
/// <summary> /// Potential fof /// </summary> /// <param name="behavior"></param> /// <param name="oldStatus"></param> /// <param name="status"></param> /// <remarks> /// Potential alternative behavior in derived classes: /// - if one fails, try another until one succeeds /// - run all children in order (until one fails, or all succeed) /// - use max completions, max failures, max successes parameters /// </remarks> protected override void OnSelectedStatusChangedForTo(IBehavior behavior, BehaviorStatus oldStatus, BehaviorStatus status) { #if SanityChecks if (behavior != SelectedChild) return; #endif switch (status) { //case BehaviorStatus.Uninitialized: // break; case BehaviorStatus.Initialized: // Do nothing -- we just selected it break; case BehaviorStatus.Running: // Do nothing -- we just started it break; case BehaviorStatus.Failed: Fail(behavior.StatusMessage); break; case BehaviorStatus.Succeeded: Succeed(); break; //case BehaviorStatus.Disposed: // break; default: l.Trace("UNEXPECTED Status for Selector.SelectedChild: " + behavior.ToString()); break; } }