Пример #1
0
        /// <summary>
        /// método que retorna todas as transição onde os pares de estados são
        /// origem na transição na lista de de transição da FSM.
        /// </summary>
        /// <param name="statePair"></param>
        /// <param name="fsm"></param>
        /// <returns></returns>
        private Transition GetListTransitionOutputOfState(StatePair statePair, FiniteStateMachine fsm)
        {
            List <Transition> listTtransitionSource = new List <Transition>();
            List <Transition> listTtransitionTarget = new List <Transition>();

            foreach (Transition transition in fsm.Transitions)
            {
                if (statePair.Si.Name.Equals(transition.SourceState.Name))
                {
                    listTtransitionSource.Add(transition);
                }
                if (statePair.Sj.Name.Equals(transition.SourceState.Name))
                {
                    listTtransitionTarget.Add(transition);
                }
            }
            foreach (var t1 in listTtransitionSource)
            {
                foreach (var t2 in listTtransitionTarget)
                {
                    if (t1.Input.Equals(t2.Input) && !t1.Output.Equals(t2.Output))
                    {
                        return(t1);
                    }
                }
            }
            return(null);
        }
Пример #2
0
 /// <summary>
 /// remove os pares de estados iguais.
 /// </summary>
 /// <param name="listStatePair"></param>
 private void removeEqualsState(List <StatePair> listStatePair)
 {
     for (int i = 0; i < listStatePair.Count; i++)
     {
         StatePair s1 = listStatePair[i];
         for (int j = i + 1; j < listStatePair.Count; j++)
         {
             StatePair s2 = listStatePair[j];
             if (IsEquals(s1, s2))
             {
                 listStatePair.Remove(s2);
                 j--;
             }
         }
     }
 }
Пример #3
0
 /// <summary>
 /// método que verifica se os pares de estados são iguais.
 /// </summary>
 /// <param name="s1"></param>
 /// <param name="s2"></param>
 /// <returns></returns>
 private bool IsEquals(StatePair s1, StatePair s2)
 {
     if (s1.Si.Name.Equals(s2.Si.Name) && s1.Sj.Name.Equals(s2.Sj.Name))
     {
         return(true);
     }
     if (s1.Si.Name.Equals(s1.Sj.Name))
     {
         return(true);
     }
     if (s2.Si.Name.Equals(s2.Sj.Name))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #4
0
 private void GetListTransitionWi(FiniteStateMachine fsm, List <StatePair> listStatePair)
 {
     for (int i = 0; i < fsm.States.Count; i++)
     {
         State s1 = fsm.States[i];
         for (int j = i + 1; j < fsm.States.Count; j++)
         {
             State             s2   = fsm.States[j];
             List <Transition> list = GetTransitionStateSource(s1, fsm.Transitions);
             foreach (Transition t in list)
             {
                 StatePair statePair = new StatePair();
                 statePair.Si = s1;
                 statePair.Sj = s2;
                 listStatePair.Add(statePair);
             }
         }
     }
 }
Пример #5
0
        /// <summary>
        /// método que popula a lista de SetW da FSM com conjunto W.
        /// </summary>
        /// <param name="statePair"></param>
        /// <param name="fsm"></param>
        private void GetWiStatePair(StatePair statePair, FiniteStateMachine fsm)
        {
            Transition t = GetListTransitionOutputOfState(statePair, fsm);

            if (t != null)
            {
                List <String> list = new List <string>();
                list.Add(t.Input);
                fsm.WiSet.Add(list);
            }
            else
            {
                List <String> listSeq = new List <string>();
                GetListOutoutStatePair(listSeq, statePair, fsm);
                List <String> list = new List <string>();
                foreach (String i in listSeq)
                {
                    list.Add(i);
                }
                fsm.WiSet.Add(list);
            }
        }
Пример #6
0
        /// <summary>
        /// metodo recursivo que obtem uma lista de entradas onde
        /// obtem o conjunto W da FSM.
        /// </summary>
        /// <param name="listSeq"></param>
        /// <param name="statePair"></param>
        /// <param name="fsm"></param>
        /// <returns></returns>
        private List <string> GetListOutoutStatePair(List <string> listSeq, StatePair statePair, FiniteStateMachine fsm)
        {
            String[][] tcSi        = TransitionCover(statePair.Si);
            String[][] tcSj        = TransitionCover(statePair.Sj);
            String     inputEquals = "";

            inputEquals = GetInputEquals(statePair.Si, statePair.Sj);

            if (!inputEquals.Equals(""))
            {
                Transition t1 = GetTransitionStateSource(statePair.Si, inputEquals, fsm.Transitions)[0];
                Transition t2 = GetTransitionStateSource(statePair.Sj, inputEquals, fsm.Transitions)[0];

                if (!t1.Output.Equals(t2.Output))
                {
                    listSeq.Add(inputEquals);
                    return(listSeq);
                }
                else
                {
                    StatePair statPairAux = new StatePair();
                    State     s           = new State(t1.TargetState.Name);
                    State     t           = new State(t2.TargetState.Name);
                    statPairAux.Si      = s;
                    statPairAux.Sj      = t;
                    statPairAux.Si.Name = s.Name;
                    statPairAux.Sj.Name = t.Name;
                    GetListOutoutStatePair(listSeq, statPairAux, fsm);
                }
            }
            else
            {
                listSeq.Add(GetAllowedInputs(statePair.Si)[0]);
                return(listSeq);
            }
            return(listSeq);
        }