Esempio n. 1
0
        /// <summary>
        ///     Method called from the view. Generate a report from a set of selected configurations once
        ///     all conditions are fulfilled.
        /// </summary>
        public void MakeReport()
        {
            Task.Run(() =>
            {
                StartLongOperation();
                // Execute the Query
                string batchFilename = LoadedBatch;

                LoadedBatch = "Running query";

                List <TrackGroup> queryResultTracks = null;
                List <Report> queryReports          = null;
                try
                {
                    Query.Execute(LoggedExperiments, OnExperimentalUnitProcessed, out queryResultTracks, out queryReports);
                }
                catch (Exception ex)
                {
                    string exception = ex.ToString();
                }
                //Clone the query
                LogQueryViewModel clonedQuery = Serialiazer.Clone(Query);

                //Create and add to list the result of the query
                LogQueryResultViewModel result = new LogQueryResultViewModel(queryResultTracks, queryReports, clonedQuery);
                LogQueryResults.Add(result);
                //set this last result as selected
                SelectedLogQueryResult = LogQueryResults[LogQueryResults.Count - 1];

                LoadedBatch = batchFilename;
                EndLongOperation();
            });
        }
Esempio n. 2
0
        public ReportViewModel(List <TrackGroup> queryResultTracks, LogQueryViewModel query, Report report)
        {
            Name = report.Name;

            //Create the plot
            PlotViewModel newPlot = new PlotViewModel(report.Name, "Time (s)", report.Name, false, true);
            //Create the stats
            StatsViewModel newStatGroup = new StatsViewModel(report.Name);

            foreach (TrackGroup group in queryResultTracks)
            {
                //plot data
                if (group.ConsolidatedTrack != null)
                {
                    SeriesGroup seriesGroup = group.ConsolidatedTrack.SeriesGroups[report];

                    foreach (Series series in seriesGroup.SeriesList)
                    {
                        string seriesName;
                        string description;
                        if (seriesGroup.SeriesList.Count == 1)
                        {
                            //only one series per track group, no multi-series track group
                            seriesName  = group.ConsolidatedTrack.TrackId;
                            description = group.ConsolidatedTrack.FullTrackId;
                        }
                        else
                        {
                            seriesName  = group.ConsolidatedTrack.TrackId + "-" + series.Id;
                            description = group.ConsolidatedTrack.FullTrackId + "-" + series.Id;
                        }

                        //add data to the plot
                        int lineSeriesId = newPlot.AddLineSeries(seriesName, description);
                        foreach (XYValue value in series.Values)
                        {
                            newPlot.AddLineSeriesValue(lineSeriesId, value.X, value.Y);
                        }

                        StatViewModel newStat =
                            new StatViewModel(group.ExperimentId, seriesName, series.Stats
                                              , group.ConsolidatedTrack.LogBinaryFile
                                              , group.ConsolidatedTrack.LogDescriptorFile
                                              , group.ConsolidatedTrack.ExperimentalUnitConfigFile);

                        newStatGroup.addStat(newStat);
                    }
                }
            }
            Plot  = newPlot;
            Stats = newStatGroup;
        }
Esempio n. 3
0
 private ReportType GetVariableReportType(LogQueryViewModel query, string variable)
 {
     //TODO: this only returns the first report type for that variable
     //This should be improved
     foreach (LoggedVariableViewModel var in query.VariablesVM)
     {
         if (var.VariableName == variable)
         {
             return(var.SelectedPlotType);
         }
     }
     return(ReportType.Undefined);
 }
Esempio n. 4
0
        /// <summary>
        ///     Method called from the view. This clear every list and field. Should be called when
        ///     we load a new experiment if one is already loaded or when we hit the delete button
        ///     from the view.
        /// </summary>
        public void ClearReportViewer()
        {
            ExperimentalUnits.Clear();
            LoggedExperiments.Clear();
            LogQueryResults.Clear();

            NotifyOfPropertyChange(() => VariablesLoaded);
            NotifyOfPropertyChange(() => ForksLoaded);

            Query = new LogQueryViewModel();
            //Add the listening function to the LogQuery object with all the parameters
            Query.PropertyChanged += OnChildPropertyChanged;

            LogsLoaded  = false;
            ForksLoaded = false;
        }
        public LogQueryResultViewModel(List <TrackGroup> queryResultTracks, List <Report> reports, LogQueryViewModel query)
        {
            Name = getDefaultQueryResultName();

            Query = query;

            // Display the reports
            foreach (Report report in reports)
            {
                ReportViewModel newReport = new ReportViewModel(queryResultTracks, query, report);
                Reports.Add(newReport);
            }

            //Set the last as selected
            if (Reports.Count > 0)
            {
                SelectedReport = Reports[Reports.Count - 1];
            }
        }
Esempio n. 6
0
        public ReportViewModel(List <TrackGroup> queryResultTracks, LogQueryViewModel query, Report report)
        {
            Name = report.Name;

            //Create the plot
            PlotViewModel newPlot = new PlotViewModel(report.Name, "Time (s)", report.Name, false, true);

            if (!query.AverageSelectedTracks)
            {
                //Create the stats
                StatsViewModel newStatGroup = new StatsViewModel(report.Name);

                //Regular line series
                foreach (TrackGroup group in queryResultTracks)
                {
                    if (group.ConsolidatedTrack != null)
                    {
                        SeriesGroup seriesGroup = group.ConsolidatedTrack.SeriesGroups[report];

                        foreach (Series series in seriesGroup.SeriesList)
                        {
                            string seriesName;
                            string description;
                            if (seriesGroup.SeriesList.Count == 1)
                            {
                                //only one series per track group, no multi-series track group
                                seriesName  = group.ConsolidatedTrack.TrackId;
                                description = group.ConsolidatedTrack.FullTrackId;
                            }
                            else
                            {
                                seriesName  = group.ConsolidatedTrack.TrackId + "-" + series.Id;
                                description = group.ConsolidatedTrack.FullTrackId + "-" + series.Id;
                            }

                            //add data to the plot
                            int lineSeriesId = newPlot.AddLineSeries(seriesName, description);

                            //force resampling if point count is over 100
                            if (series.Values.Count > 100)
                            {
                                series.Resample(100);
                            }

                            foreach (XYValue value in series.Values)
                            {
                                newPlot.AddLineSeriesValue(lineSeriesId, value.X, value.Y);
                            }

                            StatViewModel newStat =
                                new StatViewModel(group.ExperimentId, seriesName, series.Stats
                                                  , group.ConsolidatedTrack.LogBinaryFile
                                                  , group.ConsolidatedTrack.LogDescriptorFile
                                                  , group.ConsolidatedTrack.ExperimentalUnitConfigFile);

                            newStatGroup.addStat(newStat);
                        }
                    }
                }
                Stats = newStatGroup;
            }
            else
            {
                List <Series> originalSeries = new List <Series>();
                foreach (TrackGroup group in queryResultTracks)
                {
                    //Averaged line series: we need to average all the track groups
                    SeriesGroup seriesGroup = group.ConsolidatedTrack.SeriesGroups[report];

                    //take the first series
                    originalSeries.Add(seriesGroup.SeriesList[0]);
                }

                Series.AverageSeriesList(originalSeries, out Series averages, out Series minimums, out Series maximums);

                //only one series per track group, no multi-series track group
                string seriesName  = "Averaged series";
                string description = "Averaged series";

                //add a line series to the plot
                int lineSeriesId = newPlot.AddLineSeries(seriesName, description);
                int areaSeriesId = newPlot.AddAreaSeries(seriesName, description);

                //all three output series must have the same number of elements
                int sampleCount = averages.Values.Count;
                for (int sample = 0; sample < sampleCount; sample++)
                {
                    newPlot.AddLineSeriesValue(lineSeriesId, averages.Values[sample].X, averages.Values[sample].Y);
                    newPlot.AddAreaSeriesValue(areaSeriesId, averages.Values[sample].X, minimums.Values[sample].Y, maximums.Values[sample].Y);
                }
            }

            Plot = newPlot;
        }