-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added device profile export as json
- Loading branch information
Showing
50 changed files
with
1,378 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Automation.ResultFiles; | ||
|
||
namespace Automation | ||
{ | ||
|
||
public class SingleDeviceProfile { | ||
public SingleDeviceProfile(string? name) => Name = name; | ||
[Obsolete("json only")] | ||
public SingleDeviceProfile() | ||
{ | ||
|
||
} | ||
|
||
public string? Name { get; set; } | ||
public List<double> Values { get; set; } = new List<double>(); | ||
|
||
} | ||
|
||
public class JsonDeviceProfiles | ||
{ | ||
public JsonDeviceProfiles(TimeSpan timeResolution, DateTime startTime, string loadTypeName, string unit, LoadTypeInformation loadTypeInformation) | ||
{ | ||
TimeResolution = timeResolution; | ||
StartTime = startTime; | ||
LoadTypeName = loadTypeName; | ||
Unit = unit; | ||
LoadTypeInformation = loadTypeInformation; | ||
} | ||
[Obsolete("only for json")] | ||
public JsonDeviceProfiles() | ||
{ | ||
} | ||
|
||
public List<SingleDeviceProfile> DeviceProfiles { get; set; } = new List<SingleDeviceProfile>(); | ||
public TimeSpan TimeResolution { get; set; } | ||
public DateTime StartTime { get; set; } | ||
|
||
public string? LoadTypeName { get; set; } | ||
|
||
public LoadTypeInformation LoadTypeInformation { get; set; } | ||
public string? Unit { get; set; } | ||
} | ||
public class JsonSumProfile | ||
{ | ||
public JsonSumProfile(string name, TimeSpan timeResolution, DateTime startTime, string loadTypeName, string unit, LoadTypeInformation loadTypeInformation) | ||
{ | ||
Name = name; | ||
TimeResolution = timeResolution; | ||
StartTime = startTime; | ||
LoadTypeName = loadTypeName; | ||
Unit = unit; | ||
LoadTypeInformation = loadTypeInformation; | ||
} | ||
[Obsolete("only for json")] | ||
public JsonSumProfile() | ||
{ | ||
} | ||
|
||
public string? Name { get; set; } | ||
public TimeSpan TimeResolution { get; set; } | ||
public List<double> Values { get; set; } = new List<double>(); | ||
public DateTime StartTime { get; set; } | ||
|
||
public string? LoadTypeName { get; set; } | ||
|
||
public LoadTypeInformation LoadTypeInformation { get; set; } | ||
public string? Unit { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 0 additions & 125 deletions
125
CalcPostProcessor/LoadTypeHouseholdSteps/DeviceProfileFileProcessor.cs
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
CalcPostProcessor/LoadTypeHouseholdSteps/IndividualHouseholdDeviceProfileJsonProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Automation; | ||
using Automation.ResultFiles; | ||
using CalcPostProcessor.Steps; | ||
using Common; | ||
using Common.SQLResultLogging; | ||
using JetBrains.Annotations; | ||
using Newtonsoft.Json; | ||
|
||
namespace CalcPostProcessor.LoadTypeHouseholdSteps { | ||
public class IndividualHouseholdDeviceProfileJsonProcessor : HouseholdLoadTypeStepBase { | ||
[NotNull] private readonly IFileFactoryAndTracker _fft; | ||
|
||
public IndividualHouseholdDeviceProfileJsonProcessor([NotNull] CalcDataRepository repository, | ||
[NotNull] IFileFactoryAndTracker fft, | ||
[NotNull] ICalculationProfiler calculationProfiler) : base(repository, | ||
AutomationUtili.GetOptionList(CalcOption.JsonDeviceProfilesIndividualHouseholds), | ||
calculationProfiler, | ||
"Individual Household Json Device Profiles") => | ||
_fft = fft; | ||
|
||
protected override void PerformActualStep([NotNull] IStepParameters parameters) | ||
{ | ||
HouseholdLoadtypeStepParameters p = (HouseholdLoadtypeStepParameters)parameters; | ||
if (p.Key.HouseholdKey == Constants.GeneralHouseholdKey) { | ||
return; | ||
} | ||
var dstLoadType = p.LoadType; | ||
var efc = Repository.ReadEnergyFileColumns(p.Key.HouseholdKey); | ||
if (!efc.ColumnCountByLoadType.ContainsKey(dstLoadType)) | ||
{ | ||
return; | ||
} | ||
//var householdKeys = efc.ColumnEntriesByColumn[dstLoadType].Values.Select(entry => entry.HouseholdKey).Distinct().ToList(); | ||
if (!efc.ColumnCountByLoadType.ContainsKey(p.LoadType)) | ||
{ | ||
return; | ||
} | ||
var calcParameters = Repository.CalcParameters; | ||
var key = p.Key.HouseholdKey; | ||
var columns = efc.ColumnEntriesByColumn[p.LoadType].Values.Where(entry => entry.HouseholdKey == key).Select(entry => entry.Column) | ||
.ToList(); | ||
var hhname = "." + key ; | ||
var jrf = new JsonDeviceProfiles( calcParameters.InternalStepsize, | ||
calcParameters.OfficialStartTime, dstLoadType.Name, dstLoadType.UnitOfSum, dstLoadType.ConvertToLoadTypeInformation()); | ||
foreach (int i in columns) { | ||
var ce = efc.ColumnEntriesByColumn[dstLoadType][i]; | ||
SingleDeviceProfile sdp = new SingleDeviceProfile(ce.Name); | ||
foreach (var efr in p.EnergyFileRows) | ||
{ | ||
if (!efr.Timestep.DisplayThisStep) | ||
{ | ||
continue; | ||
} | ||
sdp.Values.Add(efr.GetValueForSingleCols(i)); | ||
|
||
} | ||
} | ||
|
||
var sumfile = _fft.MakeFile<StreamWriter>("DeviceProfiles." + dstLoadType.FileName + hhname + ".json", | ||
"Summed up energy profile for all devices for " + dstLoadType.Name + " as JSON file", true, | ||
ResultFileID.JsonDeviceProfiles, p.Key.HouseholdKey, TargetDirectory.Results, | ||
calcParameters.InternalStepsize, CalcOption.JsonDeviceProfilesIndividualHouseholds, | ||
dstLoadType.ConvertToLoadTypeInformation()); | ||
sumfile.Write(JsonConvert.SerializeObject(jrf, Formatting.Indented)); | ||
sumfile.Flush(); | ||
} | ||
|
||
[NotNull] | ||
public override List<CalcOption> NeededOptions => new List<CalcOption>() {CalcOption.DetailedDatFiles}; | ||
|
||
} | ||
} |
Oops, something went wrong.