Пример #1
0
        private bool StartAction()
        {
            //ShadowMaker.ShowThis(new LoadingControl("Simulation ..."));
            modelControlGrid.IsEnabled = true;

            if (!experimenter.CheckDataCollectionExists())
            {
                var result = MessageBox.Show(App.Current.MainWindow, "There are no Data Collection measurements defined in the Model.\nDo you really want to start simulation?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                if (result == MessageBoxResult.No)
                {
                    ShadowMaker.ShadowDown();
                    return(false);
                }
            }

            if (!experimenter.CheckCountersEvaluationEnabled())
            {
                var result = MessageBox.Show(App.Current.MainWindow, "Data Collection Evaluation is disabled.\nDo you want to enable Data Collection Evaluation?\n[Press Cancel to stop simulation]", "Question", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    experimenter.EnableCountersEvaluation();
                }
                if (result == MessageBoxResult.Cancel)
                {
                    ShadowMaker.ShadowDown();
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        void btnOpenProject_Click(object sender, RoutedEventArgs e)
        {
            shadowMaker.ShowThis(new UserControl()
            {
                Content    = "Opening project...",
                FontSize   = 40,
                Foreground = Brushes.Gray,
            });
            shadowMaker.ShadowUp();

            var dlgOpenFile = new OpenFileDialog();

            dlgOpenFile.Filter = "VISSIM Laboratory project file|*.vislab";
            if (dlgOpenFile.ShowDialog().Value)
            {
                OpenProject(dlgOpenFile.FileName);
            }

            shadowMaker.ShadowDown();
        }
        private void rbCustom_Checked(object sender, RoutedEventArgs e)
        {
            var colSelectionCtrl = new ColumnSelectionControl();

            colSelectionCtrl.DataContext     = columnsList;
            colSelectionCtrl.btnClose.Click += (s_, e_) =>
            {
                foreach (var item in columnsList)
                {
                    datagrid.Columns[item.Ordinal].Visibility = item.IsVisible ? Visibility.Visible : Visibility.Collapsed;
                }

                shadowMaker.ShadowDown();
                datagrid.Items.Refresh();
            };

            shadowMaker.ShowThis(colSelectionCtrl);

            shadowMaker.ShadowUp();
        }
Пример #4
0
        private void btnLoad_Click(object sender, RoutedEventArgs e)
        {
            ShadowMaker.ShadowUp();
            ShadowMaker.ShowThis(new LoadingControl("Starting VISSIM..."));

            //???
            this.modelControlGrid.IsEnabled = false;

            experimenter.LoadModelAsync(true, this.Dispatcher, () =>
            {
                this.modelControlGrid.IsEnabled = true;
                ShadowMaker.ShadowDown();
            });
        }
Пример #5
0
        private CreateExperimentControl CreateCreateExperimentControl(Experiment.ExperimentData expData)
        {
            var ctrl = new CreateExperimentControl();

            ctrl.DataContext = expData;

            //ctrl.tbkDuration.Text = duration.ToString();
            ctrl.btnCreateExperimenet.Click += (sender_, e_) =>
            {
                experimenter.CreateExperiment(expData);

                // refresh the model experiments tree
                Refresh();
                ShadowMaker.ShadowDown();
            };

            ctrl.btnCancel.Click += (sender_, e_) =>
            {
                Refresh();
                ShadowMaker.ShadowDown();
            };

            return(ctrl);
        }
Пример #6
0
        public void AnalyzeExperiment(string modelName, Experiment exp)
        {
            if (Host.List.Count(ctrl => ctrl.ModelName == modelName && ctrl.ExperimentNumber == exp.Number) == 0)
            {
                string key = modelName + exp.Number.ToString();

                if (!experimentsCache.ContainsKey(key))
                {
                    var ctrl   = CreateModelControl(modelName, exp, true);
                    var master = CreateModelControl(modelName, exp, false);

                    ctrl.Clone   = master;
                    master.Clone = ctrl;

                    experimentsCache[key] = ctrl;
                }

                //TODO [redundancy] replace isShadowUp with shadowMaker.isShadowUp
                bool isShadowUp = false;
                if (shadowMaker.Shadow == null)
                {
                    shadowMaker.ShowThis(new LoadingControl("Loading..."));
                    shadowMaker.ShadowUp();
                    isShadowUp = true;
                }

                var control = experimentsCache[key];

                ThreadPool.QueueUserWorkItem(o =>
                {
                    aex.Protect(() =>
                    {
                        // resource-intensive
                        if (!control.HasNetwork)
                        {
                            drNetwork(control);
                        }

                        if (Host.AreCountersGlobalVisible)
                        {
                            if (!control.HasPoints)
                            {
                                drPoints(control);
                            }
                            if (!control.HasCounters)
                            {
                                drCounters(control);
                            }
                        }

                        if (Host.AreTrTimesGlobalVisible)
                        {
                            if (!control.HasSections)
                            {
                                drSections(control);
                            }
                            if (!control.HasTravelTimes)
                            {
                                drTrTimes(control);
                            }
                        }

                        control.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
                        {
                            if (Host.AreCountersGlobalVisible)
                            {
                                if (!control.IsMaster)
                                {
                                    control.Clone.OpenCountersGrid();
                                }
                                else
                                {
                                    control.OpenCountersGrid();
                                }
                            }

                            if (Host.AreTrTimesGlobalVisible)
                            {
                                if (!control.IsMaster)
                                {
                                    control.Clone.OpenTrTimesGrid();
                                }
                                else
                                {
                                    control.OpenTrTimesGrid();
                                }
                            }

                            Host.List.Add(control);
                            if (isShadowUp)
                            {
                                shadowMaker.ShadowDown();
                            }
                        }));
                    });
                });
            }
        }
Пример #7
0
        void tc_Multi()
        {
            RaiseEvent(new RoutedEventArgs(TreeControl.MultiEvent));

            ShadowMaker.ShadowUp();
            modelControlGrid.IsEnabled = false;

            var x = new StartMultirunBindingSource()
            {
                DisableAnimation = true,
                NumberOfRuns     = 3
            };

            var startCtrl = new StartMultirunControl();

            startCtrl.DataContext      = x;
            startCtrl.btnCancel.Click += (sender_, e_) =>
            {
                ShadowMaker.ShadowDown();
                modelControlGrid.IsEnabled = true;
            };
            startCtrl.btnOk.Click += (sender_, e_) =>
            {
                ShadowMaker.ShadowDown();

                if (x.NumberOfRuns > 0)
                {
                    var lc = new LoadingControl();
                    if (!vissim.IsInstanciated)
                    {
                        lc.Message = "Starting VISSIM ...";
                    }
                    else
                    {
                        lc.Message = "Simulation ...";
                    }
                    ShadowMaker.ShowThis(lc);

                    experimenter.RunMultiAsync(x, this.Dispatcher
                                               , StartAction
                                               , (expData) =>
                    {
                        var ctrl = CreateCreateExperimentControl(expData);
                        ShadowMaker.ShowThis(ctrl);
                    }
                                               , (message) =>
                    {
                        lc.Message = message;
                    }
                                               );
                }
                else
                {
                    ShadowMaker.ShowThis(startCtrl);
                }

                ShadowMaker.ShadowUp();
            };

            ShadowMaker.ShowThis(startCtrl);
        }