Exemple #1
0
        protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry)
        {
            //AffordanceEnergyUseLogger aeul = new AffordanceEnergyUseLogger(_srls);
            string plotName = "Affordance Energy Use " + srcEntry.HouseholdNumberString + " " +
                              srcEntry.LoadTypeInformation?.Name;

            Profiler.StartPart(Utili.GetCurrentMethodAndClass());
            const FileProcessingResult fpr = FileProcessingResult.ShouldCreateFiles;
            var consumption = new List <Tuple <string, double> >();
            var taggingSets = new List <ChartTaggingSet>();

            if (srcEntry.FullFileName == null)
            {
                throw new LPGException("Srcfile was null");
            }
            using (var sr = new StreamReader(srcEntry.FullFileName)) {
                var header = sr.ReadLine();
                if (header == null)
                {
                    throw new LPGException("Affordance Energy Use file was empty.");
                }
                var headerArr = header.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                for (var i = 2; i < headerArr.Length; i++)
                {
                    if (!string.IsNullOrWhiteSpace(headerArr[i]))
                    {
                        taggingSets.Add(new ChartTaggingSet(headerArr[i]));
                    }
                }
                while (!sr.EndOfStream)
                {
                    var s = sr.ReadLine();
                    if (s == null)
                    {
                        throw new LPGException("Readline failed.");
                    }
                    var cols = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                    var d    = Convert.ToDouble(cols[1], CultureInfo.CurrentCulture);
                    consumption.Add(new Tuple <string, double>(cols[0], d));
                    if (cols.Length < 2)
                    {
                        throw new LPGException("The string " + s +
                                               " did not contain any csv characters, even though it should. Affordance energy use plot could not be created.");
                    }
                    for (var i = 2; i < cols.Length; i++)
                    {
                        taggingSets[i - 2].AffordanceToCategories.Add(cols[0], cols[i]);
                    }
                }
            }
            if (taggingSets.Count == 0)
            {
                Profiler.StopPart(Utili.GetCurrentMethodAndClass());
                return(FileProcessingResult.NoFilesTocreate);
            }
            MakeIntervalBars(srcEntry, plotName, Parameters.BaseDirectory, consumption, taggingSets);
            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
            return(fpr);
        }
 protected ChartBaseFileStep([JetBrains.Annotations.NotNull] ChartCreationParameters parameters,
                             [JetBrains.Annotations.NotNull] FileFactoryAndTracker fft, [JetBrains.Annotations.NotNull] ICalculationProfiler calculationProfiler,
                             [JetBrains.Annotations.NotNull] List <ResultFileID> validResultFileIds, [JetBrains.Annotations.NotNull] string stepName,
                             FileProcessingResult shouldHaveProducedFiles) : base(parameters, stepName, shouldHaveProducedFiles, fft)
 {
     _calculationProfiler = calculationProfiler;
     ResultFileIDs        = validResultFileIds;
 }
 protected GenericChartBase([JetBrains.Annotations.NotNull] ChartCreationParameters parameters,
                            [JetBrains.Annotations.NotNull] string stepName,
                            FileProcessingResult shouldHaveProducedFiles,
                            [JetBrains.Annotations.NotNull] FileFactoryAndTracker fft)
 {
     _parameters             = parameters;
     StepName                = stepName;
     ShouldHaveProducedFiles = shouldHaveProducedFiles;
     FFT = fft;
 }