Ejemplo n.º 1
0
        /// <summary>
        /// Gets the nodes and represents them.
        /// </summary>
        public override void SetGraphNodes()
        {
            foreach (FSMVState item in this.Configuration.ArrayOfFSMVState)
            {
                CustomVertex vertex = new CustomVertex(item.Name, Colors.Wheat, true);
                this.MyGraph.AddVertex(vertex);
            }

            FSMVTrigger t = new FSMVTrigger();
            try
            {
                foreach (FSMVState state in this.Configuration.ArrayOfFSMVState)
                {
                    foreach (AllowedTrigger trigger in state.ArrayOfAllowedTrigger)
                    {
                        t = this.Configuration.FoundTriggerInList(trigger);
                        if (string.IsNullOrEmpty(trigger.TriggerName))
                        {
                            this.MyGraph.AddNewEdge(trigger.StateAndTriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateAndTriggerName));
                        }
                        else
                        {
                            this.MyGraph.AddNewEdge(trigger.TriggerName, this.MyGraph.GetVertexByName(state.Name), this.MyGraph.GetVertexByName(trigger.StateName));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public FSMSequence AddNewStep(FSMSequence sequence, string steppTrigger)
        {
            FSMControl.DomainModel.SecondVersion.FSMStep step = new FSMControl.DomainModel.SecondVersion.FSMStep();
            FSMVTrigger trig = new FSMVTrigger();
            trig = this.Configuration.FoundStringTriggerList(steppTrigger);
            if (string.IsNullOrEmpty(trig.SequenceID))
            {
                step.Name = trig.CommonID;
            }
            else
            {
                step.Name = trig.SequenceID;
            }

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

            return sequence;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a new edge, a new allowed trigger to source vertex, a new trigger if it doesn't exist.
        /// </summary>
        /// <param name="vertexFrom">The vertex from.</param>
        /// <param name="trigger">The trigger.</param>
        /// <param name="vertexTo">The vertex to.</param>
        public override void AddNewEdge(CustomVertex vertexFrom, string trigger, CustomVertex vertexTo)
        {
            FSMVState state = new FSMVState();
            AllowedTrigger aw = new AllowedTrigger();
            FSMVTrigger trig = new FSMVTrigger();
            state.Name = vertexFrom.Text;
            if (string.IsNullOrEmpty(trigger))
            {
                CustomEdge edge = new CustomEdge(vertexTo.Text, vertexFrom, vertexTo);
                this.MyGraph.AddNewEdge(vertexTo.Text, vertexFrom, vertexTo);
                aw.StateAndTriggerName = trig.CommonID = vertexTo.Text;
            }
            else
            {
                CustomEdge edge = new CustomEdge(trigger, vertexFrom, vertexTo);
                this.MyGraph.AddNewEdge(vertexTo.Text, vertexFrom, vertexTo);
                aw.StateName = vertexTo.Text;
                aw.TriggerName = trigger;
                trig.Name = vertexTo.Text;
                trig.SequenceID = trigger;
            }

            foreach (var item in this.Configuration.ArrayOfFSMVState)
            {
                if (item.Name == state.Name)
                {
                    if (item.ArrayOfAllowedTrigger == null)
                    {
                        item.ArrayOfAllowedTrigger = new Collection<AllowedTrigger>();
                    }

                    item.ArrayOfAllowedTrigger.Add(aw);
                    break;
                }
            }

            this.Configuration.AddNewTrigger(trig);
        }