Example #1
0
        internal SeriesList CreateSelectedSeries()
        {
            TimeSeries.SeriesList rval = new TimeSeries.SeriesList();
            var selScenarios           = m_db.GetSelectedScenarios();

            for (int i = 0; i < m_selectedSeries.Length; i++)
            {
                Series s = m_selectedSeries[i];
                if (s.ScenarioName == "" || (selScenarios.Rows.Count == 0 && !IncludeBaseline))
                {
                    rval.Add(s);
                }
                else if (selScenarios.Rows.Count == 0 && IncludeBaseline)
                {
                    // baseline only.
                    var baseline = s.CreateBaseline();
                    if (!baseline.SiteID.Contains("reference"))
                    {
                        baseline.SiteID += " - reference";
                    }
                    rval.Add(baseline);
                }
                else// Using Scenarios.
                {
                    Series baseline = null;
                    foreach (var sn in selScenarios)
                    {
                        Series scenario = s.CreateScenario(sn);

                        if (baseline == null && (IncludeBaseline || SubtractFromBaseline))
                        {
                            baseline = s.CreateBaseline();
                        }

                        if (SubtractFromBaseline)
                        {
                            SubtractSeries impact = new SubtractSeries(scenario, baseline);
                            impact.Name = scenario.Name + " - " + baseline.Name;
                            impact.Appearance.LegendText = "(" + scenario.Appearance.LegendText
                                                           + ") - (" + baseline.Appearance.LegendText + ")";
                            impact.SiteID = baseline.SiteID;

                            rval.Add(impact);

                            if (IncludeSelected)
                            {
                                rval.Add(scenario);
                            }
                        }
                        else
                        {
                            rval.Add(scenario);
                        }
                    }

                    if (IncludeBaseline && baseline != null)
                    {
                        rval.Add(baseline);
                    }
                }
            }

            return(rval);
        }
Example #2
0
        internal SeriesList CreateSelectedSeries()
        {
            Logger.WriteLine("Begin CreateSelectedSeries()");

            TimeSeries.SeriesList rval = new TimeSeries.SeriesList();
            var selScenarios           = m_db.GetSelectedScenarios();

            Logger.WriteLine("There are " + m_selectedSeries.Length + " series selected");
            Logger.WriteLine("There are " + selScenarios.Rows.Count + " scenarios selected");

            for (int i = 0; i < m_selectedSeries.Length; i++)
            {
                Series s = m_selectedSeries[i];
                Logger.WriteLine("Series [" + i + "] " + s.Name);
                Logger.WriteLine(" ScenarioName: " + s.ScenarioName);

                if (s.ScenarioName == "" || (selScenarios.Rows.Count == 0 && !IncludeBaseline))
                {
                    Logger.WriteLine("Not using Scenario. Either blank scenario name, or no scenarios (unless baseline selected)");
                    rval.Add(s);
                }
                else if (selScenarios.Rows.Count == 0 && IncludeBaseline)
                {
                    // baseline only.
                    Logger.WriteLine("Not using Scenario. baseline only");
                    var baseline = s.CreateBaseline();
                    if (!baseline.SiteID.Contains("reference"))
                    {
                        baseline.SiteID += " - reference";
                    }
                    rval.Add(baseline);
                }
                else// Using Scenarios.
                {
                    Logger.WriteLine("Using scenarios");
                    Series baseline = null;
                    foreach (var sn in selScenarios)
                    {
                        Series scenario = s.CreateScenario(sn);
                        Logger.WriteLine("Scenario: " + scenario.ScenarioName);
                        if (baseline == null && (IncludeBaseline || SubtractFromBaseline))
                        {
                            baseline = s.CreateBaseline();
                        }

                        if (SubtractFromBaseline)
                        {
                            SubtractSeries impact = new SubtractSeries(scenario, baseline);
                            impact.Name = scenario.Name + " - " + baseline.Name;
                            impact.Appearance.LegendText = "(" + scenario.Appearance.LegendText
                                                           + ") - (" + baseline.Appearance.LegendText + ")";
                            impact.SiteID = baseline.SiteID;

                            rval.Add(impact);

                            if (IncludeSelected)
                            {
                                rval.Add(scenario);
                            }
                        }
                        else
                        {
                            rval.Add(scenario);
                        }
                    }

                    if (IncludeBaseline && baseline != null)
                    {
                        rval.Add(baseline);
                    }
                }
            }

            Logger.WriteLine("Finish CreateSelectedSeries()");
            return(rval);
        }