Ejemplo n.º 1
0
        public void AddNewModelAsync(string modelName, Dispatcher context, UserControl transitControl, Action <bool, string, UserControl> finalAction)
        {
            ThreadPool.QueueUserWorkItem(o =>
            {
                aex.Protect(() =>
                {
                    bool result = AddNewModel(modelName);

                    context.Invoke(DispatcherPriority.Background,
                                   new ThreadStart(delegate()
                    {
                        finalAction(result, modelName, transitControl);
                    }));
                });
            });
        }
Ejemplo n.º 2
0
        private void Host_GenerateCountersReport(object sender, EventArgs <DataTableEx, Dispatcher> e)
        {
            var list = new List <TwoStrings>();

            var dt = e.Value.dt = new DataTable();

            dt.Columns.Add(new DataColumn("Experiment"));
            dt.Columns.Add(new DataColumn("Measur\x2024"));

            e.Param.Invoke(DispatcherPriority.Background, new ThreadStart(delegate()
            {
                list = (from m in Host.List
                        select new TwoStrings()
                {
                    ModelName = m.ModelName,
                    ExperimentNumber = m.ExperimentNumber,
                }).ToList();
            }));

            var dirs = from m in list
                       select new
            {
                ExpName = string.Format("{0}#{1}", m.ModelName, m.ExperimentNumber),
                Path    = clerk.GetExperimentModelDirName(m.ModelName, m.ExperimentNumber)
            };

            var experiments = from d in dirs
                              select new DataCollection()
            {
                ExperimentName = d.ExpName,
                AggregatedData = TextProcessor.GetCountersData2(d.Path)
            };

            // columns
            var parameters = from exp in experiments
                             from data in exp.AggregatedData
                             from cell in data.Cells
                             group cell by new { F = cell.Function, H = cell.Header, V = cell.VehType } into gr
            select BuildHeader(new DataCollectionItem()
            {
                Function = gr.Key.F,
                Header   = gr.Key.H,
                VehType  = gr.Key.V,
            });;

            // creating columns
            foreach (var param in parameters)
            {
                var col = new DataColumn(param);
                dt.Columns.Add(col);
            }

            var xxx = from exp in experiments
                      from data in exp.AggregatedData
                      //group data by new { data.Id, exp.ExperimentName } into gr
                      select new
            {
                CounterId = data.Id.ToString(),
                ExpName   = exp.ExperimentName,
            };

            foreach (var item in xxx)
            {
                var row = dt.NewRow();
                row[0] = item.ExpName;
                row[1] = item.CounterId;
                aex.Protect(() => dt.Rows.Add(row));
            }

            e.Value.Items = from exp in experiments
                            from data in exp.AggregatedData
                            from cell in data.Cells
                            select new ItemDescriptor()
            {
                CounterId = data.Id.ToString(),
                ColName   = BuildHeader(cell),
                RowName   = exp.ExperimentName,
                Value     = cell,
            };

            foreach (var item in e.Value.Items)
            {
                var row = dt.Select(string.Format("[Experiment] = '{0}' AND [Measur\x2024] = '{1}'"
                                                  , item.RowName
                                                  , item.CounterId)).FirstOrDefault();

                row.SetField <DataCollectionItem>(item.ColName, item.Value);
            }
        }
Ejemplo n.º 3
0
        public void LoadModelToVissim(bool forceLoadVissim)
        {
            if (forceLoadVissim || vissim.IsInstanciated)
            {
                string net    = manager.GetModelInputFileName(modelName);
                string layout = manager.GetModelSettingsFileName(modelName);

                aex.Protect(() => vissim.Instance.LoadNet(net));
                aex.Protect(() => vissim.Instance.LoadLayout(layout));
            }
        }