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([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(); } }