protected override void RunActualProcess([NotNull] ScenarioSliceParameters slice)
        {
            var dbSrcProfiles = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);
            var dbDstProfiles = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.ProfileGeneration, slice);

            dbDstProfiles.RecreateTable <ResidualProfile>();
            var bkw         = dbSrcProfiles.Fetch <BkwProfile>();
            var rlmProfiles = dbSrcProfiles.Fetch <RlmProfile>();
            var main        = new Profile(bkw[0].Profile);

            foreach (var rlm in rlmProfiles)
            {
                Profile profile = new Profile(rlm.Name, rlm.Profile.Values, rlm.Profile.EnergyOrPower);
                main = main.Minus(profile, "residual");
            }

            JsonSerializableProfile jsp = new JsonSerializableProfile(main);
            var residualProfile         = new ResidualProfile("Residual after all RLMs")
            {
                Profile = jsp
            };

            dbDstProfiles.BeginTransaction();
            dbDstProfiles.Save(residualProfile);
            dbDstProfiles.CompleteTransaction();
        }
示例#2
0
        protected override void RunActualProcess()
        {
            string                  fn          = CombineForRaw("stadtprofil_15min_auflösung.csv");
            const string            profilename = "01-bkwlast";
            var                     bkwRaw      = ZZ_ProfileImportHelper.ReadCSV(fn, profilename);
            JsonSerializableProfile jsp         = new JsonSerializableProfile(bkwRaw);
            var                     bkp         = new BkwProfile {
                Profile = jsp,
                Name    = "BKW übergabe"
            };

            var db = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);

            db.RecreateTable <BkwProfile>();
            db.BeginTransaction();
            db.Save(bkp);
            db.CompleteTransaction();
        }
        private TemperatureProfileImport ReadOneProfile([NotNull] string filename, int year)
        {
            var temps = ReadTemperatures(CombineForFlaSettings(filename));

            if (temps.Count == 8784)
            {
                temps = temps.Take(8760).ToList();
            }

            if (temps.Count != 8760)
            {
                throw new FlaException("Invalid value count: " + temps.Count);
            }

            JsonSerializableProfile  jsp = new JsonSerializableProfile(filename, temps.AsReadOnly(), EnergyOrPower.Temperatures);
            TemperatureProfileImport tpi = new TemperatureProfileImport(filename, year, jsp);

            return(tpi);
        }
 public LightingProfile([NotNull] string name, [NotNull] JsonSerializableProfile profile, [NotNull] string guid)
 {
     Name    = name;
     Profile = profile;
     Guid    = guid;
 }
示例#5
0
 public RlmProfile([JetBrains.Annotations.NotNull] string name, int id, [JetBrains.Annotations.NotNull] JsonSerializableProfile profile)
 {
     Name    = name;
     ID      = id;
     Profile = profile;
 }
示例#6
0
        private RlmProfile ImportOneProfile([NotNull] FileInfo filename)
        {
            var multiplier = 0;

            if (filename.Name.Contains("_Bezug"))
            {
                multiplier = -1;
            }

            if (filename.Name.Contains("_Abgabe"))
            {
                multiplier = 1;
            }

            if (multiplier == 0)
            {
                throw new Exception("Unknown profile type:" + filename.Name);
            }

            Info("Importing " + filename.Name);
            ExcelHelper eh  = new ExcelHelper(Services.Logger, MyStage);
            var         arr = eh.ExtractDataFromExcel2(filename.FullName, 2, "A1", "F35041", out var _);

            var hdict = new Dictionary <string, int>();

            for (var i = 0; i < arr.GetLength(1); i++)
            {
                var o = arr[0, i];
                if (o == null)
                {
                    continue;
                }

                hdict.Add(o.ToString(), i);
            }

            var vals     = new double[35040];
            var dtlookup = new Dictionary <DateTime, int>();
            var d        = new DateTime(2017, 1, 1);

            for (var i = 0; i < 35040; i++)
            {
                dtlookup.Add(d, i);
                d = d.AddMinutes(15);
            }

            for (var row = 1; row < arr.GetLength(0); row++)
            {
                if (arr[row, hdict["Zeitpunkt (Beginn Messung)"]] == null)
                {
                    continue;
                }

                if (string.IsNullOrWhiteSpace(arr[row, hdict["Zeitpunkt (Beginn Messung)"]].ToString()))
                {
                    continue;
                }

                var dt  = Helpers.GetDateTime(arr[row, hdict["Zeitpunkt (Beginn Messung)"]]);
                var idx = dtlookup[dt];
                vals[idx] = multiplier * Helpers.GetNoNullDouble(arr[row, hdict["Wert"]]);
                var unit = Helpers.GetString(arr[row, hdict["Einheit"]]);
                if (unit != "kW")
                {
                    throw new Exception("unit not kw in file:" + filename.FullName);
                }
            }

            var lstvals = new List <double>(vals);
            var prof    = new JsonSerializableProfile(filename.Name, lstvals.AsReadOnly(), EnergyOrPower.Power);
            var a       = new RlmProfile(filename.Name, 0, prof);

            if (a.Profile.Values.Any(x => double.IsNaN(x)))
            {
                throw new FlaException("Profile was broken: " + filename.FullName);
            }

            return(a);
        }