Exemple #1
0
        private void GraphBuilder_ReturnResult()
        {
            try
            {
                Mapping = GraphBuilder.Mapping;

                if (Common.Utility.Utilities.IsUnixOS)
                {
                    this.TableLayoutPanel.Controls.Clear();

                    SimulatorViewer = GraphBuilder.SimulatorViewer;
                    SimulatorViewer.Dock = DockStyle.Fill;
                    SimulatorViewer.Resize += new EventHandler(SimulatorViewer_Resize);

                    this.TableLayoutPanel.Controls.Add(this.SimulatorViewer);
                    this.TableLayoutPanel.Controls.Add(this.SplitContainer);
                    this.TableLayoutPanel.Controls.Add(this.StateInfoControl);

                }
                else
                {
                    SimulatorViewerDockWindow.Controls.Remove(SimulatorViewer);
                    SimulatorViewer = GraphBuilder.SimulatorViewer;
                    SimulatorViewer.Resize += new EventHandler(SimulatorViewer_Resize);

                    SimulatorViewerDockWindow.Controls.Add(SimulatorViewer);
                }

                if (GraphBuilder.ForceSimuationStop)
                {
                    MessageBox.Show(
                        string.Format(Resources.The_simulation_is_forced_to_stop_due_to_the_huge_space_size,
                                      Classes.Ultility.Ultility.SIMULATION_BOUND), Resources.Warning,
                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                StatusLabel.Text =
                    string.Format(Resources.Graph_Generated___0__Nodes___1__Edges, (SimulatorViewer.Graph.NodeCount - 1),
                                  (SimulatorViewer.Graph.EdgeCount - 1)) + CutNumberString;

                //StatusLabel.Text = "Graph Generated: " +  + " Nodes, " +  + " Edges" + ;

                //SimulatorViewer.Graph.UserData = Classes.Ultility.Ultility.CutNumber;todo: what is the cutnumber used here for?
                EnableControls();
                //Classes.Ultility.Ultility.CutNumber = -1;
                StateInfoControl.SetText("", null);
                Button_GenerateGraph.Text = GENERATE_GRAPH;
                GraphBuilder = null;
            }
            catch (Exception ex)
            {
                PrintErrorMsg(ex);
            }
        }
Exemple #2
0
        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);
                    }
                }
            }
        }
Exemple #3
0
        private void GraphBuilder_Failed(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                Mapping = GraphBuilder.Mapping;

                SimulatorViewerDockWindow.Controls.Remove(SimulatorViewer);
                SimulatorViewer = GraphBuilder.SimulatorViewer;
                SimulatorViewer.Resize += new EventHandler(SimulatorViewer_Resize);

                SimulatorViewerDockWindow.Controls.Add(SimulatorViewer);

                StatusLabel.Text = Resources.Error_Happened;

                if (e.Exception is RuntimeException)
                {
                    Common.Utility.Utilities.LogRuntimeException(e.Exception as RuntimeException);
                }
                else
                {
                    Common.Utility.Utilities.LogException(e.Exception, Spec);
                    //MessageBox.Show("Exception happened in simulation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                EnableControls();
                //Classes.Ultility.Ultility.CutNumber = -1;
                StateInfoControl.SetText("", null);

                Button_GenerateGraph.Text = GENERATE_GRAPH;
                GraphBuilder = null;
            }
            catch (Exception ex)
            {
                PrintErrorMsg(ex);
            }
        }