コード例 #1
0
ファイル: SimulationWorker.cs プロジェクト: MinhHuong/WSN-PN
        public void AddToTrace(string srcID, EventStepSim step, string id, string key)
        {
            ListViewItem item = new ListViewItem(new string[] { srcID, step.Event, id, step.SourceProcess });

            ListView_Trace.Items.Add(item);

            item     = new ListViewItem(new string[] { srcID, step.Event, id, step.SourceProcess });
            item.Tag = key;

            OnAction(item);
        }
コード例 #2
0
ファイル: EventStepSim.cs プロジェクト: vu111293/pat-design
        private void AddAllTauReachableSteps(ConfigurationBase step, List <EventStepSim> listResutlt)
        {
            NormalizedState NState = NormalizedState.TauReachable(new List <ConfigurationBase>()
            {
                step
            });

            foreach (ConfigurationBase state in NState.States)
            {
                //for each step in this
                IEnumerable <ConfigurationBase> templist = state.MakeOneMove();

                bool hasNonTauEvent = false;
                foreach (ConfigurationBase step1 in templist)
                {
                    if (step1.Event != Common.Classes.Ultility.Constants.TAU)
                    {
                        hasNonTauEvent = true;
                        break;
                    }
                }

                //if the step has non-tau transition, this should be a boundary step, and we need to keep it
                if (hasNonTauEvent || state.IsDeadLock)
                {
                    if (state.Event == Common.Classes.Ultility.Constants.TAU)
                    {
                        //do we need to add the *
                        state.Event       = step.Event; //+ "*"
                        state.DisplayName = null;
                    }

                    EventStepSim step1Sim = new EventStepSim(state);

                    bool contains = false;
                    foreach (EventStepSim sim in listResutlt)
                    {
                        if (sim.Event == step1Sim.Event && sim.StepID == step1Sim.StepID)
                        {
                            contains = true;
                            break;
                        }
                    }

                    //duplicated steps should not be added in.
                    if (!contains)
                    {
                        listResutlt.Add(step1Sim);
                    }
                }
            }
        }
コード例 #3
0
ファイル: SimulationWorker.cs プロジェクト: MinhHuong/WSN-PN
        public virtual void Initialize(SimulationForm simForm, EventStepSim currentStep, string currentNode, ListView trace, Graph igraph)
        {
            //initialize the parameters
            isiTarget = simForm;

            initialStep    = currentStep;
            initialString  = currentNode;
            ListView_Trace = new ListView();
            if (trace.Items.Count > 0)
            {
                ListView_Trace.Items.Add(trace.Items[0].Clone() as ListViewItem);
            }

            HideTauTransition = simForm.HideTauTransition;
            visited           = new Hashtable(simForm.visited);
            graph             = CloneGraph(igraph);
            intGraph          = CloneGraph(igraph);
            Mapping           = new Dictionary <string, ProcessData>(simForm.Mapping);


            SimulatorViewer = new GViewer();
            this.SimulatorViewer.AsyncLayout     = false;
            this.SimulatorViewer.BackwardEnabled = true;
            this.SimulatorViewer.BuildHitTree    = true;
            this.SimulatorViewer.ForwardEnabled  = true;
            this.SimulatorViewer.Graph           = null;
            this.SimulatorViewer.LayoutAlgorithmSettingsButtonVisible = true;
            this.SimulatorViewer.MouseHitDistance          = 0.05;
            this.SimulatorViewer.Name                      = "SimulatorViewer";
            this.SimulatorViewer.NavigationVisible         = true;
            this.SimulatorViewer.NeedToCalculateLayout     = true;
            this.SimulatorViewer.PanButtonPressed          = false;
            this.SimulatorViewer.SaveAsImageEnabled        = true;
            this.SimulatorViewer.SaveAsMsaglEnabled        = true;
            this.SimulatorViewer.SaveButtonVisible         = true;
            this.SimulatorViewer.SaveGraphButtonVisible    = true;
            this.SimulatorViewer.SaveInVectorFormatEnabled = true;
            this.SimulatorViewer.ToolBarIsVisible          = true;
            this.SimulatorViewer.ZoomF                     = 1;
            this.SimulatorViewer.ZoomFraction              = 0.5;
            this.SimulatorViewer.ZoomWindowThreshold       = 0.05;
            this.SimulatorViewer.Dock                      = DockStyle.Fill;
        }
コード例 #4
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
        private void Button_GenerateGraph_Click(object sender, EventArgs e)
        {
            if (this.Button_GenerateGraph.Text == STOP)
            {
                if (GraphBuilder != null)
                {
                    Button_GenerateGraph.Enabled = false;
                    GraphBuilder.Cancel();
                }
            }
            else
            {

                if (CanGrabLock())
                {
                    DisableControls();

                    try
                    {

                        Button_GenerateGraph.Enabled = true;
                        Button_GenerateGraph.Text = STOP;

                        //P startingProcess = Spec.GetProcessDef();
                        CutNumberString = "";
                        //if (startingProcess.MustBeAbstracted())
                        //{

                        //    CutNumberForm cutNumberForm = new CutNumberForm();
                        //    if (cutNumberForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        //    {
                        //        Classes.Ultility.Ultility.CutNumber = (int) cutNumberForm.NumericUpDown_CutNumber.Value;
                        //        //startingProcess.SetCutNumber(new List<string>());

                        //        CutNumberString = " (Cut Number " + Classes.Ultility.Ultility.CutNumber + ")";

                        //    }
                        //    else
                        //    {
                        //        EnableControls();
                        //        return;
                        //    }
                        //}
                        //else
                        //{
                        //Classes.Ultility.Ultility.CutNumber = -1;
                        //}

                        this.ListView_Trace.Items.Clear();
                        this.ListView_EnabledEvents.Items.Clear();
                        Timer_Run.Stop();
                        Timer_Replay.Stop();
                        Timer_SimulateTrace.Stop();

                        this.SimulationInitialize(true);

                        ListView_EnabledEvents.Items.Clear();

                        EventStepSim initalStep =
                            new EventStepSim(Spec.SimulationInitialization(this.ComboBox_Process.Text));
                        //, Common.Ultility.Constants.INITIAL_EVENT, null, SpecProcess.GetEnvironment());

                        GraphBuilder = new SimulationWorker();
                        GraphBuilder.Initialize(this, initalStep, InitialState, ListView_Trace, g);

                        GraphBuilder.Failed += new System.Threading.ThreadExceptionEventHandler(GraphBuilder_Failed);
                        GraphBuilder.Cancelled += new EventHandler(GraphBuilder_Cancelled);
                        GraphBuilder.Action += new SimulationWorker.ActionEvent(GraphBuilder_Action);

                        if (Common.Utility.Utilities.IsUnixOS)
                        {
                            GraphBuilder.InternalStart();
                            GraphBuilder_ReturnResult();
                        }
                        else
                        {
                            GraphBuilder.ReturnResult +=
                                new SimulationWorker.ReturnResultEvent(GraphBuilder_ReturnResult);
                            GraphBuilder.Print += new SimulationWorker.PrintingEvent(GraphBuilder_Print);
                            GraphBuilder.Start();
                        }

                    }
                    catch (Exception ex)
                    {
                        PrintErrorMsg(ex);
                    }
                }
            }
        }
コード例 #5
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
        private void AddCounterExamplePrefixPathNode(ref string sourceProcess, ConfigurationBase stepOld, bool firstSCC)
        {
            Node n = null;
            Edge edge = null;

            //EventStepSim fromStep = CounterExampleTrace[j-1];

            EventStepSim step = new EventStepSim(stepOld);

            step.SourceProcess = sourceProcess;

            //change all nodes to white node!
            foreach (Node mapN in g.NodeMap.Values)
            {
                if (mapN.Attr.FillColor == Color.Red)
                {
                    mapN.Attr.FillColor = Color.White;
                }
            }

            string stepString;
            ////string nextState = step.ToFullString();

            if (step.StepVisited(visited, out stepString))
            {
                Node srcNode = g.FindNode(step.SourceProcess);

                edge = null;
                foreach (Edge outEdge in srcNode.OutEdges)
                {
                    if (outEdge.LabelText == step.Event && outEdge.Target == stepString)
                    {
                        //duplicate edge is found
                        edge = outEdge;
                        break;
                    }
                }

                if (edge == null)
                {
                    edge = g.AddEdge(step.SourceProcess, step.Event, stepString);
                }

                n = edge.TargetNode; // g.NodeMap[stepString] as Node;

                AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);
            }
            else
            {
                visited.Add(stepString, null);

                //add the new node and set it to red.
                n = g.AddNode(stepString);
                n.LabelText = (g.NodeCount - 1).ToString();
                n.UserData = step; //// nextState;

                edge = g.AddEdge(step.SourceProcess, step.Event, stepString);

                AddToTrace(edge.SourceNode.LabelText, step, n.LabelText, stepString);
            }

            if (firstSCC)
            {
                n.Attr.FillColor = Color.LightGreen;
            }
            else
            {
                n.Attr.FillColor = Color.Red;
            }

            sourceProcess = stepString;

            string key = GetTraceEvent(this.ListView_Trace.Items.Count) + stepString;
            if (!Mapping.ContainsKey(key))
            {
                Mapping.Add(key, new ProcessData(step, CloneGraph(g), CloneEnabledEvent()));
            }

            UpdateStore(step);
        }
コード例 #6
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
 public ProcessData(EventStepSim state, Graph g, List<EventStepSim> enabled)
 {
     this.State = state;
     this.Graph = g;
     CurrentEnabledSteps = enabled;
 }
コード例 #7
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
 public void AddToTrace(string srcID, EventStepSim step, string id, string key)
 {
     ListViewItem item = new ListViewItem(new string[] {srcID, step.Event, id});
     item.Tag = step.StepToString;
     ListView_Trace.Items.Add(item);
     Traces.Add(key);
 }
コード例 #8
0
ファイル: SimulationWorker.cs プロジェクト: MinhHuong/WSN-PN
        private void BuildCompleteGraph()
        {
            Stack <EventStepSim> searchStack = new Stack <EventStepSim>();

            searchStack.Push(initialStep);

            Stack <string> stringStack = new Stack <string>();

            stringStack.Push(initialString);

            while (searchStack.Count > 0)
            {
                if (visited.Count > Classes.Ultility.Ultility.SIMULATION_BOUND)
                {
                    ForceSimuationStop = true;
                    return;
                }

                if (CancelRequested)
                {
                    return;
                }

                EventStepSim currentStep = searchStack.Pop();
                string       currentNode = stringStack.Pop();

                List <EventStepSim> list = currentStep.MakeOneMove(HideTauTransition);

                foreach (EventStepSim step in list)
                {
                    //change all nodes to white node!
                    foreach (Node mapN in graph.NodeMap.Values)
                    {
                        mapN.Attr.FillColor = Color.White;
                    }

                    string stepString;
                    //string nextState = step.ToFullString();
                    step.SourceProcess = currentStep.StepToString;//.Process.ToString();


                    if (step.StepVisited(visited, out stepString))
                    {
                        Node srcNode = graph.FindNode(currentNode);

                        Edge edge = null;
                        foreach (Edge outEdge in srcNode.OutEdges)
                        {
                            if (outEdge.LabelText == step.Event && outEdge.Target == stepString)
                            {
                                //duplicate edge is found
                                edge = outEdge;
                                break;
                            }
                        }

                        if (edge == null)
                        {
                            edge = graph.AddEdge(currentNode, step.Event, stepString);

                            edge.TargetNode.Attr.FillColor = Color.Red;
                            //(graph.NodeMap[stepString] as Node).Attr.FillColor = Color.Red;

                            //update the ListView_Trace and clone graph
                            AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);

                            string key = GetTraceEvent(ListView_Trace.Items.Count) + stepString;
                            if (!Mapping.ContainsKey(key))
                            {
                                Mapping.Add(key, new ProcessData(step, CloneGraph(graph), new List <EventStepSim>(0)));
                            }
                        }
                    }
                    else
                    {
                        visited.Add(stepString, null);

                        Edge e = graph.AddEdge(currentNode, step.Event, stepString);

                        e.TargetNode.LabelText      = (graph.NodeCount - 1).ToString();
                        e.TargetNode.UserData       = step; // nextState;
                        e.TargetNode.Attr.FillColor = Color.Red;

                        //update the ListView_Trace and clone graph
                        AddToTrace(e.SourceNode.LabelText, step, e.TargetNode.LabelText, stepString);
                        string key = GetTraceEvent(ListView_Trace.Items.Count) + stepString;
                        if (!Mapping.ContainsKey(key))
                        {
                            Mapping.Add(key, new ProcessData(step, CloneGraph(graph), new List <EventStepSim>(0)));
                        }

                        searchStack.Push(step);
                        stringStack.Push(stepString);
                        //BuildCompleteGraph(step, stepString);
                    }
                }
            }

            foreach (Node node in graph.NodeMap.Values)
            {
                foreach (Edge edge1 in node.OutEdges)
                {
                    foreach (Edge edge2 in node.OutEdges)
                    {
                        if (edge1 != edge2)
                        {
                            if (edge1.TargetNode == edge2.TargetNode)
                            {
                                if (edge1.LabelText == edge2.LabelText)
                                {
                                    System.Diagnostics.Debug.Assert(false, "Duplicated Transition in the Simulator");
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
ファイル: SimulationWorker.cs プロジェクト: nhannhan159/PAT
        public virtual void Initialize(SimulationForm simForm, EventStepSim currentStep, string currentNode, ListView trace, Graph igraph)
        {
            //initialize the parameters
            isiTarget = simForm;

            initialStep = currentStep;
            initialString = currentNode;
            ListView_Trace = new ListView();
            if(trace.Items.Count > 0)
            {
                ListView_Trace.Items.Add(trace.Items[0].Clone() as ListViewItem);
            }

            HideTauTransition = simForm.HideTauTransition;
            visited = new Hashtable(simForm.visited);
            graph = CloneGraph(igraph);
            intGraph = CloneGraph(igraph);
            Mapping = new Dictionary<string, ProcessData>(simForm.Mapping);

            SimulatorViewer = new GViewer();
            this.SimulatorViewer.AsyncLayout = false;
            this.SimulatorViewer.BackwardEnabled = true;
            this.SimulatorViewer.BuildHitTree = true;
            this.SimulatorViewer.ForwardEnabled = true;
            this.SimulatorViewer.Graph = null;
            this.SimulatorViewer.LayoutAlgorithmSettingsButtonVisible = true;
            this.SimulatorViewer.MouseHitDistance = 0.05;
            this.SimulatorViewer.Name = "SimulatorViewer";
            this.SimulatorViewer.NavigationVisible = true;
            this.SimulatorViewer.NeedToCalculateLayout = true;
            this.SimulatorViewer.PanButtonPressed = false;
            this.SimulatorViewer.SaveAsImageEnabled = true;
            this.SimulatorViewer.SaveAsMsaglEnabled = true;
            this.SimulatorViewer.SaveButtonVisible = true;
            this.SimulatorViewer.SaveGraphButtonVisible = true;
            this.SimulatorViewer.SaveInVectorFormatEnabled = true;
            this.SimulatorViewer.ToolBarIsVisible = true;
            this.SimulatorViewer.ZoomF = 1;
            this.SimulatorViewer.ZoomFraction = 0.5;
            this.SimulatorViewer.ZoomWindowThreshold = 0.05;
            this.SimulatorViewer.Dock = DockStyle.Fill;
        }
コード例 #10
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
        /// <summary>
        /// pass the index to make sure the current step is removed from the CurrentEnableEventList
        /// </summary>
        /// <param name="step"></param>
        private void MakeOneMove(EventStepSim step, int stepIndex)
        {
            if (WarningFlag)
            {
                if (
                    MessageBox.Show(
                        Resources.The_execution_of_the_step_will_destroy_the_current_trace__Do_you_want_to_continue_,
                        Resources.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
                WarningFlag = false;

                int index = this.ListView_Trace.SelectedIndices[0];

                while (this.ListView_Trace.Items.Count - 1 > index)
                {
                    Traces.RemoveAt(this.ListView_Trace.Items.Count - 1);
                    ListView_Trace.Items.RemoveAt(this.ListView_Trace.Items.Count - 1);
                }
            }

            if (this.ListView_Trace.SelectedIndices.Count > 0)
            {
                this.ListView_Trace.SelectedItems[0].Selected = false;
            }

            if(displayAllEnabledStatesToolStripMenuItem.Checked)
            {
                CurrentEnableEventList.RemoveAt(stepIndex);
            }
            else
            {
                CurrentEnableEventList.Clear();
            }
            //CurrentEnableEventList.RemoveAt(stepIndex); //.Remove(step);

            //change all nodes to white node!
            foreach (Node mapN in g.NodeMap.Values)
            {
                mapN.Attr.FillColor = Color.White;
            }

            string stepString;
            //string nextState = step.ToFullString();

            if (displayAllEnabledStatesToolStripMenuItem.Checked)
            {
                for (int i = 0; i < CurrentEnableEventList.Count; i++)
                {
                    EventStepSim simStep = CurrentEnableEventList[i];
                    simStep.IsCurrentEvent = false;
                    CurrentEnableEventList[i] = simStep;
                }
            }

            if (step.StepVisited(visited, out stepString))
            {
                //Edge edge = g.AddEdge(step.SourceProcess, step.Event, stepString);
                //(g.NodeMap[stepString] as Node).Attr.FillColor = Color.Red;

                Node srcNode = g.FindNode(step.SourceProcess);

                Edge edge = null;
                foreach (Edge outEdge in srcNode.OutEdges)
                {
                    if (outEdge.LabelText == step.Event && outEdge.Target == stepString)
                    {
                        //duplicate edge is found
                        edge = outEdge;
                        break;
                    }
                }

                if (edge == null)
                {
                    foreach (Edge outEdge in srcNode.SelfEdges)
                    {
                        if (outEdge.LabelText == step.Event && outEdge.Target == stepString)
                        {
                            //duplicate edge is found
                            edge = outEdge;
                            break;
                        }
                    }
                }

                if (edge == null)
                {
                    edge = g.AddEdge(step.SourceProcess, step.Event, stepString);
                }

                edge.TargetNode.Attr.FillColor = Color.Red;

                AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);

                if (displayAllEnabledStatesToolStripMenuItem.Checked)
                {
                    for (int i = 0; i < CurrentEnableEventList.Count; i++)
                    {
                        EventStepSim simStep = CurrentEnableEventList[i];
                        if (simStep.SourceProcess == stepString)
                        {
                            simStep.IsCurrentEvent = true;
                            CurrentEnableEventList[i] = simStep;
                        }
                    }
                }

                List<EventStepSim> list = step.MakeOneMove(HideTauTransition);
                for (int i = 0; i < list.Count; i++)
                {
                    EventStepSim s = list[i];
                    s.SourceProcess = stepString;

                    s.IsUnvisitedStep = true;
                    foreach (Edge outEdge in edge.TargetNode.OutEdges)
                    {
                        if (outEdge.LabelText == s.Event && outEdge.Target == s.StepID)
                        {
                            s.IsUnvisitedStep = false;
                            break;
                        }
                    }

                    if (s.IsUnvisitedStep)
                    {
                        foreach (Edge outEdge in edge.TargetNode.SelfEdges)
                        {
                            if (outEdge.LabelText == s.Event && outEdge.Target == stepString)
                            {
                                s.IsUnvisitedStep = false;
                                break;
                            }
                        }
                    }

                    list[i] = s;
                }

                CurrentEnableEventList.AddRange(list);
            }
            else
            {
                visited.Add(stepString, null);

                //add the new node and set it to red.
                Node n = g.AddNode(stepString);
                n.LabelText = (g.NodeCount - 1).ToString();
                n.UserData = step; // nextState;
                n.Attr.FillColor = Color.Red;

                Edge edge = g.AddEdge(step.SourceProcess, step.Event, stepString);

                AddToTrace(edge.SourceNode.LabelText, step, n.LabelText, stepString);

                List<EventStepSim> list = step.MakeOneMove(HideTauTransition);
                for (int i = 0; i < list.Count; i++)
                {
                    EventStepSim s = list[i];
                    s.SourceProcess = stepString;

                    s.IsUnvisitedStep = true;
                    foreach (Edge outEdge in edge.TargetNode.OutEdges)
                    {
                        if (outEdge.LabelText == s.Event && outEdge.Target == s.StepID)
                        {
                            s.IsUnvisitedStep = false;
                            break;
                        }
                    }

                    if (s.IsUnvisitedStep)
                    {
                        foreach (Edge outEdge in edge.TargetNode.SelfEdges)
                        {
                            if (outEdge.LabelText == s.Event && outEdge.Target == stepString)
                            {
                                s.IsUnvisitedStep = false;
                                break;
                            }
                        }
                    }

                    list[i] = s;
                }

                CurrentEnableEventList.AddRange(list);
            }

            SimulatorViewer.Graph = g;
            SimulatorViewer.Invalidate();

            string key = GetTraceEvent(this.ListView_Trace.Items.Count) + stepString;
            if (!Mapping.ContainsKey(key))
            {
                Mapping.Add(key, new ProcessData(step, CloneGraph(g), CloneEnabledEvent()));
            }

            UpdateStore(step);

            FillCurrentEnabledList();
        }
コード例 #11
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
        private void DisplayCounterExample()
        {
            if (CanGrabLock())
            {

                DisableControls();
                try
                {
                    int LoopIndex = 0;
                    if (Assertion is AssertionLTL && Assertion.VerificationOutput.LoopIndex >= 0)
                    {
                        LoopIndex = Assertion.VerificationOutput.LoopIndex;
                    }

                    SimulationInitialize(false);

                    this.CurrentEnableEventList.Clear();
                    this.ListView_EnabledEvents.Items.Clear();

                    if (Button_DisplayCounterexample.Checked)
                    {
                        string sourceProcess = InitialState;

                        for (int j = 1; j < Assertion.VerificationOutput.CounterExampleTrace.Count; j++)
                        {
                            Node n = null;
                            Edge edge = null;

                            //EventStepSim fromStep = CounterExampleTrace[j-1];
                            ConfigurationBase stepOld = Assertion.VerificationOutput.CounterExampleTrace[j];

                            EventStepSim step = new EventStepSim(stepOld);
                            step.SourceProcess = sourceProcess;

                            string stepString;

                            if (step.StepVisited(visited, out stepString))
                            {
                                //take out the duplicated edges
                                //bool hasMatch = false;
                                Edge matchEdge = null;

                                foreach (Edge e1 in g.Edges)
                                {
                                    if (e1.Source == step.SourceProcess && e1.Target == stepString &&
                                        e1.LabelText == step.Event && e1.Attr.Color == Color.DarkOrange)
                                    {
                                        //hasMatch = true;
                                        matchEdge = e1;
                                        break;
                                    }
                                }

                                if (matchEdge == null)
                                {
                                    edge = g.AddEdge(step.SourceProcess, step.Event, stepString);
                                    n = g.NodeMap[stepString] as Node;

                                    AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);
                                }
                                else
                                {
                                    edge = matchEdge;
                                    n = edge.TargetNode;
                                    AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);

                                    sourceProcess = stepString;
                                    //continue;
                                }
                            }
                            else
                            {
                                visited.Add(stepString, null);

                                //add the new node and set it to red.
                                n = g.AddNode(stepString);
                                n.LabelText = (g.NodeCount - 1).ToString();
                                n.UserData = step; //// step.ToFullString();

                                edge = g.AddEdge(step.SourceProcess, step.Event, stepString);

                                AddToTrace(edge.SourceNode.LabelText, step, n.LabelText, stepString);
                            }

                            sourceProcess = stepString;
                            string key = GetTraceEvent(this.ListView_Trace.Items.Count) + stepString;

                            //states in SCC are yellow colored.
                            if (LoopIndex > 0 && j >= LoopIndex)
                            {
                                edge.Label.FontColor = Color.DarkOrange;
                                edge.Attr.Color = Color.DarkOrange;
                                n.Attr.FillColor = Color.Yellow;
                            }
                            else
                            {
                                //change all nodes to white node!
                                foreach (Node mapN in g.NodeMap.Values)
                                {
                                    if (mapN.Attr.FillColor == Color.Red)
                                    {
                                        mapN.Attr.FillColor = Color.White;
                                    }
                                }

                                //the last node of the path is inside SCC, which should be in yellow color!
                                if (LoopIndex > 0 && j == LoopIndex - 1)
                                {
                                    n.Attr.FillColor = Color.Yellow;
                                }
                                else
                                {
                                    n.Attr.FillColor = Color.Red;
                                }
                            }

                            if (!Mapping.ContainsKey(key))
                            {
                                Mapping.Add(key,
                                            new ProcessData(step, CloneGraph(g), CloneEnabledEvent()));
                            }

                            UpdateStore(step);
                        }

                        SimulatorViewer.Graph = g;
                        SimulatorViewer.Invalidate();
                    }
                    //else
                    //{
                    //    List<string> FairSCC = (Assertion as AssertionLTL).FairSCC;
                    //    Dictionary<int, EventBAPair> SCC2EventStepMapping = (Assertion as AssertionLTL).SCC2EventStepMapping;
                    //    Dictionary<int, List<int>> OutgoingTransitionTable =
                    //        (Assertion as AssertionLTL).OutgoingTransitionTable;

                    //    string sourceProcess = InitialState;
                    //    //print out the prefix path, and mark the last node as green color (inside SCC)
                    //    for (int j = 1; j < LoopIndex; j++)
                    //    {
                    //        AddCounterExamplePrefixPathNode(ref sourceProcess, Assertion.VerificationOutput.CounterExampleTrace[j],
                    //                                        j == LoopIndex - 1);
                    //    }

                    //    for (int i = 0; i < FairSCC.Count; i++)
                    //    {
                    //        Node n = null;
                    //        Edge edge = null;

                    //        //get sourceProcess of the current SCC node
                    //        ConfigurationBase stepSJ = SCC2EventStepMapping[FairSCC[i]].configuration;
                    //        EventStepSim stepSJSJ = new EventStepSim(stepSJ);
                    //        stepSJSJ.StepVisited(visited, out sourceProcess);

                    //        //check all the transitions
                    //        List<int> outgoing = OutgoingTransitionTable[FairSCC[i]];
                    //        for (int j = 0; j < outgoing.Count; j++)
                    //        {
                    //            int w = outgoing[j];
                    //            if (FairSCC.Contains(w))
                    //            {
                    //                ConfigurationBase stepOld = SCC2EventStepMapping[w].configuration;

                    //                EventStepSim step = new EventStepSim(stepOld); //.Process, stepOld.Event, stepOld.HidenEvent, stepOld.GlobalEnv
                    //                step.SourceProcess = sourceProcess;

                    //                string stepString;
                    //                //string nextState = step.StepToString;

                    //                if (step.StepVisited(visited, out stepString))
                    //                {
                    //                    //ignore the transition which is in side the graph already!
                    //                    bool hasMatch = false;
                    //                    foreach (Edge e1 in g.Edges)
                    //                    {
                    //                        if (e1.Source == sourceProcess && e1.Target == stepString &&
                    //                            e1.LabelText == step.Event && e1.Attr.Color == Color.DarkGreen)
                    //                        {
                    //                            hasMatch = true;
                    //                            break;
                    //                        }
                    //                    }

                    //                    if (!hasMatch)
                    //                    {
                    //                        //liuyang added code for the bug start
                    //                        //this is really a special case, where the hidden events are different for the last tau step
                    //                        if (step.Config.Event == Constants.TAU)
                    //                        {
                    //                            //ConfigurationBase[] steps = CounterExampleTrace[i - 1].MakeOneMove();
                    //                            List<EventStepSim> steps = ((g.NodeMap[sourceProcess] as Node).UserData as EventStepSim).MakeOneMove(false);
                    //                            foreach (EventStepSim istep in steps)
                    //                            {
                    //                                if (istep.StepID == stepString)
                    //                                {
                    //                                    step = istep;
                    //                                    break;
                    //                                }
                    //                            }
                    //                        }

                    //                        edge = g.AddEdge(sourceProcess, step.Event, stepString);
                    //                        //liuyang added code for the bug end

                    //                        n = g.NodeMap[stepString] as Node;

                    //                        AddToTrace(edge.SourceNode.LabelText, step, edge.TargetNode.LabelText, stepString);
                    //                    }
                    //                    else
                    //                    {
                    //                        continue;
                    //                    }
                    //                }
                    //                else
                    //                {
                    //                    visited.Add(stepString, null);

                    //                    //add the new node and set it to red.
                    //                    n = g.AddNode(stepString);
                    //                    n.LabelText = (g.NodeCount - 1).ToString();
                    //                    n.UserData = step; //// nextState;
                    //                    edge = g.AddEdge(sourceProcess, step.Event, stepString);

                    //                    AddToTrace(edge.SourceNode.LabelText, step, n.LabelText, stepString);
                    //                }

                    //                //set the current node to be Green
                    //                edge.Label.FontColor = Color.DarkGreen;
                    //                edge.Attr.Color = Color.DarkGreen;
                    //                n.Attr.FillColor = Color.LightGreen;

                    //                string key = GetTraceEvent(this.ListView_Trace.Items.Count) + stepString;
                    //                if (!Mapping.ContainsKey(key))
                    //                {
                    //                    Mapping.Add(key,
                    //                                new ProcessData(step, CloneGraph(g), CloneEnabledEvent()));
                    //                }

                    //                UpdateStore(step);
                    //            }
                    //        }
                    //    }

                    //    SimulatorViewer.Graph = g;
                    //    SimulatorViewer.Invalidate();
                    //}

                    StatusLabel.Text = string.Format(Resources.Graph_Generated___0__Nodes___1__Edges, (g.NodeCount - 1),
                                                     (g.EdgeCount - 1));

                    this.CurrentEnableEventList.Clear();
                    this.ListView_EnabledEvents.Items.Clear();

                    EnableControls();

                }
                catch (Exception ex)
                {
                    PrintErrorMsg(ex);
                }
            }
        }
コード例 #12
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
 private List<EventStepSim> CloneEnabledEvent()
 {
     List<EventStepSim> events = new List<EventStepSim>();
     foreach (EventStepSim sim in CurrentEnableEventList)
     {
         EventStepSim step = new EventStepSim(sim.Config);
         step.IsUnvisitedStep = sim.IsUnvisitedStep;
         step.IsCurrentEvent = sim.IsCurrentEvent;
         step.SourceProcess = sim.SourceProcess;
         step.StepToString = sim.StepToString;
         events.Add(step);
     }
     return events;
 }
コード例 #13
0
ファイル: EventStepSim.cs プロジェクト: nhannhan159/PAT
        public List<EventStepSim> MakeOneMove(bool HideTauTransition)
        {
            List<EventStepSim> listResutlt = new List<EventStepSim>();
            IEnumerable<ConfigurationBase> list = Config.MakeOneMove();

            if(HideTauTransition)
            {
                //for the current moves
                foreach (ConfigurationBase step in list)
                {
                    //if is not tau, means a valid one
                    if (step.Event != Common.Classes.Ultility.Constants.TAU)
                    {
                        //then we find the tau-reachable of this step
                        AddAllTauReachableSteps(step, listResutlt);
                    }
                    //this should be case for initial event
                    else if (Config.Event == Common.Classes.Ultility.Constants.INITIAL_EVENT)
                    {
                        Debug.Assert(Config.Event == Common.Classes.Ultility.Constants.INITIAL_EVENT);

                        NormalizedState NState = NormalizedState.TauReachable(new List<ConfigurationBase>() {step});

                        foreach (ConfigurationBase state in NState.States)
                        {
                            IEnumerable<ConfigurationBase> templist = state.MakeOneMove();

                            foreach (ConfigurationBase step1 in templist)
                            {
                                if (step1.Event != Common.Classes.Ultility.Constants.TAU)
                                {
                                    //then we find the tau-reachable of this step
                                    AddAllTauReachableSteps(step1, listResutlt);
                                }
                            }
                        }
                    }
                }

            }
            else
            {
                foreach (ConfigurationBase step in list)
                {
                    bool contains = false;
                    EventStepSim step1Sim = new EventStepSim(step);
                    foreach (EventStepSim sim in listResutlt)
                    {
                        if (sim.Event == step.Event && sim.StepID == step1Sim.StepID)
                        {
                            contains = true;
                            break;
                        }
                    }

                    //duplicated steps should not be added in.
                    if (!contains)
                    {
                        listResutlt.Add(step1Sim);
                    }
                }
            }

            return listResutlt;
        }
コード例 #14
0
ファイル: EventStepSim.cs プロジェクト: nhannhan159/PAT
        private void AddAllTauReachableSteps(ConfigurationBase step, List<EventStepSim> listResutlt)
        {
            NormalizedState NState = NormalizedState.TauReachable(new List<ConfigurationBase>() {step});

            foreach (ConfigurationBase state in NState.States)
            {
                //for each step in this
                IEnumerable<ConfigurationBase> templist = state.MakeOneMove();

                bool hasNonTauEvent = false;
                foreach (ConfigurationBase step1 in templist)
                {
                    if (step1.Event != Common.Classes.Ultility.Constants.TAU)
                    {
                        hasNonTauEvent = true;
                        break;
                    }
                }

                //if the step has non-tau transition, this should be a boundary step, and we need to keep it
                if (hasNonTauEvent || state.IsDeadLock)
                {
                    if (state.Event == Common.Classes.Ultility.Constants.TAU)
                    {
                        //do we need to add the *
                        state.Event = step.Event; //+ "*"
                        state.DisplayName = null;
                    }

                    EventStepSim step1Sim = new EventStepSim(state);

                    bool contains = false;
                    foreach (EventStepSim sim in listResutlt)
                    {
                        if (sim.Event == step1Sim.Event && sim.StepID == step1Sim.StepID)
                        {
                            contains = true;
                            break;
                        }
                    }

                    //duplicated steps should not be added in.
                    if (!contains)
                    {
                        listResutlt.Add(step1Sim);
                    }
                }
            }
        }
コード例 #15
0
ファイル: EventStepSim.cs プロジェクト: vu111293/pat-design
        public List <EventStepSim> MakeOneMove(bool HideTauTransition)
        {
            List <EventStepSim>             listResutlt = new List <EventStepSim>();
            IEnumerable <ConfigurationBase> list        = Config.MakeOneMove();

            if (HideTauTransition)
            {
                //for the current moves
                foreach (ConfigurationBase step in list)
                {
                    //if is not tau, means a valid one
                    if (step.Event != Common.Classes.Ultility.Constants.TAU)
                    {
                        //then we find the tau-reachable of this step
                        AddAllTauReachableSteps(step, listResutlt);
                    }
                    //this should be case for initial event
                    else if (Config.Event == Common.Classes.Ultility.Constants.INITIAL_EVENT)
                    {
                        Debug.Assert(Config.Event == Common.Classes.Ultility.Constants.INITIAL_EVENT);

                        NormalizedState NState = NormalizedState.TauReachable(new List <ConfigurationBase>()
                        {
                            step
                        });

                        foreach (ConfigurationBase state in NState.States)
                        {
                            IEnumerable <ConfigurationBase> templist = state.MakeOneMove();

                            foreach (ConfigurationBase step1 in templist)
                            {
                                if (step1.Event != Common.Classes.Ultility.Constants.TAU)
                                {
                                    //then we find the tau-reachable of this step
                                    AddAllTauReachableSteps(step1, listResutlt);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (ConfigurationBase step in list)
                {
                    bool         contains = false;
                    EventStepSim step1Sim = new EventStepSim(step);
                    foreach (EventStepSim sim in listResutlt)
                    {
                        if (sim.Event == step.Event && sim.StepID == step1Sim.StepID)
                        {
                            contains = true;
                            break;
                        }
                    }

                    //duplicated steps should not be added in.
                    if (!contains)
                    {
                        listResutlt.Add(step1Sim);
                    }
                }
            }

            return(listResutlt);
        }
コード例 #16
0
ファイル: SimulationWorker.cs プロジェクト: nhannhan159/PAT
        public void AddToTrace(string srcID, EventStepSim step, string id, string key)
        {
            ListViewItem item = new ListViewItem(new string[] { srcID, step.Event, id, step.SourceProcess });
            ListView_Trace.Items.Add(item);

            item = new ListViewItem(new string[] { srcID, step.Event, id, step.SourceProcess });
            item.Tag = key;

            OnAction(item);
        }
コード例 #17
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
        private void SimulationInitialize(bool moveFirsStep)
        {
            //clear the trace and visited table
            Traces.Clear();
            visited.Clear();
            ListView_Trace.Items.Clear();

            //get the starting process

            //create the initial step
            EventStepSim initialStep = new EventStepSim(Spec.SimulationInitialization(this.ComboBox_Process.Text));
            //new EventStepSim(startingProcess, Common.Ultility.Constants.INITIAL_EVENT, null, SpecProcess.GetEnvironment()));

            //use the process string as the definition ref string, this is the only special case needs to be taken care of
            //initialStep.ProcessToString = startingProcess.Def.ToString();
            //todo: tobe checked
            //initialStep.ProcessToString = startingProcess.ToString();

            InitialState = initialStep.StepID;

            //string initialLabel = initialStep.ToFullString();

            AddToTrace("0", initialStep, "1", InitialState);

            CurrentEnableEventList.Clear();

            if (moveFirsStep)
            {
                //try
                //{
                List<EventStepSim> list = initialStep.MakeOneMove(HideTauTransition);

                for (int i = 0; i < list.Count; i++)
                {
                    EventStepSim step = list[i];
                    step.SourceProcess = InitialState;
                    step.IsUnvisitedStep = true;
                    list[i] = step;
                }

                CurrentEnableEventList.AddRange(list);
                //}
                //catch (Exception ex)
                //{

                //}
            }

            visited.Add(InitialState, null);

            g = new Graph("Graph");
            //g.GraphAttr.Orientation = System.Windows.Forms.Orientation.Landscape;
            g.Attr.LayerDirection = Direction;
            Node n = g.AddNode(InitialState);
            n.Attr.FillColor = Color.Red;
            n.LabelText = "1";
            n.UserData = initialStep; //initialLabel;

            Node tempN = g.AddNode(INITIAL_STATE);
            tempN.Attr.LineWidth = 0;
            tempN.Attr.Color = Color.White;
            tempN.LabelText = "";
            tempN.UserData = "";
            g.AddEdge(INITIAL_STATE, InitialState);

            //clear the mapping table
            Mapping.Clear();
            Mapping.Add(GetTraceEvent(this.ListView_Trace.Items.Count) + InitialState,
                        new ProcessData(initialStep, CloneGraph(g), CloneEnabledEvent()));

            SimulatorViewer.Graph = g;
            SimulatorViewer.Validate();

            FillCurrentEnabledList();
            UpdateStore(initialStep);

            WarningFlag = false;
        }
コード例 #18
0
ファイル: SimulationWorker.cs プロジェクト: nhannhan159/PAT
 public void MyInit(EventStepSim currentStep, string currentNode)
 {
     this.graph = new Graph("myGraph");
     this.initialStep = currentStep;
     this.initialString = currentNode;
     this.ListView_Trace = new ListView();
     this.visited = new Hashtable();
     this.Mapping = new Dictionary<string, ProcessData>();
 }
コード例 #19
0
ファイル: SimulationForm.cs プロジェクト: nhannhan159/PAT
 private void UpdateStore(EventStepSim step)
 {
     StateInfoControl.SetText(step.StepToString,
                              Spec.MapConfigurationToImage(step.Config, (StateInfoControl.Width - 15)*2));
 }