public static void RunInterrupterBranch(IBTExecutor executor, int numTicks)
 {
     var counter = 0;
     do
     {
         executor.Tick();
         counter++;
     } while (executor.GetStatus() == Status.Running && counter < numTicks);
 }
Ejemplo n.º 2
0
        public static void RunInterrupterBranch(IBTExecutor executor, int numTicks)
        {
            var counter = 0;

            do
            {
                executor.Tick();
                counter++;
            } while (executor.GetStatus() == Status.Running && counter < numTicks);
        }
Ejemplo n.º 3
0
        /**
         * This method ticks <code>executor</code> {@value #NUM_TICKS_LONG_TICK} times. If the executor
         * finishes earlier, it is not ticked anymore, and the ticking process stops.
         *
         * @param executor
         *            the IBTExecutor that is ticked.
         */

        private void longTick(IBTExecutor executor)
        {
            if (executor.GetStatus() == Status.Running || executor.GetStatus() == Status.Uninitialized)
            {
                int counter = 0;
                do
                {
                    executor.Tick();
                    counter++;
                } while (executor.GetStatus() == Status.Running && counter < NumTicksLongTick);
            }
        }
Ejemplo n.º 4
0
        /**
         * Evaluate all the guards that have not finished yet, that is, those whose
         * result in {@link #guardsResults} is {@link Status#RUNNING}, by ticking
         * them.
         * <p>
         * If all the guards have finished in failure, this method returns a Tuple
         * whose first element is {@link Status#FAILURE}. If there is at least one
         * guard still being evaluated, the first element of the Tuple contains
         * {@link Status#RUNNING}. If all the guards have been evaluated and at
         * least one has succeeded, the first element of the Tuple is
         * {@link Status#SUCCESS}, and the second one is the index, over the list of
         * guards ({@link #guardsExecutors}) , of the first guard (that with the
         * highest priority) that has succeeded.
         *
         */

        private Tuple <Status, int> evaluateGuards()
        {
            bool oneRunning = false;

            /* First, evaluate all the guards that have not finished yet. */
            for (int i = 0; i < _guardsExecutors.Count; i++)
            {
                IBTExecutor guardExecutor = _guardsExecutors[i];
                if (guardExecutor != null)
                {
                    if (guardsResults[i] == Status.Running)
                    {
                        guardExecutor.Tick();
                        guardsResults[i] = guardExecutor.GetStatus();
                        if (guardsResults[i] == Status.Running)
                        {
                            oneRunning = true;
                        }
                    }
                }
            }

            /* If there is at least one still running... */
            if (oneRunning)
            {
                return(new Tuple <Status, int>(Status.Running, -1));
            }

            /* If all of them have finished we check which one succeeded first. */
            for (int i = 0; i < guardsResults.Count; i++)
            {
                if (guardsResults[i] == Status.Success)
                {
                    return(new Tuple <Status, int>(Status.Success, i));
                }
            }

            /* Otherwise, the evaluation has failed. */
            return(new Tuple <Status, int>(Status.Failure, -1));
        }
 /**
  * This method ticks <code>executor</code> {@value #NUM_TICKS_LONG_TICK} times. If the executor
  * finishes earlier, it is not ticked anymore, and the ticking process stops.
  *
  * @param executor
  *            the IBTExecutor that is ticked.
  */
 private void longTick(IBTExecutor executor)
 {
     if (executor.GetStatus() == Status.Running || executor.GetStatus() == Status.Uninitialized)
     {
         int counter = 0;
         do
         {
             executor.Tick();
             counter++;
         } while (executor.GetStatus() == Status.Running && counter < NumTicksLongTick);
     }
 }