public void RunTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { ActionEntryLogger ael = new ActionEntryLogger(wd.SqlResultLoggingService); HouseholdKey key = new HouseholdKey("hhkey"); List <IDataSaverBase> savers = new List <IDataSaverBase> { ael }; InputDataLogger idl = new InputDataLogger(savers.ToArray()); TimeStep ts = new TimeStep(1, 0, true); ActionEntry ae1 = new ActionEntry("blub", key, ts, DateTime.Now, "123".ToStrGuid(), "name", false, "affname", "affguid".ToStrGuid(), 0, BodilyActivityLevel.Low); List <IHouseholdKey> aes = new List <IHouseholdKey> { ae1 }; idl.SaveList(aes); var res = ael.Read(key); var s1 = JsonConvert.SerializeObject(aes, Formatting.Indented); var s2 = JsonConvert.SerializeObject(res, Formatting.Indented); s1.Should().Be(s2); wd.CleanUp(); } }
private static void CheckForOverdoneOffsets([NotNull] string path, [NotNull] SqlResultLoggingService srls) { //var actionsName = Path.Combine(path, "Reports", "ActionsEachStep.HH1.csv"); var wwDeviceProfiles = Path.Combine(path, "Results", "DeviceProfiles.Warm Water.csv"); HouseholdKeyLogger hkl = new HouseholdKeyLogger(srls); var hhkeys = hkl.Load(); if (hhkeys.Count != 2) { throw new LPGException("Unknown key"); } var selectedKey = hhkeys[1].HHKey; //SingleTimestepActionEntryLogger stael = new SingleTimestepActionEntryLogger(srls); ActionEntryLogger ael = new ActionEntryLogger(srls); // var actionEachStep = stael.Read(selectedKey); var actions = ael.Read(selectedKey); List <EnergyUseEntry> eues; using (var sr2 = new StreamReader(wwDeviceProfiles)) { eues = new List <EnergyUseEntry>(); var header = sr2.ReadLine(); if (header == null) { throw new LPGException("Readline failed"); } var headerarr = header.Split(';'); while (!sr2.EndOfStream) { var s = sr2.ReadLine(); if (s == null) { throw new LPGException("readline fail"); } var eue = new EnergyUseEntry(s, headerarr); eues.Add(eue); } sr2.Close(); } var breakfast = actions.First(x => x.AffordanceName == "eat breakfast (1 h)"); var brtimestep = breakfast.TimeStep.ExternalStep + 2; //+2 to cover varying duration. for (var i = 0; i < eues.Count; i++) { if (eues[i].Timestep != i) { throw new LPGException("Invalid timestep."); } } var stepcount = 2; const string sinkname = "HH1 - Kitchen - Kitchen Sink (5L/min) [L]"; while (Math.Abs(eues[brtimestep + stepcount].Values[sinkname]) < Constants.Ebsilon) { stepcount++; } if (stepcount > 25) { throw new LPGException("Stepcount between two warm water uses during breakfast was : " + stepcount + ", but it should be about 20. Timestep: " + brtimestep); } }
public List<ActionEntry> ReadActionEntries([NotNull] HouseholdKey key) { ActionEntryLogger ael = new ActionEntryLogger(_srls); return ael.Read(key); }