protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry)
        {
            string plotName = "Devices " + srcEntry.HouseholdKey + " " + srcEntry.LoadTypeInformation?.Name;

            Profiler.StartPart(Utili.GetCurrentMethodAndClass());
            var lti = srcEntry.LoadTypeInformation;

            if (lti == null)
            {
                throw new LPGException("LTI was null");
            }

            var timestep         = srcEntry.TimeResolution;
            var unitName         = lti.Name + " in " + lti.UnitOfPower + string.Empty;
            var yaxisLabel       = ChartLocalizer.Get().GetTranslation(unitName);
            var conversionfactor = lti.ConversionFaktor;

            if (srcEntry.FullFileName == null)
            {
                throw new LPGException("filename was null");
            }
            GetFirstAndLastDate(srcEntry.FullFileName, out DateTime first, out var last);
            var selectedDateTimes = new List <DateTime>();
            var r       = new Random();
            var allDays = new List <DateTime>();
            var curr    = first;

            while (curr <= last)
            {
                allDays.Add(curr);
                curr = curr.AddDays(1);
            }
            for (var i = 0; i < DaysToMake && allDays.Count > 0; i++)
            {
                var idx = r.Next(allDays.Count);
                selectedDateTimes.Add(allDays[idx]);
                allDays.RemoveAt(idx);
            }
            selectedDateTimes.Sort();
            //var tagFiles =_Parameters.BaseDirectory.GetFiles(Constants.DeviceTaggingSetFileName);
            var taggingSets = DeviceTaggingSetList.Read(_srls);
            var x           = ReadAllDays(srcEntry, conversionfactor, selectedDateTimes,
                                          taggingSets, plotName, Parameters.BaseDirectory,
                                          yaxisLabel, timestep);

            Profiler.StopPart(Utili.GetCurrentMethodAndClass());
            return(x);
        }
        private FileProcessingResult ReadAllDays([JetBrains.Annotations.NotNull] ResultFileEntry rfe, double conversionfactor, [JetBrains.Annotations.NotNull] List <DateTime> selectedDateTimes,
                                                 [JetBrains.Annotations.NotNull] DeviceTaggingSetList taggingSets, [JetBrains.Annotations.NotNull] string plotName, [JetBrains.Annotations.NotNull] DirectoryInfo basisPath, [JetBrains.Annotations.NotNull] string yaxisLabel,
                                                 TimeSpan timestep)
        {
            var pngCount = 0;

            try {
                var headers = new List <string>();
                if (rfe.FullFileName == null)
                {
                    throw new LPGException("filename was null");
                }
                using (var sr = new StreamReader(rfe.FullFileName)) {
                    var topLine = sr.ReadLine();
                    if (topLine == null)
                    {
                        throw new LPGException("Readline failed.");
                    }
                    var header1 = topLine.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                    if (header1.Length < 2)
                    {
                        throw new LPGException("Could not split the line from the device profiles properly: " +
                                               header1);
                    }
                    headers.AddRange(header1);
                    var dayEntry = new DayEntry(DateTime.MinValue);
                    while (!sr.EndOfStream)
                    {
                        var s = sr.ReadLine();
                        if (s == null)
                        {
                            throw new LPGException("Readline failed.");
                        }
                        var cols = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None);
                        if (cols.Length < 2)
                        {
                            throw new LPGException("Could not split the line from the device profiles properly: " + s);
                        }

                        var success1 = DateTime.TryParse(cols[1], CultureInfo.CurrentCulture, DateTimeStyles.None,
                                                         out var dt);
                        if (!success1)
                        {
                            Logger.Error("Parsing failed in Deviceprofile.MakePlot.");
                            continue;
                        }
                        if (GetDay(dt) != dayEntry.Day)
                        {
                            if (selectedDateTimes.Contains(dayEntry.Day))
                            {
                                var loadtypeNames =
                                    taggingSets.TaggingSets.SelectMany(x => x.LoadTypesForThisSet).Select(y => y.Name)
                                    .ToList();
                                foreach (var deviceTaggingSetInfo in taggingSets.TaggingSets)
                                {
                                    {
                                        var sum = dayEntry.Values.Select(x => x.Sum()).Sum();
                                        if (loadtypeNames.Contains(rfe.LoadTypeInformation?.Name) && Math.Abs(sum) > Constants.Ebsilon)
                                        {
                                            var makePng = pngCount <= 8;
                                            MakeChartFromDay(rfe.FullFileName, plotName, basisPath, yaxisLabel,
                                                             timestep,
                                                             headers,
                                                             dayEntry, deviceTaggingSetInfo, makePng);
                                            GC.WaitForPendingFinalizers();
                                            GC.Collect();

                                            pngCount++;
                                        }
                                    }
                                }
                            }
                            dayEntry = new DayEntry(GetDay(dt));
                        }
                        dayEntry.Times.Add(dt);
                        var result = new double[headers.Count];
                        for (var index = 0; index < cols.Length; index++)
                        {
                            var col     = cols[index];
                            var success = double.TryParse(col, out double d);
                            if (success)
                            {
                                result[index] = d / conversionfactor;
                            }
                        }
                        dayEntry.Values.Add(result);
                    }
                }
            }
            catch (Exception ex) {
                Logger.Exception(ex);
                throw;
            }
            if (pngCount > 0)
            {
                return(FileProcessingResult.ShouldCreateFiles);
            }
            return(FileProcessingResult.NoFilesTocreate);
        }