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 FSMVState OneStep(FSMStep currentStep, FSMVState currentState, Color color)
        {
            this.MyGraph.ChangeOneVertexColor(currentState.Name, color);
            FSMVState   newState       = new FSMVState();
            FSMVTrigger triggerFounded = this.Configuration.FoundSteppInTriggerList(currentStep);

            if (triggerFounded != null)
            {
                AllowedTrigger allowedTrigger = new AllowedTrigger();
                allowedTrigger = currentState.FoundTriggerInCureentState(triggerFounded);
                if (allowedTrigger != null)
                {
                    newState = new FSMVState();
                    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();

            FSMVState initialState = new FSMVState();
            FSMVState otherState   = new FSMVState();

            if (sequence.ArrayOfStep.Count != 0)
            {
                initialState = this.Configuration.ArrayOfFSMVState.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))
                    {
                        FSMVState auxState = new FSMVState();
                        auxState   = otherState;
                        otherState = new FSMVState();
                        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
        /// <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 FSMVState OneStep(FSMStep currentStep, FSMVState currentState, Color color)
        {
            this.MyGraph.ChangeOneVertexColor(currentState.Name, color);
            FSMVState newState = new FSMVState();
            FSMVTrigger triggerFounded = this.Configuration.FoundSteppInTriggerList(currentStep);
            if (triggerFounded != null)
            {
                AllowedTrigger allowedTrigger = new AllowedTrigger();
                allowedTrigger = currentState.FoundTriggerInCureentState(triggerFounded);
                if (allowedTrigger != null)
                {
                    newState = new FSMVState();
                    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.º 4
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();

            FSMVState initialState = new FSMVState();
            FSMVState otherState = new FSMVState();

            if (sequence.ArrayOfStep.Count != 0)
            {
                initialState = this.Configuration.ArrayOfFSMVState.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))
                    {
                        FSMVState auxState = new FSMVState();
                        auxState = otherState;
                        otherState = new FSMVState();
                        otherState = this.OneStep(step, auxState, Colors.Yellow);
                    }
                }
            }
            else
            {
                return new OperationResult(false, "Sequence with no steps!");
            }

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