protected FAInfo UpdateClosureInformation(FA synth, FA currentFA, CGraph.CMergeGraphOperation mergeOperation)
    {
        FAInfo closureOperandInfo = synth.GetFAInfo();     // get access to the closure operand FA
        FAInfo currentFAInfo      = currentFA.GetFAInfo(); // get access to the current FA info

        foreach (FALoop faLoop in closureOperandInfo.MLoopsInFa.Values)
        {
            FALoop     newloop = new FALoop();
            CGraphNode entry   = faLoop.MEntryNode;
            newloop.MEntryNode = mergeOperation.GetMirrorNode(entry);
            CGraphNode exit = faLoop.MExitNode;
            newloop.MExitNode = mergeOperation.GetMirrorNode(exit);
            foreach (CGraphNode cGraphNode in faLoop.MParticipatingNodes)
            {
                newloop.MParticipatingNodes.Add(mergeOperation.GetMirrorNode(cGraphNode));
            }
            FALoop.ClosureType closureType = faLoop.MClosureType;
            Range <int>        clsrng      = faLoop.MClosureRange;
            if (clsrng != null)
            {
                newloop.MClosureRange = new Range <int>(clsrng);
            }
            newloop.MClosureType = faLoop.MClosureType;
            newloop.MLoopSerial  = faLoop.MLoopSerial;
            currentFAInfo.AddFALoop(newloop);
        }

        return(currentFAInfo);
    }
    private FA CreateNewFA(FA synth)
    {
        CGraphNode oldEntryNode, oldExitNode;
        FA         m_currentFA = new FA();

        m_ThompsonInfo = new ThompsonInfo(m_currentFA, m_ThompsonInfoKey);
        m_ThompsonInfo.InitFAInfo(new ThompsonFAInfo());

        //2.Merge graph
        m_mergeOperation = m_currentFA.Merge(synth, CGraph.CMergeGraphOperation.MergeOptions.MO_DEFAULT);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, FA.m_FAINFOKEY);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, FA.m_FAINFOKEY);

        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_EDGE, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_GRAPH, m_ThompsonInfoKey);
        m_mergeOperation.MergeGraphInfo(synth, GraphElementType.ET_NODE, m_ThompsonInfoKey);

        // Create boundary nodes
        m_newFASource = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFASource, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_newFASource, m_mergeOperation.GetMirrorNode(synth.M_Initial), GraphType.GT_DIRECTED);
        m_newFATarget = m_currentFA.CreateGraphNode <CGraphNode>();
        m_ThompsonInfo.InitNodeInfo(m_newFATarget, new ThompsonNodeFAInfo());

        m_currentFA.AddGraphEdge <CGraphEdge, CGraphNode>(m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]), m_newFATarget, GraphType.GT_DIRECTED);

        //4.Create the initial and the final node
        oldEntryNode          = m_mergeOperation.GetMirrorNode(synth.M_Initial);
        oldExitNode           = m_mergeOperation.GetMirrorNode(synth.GetFinalStates()[0]);
        m_currentFA.M_Initial = m_newFASource;
        m_currentFA.SetFinalState(m_newFATarget);
        m_currentFA.UpdateAlphabet();

        // Update closure information from operand closure
        FAInfo currentFAInfo = UpdateClosureInformation(synth, m_currentFA, m_mergeOperation);

        // Update closure information from current closure
        m_currentFAloop             = new FALoop();
        m_currentFAloop.MEntryNode  = oldEntryNode;
        m_currentFAloop.MExitNode   = oldExitNode;
        m_currentFAloop.MLoopSerial = m_currentClosureSerial;
        CIt_GraphNodes it = new CIt_GraphNodes(m_currentFA);

        for (it.Begin(); !it.End(); it.Next())
        {
            if (it.M_CurrentItem != m_currentFA.M_Initial &&
                it.M_CurrentItem != m_currentFA.GetFinalStates()[0])
            {
                m_currentFAloop.MParticipatingNodes.Add(it.M_CurrentItem);
            }
        }
        // Add new closure to the current FA
        currentFAInfo.AddFALoop(m_currentFAloop);

        return(m_currentFA);
    }
Beispiel #3
0
        /// <summary>
        /// Used internally by the derived viewer that may also set the modelprogram
        /// </summary>
        internal void SetStateMachine(FSM fa, StateProvider stateProvider, ModelProgram mp1, Set<Transition> groupingTransitions)
        {
            // Clear the node and transition tables and the cache
            this.mp = mp1;
            // nodes.Clear(); // not needed for mp2dot, I believe
            // transitions.Clear(); // ditto
            //reductCache.Clear();
            //this.faInfo = new FAInfo(this.stateViewer1.DefaultModelName, fa, stateProvider, mp1);
            this.faInfo = new FAInfo("Fsm", fa, stateProvider, mp1); // defined in StateView.cs
            this.finiteAutomatonContext = new FAContext(fa, stateProvider, faInfo.ReductNames.Last, mp1);
            this.finiteAutomatonContext.groupingTransitions = groupingTransitions;
            //this.reductCache[this.faInfo.ReductNames.Last] = this.finiteAutomatonContext;

            // removed code here
        }
Beispiel #4
0
 /// <summary>
 /// Used internally by the derived viewer that may also set the modelprogram
 /// </summary>
 internal void SetStateMachine(FSM fa, StateProvider stateProvider, ModelProgram mp1, Set<Transition> groupingTransitions)
 {
     // Clear the node and transition tables and the cache
     this.mp = mp1;
     nodes.Clear();
     transitions.Clear();
     //reductCache.Clear();
     this.faInfo = new FAInfo(this.stateViewer1.DefaultModelName, fa, stateProvider, mp1);
     this.finiteAutomatonContext = new FAContext(fa, stateProvider, faInfo.ReductNames.Last, mp1);
     this.finiteAutomatonContext.groupingTransitions = groupingTransitions;
     //this.reductCache[this.faInfo.ReductNames.Last] = this.finiteAutomatonContext;
     this.projectionButton.Text = "     " + faInfo.ReductNames.Last.name.ToString();
     this.projectionButton.ToolTipText = faInfo.ReductNames.Last.name.ToString();
     if (faInfo.IsProduct)
     {
         this.projectionButton.Enabled = true;
         EnableProjection();
     }
     else
     {
         this.projectionButton.Enabled = false;
     }
     graphChanged = true;
     PerformLayout();
 }