Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ProcessingContextStep PopStep()
        {
            ProcessingContextStep step = null;

            if (CurrentProcessingContext.m_NextExecutions.Count > 0)
            {
                step = CurrentProcessingContext.m_NextExecutions[0];
                CurrentProcessingContext.m_NextExecutions.RemoveAt(0);
                CurrentProcessingContext.m_Executed.Add(step);
            }
            else
            {
                if (CurrentProcessingContext.Finished != null)
                {
                    CurrentProcessingContext.Finished(CurrentProcessingContext, EventArgs.Empty);
                }

                if (CurrentProcessingContext.Parent != null)
                {
                    ProcessingContext c = CurrentProcessingContext;
                    CurrentProcessingContext.Parent.Child = null;
                    // Call Parent.PopStep() else the execution will stop because step is null
                    step = c.Parent.PopStep();
                }
            }

            return(step);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node_"></param>
        public ProcessingContextStep RegisterNextExecution(NodeSlot slot_)
        {
            if (slot_.Node is ActionNode == false)
            {
                throw new InvalidOperationException("ProcessingContext.RegisterNextExecution() : the node is not an ActionNode");
            }

            ProcessingContextStep step = new ProcessingContextStep(SequenceBase, CurrentFrame, slot_);

            CurrentProcessingContext.m_NextExecutions.Add(step);
            return(step);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        private void ProcessLoop(bool sleep_ = true)
        {
            bool processing = true;

            while (processing == true &&
                   m_MustStop == false)
            {
                if (m_IsOnPause == false)
                {
                    processing = DoOneStep();

                    if (processing == true)
                    {
                        State = SequenceState.Running;
                    }
                }
                else if (m_UpdateOnlyOneStep == true)
                {
                    m_UpdateOnlyOneStep = false;
                    processing          = DoOneStep();

                    if (processing == true)
                    {
                        State = SequenceState.Pause;
                    }
                }

                if (sleep_ == true)
                {
                    // Do sleep else all WPF bindings will block the UI thread
                    // 5ms else the UI is not enough responsive
                    System.Threading.Thread.Sleep(5);
                }
            }
            ;

            State           = SequenceState.Stop;
            m_LastExecution = null;

            foreach (ProcessingContext c in m_CallStacks)
            {
                c.SequenceBase.ResetNodes();
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns>true if there is at least one node to be activated else returns false</returns>
        public bool DoOneStep()
        {
            if (GetNumberOfActiveProcess() > 0)
            {
                if (State == SequenceState.Pause)
                {
                    if (m_LastExecution != null)
                    {
                        m_LastExecution.Slot.Node.IsProcessing = false;
                    }
                }

                ProcessingContext     context     = m_CallStacks[m_CurrentCallStackIndex];
                ProcessingContextStep contextStep = context.PopStep();

                if (contextStep == null)
                {
                    m_CallStacks.Remove(context);
                    context.SequenceBase.ResetNodes();
                }
                else
                {
                    ActionNode node = contextStep.Slot.Node as ActionNode;
                    m_LastExecution = contextStep;

                    ActionNode.ProcessingInfo info = node.Activate(context, contextStep.Slot);
                    node.ErrorMessage = info.ErrorMessage;

                    if (info.State == ActionNode.LogicState.Error)
                    {
                        context.IsOnError = true;
                    }

                    if (State == SequenceState.Pause)
                    {
                        m_LastExecution.Slot.Node.IsProcessing = true;
                    }
                }
            }

            return(SetNextProcess());
        }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context_"></param>
 /// <param name="step_"></param>
 public void RemoveExecution(ProcessingContext context_, ProcessingContextStep step_)
 {
     context_.m_NextExecutions.Remove(step_);
 }