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(); }
/* * 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) { return; #pragma warning disable S1135 // Track uses of "TODO" tags //TODO: reimplement #pragma warning disable 162 foreach (var key in Repository.HouseholdKeys) { #pragma warning restore S1135 // Track uses of "TODO" tags var activations = Repository.LoadDeviceActivations(key.HHKey); Dictionary <StrGuid, Dictionary <string, double> > energyusePerAffordanceByLoadtype = new Dictionary <StrGuid, Dictionary <string, double> >(); foreach (DeviceActivationEntry activationEntry in activations) { if (!energyusePerAffordanceByLoadtype.ContainsKey(activationEntry.LoadTypeGuid)) { energyusePerAffordanceByLoadtype.Add(activationEntry.LoadTypeGuid, new Dictionary <string, double>()); } if (!energyusePerAffordanceByLoadtype[activationEntry.LoadTypeGuid] .ContainsKey(activationEntry.AffordanceName)) { energyusePerAffordanceByLoadtype[activationEntry.LoadTypeGuid].Add(activationEntry.AffordanceName, 0); } energyusePerAffordanceByLoadtype[activationEntry.LoadTypeGuid][activationEntry.AffordanceName] += activationEntry.TotalEnergySum; } Run(energyusePerAffordanceByLoadtype, Repository.CalcObjectInformation.CalcObjectName, new List <CalcHouseholdPlanDto>(), _fft, key.HHKey, MakeActivationsPerFrequencies.AffordanceTaggingSetByPersonByTag, MakeActivationsPerFrequencies.AffordanceTaggingSetByPersonByTagExecutioncount); } #pragma warning restore 162 }
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 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) { var calcParameters = _repository.CalcParameters; HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } var householdKey = entry.HHKey; _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass()); Logger.Info("Starting to complete list of heat gains by human activity at each time step..."); var singletimestepEntries = _repository.ReadSingleTimestepActionEntries(householdKey) .OrderBy(x => x.TimeStep) .ToList(); if (singletimestepEntries.Count == 0) { throw new LPGException("No file for actions each time step found"); } var actionEntries = _repository.ReadActionEntries(householdKey); if (actionEntries.Count == 0) { throw new LPGException(""); } var actionEntryDict = new Dictionary <StrGuid, ActionEntry>(); foreach (var ae in actionEntries) { actionEntryDict.Add(ae.ActionEntryGuid, ae); } BodilyActivityLevelStatistics bals = new BodilyActivityLevelStatistics(householdKey); foreach (BodilyActivityLevel level in Enum.GetValues(typeof(BodilyActivityLevel))) { bals.ActivityLevels.Add(level, new List <double>(new double[calcParameters.OfficalTimesteps])); } foreach (var actionEntry in singletimestepEntries) { var ae = actionEntryDict[actionEntry.ActionEntryGuid]; var ts = actionEntry.TimeStep; bals.ActivityLevels[ae.BodilyActivityLevel][ts] += 1; } _inputDataLogger.Save(householdKey, bals); _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass()); }
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) { HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } BuildActivitiesPerMinute(entry.HHKey, Repository.AffordanceTaggingSets, Repository.GetPersons(entry.HHKey)); }
protected override void PerformActualStep(IStepParameters parameters) { HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } Run(_fft, entry.HHKey); }
protected override void PerformActualStep(IStepParameters parameters) { HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } BuildActivationsPerHours(_fft, entry.HHKey, Repository.AffordanceTaggingSets, Repository.ReadActionEntries(entry.HHKey)); }
/* * [JetBrains.Annotations.NotNull] * private Dictionary<HouseholdKey, Dictionary<CalcLoadTypeDto, Dictionary<string, Dictionary<string, double>>>> * _energyUseListByHouseholdAffordancePersonAndLoadtype; * * [JetBrains.Annotations.NotNull] * private readonly Dictionary<HouseholdKey, Dictionary<CalcLoadTypeDto, Dictionary<string, List<double>>>> * _energyUseListByHouseholdAffordanceAndLoadtype; * * [JetBrains.Annotations.NotNull] * public Dictionary<HouseholdKey, Dictionary<CalcLoadTypeDto, Dictionary<string, double>>> EnergyUseByHouseholdAffordanceAndLoadtype { get; } */ /* * public void RegisterDeviceActivation([JetBrains.Annotations.NotNull] HouseholdKey householdKey, [JetBrains.Annotations.NotNull] string affordanceName, * [JetBrains.Annotations.NotNull] CalcLoadTypeDto loadType, double value, * [JetBrains.Annotations.NotNull] double[] allvalues, [JetBrains.Annotations.NotNull] string activatorName) * { * * if (!EnergyUseByHouseholdAffordanceAndLoadtype.ContainsKey(householdKey)) { * EnergyUseByHouseholdAffordanceAndLoadtype.Add(householdKey, * new Dictionary<CalcLoadTypeDto, Dictionary<string, double>>()); * _energyUseListByHouseholdAffordanceAndLoadtype.Add(householdKey, * new Dictionary<CalcLoadTypeDto, Dictionary<string, List<double>>>()); * _energyUseListByHouseholdAffordancePersonAndLoadtype.Add(householdKey, * new Dictionary<CalcLoadTypeDto, Dictionary<string, Dictionary<string, double>>>()); * } * * if (!EnergyUseByHouseholdAffordanceAndLoadtype[householdKey].ContainsKey(loadType)) { * EnergyUseByHouseholdAffordanceAndLoadtype[householdKey].Add(loadType, new Dictionary<string, double>()); * _energyUseListByHouseholdAffordanceAndLoadtype[householdKey] * .Add(loadType, new Dictionary<string, List<double>>()); * _energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey] * .Add(loadType, new Dictionary<string, Dictionary<string, double>>()); * } * * if (!_energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey][loadType] * .ContainsKey(affordanceName)) { * _energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey][loadType] * .Add(affordanceName, new Dictionary<string, double>()); * } * * if (!_energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey][loadType][affordanceName] * .ContainsKey(activatorName)) { * _energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey][loadType][affordanceName] * .Add(activatorName, 0); * } * * if (!EnergyUseByHouseholdAffordanceAndLoadtype[householdKey][loadType].ContainsKey(affordanceName)) { * EnergyUseByHouseholdAffordanceAndLoadtype[householdKey][loadType].Add(affordanceName, 0); * _energyUseListByHouseholdAffordanceAndLoadtype[householdKey][loadType] * .Add(affordanceName, new List<double>()); * } * * EnergyUseByHouseholdAffordanceAndLoadtype[householdKey][loadType][affordanceName] += value; * * _energyUseListByHouseholdAffordanceAndLoadtype[householdKey][loadType][affordanceName].AddRange(allvalues); * _energyUseListByHouseholdAffordancePersonAndLoadtype[householdKey][loadType][affordanceName][activatorName] += * value; * if (_energyUseListByHouseholdAffordanceAndLoadtype[householdKey][loadType][affordanceName].Count > * _maxTime) { * _maxTime = _energyUseListByHouseholdAffordanceAndLoadtype[householdKey][loadType][affordanceName].Count; * } * }*/ /* * public void WriteResults([JetBrains.Annotations.NotNull] List<CalcAffordanceTaggingSetDto> affTaggingSets) * { * if (_wroteResultsAlready) * { * return; * } * * foreach (var householdDict in * EnergyUseByHouseholdAffordanceAndLoadtype) * { * foreach (var loadTypeDict in householdDict.Value) * { * using (var sw = * _fft.MakeFile<StreamWriter>( * "AffordanceEnergyUse." + householdDict.Key + "." + loadTypeDict.Key.FileName + ".csv", * "Energy use per affordance " + loadTypeDict.Key.Name, true, * ResultFileID.AffordanceEnergyUse, * householdDict.Key, TargetDirectory.Reports, _calcParameters.InternalStepsize, * loadTypeDict.Key.ConvertToLoadTypeInformation())) * { * var header = "Affordance" + _calcParameters.CSVCharacter + "Energy use [" + * loadTypeDict.Key.UnitOfSum + "]" + _calcParameters.CSVCharacter; * foreach (var set in affTaggingSets) * { * if (set.LoadTypes.Contains(loadTypeDict.Key)) * { * header += set.Name + _calcParameters.CSVCharacter; * } * } * * sw.WriteLine(header); * foreach (var affordanceTuple in loadTypeDict.Value) * { * var sb = new StringBuilder(); * sb.Append(affordanceTuple.Key); * sb.Append(_calcParameters.CSVCharacter); * sb.Append(affordanceTuple.Value * loadTypeDict.Key.ConversionFactor); * foreach (var set in affTaggingSets) * { * if (set.LoadTypes.Contains(loadTypeDict.Key)) * { * sb.Append(_calcParameters.CSVCharacter); * if (set.AffordanceToTagDict.ContainsKey(affordanceTuple.Key)) * { * sb.Append(set.AffordanceToTagDict[affordanceTuple.Key]); * } * else * { * sb.Append(affordanceTuple.Key); * } * } * } * * sw.WriteLine(sb); * } * } * } * } * * foreach ( * var * householdDict in _energyUseListByHouseholdAffordancePersonAndLoadtype) * { * foreach (var loadTypeDict in * householdDict.Value) * { * using (var sw = * _fft.MakeFile<StreamWriter>( * "AffordanceEnergyUsePerPerson." + householdDict.Key + "." + loadTypeDict.Key.FileName + * ".csv", "Energy use per affordance per Person for " + loadTypeDict.Key.Name, true, * ResultFileID.AffordancePersonEnergyUse, householdDict.Key, * TargetDirectory.Reports, _calcParameters.InternalStepsize, * loadTypeDict.Key.ConvertToLoadTypeInformation())) * { * sw.WriteLine("Energy use per affordance per Person in [" + loadTypeDict.Key.UnitOfSum + "]"); * var header = "Affordance" + _calcParameters.CSVCharacter; * var persons = new List<string>(); * * foreach (var affDict in loadTypeDict.Value) * { * foreach (var person in affDict.Value) * { * if (!persons.Contains(person.Key)) * { * persons.Add(person.Key); * } * } * } * * foreach (var person in persons) * { * header += person + _calcParameters.CSVCharacter; * } * * sw.WriteLine(header); * * foreach (var affdict in loadTypeDict.Value) * { * var line = affdict.Key + _calcParameters.CSVCharacter; * * foreach (var person in persons) * { * if (affdict.Value.ContainsKey(person)) * { * line += affdict.Value[person] * loadTypeDict.Key.ConversionFactor + * _calcParameters.CSVCharacter; * } * else * { * line += 0 + _calcParameters.CSVCharacter; * } * } * * sw.WriteLine(line); * } * } * } * } * * _wroteResultsAlready = true; * }*/ protected override void PerformActualStep(IStepParameters parameters) { HouseholdLoadtypeStepParameters hsp = (HouseholdLoadtypeStepParameters)parameters; if (hsp.Key.HHKey == Constants.GeneralHouseholdKey || hsp.Key.HHKey == Constants.HouseKey) { return; } var deviceActivations = Repository.LoadDeviceActivations(hsp.Key.HHKey); if (deviceActivations.Count == 0) { throw new LPGException("No device activations were found"); } Dictionary <string, AffordanceEnergyUseEntry> energyUseEntries = new Dictionary <string, AffordanceEnergyUseEntry>(); foreach (DeviceActivationEntry ae in deviceActivations) { string key = AffordanceEnergyUseEntry.MakeKey(ae.HouseholdKey, ae.LoadTypeGuid, ae.AffordanceName, ae.ActivatorName); if (!energyUseEntries.ContainsKey(key)) { energyUseEntries.Add(key, new AffordanceEnergyUseEntry( ae.HouseholdKey, ae.LoadTypeGuid, ae.AffordanceName, ae.ActivatorName, ae.LoadTypeName)); } var aeu = energyUseEntries[key]; aeu.EnergySum += ae.TotalEnergySum; aeu.TotalActivationDurationInSteps += ae.DurationInSteps; aeu.NumberOfActivations++; } if (energyUseEntries.Count == 0) { throw new LPGException("No energy use entries were found."); } _logger.Save(hsp.Key.HHKey, energyUseEntries.Values.ToList()); }
protected override void PerformActualStep(IStepParameters parameters) { var calcParameters = _repository.CalcParameters; HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } var householdKey = entry.HHKey; _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass()); Logger.Info("Starting to complete list of actions for each person at each time step for statistical analysis..."); var displayNegativeTime = calcParameters.ShowSettlingPeriodTime; var activitiesPerPerson = ReadActivities(householdKey); //var fileIdx = 0; if (activitiesPerPerson.Count == 0) { throw new LPGException("There were no activities for any person in the household " + householdKey.Key); } List <SingleTimestepActionEntry> allSteps = new List <SingleTimestepActionEntry>(); foreach (var personActivities in activitiesPerPerson) { Logger.Info("Starting to generate the carpet plot for " + personActivities.Key.Name + "..."); var times = MakeTimeArray(displayNegativeTime, personActivities.Value); allSteps.AddRange(times); } _inputDataLogger.SaveList(allSteps.ConvertAll(x => (IHouseholdKey)x)); _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass()); }
protected override void PerformActualStep(IStepParameters parameters) { LoadtypeStepParameters p = (LoadtypeStepParameters)parameters; Run(p.LoadType, p.EnergyFileRows, _fft); }
protected override void PerformActualStep(IStepParameters parameters) { WriteAffordanceTags(); }
protected override void PerformActualStep([JetBrains.Annotations.NotNull] IStepParameters parameters) { HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; if (hhp.Key.KeyType != HouseholdKeyType.Household) { return; } if (!Repository.CalcParameters.TransportationEnabled) { return; } var hhkey = hhp.Key.HHKey; ReadActivities(hhkey, out var statebyDevice, out var siteByDevice, out var socByDevice, out var drivingDistanceByDevice); foreach (var soc in socByDevice) { //state of charge JsonSumProfile jsp = new JsonSumProfile("State of Charge for " + soc.Key + " " + hhkey.Key, Repository.CalcParameters.InternalStepsize, Repository.CalcParameters.OfficialStartTime, "State of charge - " + soc.Key, "", null, hhp.Key); foreach (var entry in soc.Value) { if (entry.Time.DisplayThisStep) { jsp.Values.Add(entry.Val); } } var sumfile = _fft.MakeFile <StreamWriter>("Soc." + soc.Key + "." + hhkey.Key + ".json", "SOC Values for " + soc.Key + " in the household " + hhkey.Key, true, ResultFileID.JsonTransportSoc, hhkey, TargetDirectory.Results, Repository.CalcParameters.InternalStepsize, CalcOption.TansportationDeviceJsons, null, null, soc.Key); sumfile.Write(JsonConvert.SerializeObject(jsp, Formatting.Indented)); sumfile.Flush(); } foreach (var soc in drivingDistanceByDevice) { //driving distance JsonSumProfile jsp = new JsonSumProfile("Driving Distance for " + soc.Key + " " + hhkey.Key, Repository.CalcParameters.InternalStepsize, Repository.CalcParameters.OfficialStartTime, "Driving Distance - " + soc.Key, "", null, hhp.Key); foreach (var entry in soc.Value) { if (entry.Time.DisplayThisStep) { jsp.Values.Add(entry.Val); } } var sumfile = _fft.MakeFile <StreamWriter>("DrivingDistance." + soc.Key + "." + hhkey.Key + ".json", "Driving Distance for " + soc.Key + " in the household " + hhkey.Key, true, ResultFileID.JsonTransportDrivingDistance, hhkey, TargetDirectory.Results, Repository.CalcParameters.InternalStepsize, CalcOption.TansportationDeviceJsons, null, null, soc.Key); sumfile.Write(JsonConvert.SerializeObject(jsp, Formatting.Indented)); sumfile.Flush(); } foreach (var soc in statebyDevice) { //driving distance JsonEnumProfile jsp = new JsonEnumProfile("Car State for " + soc.Key + " " + hhkey.Key, Repository.CalcParameters.InternalStepsize, Repository.CalcParameters.OfficialStartTime, "Car State - " + soc.Key, "", null, hhp.Key); foreach (var entry in soc.Value) { if (entry.Time.DisplayThisStep) { jsp.Values.Add(entry.Category); } } var sumfile = _fft.MakeFile <StreamWriter>("Carstate." + soc.Key + "." + hhkey.Key + ".json", "Car State for " + soc.Key + " in the household " + hhkey.Key, true, ResultFileID.JsonTransportDeviceState, hhkey, TargetDirectory.Results, Repository.CalcParameters.InternalStepsize, CalcOption.TansportationDeviceJsons, null, null, soc.Key); sumfile.Write(JsonConvert.SerializeObject(jsp, Formatting.Indented)); sumfile.Flush(); } foreach (var soc in siteByDevice) { //driving distance JsonEnumProfile jsp = new JsonEnumProfile("Car Location for " + soc.Key + " " + hhkey.Key, Repository.CalcParameters.InternalStepsize, Repository.CalcParameters.OfficialStartTime, "Car Location - " + soc.Key, "", null, hhp.Key); foreach (var entry in soc.Value) { if (entry.Time.DisplayThisStep) { jsp.Values.Add(entry.Category); } } var sumfile = _fft.MakeFile <StreamWriter>("CarLocation." + soc.Key + "." + hhkey.Key + ".json", "Car Location for " + soc.Key + " in the household " + hhkey.Key, true, ResultFileID.JsonTransportDeviceLocation, hhkey, TargetDirectory.Results, Repository.CalcParameters.InternalStepsize, CalcOption.TansportationDeviceJsons, null, null, soc.Key); sumfile.Write(JsonConvert.SerializeObject(jsp, Formatting.Indented)); sumfile.Flush(); } }
protected override void PerformActualStep(IStepParameters parameters) { HouseholdStepParameters hhp = (HouseholdStepParameters)parameters; var entry = hhp.Key; if (entry.KeyType != HouseholdKeyType.Household) { return; } var householdKey = entry.HHKey; _calculationProfiler.StartPart(Utili.GetCurrentMethodAndClass()); Logger.Info("Starting to complete list of actions for each person at each time step for statistical analysis..."); var activitiesPerPerson = ReadActivities(householdKey); //var fileIdx = 0; if (activitiesPerPerson.Count == 0) { throw new LPGException("There were no activities for any person in the household " + householdKey.Key); } var affs = ReadActivities(householdKey); var sactionEntries = _repository.ReadSingleTimestepActionEntries(householdKey); Dictionary <BodilyActivityLevel, List <int> > personCountByActivity = new Dictionary <BodilyActivityLevel, List <int> >(); foreach (BodilyActivityLevel bal in Enum.GetValues(typeof(BodilyActivityLevel))) { personCountByActivity.Add(bal, new List <int>(new int[_repository.CalcParameters.OfficalTimesteps])); } foreach (var singleTimestepActionEntry in sactionEntries) { var aff = affs[singleTimestepActionEntry.ActionEntryGuid]; personCountByActivity[aff.BodilyActivityLevel][singleTimestepActionEntry.TimeStep]++; } foreach (var pair in personCountByActivity) { JsonSumProfile jsp = new JsonSumProfile("Person Count for Activity Level " + pair.Key.ToString() + " " + householdKey.Key, Repository.CalcParameters.InternalStepsize, Repository.CalcParameters.OfficialStartTime, "Person Count for - " + pair.Key.ToString(), "", null, hhp.Key); foreach (var val in pair.Value) { jsp.Values.Add(val); } var sumfile = _fft.MakeFile <StreamWriter>("BodilyActivityLevel." + pair.Key + "." + householdKey.Key + ".json", "Bodily Activity Level for " + pair.Key + " in the household " + householdKey.Key, true, ResultFileID.BodilyActivityJsons, householdKey, TargetDirectory.Results, Repository.CalcParameters.InternalStepsize, CalcOption.BodilyActivityStatistics, null, null, pair.Key.ToString()); sumfile.Write(JsonConvert.SerializeObject(jsp, Formatting.Indented)); sumfile.Flush(); } _calculationProfiler.StopPart(Utili.GetCurrentMethodAndClass()); }
protected override void PerformActualStep(IStepParameters parameters) { var p = (HouseholdLoadtypeStepParameters)parameters; if (p.Key.KeyType == HouseholdKeyType.General) { return; } //if (p.Key.KeyType == HouseholdKeyType.House) //{ //return; //} var deviceActivationEntries = Repository.LoadDeviceActivations(p.Key.HHKey); var deviceEnergyDict = new Dictionary <string, double>(); foreach (var activationEntry in deviceActivationEntries) { if (activationEntry.LoadTypeGuid != p.LoadType.Guid) { continue; } if (!deviceEnergyDict.ContainsKey(activationEntry.DeviceName)) { deviceEnergyDict.Add(activationEntry.DeviceName, 0); } deviceEnergyDict[activationEntry.DeviceName] += activationEntry.TotalEnergySum; } var deviceTaggingSetInformations = Repository.GetDeviceTaggingSets(); var deviceNameToCategory = new Dictionary <string, string>(); var avgYearlyDict = new Dictionary <CalcLoadTypeDto, Dictionary <StrGuid, double> >(); if (p.Key.KeyType != HouseholdKeyType.House) { avgYearlyDict = GetAverageYearlyConsumptionPerDevice( Repository.LoadDevices(p.Key.HHKey).ConvertAll(x => (ICalcDeviceDto)x)); var devices = Repository.LoadDevices(p.Key.HHKey); foreach (var device in devices) { if (deviceNameToCategory.ContainsKey(device.Name)) { continue; } deviceNameToCategory.Add(device.Name, device.DeviceCategoryName); } } var efc = Repository.ReadEnergyFileColumns(p.Key.HHKey); MakeSumsForJson(p.LoadType, p.EnergyFileRows, efc, p.Key.HHKey); Run(p.LoadType, p.EnergyFileRows, _fft, efc, avgYearlyDict, deviceTaggingSetInformations, deviceNameToCategory, deviceEnergyDict, p.Key.HHKey); //Repository.DeviceSumInformationList, }