示例#1
0
        public ICollection <ProjectBean> extract()
        {
            ICollection <StatDataHolder> tracker = TimeTrackerEngine.getStatistics();

            Dictionary <long, IntervalHolder[]> groupedByProjectId = (Dictionary <long, IntervalHolder[]>)tracker.GroupBy(item => item.projectId)
                                                                     .ToDictionary(
                item => item.Key,
                item => item.Select(i => i.time).ToArray()
                );
            ICollection <ProjectBean> result = new List <ProjectBean>();

            foreach (long key in groupedByProjectId.Keys)
            {
                IntervalHolder[] ih = groupedByProjectId[key];

                double totalTime = 0;

                foreach (IntervalHolder h in ih)
                {
                    totalTime += h.getTo() - h.getFrom();
                }

                result.Add(new ProjectBean(key, key.ToString(), totalTime));
            }

            return(result);
        }
示例#2
0
        public ICollection <ResourceBean> extract()
        {
            ICollection <StatDataHolder> tracker = TimeTrackerEngine.getStatistics();
            IDictionary <ResourceDataHolder, IList <IntervalHolder> > resources = new Dictionary <ResourceDataHolder, IList <IntervalHolder> >();

            foreach (StatDataHolder statDH in tracker)
            {
                foreach (ResourceDataHolder resDH in statDH.resources)
                {
                    if (resources.ContainsKey(resDH))
                    {
                        resources[resDH].Add(statDH.time);
                    }
                    else
                    {
                        List <IntervalHolder> time = new List <IntervalHolder>();
                        time.Add(statDH.time);
                        resources.Add(resDH, time);
                    }
                }
            }

            ICollection <ResourceBean> resourcesTimeSum = resources.Select(
                i => new ResourceBean(i.Key.id,
                                      i.Key.name,
                                      mapping[i.Key.type],
                                      i.Value.Sum(j => j.getTo() - j.getFrom()),
                                      i.Value.Sum(j => j.getTo() - j.getFrom()) / TimeTrackerEngine.fullTime * 100
                                      )
                ).ToList();

            return(resourcesTimeSum);
        }
示例#3
0
        public ICollection <ProcedureBean> extract()
        {
            ICollection <StatDataHolder> tracker = TimeTrackerEngine.getStatistics();


            var groupedByProcedure = tracker.Select(i => new { Value = i, index = i.procedureId }).
                                     GroupBy(item => item.index).
                                     ToDictionary(
                p => p.Key,
                p => p.Select(a => a.Value).ToList()
                );

            ICollection <ProcedureBean> result = new List <ProcedureBean>();

            foreach (var item in groupedByProcedure)
            {
                long procedureId         = item.Key;
                List <StatDataHolder> dh = item.Value;

                int    count = dh.Count();
                double min   = dh.Min(i => i.time.getTo() - i.time.getFrom());
                double max   = dh.Max(i => i.time.getTo() - i.time.getFrom());
                double avg   = dh.Average(i => i.time.getTo() - i.time.getFrom());

                result.Add(new ProcedureBean(procedureId, dh[0].procedureName, count, min, avg, max));
            }

            return(result);
        }
示例#4
0
        public override void execute()
        {
            Timer timer = Timer.Instance;

            double overallEfficiency = 0.0000001; //  some inaccuracy

            Project prj = getProjectFromReadyQueue();

            if (prj != null)
            {
                if (busyResBefore == null)
                {
                    busyResBefore = new List <Resource>(resources.Where(i => i.isBusy == true));
                }

                needTime = getNeedTime(overallEfficiency, prj.complexity);

                operationTime += timer.getStep();

                if (operationTime >= needTime)
                {
                    operationTime = 0;
                    Entity outputEntity = getOutputs().First();
                    outputEntity.addProjectToQueue(prj);
                    getReadyProjectQueue().Remove(prj);

                    ICollection <ResourceDataHolder> resList = getUsedResources();

                    TimeTrackerEngine.track(this.id, this.name, prj.id, resList, timer.getTime() - needTime, timer.getTime());

                    foreach (Resource res in getResources())
                    {
                        if (res is WorkerResource)
                        {
                            foreach (InstrumentResource instrument in (res as WorkerResource).instruments)
                            {
                                foreach (MaterialResource material in instrument.materials)
                                {
                                    material.users.Remove(this.id);
                                    material.isBusy = false;
                                }

                                instrument.users.Remove(this.id);
                                instrument.isBusy = false;
                            }
                        }
                        res.users.Remove(this.id);
                        res.isBusy = false;
                    }

                    busyResBefore = null;
                }
            }
        }
示例#5
0
        private void btnRun_Click(object sender, RoutedEventArgs e)
        {
            Model.Instance.timeRestriction = TimeConverter.fromHumanToModel(Project.Instance.TimeRestiction);
            TimeTrackerEngine.clear();

            controller.simulate();

            TimeWithMeasure simulationTime = TimeConverter.fromModelToHuman(controller.SimulationTime);

            time.Content          = Math.Round(simulationTime.doubleValue, 3) + " " + simulationTime.measure.Name;
            runStatus.Content     = ProcessingStateMethods.GetDescription(controller.SimulationState);
            totalRunCount.Content = totalRunCount.Content == null ? 1 : int.Parse(totalRunCount.Content.ToString()) + 1;
            if (controller.SimulationState == ProcessingState.FINE)
            {
                image.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/Resources/failure.png", UriKind.Absolute));
            }

            TimeTrackerEngine.fullTime = Timer.Instance.getTime();

            ProjectsStatisticsDE      prjExt      = new ProjectsStatisticsDE();
            ICollection <ProjectBean> projectStat = prjExt.extract();

            ProcedureStatisticsDE       procExtr      = new ProcedureStatisticsDE();
            ICollection <ProcedureBean> procedureStat = procExtr.extract();

            ResourceStatisticDE        reExt        = new ResourceStatisticDE();
            ICollection <ResourceBean> resourseStat = reExt.extract();

            taskTab.ItemsSource      = projectStat;
            procedureTab.ItemsSource = procedureStat;
            resourceTab.ItemsSource  = resourseStat;
        }