Ejemplo n.º 1
0
        /// <summary>
        /// Gets the machine to next state with given step.
        /// </summary>
        /// <param name="curredntStep">The currednt step.</param>
        /// <param name="currentState">State of the current.</param>
        /// <returns></returns>
        public FSMState OneStep(FSMStep currentStep, FSMState currentState, Color color)
        {
            this.MyGraph.ChangeOneVertexColor(currentState.Name, color);
            FSMState   newState       = new FSMState();
            FSMTrigger triggerFounded = this.Configuration.FoundSteppInTriggerList(currentStep);

            if (triggerFounded != null)
            {
                AllowedTrigger allowedTrigger = new AllowedTrigger();
                allowedTrigger = currentState.FoundTriggerInCureentState(triggerFounded);
                if (allowedTrigger != null)
                {
                    newState = new FSMState();
                    if (string.IsNullOrEmpty(allowedTrigger.StateName))
                    {
                        newState = this.Configuration.FoundNextState(allowedTrigger.StateAndTriggerName);
                    }
                    else
                    {
                        newState = this.Configuration.FoundNextState(allowedTrigger.StateName);
                    }

                    if (newState != null)
                    {
                        this.MyGraph.ChangeOneVertexColor(newState.Name, color);
                        CustomEdge edge = new CustomEdge(null, null);

                        if (string.Compare(currentState.Name, newState.Name) == 0)
                        {
                            this.MyGraph.Vertices.Where(v => (string.Compare(v.Text, currentState.Name) == 0)).FirstOrDefault().Represented = true;
                        }

                        edge = this.MyGraph.GetEdgeBetween(currentState.Name, newState.Name);
                        this.MyGraph.ChangeOneEdgeColor(edge, Colors.Yellow);
                    }
                }
            }

            return(newState);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Represents the sequence by changing vertices and edges color.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <param name="sequence">The sequence.</param>
        /// /// <param name="oneSequence">if is true the Property Represented will be setted true.</param>
        public OperationResult RepresentSequence(Color color, FSMSequence sequence, bool oneSequence)
        {
            if (oneSequence)
            {
                this.MyGraph.ResetToDefault();
            }

            FSMStep  stepp        = new FSMStep();
            FSMState initialState = new FSMState();
            FSMState otherState   = new FSMState();

            if (sequence.ArrayOfStep.Count != 0)
            {
                initialState = this.Configuration.ArrayOfFSMState.FirstOrDefault();
                stepp        = sequence.ArrayOfStep.First();
                otherState   = this.OneStep(stepp, initialState, Colors.Yellow);

                for (int i = 1; i < sequence.ArrayOfStep.Count; i++)
                {
                    FSMStep step = new FSMStep();
                    step = sequence.ArrayOfStep.ElementAt(i);
                    if (!string.IsNullOrEmpty(otherState.Name))
                    {
                        FSMState auxState = new FSMState();
                        auxState   = otherState;
                        otherState = new FSMState();
                        otherState = this.OneStep(step, auxState, Colors.Yellow);
                    }
                }
            }
            else
            {
                return(new OperationResult(false, "Sequence with no steps!"));
            }

            return(new OperationResult(true, "Sequence represented succesfully!"));
        }
Ejemplo n.º 3
0
        public FSMSequence AddNewStep(FSMSequence sequence, string steppTrigger)
        {
            FSMStep    step  = new FSMStep();
            FSMTrigger triig = new FSMTrigger();

            triig = this.Configuration.FoundStringTriggerList(steppTrigger);
            if (string.IsNullOrEmpty(triig.SequenceID))
            {
                step.Name = triig.CommonID;
            }
            else
            {
                step.Name = triig.SequenceID;
            }

            step.Weight           = "2";
            step.TimeoutInSeconds = " 2";
            if (!string.IsNullOrEmpty(step.Name))
            {
                sequence.ArrayOfStep.Add(step);
            }

            return(sequence);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the machine to next state with given step.
        /// </summary>
        /// <param name="curredntStep">The currednt step.</param>
        /// <param name="currentState">State of the current.</param>
        /// <returns></returns>
        public FSMState OneStep(FSMStep currentStep, FSMState currentState, Color color)
        {
            this.MyGraph.ChangeOneVertexColor(currentState.Name, color);
            FSMState newState = new FSMState();
            FSMTrigger triggerFounded = this.Configuration.FoundSteppInTriggerList(currentStep);
            if (triggerFounded != null)
            {
                AllowedTrigger allowedTrigger = new AllowedTrigger();
                allowedTrigger = currentState.FoundTriggerInCureentState(triggerFounded);
                if (allowedTrigger != null)
                {
                    newState = new FSMState();
                    if (string.IsNullOrEmpty(allowedTrigger.StateName))
                    {
                        newState = this.Configuration.FoundNextState(allowedTrigger.StateAndTriggerName);
                    }
                    else
                    {
                        newState = this.Configuration.FoundNextState(allowedTrigger.StateName);
                    }

                    if (newState != null)
                    {
                        this.MyGraph.ChangeOneVertexColor(newState.Name, color);
                        CustomEdge edge = new CustomEdge(null, null);

                        if (string.Compare(currentState.Name, newState.Name) == 0)
                        {
                            this.MyGraph.Vertices.Where(v => (string.Compare(v.Text, currentState.Name) == 0)).FirstOrDefault().Represented = true;
                        }

                        edge = this.MyGraph.GetEdgeBetween(currentState.Name, newState.Name);
                        this.MyGraph.ChangeOneEdgeColor(edge, Colors.Yellow);
                    }
                }
            }

            return newState;
        }
Ejemplo n.º 5
0
        public FSMSequence AddNewStep(FSMSequence sequence, string steppTrigger)
        {
            FSMStep step = new FSMStep();
            FSMTrigger triig = new FSMTrigger();
            triig = this.Configuration.FoundStringTriggerList(steppTrigger);
            if (string.IsNullOrEmpty(triig.SequenceID))
            {
                step.Name = triig.CommonID;
            }
            else
            {
                step.Name = triig.SequenceID;
            }

            step.Weight = "2";
            step.TimeoutInSeconds = " 2";
            if (!string.IsNullOrEmpty(step.Name))
            {
                sequence.ArrayOfStep.Add(step);
            }

            return sequence;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Represents the sequence by changing vertices and edges color.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <param name="sequence">The sequence.</param>
        /// /// <param name="oneSequence">if is true the Property Represented will be setted true.</param>
        public OperationResult RepresentSequence(Color color, FSMSequence sequence, bool oneSequence)
        {
            if (oneSequence)
            {
                this.MyGraph.ResetToDefault();
            }

            FSMStep stepp = new FSMStep();
            FSMState initialState = new FSMState();
            FSMState otherState = new FSMState();

            if (sequence.ArrayOfStep.Count != 0)
            {
                initialState = this.Configuration.ArrayOfFSMState.FirstOrDefault();
                stepp = sequence.ArrayOfStep.First();
                otherState = this.OneStep(stepp, initialState, Colors.Yellow);

                for (int i = 1; i < sequence.ArrayOfStep.Count; i++)
                {
                    FSMStep step = new FSMStep();
                    step = sequence.ArrayOfStep.ElementAt(i);
                    if (!string.IsNullOrEmpty(otherState.Name))
                    {
                        FSMState auxState = new FSMState();
                        auxState = otherState;
                        otherState = new FSMState();
                        otherState = this.OneStep(step, auxState, Colors.Yellow);
                    }
                }
            }
            else
            {
                return new OperationResult(false, "Sequence with no steps!");
            }

            return new OperationResult(true, "Sequence represented succesfully!");
        }