/* * private void WriteHeader([JetBrains.Annotations.NotNull] FileFactoryAndTracker fft, [JetBrains.Annotations.NotNull] HouseholdKey householdKey) * { * StreamWriter sw; * if (householdKey == Constants.TotalsKey) { * sw = fft.MakeFile<StreamWriter>("TotalsPerLoadtype.csv", "Totals per load type", true, * ResultFileID.Totals, Constants.TotalsKey, TargetDirectory.Reports, * _calcParameters.InternalStepsize); * } * else { * sw = fft.MakeFile<StreamWriter>("TotalsPerLoadtype." + householdKey + ".csv", * "Totals per load type for " + householdKey, true, ResultFileID.TotalsPerHousehold, * householdKey, TargetDirectory.Reports, _calcParameters.InternalStepsize); * } * _files.Add(householdKey, sw); * sw.WriteLine("Load type" + _calcParameters.CSVCharacter + "Sum" + * _calcParameters.CSVCharacter + "Units" + * _calcParameters.CSVCharacter + "Readable" + * _calcParameters.CSVCharacter + "Units" + * _calcParameters.CSVCharacter + "Per Day" + * _calcParameters.CSVCharacter + "Units" + * _calcParameters.CSVCharacter + "Minimum Values" + * _calcParameters.CSVCharacter + "Minmum Value Unit" + * _calcParameters.CSVCharacter + "Maximum Values" + * _calcParameters.CSVCharacter + "Maximum Value Unit" + * _calcParameters.CSVCharacter + "Per Person" + * _calcParameters.CSVCharacter + "Unit" + * _calcParameters.CSVCharacter + "Per Person and Day" + * _calcParameters.CSVCharacter + "Unit"); * }*/ /* * private void WriteToGeneralFile(double sum, [JetBrains.Annotations.NotNull] CalcLoadTypeDto dstLoadType, double min, double max, int numberOfPersons) * { * var s = dstLoadType.Name + _calcParameters.CSVCharacter; * s += sum + _calcParameters.CSVCharacter; * s += dstLoadType.UnitOfPower + "*" + _calcParameters.InternalStepsize.TotalSeconds + * " seconds" + _calcParameters.CSVCharacter; * s += sum * dstLoadType.ConversionFactor + _calcParameters.CSVCharacter + * dstLoadType.UnitOfSum; * var totaldays = * (_calcParameters.OfficialEndTime - _calcParameters.OfficialStartTime) * .TotalDays; * s += _calcParameters.CSVCharacter + sum * dstLoadType.ConversionFactor / totaldays + * _calcParameters.CSVCharacter + dstLoadType.UnitOfSum; * s += _calcParameters.CSVCharacter + min + _calcParameters.CSVCharacter + * dstLoadType.UnitOfPower; * s += _calcParameters.CSVCharacter + max + _calcParameters.CSVCharacter + * dstLoadType.UnitOfPower; * s += _calcParameters.CSVCharacter + sum * dstLoadType.ConversionFactor / numberOfPersons + * _calcParameters.CSVCharacter + dstLoadType.UnitOfSum; * s += _calcParameters.CSVCharacter + * sum * dstLoadType.ConversionFactor / numberOfPersons / totaldays + * _calcParameters.CSVCharacter + dstLoadType.UnitOfSum; * _fft.GetResultFileEntry(ResultFileID.Totals, null, Constants.TotalsKey, null, null).StreamWriter? * .WriteLine(s); * _fft.GetResultFileEntry(ResultFileID.Totals, null, Constants.TotalsKey, null, null).StreamWriter? * .Flush(); * }*/ protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var totaldays = (Repository.CalcParameters.OfficialEndTime - Repository.CalcParameters.OfficialStartTime).TotalDays; Dictionary <CalcLoadTypeDto, double> totalsPerLoadType = new Dictionary <CalcLoadTypeDto, double>(); //CalculateTotal(energyFileRows, loadType, totalsPerLoadType, Repository.GetPersons(householdKey).Count); var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); RunIndividualHouseholds(p.LoadType, p.EnergyFileRows, efc, totalsPerLoadType); List <TotalsPerLoadtypeEntry> totals = new List <TotalsPerLoadtypeEntry>(); foreach (HouseholdKeyEntry entry in Repository.HouseholdKeys) { if (entry.KeyType == HouseholdKeyType.General) { continue; } HouseholdKey key = entry.HHKey; int personscount = 0; if (entry.KeyType == HouseholdKeyType.Household) { personscount = Repository.GetPersons(key).Count; } foreach (KeyValuePair <CalcLoadTypeDto, double> pair in totalsPerLoadType) { totals.Add(new TotalsPerLoadtypeEntry(key, pair.Key, pair.Value, personscount, totaldays)); } } _inputDataLogger.SaveList(totals.ConvertAll(x => (IHouseholdKey)x)); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var dsc = new DateStampCreator(Repository.CalcParameters); var calcParameters = Repository.CalcParameters; CalcLoadTypeDto dstLoadType = p.LoadType; var householdKey = Constants.GeneralHouseholdKey; var sumfile = _fft.MakeFile <StreamWriter>("SumProfiles." + dstLoadType.Name + ".csv", "Summed up energy profile for all devices for " + dstLoadType.Name, true, ResultFileID.CSVSumProfile, householdKey, TargetDirectory.Results, calcParameters.InternalStepsize, CalcOption.HouseSumProfilesFromDetailedDats, dstLoadType.ConvertToLoadTypeInformation()); sumfile.WriteLine(dstLoadType.Name + "." + dsc.GenerateDateStampHeader() + "Sum [" + dstLoadType.UnitOfSum + "]"); foreach (var efr in p.EnergyFileRows) { if (!efr.Timestep.DisplayThisStep) { continue; } var time = dsc.MakeTimeString(efr.Timestep); var sumstring = time + (efr.SumCached * dstLoadType.ConversionFactor).ToString(Config.CultureInfo); sumfile.WriteLine(sumstring); } }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var dsc = new DateStampCreator(Repository.CalcParameters); var dstLoadType = p.LoadType; var householdKey = Constants.GeneralHouseholdKey; var calcParameters = Repository.CalcParameters; var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); var deviceProfileCsv = _fft.MakeFile <StreamWriter>("DeviceProfiles." + dstLoadType.Name + ".csv", "Energy use by each device in each Timestep for " + dstLoadType.Name + " for the entire house", true, ResultFileID.DeviceProfileCSV, householdKey, TargetDirectory.Results, calcParameters.InternalStepsize, CalcOption.DeviceProfilesHouse, dstLoadType.ConvertToLoadTypeInformation()); deviceProfileCsv.WriteLine(dstLoadType.Name + "." + dsc.GenerateDateStampHeader() + efc.GetTotalHeaderString(dstLoadType, null)); foreach (var efr in p.EnergyFileRows) { if (!efr.Timestep.DisplayThisStep) { continue; } var time = dsc.MakeTimeString(efr.Timestep); var individual = time + efr.GetEnergyEntriesAsString(true, dstLoadType, null, calcParameters.CSVCharacter); deviceProfileCsv.WriteLine(individual); } deviceProfileCsv.Flush(); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); Run(p.LoadType, p.EnergyFileRows, _fft, efc); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; RunPolysun(p.LoadType, p.EnergyFileRows, _fft, Repository.CalcObjectInformation.CalcObjectName); //var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); //RunIndividualHouseholdsPolysun(p.LoadType,p.EnergyFileRows,_fft,efc); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); Run(p.LoadType, p.EnergyFileRows, efc); foreach (HouseholdKeyEntry key in Repository.HouseholdKeys) { RunIndividualHouseholds(p.LoadType, p.EnergyFileRows, efc, key.HHKey); } }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; var efc = Repository.ReadEnergyFileColumns(Constants.GeneralHouseholdKey); if (!efc.ColumnCountByLoadType.ContainsKey(p.LoadType)) { //this household / house has no devices of this load type return; } Run(p.LoadType, p.EnergyFileRows, efc); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; Run(p.LoadType, p.EnergyFileRows, _fft); }
private void RunLoadTypeDependend([CanBeNull][ItemNotNull] List <string> loadTypesForPostProcessing) { if (_loadTypeSumPostProcessingSteps.Any(x => x.IsEnabled())) { _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - Calculation of the sums per load type"); foreach (var calcLoadType in _repository.LoadTypes) { //if (!_fft.CheckForResultFileEntry(ResultFileID.OnlineSumActivationFiles, // calcLoadType.Name, // Constants.GeneralHouseholdKey, // null, // null)) { // Logger.Info("Skipping post-processing of load type " + calcLoadType.Name + // " because there was no sum dat file generated for it."); // continue; //} if (loadTypesForPostProcessing != null && loadTypesForPostProcessing.Count > 0 && !loadTypesForPostProcessing.Contains(calcLoadType.Name)) { Logger.Info("Skipping post-processing of load type " + calcLoadType.Name + " because it was not specified."); continue; } _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - " + calcLoadType.Name); foreach (ILoadTypeSumStep loadTypePostProcessingStep in _loadTypeSumPostProcessingSteps) { LoadtypeSumStepParameters ltsp = new LoadtypeSumStepParameters(calcLoadType); loadTypePostProcessingStep.Run(ltsp); } _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - " + calcLoadType.Name); } _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - Calculation of the sums per load type"); } if (!_loadTypePostProcessingSteps.Any(x => x.IsEnabled()) && !_householdloadTypePostProcessingSteps.Any(x => x.IsEnabled()) ) { return; } _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - Calculation of the individual profiles for devices and households"); // needs to be persistent object to keep the dictionary for all load types int fileCount = 0; foreach (var calcLoadType in _repository.LoadTypes) { if (!_fft.CheckForResultFileEntry(ResultFileID.OnlineDeviceActivationFiles, calcLoadType.Name, Constants.GeneralHouseholdKey, null, null)) { Logger.Info("Skipping post-processing of load type " + calcLoadType.Name + " because there was no dat file generated for it."); continue; } if (loadTypesForPostProcessing != null && loadTypesForPostProcessing.Count > 0 && !loadTypesForPostProcessing.Contains(calcLoadType.Name)) { Logger.Info("Skipping post-processing of load type " + calcLoadType.Name + " because it was not specified."); continue; } _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass() + " - " + calcLoadType.Name); List <OnlineEnergyFileRow> energyFileRows = ReadOnlineEnergyFileRowsIntoMemory(calcLoadType, out var total); fileCount++; if (Config.IsInUnitTesting && Config.ExtraUnitTestChecking) { Logger.Info("Starting total:" + total); CheckTotalsForChange(energyFileRows, total); } foreach (ILoadTypeStep loadTypePostProcessingStep in _loadTypePostProcessingSteps) { LoadtypeStepParameters ltsp = new LoadtypeStepParameters(calcLoadType, energyFileRows); loadTypePostProcessingStep.Run(ltsp); } foreach (HouseholdKeyEntry entry in _repository.HouseholdKeys) { foreach (var ltpps in _householdloadTypePostProcessingSteps) { HouseholdLoadtypeStepParameters ltsp = new HouseholdLoadtypeStepParameters(entry, calcLoadType, energyFileRows); ltpps.Run(ltsp); } } _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - " + calcLoadType.Name); } if (fileCount == 0) { var ltp = _loadTypePostProcessingSteps.Where(x => x.IsEnabled()).Select(x => x.StepName).ToList(); var hhltp = _householdloadTypePostProcessingSteps.Where(x => x.IsEnabled()).Select(x => x.StepName) .ToList(); string s1 = string.Join("\n", ltp); string s2 = string.Join("\n", hhltp); throw new LPGException("Not a single file for postprocessing was found, but the following steps were enabled:" + s1 + "\n" + s2); } _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass() + " - Calculation of the individual profiles for devices and households"); //if (_repository.DeviceSumInformationList.DeviceSums.Count > 0) { // _repository.DeviceSumInformationList.WriteJson(_fft, _repository.CalcParameters.InternalStepsize); // } }