예제 #1
0
 /// <summary>
 /// Rebuild this Flow Item
 /// </summary>
 public override void Rebuild()
 {
     lock (this)
     {
         validMethods.Clear();
         bool problem = false;
         if (HasChildren)
         {
             foreach (CompBase comp in ChildArray)
             {
                 SMMethod method = comp as SMMethod;
                 method.Rebuild();
                 if (method.IsValid)
                 {
                     validMethods.Add(method);
                 }
                 else
                 {
                     problem = true;
                 }
             }
         }
         HasProblem = problem;
         if (validMethods.Count == 0)
         {
             U.LogError("Need a valid method for '{0}'", Name);
         }
         waitHandles = new ManualResetEvent[validMethods.Count];
         for (int i = 0; i < validMethods.Count; i++)
         {
             waitHandles[i] = validMethods[i].waitHandle;
         }
         NeedsRebuild = false;
     }
 }
예제 #2
0
        /// <summary>
        /// Use ToString to get underlying content
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string text = string.Empty;

            text = "ID:" + this.Name + Environment.NewLine;
            if (HasChildren)
            {
                foreach (CompBase comp in ChildArray)
                {
                    SMMethod method = comp as SMMethod;
                    if (method.IsValid)
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            text += "\n";
                        }
                        text += comp.ToString();
                    }
                }
            }
            else
            {
                text = Name;
            }
            return(text);
        }
        /// <summary>
        /// Use ToString to get underlying content
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string text = string.Empty;

            text = "ID:" + this.Name + Environment.NewLine;
            if (HasMethod)
            {
                foreach (CompBase comp in ChildArray)
                {
                    SMMethod method = comp as SMMethod;
                    if (method.IsValid)
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            text += "\n";
                        }
                        text += comp.ToString();
                    }
                }
            }

            if (HasTransition)
            {
                text += "\n";
                text += "\n";
                foreach (SMTransition transition in TransitionList)
                {
                    text += "Goto " + transition.TransitionTargetID + Environment.NewLine;
                }
            }

            return(text);
        }
예제 #4
0
        /// <summary>
        /// Clone this component
        /// </summary>
        /// <param name="name"></param>
        /// <param name="bRecursivley"></param>
        /// <returns></returns>
        public override CompBase Clone(string name, bool bRecursivley)
        {
            SMMethod newComp = base.Clone(name, bRecursivley) as SMMethod;

            newComp.MethodID = MethodID;
            return(newComp);
        }
        /// <summary>
        /// Rebuild this Flow Item
        /// </summary>
        public override void Rebuild()
        {
            lock (this)
            {
                //Prepare Valid Method
                validMethods.Clear();
                bool problem = false;
                if (HasChildren && HasMethod)
                {
                    foreach (CompBase comp in ChildArray)
                    {
                        SMMethod method = comp as SMMethod;
                        method.Rebuild();
                        if (method.IsValid)
                        {
                            validMethods.Add(method);
                        }
                        else
                        {
                            problem = true;
                        }
                    }
                }
                HasProblem = problem;
                if (validMethods.Count == 0)
                {
                    U.LogError("Need a valid method for '{0}'", Name);
                }
                waitHandles = new ManualResetEvent[validMethods.Count];
                for (int i = 0; i < validMethods.Count; i++)
                {
                    waitHandles[i] = validMethods[i].waitHandle;
                }

                //Prepare Valid Transition
                validTransitions.Clear();
                if (HasTransition)
                {
                    foreach (SMTransition transition in TransitionList)
                    {
                        transition.ParentContainer = this.ParentContainer;
                        transition.StateMachine    = this.StateMachine;
                        transition.Rebuild();
                        if (transition.IsValid)
                        {
                            validTransitions.Add(transition);
                        }
                        else
                        {
                            problem = true;
                        }
                    }
                }

                waitHandlesTransitions = new ManualResetEvent[validTransitions.Count];
                for (int i = 0; i < validTransitions.Count; i++)
                {
                    waitHandlesTransitions[i] = TransitionList[i].waitHandle;
                }


                HasProblem = problem;
                if (validMethods.Count == 0 && validTransitions.Count == 0)
                {
                    U.LogError("Need a valid method and transition for '{0}'", Name);
                }
                NeedsRebuild = false;
            }
        }