コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenerateSequenceWindow"/> class.
        /// </summary>
        /// <param name="fsm">The Finite State Machine.</param>
        public GenerateSequenceWindow(StateMachine fsm)
            : this()
        {
            if (fsm != null)
            {
                fsm.MyGraph.ResetToDefault();
                this.DataContext    = fsm;
                this.listOfVertices = new Stack <CustomVertex>();
            }

            if (fsm is FirstStateMachine)
            {
                this.machine                          = new FirstStateMachine(fsm.CurrentVersion);
                this.machine                          = fsm;
                firstStep.Text                        = "First state is " + ((FirstStateMachine)this.machine).Configuration.ArrayOfFSMState.FirstOrDefault().Name + "! Select next sequence!";
                this.sequenceFirstVersion             = new FSMControl.DomainModel.FirstVersion.FSMSequence();
                this.sequenceFirstVersion.ArrayOfStep = new System.Collections.ObjectModel.Collection <DomainModel.FirstVersion.FSMStep>();
            }
            else
            {
                this.machine                           = new SecondStateMachine(fsm.CurrentVersion);
                this.machine                           = fsm;
                firstStep.Text                         = "First state is " + ((SecondStateMachine)this.machine).Configuration.ArrayOfFSMVState.FirstOrDefault().Name + "! Select next sequence!";
                this.sequenceSecondVersion             = new FSMControl.DomainModel.SecondVersion.FSMSequence();
                this.sequenceSecondVersion.ArrayOfStep = new System.Collections.ObjectModel.Collection <DomainModel.SecondVersion.FSMStep>();
            }

            this.listOfVertices.Push(this.machine.MyGraph.Vertices.FirstOrDefault());
            this.DataContext = this.machine.MyGraph;
        }
コード例 #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="GenerateSequenceWindow"/> class.
    /// </summary>
    /// <param name="fsm">The Finite State Machine.</param>
    public GenerateSequenceWindow(StateMachine fsm)
      : this()
    {
      if (fsm != null)
      {
        fsm.MyGraph.ResetToDefault();
        this.DataContext = fsm;
        this.listOfVertices = new Stack<CustomVertex>();
      }

      if (fsm is FirstStateMachine)
      {
        this.machine = new FirstStateMachine(fsm.CurrentVersion);
        this.machine = fsm;
        firstStep.Text = "First state is " + ((FirstStateMachine)this.machine).Configuration.ArrayOfFSMState.FirstOrDefault().Name + "! Select next sequence!";
        this.sequenceFirstVersion = new FSMControl.DomainModel.FirstVersion.FSMSequence();
        this.sequenceFirstVersion.ArrayOfStep = new System.Collections.ObjectModel.Collection<DomainModel.FirstVersion.FSMStep>();
      }
      else
      {
        this.machine = new SecondStateMachine(fsm.CurrentVersion);
        this.machine = fsm;
        firstStep.Text = "First state is " + ((SecondStateMachine)this.machine).Configuration.ArrayOfFSMVState.FirstOrDefault().Name + "! Select next sequence!";
        this.sequenceSecondVersion = new FSMControl.DomainModel.SecondVersion.FSMSequence();
        this.sequenceSecondVersion.ArrayOfStep = new System.Collections.ObjectModel.Collection<DomainModel.SecondVersion.FSMStep>();
      }

      this.listOfVertices.Push(this.machine.MyGraph.Vertices.FirstOrDefault());
      this.DataContext = this.machine.MyGraph;
    }
コード例 #3
0
        /// <summary>
        /// Represents the selected sequence.
        /// </summary>
        private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e)
        {
            if (cbSequences.SelectedIndex != -1)
            {
                switch (this.version.ID)
                {
                case 1:
                {
                    FSMControl.DomainModel.FirstVersion.FSMSequence seq = new FSMControl.DomainModel.FirstVersion.FSMSequence();
                    seq = (FSMControl.DomainModel.FirstVersion.FSMSequence)cbSequences.SelectedItem;
                    if (seq.ArrayOfStep.Count == 0)
                    {
                        MessageBox.Show("Sequence with no steps!");
                    }
                    else
                    {
                        ((FirstStateMachine)this.machine).MyGraph.ResetToDefault();
                        ((FirstStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true);
                        console.Text += "Sequence represented successfully!\r\n";
                        scrConsole.ScrollToEnd();
                        this.DataContext = this.machine.MyGraph;
                    }

                    break;
                }

                case 2:
                {
                    FSMControl.DomainModel.SecondVersion.FSMSequence seq = new FSMControl.DomainModel.SecondVersion.FSMSequence();
                    seq = (FSMControl.DomainModel.SecondVersion.FSMSequence)cbSequences.SelectedItem;
                    if (seq.ArrayOfStep.Count == 0)
                    {
                        MessageBox.Show("Sequence with no steps!");
                    }
                    else
                    {
                        ((SecondStateMachine)this.machine).MyGraph.ResetToDefault();
                        if (((SecondStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true).Succes)
                        {
                            ((SecondStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true);
                            console.Text += "Sequence represented successfully!\r\n";
                            scrConsole.ScrollToEnd();
                            this.DataContext = this.machine.MyGraph;
                        }
                        else
                        {
                            MessageBox.Show(((SecondStateMachine)this.machine).RepresentSequence(Colors.Red, seq, true).Message);
                        }
                    }

                    break;
                }
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Handles the Click event of the done control.
 /// Saves generated sequence to current finite state machine
 /// </summary>
 private void Done_Click(object sender, RoutedEventArgs e)
 {
     if (this.machine is FirstStateMachine)
     {
         if (string.IsNullOrEmpty(seqName.Text) || string.IsNullOrEmpty(seqDesc.Text))
         {
             MessageBox.Show("You must enter a name and a description for sequence!");
         }
         else
         {
             this.sequenceFirstVersion.Name             = seqName.Text;
             this.sequenceFirstVersion.Description      = seqDesc.Text;
             this.sequenceFirstVersion.FinalDescription = seqFinalDesc.Text;
             ((FirstStateMachine)this.machine).Sequences.ArrayOfSequence.Add(this.sequenceFirstVersion);
             MessageBox.Show("Sequence added!");
             this.sequenceFirstVersion = new DomainModel.FirstVersion.FSMSequence();
             this.Close();
         }
     }
     else
     {
         if (string.IsNullOrEmpty(seqName.Text) || string.IsNullOrEmpty(seqDesc.Text))
         {
             MessageBox.Show("You must enter a name and a description for sequence!");
         }
         else
         {
             this.sequenceSecondVersion.Name             = seqName.Text;
             this.sequenceSecondVersion.Description      = seqDesc.Text;
             this.sequenceSecondVersion.FinalDescription = seqFinalDesc.Text;
             ((SecondStateMachine)this.machine).Sequences.ArrayOfSequence.Add(this.sequenceSecondVersion);
             MessageBox.Show("Sequence added!");
             this.sequenceSecondVersion = new DomainModel.SecondVersion.FSMSequence();
             this.DataContext           = this.machine.MyGraph;
             this.Close();
         }
     }
 }
コード例 #5
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!"));
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: FSMView.xaml.cs プロジェクト: dezGusty/fsmview
    /// <summary>
    /// Represents the selected sequence.
    /// </summary>
    private void ComboBox_SelectionChanged(object sender, RoutedEventArgs e)
    {
      if (cbSequences.SelectedIndex != -1)
      {
        switch (this.version.ID)
        {
          case 1:
            {
              FSMControl.DomainModel.FirstVersion.FSMSequence seq = new FSMControl.DomainModel.FirstVersion.FSMSequence();
              seq = (FSMControl.DomainModel.FirstVersion.FSMSequence)cbSequences.SelectedItem;
              if (seq.ArrayOfStep.Count == 0)
              {
                MessageBox.Show("Sequence with no steps!");
              }
              else
              {
                ((FirstStateMachine)this.machine).MyGraph.ResetToDefault();
                ((FirstStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true);
                console.Text += "Sequence represented successfully!\r\n";
                scrConsole.ScrollToEnd();
                this.DataContext = this.machine.MyGraph;
              }

              break;
            }

          case 2:
            {
              FSMControl.DomainModel.SecondVersion.FSMSequence seq = new FSMControl.DomainModel.SecondVersion.FSMSequence();
              seq = (FSMControl.DomainModel.SecondVersion.FSMSequence)cbSequences.SelectedItem;
              if (seq.ArrayOfStep.Count == 0)
              {
                MessageBox.Show("Sequence with no steps!");
              }
              else
              {
                ((SecondStateMachine)this.machine).MyGraph.ResetToDefault();
                if (((SecondStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true).Succes)
                {
                  ((SecondStateMachine)this.machine).RepresentSequence(Colors.Yellow, seq, true);
                  console.Text += "Sequence represented successfully!\r\n";
                  scrConsole.ScrollToEnd();
                  this.DataContext = this.machine.MyGraph;
                }
                else
                {
                  MessageBox.Show(((SecondStateMachine)this.machine).RepresentSequence(Colors.Red, seq, true).Message);
                }
              }

              break;
            }
        }
      }
    }
コード例 #8
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;
        }
コード例 #9
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!");
        }
コード例 #10
0
 /// <summary>
 /// Handles the Click event of the done control.
 /// Saves generated sequence to current finite state machine
 /// </summary>
 private void Done_Click(object sender, RoutedEventArgs e)
 {
   if (this.machine is FirstStateMachine)
   {
     if (string.IsNullOrEmpty(seqName.Text) || string.IsNullOrEmpty(seqDesc.Text))
     {
       MessageBox.Show("You must enter a name and a description for sequence!");
     }
     else
     {
       this.sequenceFirstVersion.Name = seqName.Text;
       this.sequenceFirstVersion.Description = seqDesc.Text;
       this.sequenceFirstVersion.FinalDescription = seqFinalDesc.Text;
       ((FirstStateMachine)this.machine).Sequences.ArrayOfSequence.Add(this.sequenceFirstVersion);
       MessageBox.Show("Sequence added!");
       this.sequenceFirstVersion = new DomainModel.FirstVersion.FSMSequence();
       this.Close();
     }
   }
   else
   {
     if (string.IsNullOrEmpty(seqName.Text) || string.IsNullOrEmpty(seqDesc.Text))
     {
       MessageBox.Show("You must enter a name and a description for sequence!");
     }
     else
     {
       this.sequenceSecondVersion.Name = seqName.Text;
       this.sequenceSecondVersion.Description = seqDesc.Text;
       this.sequenceSecondVersion.FinalDescription = seqFinalDesc.Text;
       ((SecondStateMachine)this.machine).Sequences.ArrayOfSequence.Add(this.sequenceSecondVersion);
       MessageBox.Show("Sequence added!");
       this.sequenceSecondVersion = new DomainModel.SecondVersion.FSMSequence();
       this.DataContext = this.machine.MyGraph;
       this.Close();
     }
   }
 }