diff --git a/Automation/Automation.csproj b/Automation/Automation.csproj index 5ea9e0da..88170def 100644 --- a/Automation/Automation.csproj +++ b/Automation/Automation.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows @@ -13,10 +13,10 @@ 9.0 - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalcPostProcessor/CalcPostProcessor.csproj b/CalcPostProcessor/CalcPostProcessor.csproj index 11a99f54..c1b549e9 100644 --- a/CalcPostProcessor/CalcPostProcessor.csproj +++ b/CalcPostProcessor/CalcPostProcessor.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows @@ -13,11 +13,11 @@ 9.0 - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalcPostProcessorTests/CalcPostProcessorTests.csproj b/CalcPostProcessorTests/CalcPostProcessorTests.csproj index a4e812f6..679fc80c 100644 --- a/CalcPostProcessorTests/CalcPostProcessorTests.csproj +++ b/CalcPostProcessorTests/CalcPostProcessorTests.csproj @@ -1,6 +1,6 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 enable @@ -11,22 +11,22 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Calculation.Tests/Calculation.Tests.csproj b/Calculation.Tests/Calculation.Tests.csproj index c383db83..4a672c83 100644 --- a/Calculation.Tests/Calculation.Tests.csproj +++ b/Calculation.Tests/Calculation.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 disable @@ -16,22 +16,22 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalculationController.Tests/CalcFactories/CalcPersonFactoryTests.cs b/CalculationController.Tests/CalcFactories/CalcPersonFactoryTests.cs index 90cb8c7c..b54fc700 100644 --- a/CalculationController.Tests/CalcFactories/CalcPersonFactoryTests.cs +++ b/CalculationController.Tests/CalcFactories/CalcPersonFactoryTests.cs @@ -57,7 +57,7 @@ public void AddMoreDesiresTest() var p = new Person("blub", 1, 1, 1, 1, PermittedGender.Male, string.Empty, string.Empty, Guid.NewGuid().ToStrGuid()); //var tt = new TraitTag("traittag", "", TraitLimitType.NoLimit, TraitPriority.All, Guid.NewGuid().ToStrGuid()); - var livingPatternTag = new LivingPatternTag("tag","",StrGuid.New()); + var livingPatternTag = new LivingPatternTag("tag", 1.0,"",StrGuid.New()); var mhp = new ModularHouseholdPerson(null, -1, p.PrettyName, "", p, livingPatternTag, Guid.NewGuid().ToStrGuid()); persons.Add(mhp); var hhVacations = new List(); diff --git a/CalculationController.Tests/CalculationController.Tests.csproj b/CalculationController.Tests/CalculationController.Tests.csproj index 350fdd9f..563ffda4 100644 --- a/CalculationController.Tests/CalculationController.Tests.csproj +++ b/CalculationController.Tests/CalculationController.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 disable @@ -11,22 +11,22 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalculationController/CalculationController.csproj b/CalculationController/CalculationController.csproj index 3c35bd57..39bd6781 100644 --- a/CalculationController/CalculationController.csproj +++ b/CalculationController/CalculationController.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows @@ -14,12 +14,12 @@ 9.0 - - + + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalculationController/Integrity/HouseholdTraitChecker.cs b/CalculationController/Integrity/HouseholdTraitChecker.cs index 9d4e2f31..754c607f 100644 --- a/CalculationController/Integrity/HouseholdTraitChecker.cs +++ b/CalculationController/Integrity/HouseholdTraitChecker.cs @@ -510,9 +510,9 @@ protected override void Run(Simulator sim, CheckingOptions options) List traitsWithMissingTags = new List(); const string officeTag = "Living Pattern / Office"; const string wfhtag = "Living Pattern / Work From Home"; - const string worktag = "Work / Work"; + const string worktag_prefix = "Work / Work"; foreach (var item in sim.HouseholdTraits.Items) { - if (item.Tags.Any(x => x.Tag.Name == worktag)) { + if (item.Tags.Any(x => x.Tag.Name.StartsWith(worktag_prefix))) { continue; } if (item.LivingPatternTags.Any(x => x.Tag.Name.StartsWith(officeTag))) { diff --git a/CalculationEngine/CalcConsistencyCheck.cs b/CalculationEngine/CalcConsistencyCheck.cs index cee6f2fe..7d74f250 100644 --- a/CalculationEngine/CalcConsistencyCheck.cs +++ b/CalculationEngine/CalcConsistencyCheck.cs @@ -82,7 +82,7 @@ public static void CheckConsistency([JetBrains.Annotations.NotNull] CalcHousehol { foreach (var route in chh.TransportationHandler.TravelRoutes) { - if (route.PersonID != null && !chh.Persons.Exists(person => person.ID == route.PersonID)) + if (route.PersonID != null && route.PersonID != -1 && !chh.Persons.Exists(person => person.ID == route.PersonID)) { throw new DataIntegrityException("Usage of the route \"" + route.Name + "\" in the selected travel route set was restricted to a person " + "that is not in the selected household. Change the Person restriction or choose a different travel route set for this household."); diff --git a/CalculationEngine/CalculationEngine.csproj b/CalculationEngine/CalculationEngine.csproj index edaefea3..4927a06c 100644 --- a/CalculationEngine/CalculationEngine.csproj +++ b/CalculationEngine/CalculationEngine.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows @@ -13,10 +13,10 @@ 9.0 - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CalculationEngine/HouseholdElements/CalcPerson.cs b/CalculationEngine/HouseholdElements/CalcPerson.cs index 8b2dcc9b..eb57d296 100644 --- a/CalculationEngine/HouseholdElements/CalcPerson.cs +++ b/CalculationEngine/HouseholdElements/CalcPerson.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Text; using Automation; using Automation.ResultFiles; using CalculationEngine.Helper; @@ -586,55 +587,22 @@ private ICalcAffordanceBase FindBestAffordance([JetBrains.Annotations.NotNull] T throw new LPGException("Random number generator was not initialized"); } + AffordanceStatusClass? status = null; + if (_calcRepo.CalcParameters.IsSet(CalcOption.ThoughtsLogfile)) + { + status = new AffordanceStatusClass(); + } var allAffordances = - NewGetAllViableAffordancesAndSubs(time, null, false, allAffs, false); + NewGetAllViableAffordancesAndSubs(time, status, false, allAffs, false); if(allAffordances.Count == 0 && (time.ExternalStep < 0 || _calcRepo.CalcParameters.IgnorePreviousActivitesWhenNeeded)) { allAffordances = - NewGetAllViableAffordancesAndSubs(time, null, false, allAffs, true); + NewGetAllViableAffordancesAndSubs(time, status, false, allAffs, true); } allAffordances.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name)); //no affordances, so search again for the error messages - if (allAffordances.Count == 0) { - - var status = new AffordanceStatusClass(); - NewGetAllViableAffordancesAndSubs(time, status, false, allAffs, false); - var ts = new TimeSpan(0, 0, 0, - (int)_calcRepo.CalcParameters.InternalStepsize.TotalSeconds * time.InternalStep); - var dt = _calcRepo.CalcParameters.InternalStartTime.Add(ts); - var s = "At Timestep " + time.ExternalStep + " (" + dt.ToLongDateString() + " " + dt.ToShortTimeString() + ")" + - " not a single affordance was available for " + Name + - " in the household " + _calcPerson.HouseholdName + "." + Environment.NewLine + - "Since the people in this simulation can't do nothing, calculation can not continue." + - " The simulation seed was " + simulationSeed + ". " + Environment.NewLine + Name + " was "; - if (IsSick[time.InternalStep]) { - s += " sick at the time."+ Environment.NewLine; - } - else { - s += " not sick at the time."+ Environment.NewLine; - } - - s += _calcPerson.Name + " was at " + CurrentLocation.Name + "." + Environment.NewLine; - s += "The setting for the number of required unique affordances in a row was set to " + _calcRepo.CalcParameters.AffordanceRepetitionCount + "." + Environment.NewLine; - if (status.Reasons.Count > 0) { - s += " The status of each affordance is as follows:" + Environment.NewLine; - foreach (var reason in status.Reasons) { - s = s + Environment.NewLine + reason.Affordance.Name + ":" + reason.Reason; - } - } - else { - s += " Not a single viable affordance was found."; - } - - s += Environment.NewLine + Environment.NewLine + "The last activity of each Person was:"; - foreach (var calcPerson in persons) { - var name = "(none)"; - if (calcPerson._currentAffordance != null) { - name = calcPerson._currentAffordance.Name; - } - - s += Environment.NewLine + calcPerson.Name + ": " + name; - } + if (allAffordances.Count == 0) + { if (_calcRepo.CalcParameters.EnableIdlemode) { var idleaff = CurrentLocation.IdleAffs[this]; @@ -642,9 +610,17 @@ private ICalcAffordanceBase FindBestAffordance([JetBrains.Annotations.NotNull] T //Logger.Info(s); return idleaff; } + var status_err = new AffordanceStatusClass(); + NewGetAllViableAffordancesAndSubs(time, status_err, false, allAffs, false); + var s = MakeDetailledAffordanceStatusMessage(time, persons, simulationSeed, status_err, 0); throw new DataIntegrityException(s); } - + if (_calcRepo.CalcParameters.IsSet(CalcOption.ThoughtsLogfile)) + { + var thought = MakeDetailledAffordanceStatusMessage(time, persons, simulationSeed, status!, allAffordances.Count); + var thoughtEntry = new ThoughtEntry(this, time, thought); + _calcRepo.Logfile.ThoughtsLogFile1!.WriteEntry(thoughtEntry, _calcPerson.HouseholdKey); + } if (_calcRepo.Rnd == null) { throw new LPGException("Random number generator was not initialized"); } @@ -652,6 +628,69 @@ private ICalcAffordanceBase FindBestAffordance([JetBrains.Annotations.NotNull] T return GetBestAffordanceFromList(time, allAffordances); } + /// + /// Creates a detailed message naming the reason why affordances were unavailable. + /// This can be used to check why certain affordances were selected, or why no affordance + /// was available at all. + /// + /// current TimeStep + /// list of all persons + /// the simulation seed + /// the status object storing reasons for unavailable affordances + /// number of available affordances + /// + private string MakeDetailledAffordanceStatusMessage(TimeStep time, List persons, int simulationSeed, AffordanceStatusClass status, int availableAffordances) + { + var ts = new TimeSpan(0, 0, 0, + (int)_calcRepo.CalcParameters.InternalStepsize.TotalSeconds * time.InternalStep); + var dt = _calcRepo.CalcParameters.InternalStartTime.Add(ts); + var s = new StringBuilder(); + s.Append("At Timestep " + time.ExternalStep + " (" + dt.ToLongDateString() + " " + dt.ToShortTimeString() + ")" + + availableAffordances + " affordances were available for " + Name + + " in the household " + _calcPerson.HouseholdName + "." + Environment.NewLine); + if (availableAffordances == 0) + { + s.Append("Since the people in this simulation can't do nothing, calculation can not continue. "); + } + s.Append("The simulation seed was " + simulationSeed + ". " + Environment.NewLine + Name + " was "); + if (IsSick[time.InternalStep]) + { + s.Append(" sick at the time." + Environment.NewLine); + } + else + { + s.Append(" not sick at the time." + Environment.NewLine); + } + + s.Append(_calcPerson.Name + " was at " + CurrentLocation.Name + "." + Environment.NewLine); + s.Append("The setting for the number of required unique affordances in a row was set to " + _calcRepo.CalcParameters.AffordanceRepetitionCount + "." + Environment.NewLine); + if (status.Reasons.Count > 0) + { + s.Append(" The status of each affordance is as follows:" + Environment.NewLine); + foreach (var reason in status.Reasons) + { + s.Append(Environment.NewLine + reason.Affordance.Name + ":" + reason.Reason); + } + } + else + { + s.Append(" Not a single viable affordance was found."); + } + + s.Append(Environment.NewLine + Environment.NewLine + "The last activity of each Person was:"); + foreach (var calcPerson in persons) + { + var name = "(none)"; + if (calcPerson._currentAffordance != null) + { + name = calcPerson._currentAffordance.Name; + } + + s.Append(Environment.NewLine + calcPerson.Name + ": " + name); + } + return s.ToString(); + } + [JetBrains.Annotations.NotNull] private ICalcAffordanceBase GetBestAffordanceFromList([JetBrains.Annotations.NotNull] TimeStep time, [JetBrains.Annotations.NotNull][ItemNotNull] List allAvailableAffordances) diff --git a/ChartCreator2.Tests/ChartCreator2.Tests.csproj b/ChartCreator2.Tests/ChartCreator2.Tests.csproj index 38871036..35291527 100644 --- a/ChartCreator2.Tests/ChartCreator2.Tests.csproj +++ b/ChartCreator2.Tests/ChartCreator2.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 disable @@ -12,20 +12,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ChartCreator2/ChartCreator2.csproj b/ChartCreator2/ChartCreator2.csproj index 1181b730..28f6c730 100644 --- a/ChartCreator2/ChartCreator2.csproj +++ b/ChartCreator2/ChartCreator2.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows enable @@ -20,18 +20,18 @@ - - - + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/ChartCreator2/OxyCharts/SumProfiles.cs b/ChartCreator2/OxyCharts/SumProfiles.cs index 3b0f7774..955bde24 100644 --- a/ChartCreator2/OxyCharts/SumProfiles.cs +++ b/ChartCreator2/OxyCharts/SumProfiles.cs @@ -130,7 +130,7 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry) var col = cols[cols.Length - 1]; var success = double.TryParse(col, out double d); if (!success) { - throw new LPGException("Double Trouble reading the file " + srcEntry.FileName); + throw new LPGException("Error reading file '" + srcEntry.FullFileName + "': Could not parse double from '" + col + "'"); } if (srcEntry.LoadTypeInformation == null) { diff --git a/ChartCreator2/OxyCharts/SumProfilesExternal.cs b/ChartCreator2/OxyCharts/SumProfilesExternal.cs index 02fd551b..fcd6dc78 100644 --- a/ChartCreator2/OxyCharts/SumProfilesExternal.cs +++ b/ChartCreator2/OxyCharts/SumProfilesExternal.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using Automation; using Automation.ResultFiles; using Common; +using Common.JSON; using OxyPlot; using OxyPlot.Axes; using OxyPlot.Series; @@ -11,14 +13,17 @@ namespace ChartCreator2.OxyCharts { internal class SumProfilesExternal : ChartBaseFileStep { + private readonly CalcParameters _calcParameters; + public SumProfilesExternal([JetBrains.Annotations.NotNull] ChartCreationParameters parameters, [JetBrains.Annotations.NotNull] FileFactoryAndTracker fft, - [JetBrains.Annotations.NotNull] ICalculationProfiler calculationProfiler) : base(parameters, fft, + [JetBrains.Annotations.NotNull] ICalculationProfiler calculationProfiler, CalcParameters calcParameters) : base(parameters, fft, calculationProfiler, new List() { ResultFileID.CSVSumProfileExternal }, "Sim Profiles External Time Resolution", FileProcessingResult.ShouldCreateFiles ) { + _calcParameters = calcParameters; } protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) @@ -32,6 +37,10 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) { throw new LPGException("filename was null"); } + // specify the number format to use for parsing + NumberFormatInfo formatInfo = new NumberFormatInfo(); + formatInfo.NumberDecimalSeparator = _calcParameters.DecimalSeperator; + using (var sr = new StreamReader(rfe.FullFileName)) { sr.ReadLine(); @@ -44,10 +53,10 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) } var cols = s.Split(Parameters.CSVCharacterArr, StringSplitOptions.None); var col = cols[cols.Length - 1]; - var success = double.TryParse(col, out var d); + var success = double.TryParse(col, NumberStyles.Float, formatInfo, out var d); if (!success) { - throw new LPGException("Double Trouble!"); + throw new LPGException("Error reading file '" + rfe.FullFileName + "': Could not parse double from '" + col + "'"); } values.Add(d); } diff --git a/ChartCreator2/OxyCharts/Temperatures.cs b/ChartCreator2/OxyCharts/Temperatures.cs index 5a859247..c3f30c3a 100644 --- a/ChartCreator2/OxyCharts/Temperatures.cs +++ b/ChartCreator2/OxyCharts/Temperatures.cs @@ -41,7 +41,7 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) var col = cols[cols.Length - 1]; var success = double.TryParse(col, out double d); if (!success) { - throw new LPGException("Double Trouble!"); + throw new LPGException("Error reading file '" + rfe.FullFileName + "': Could not parse double from '" + col + "'"); } values.Add(d); } diff --git a/ChartCreator2/OxyCharts/TimeOfUse.cs b/ChartCreator2/OxyCharts/TimeOfUse.cs index 8d8e9dc1..0e22e809 100644 --- a/ChartCreator2/OxyCharts/TimeOfUse.cs +++ b/ChartCreator2/OxyCharts/TimeOfUse.cs @@ -53,7 +53,7 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry rfe) if (col.Length > 0) { var success = double.TryParse(col, out double d); if (!success) { - throw new LPGException("Double Trouble! " + rfe.FileName); + throw new LPGException("Error reading file '" + rfe.FullFileName + "': Could not parse double from '" + col + "'"); } devices[index].Values.Add(d); } diff --git a/ChartCreator2/OxyCharts/WeekdayProfiles.cs b/ChartCreator2/OxyCharts/WeekdayProfiles.cs index daf2812a..18632037 100644 --- a/ChartCreator2/OxyCharts/WeekdayProfiles.cs +++ b/ChartCreator2/OxyCharts/WeekdayProfiles.cs @@ -192,7 +192,7 @@ protected override FileProcessingResult MakeOnePlot(ResultFileEntry srcEntry) if (col.Length > 0) { var success = double.TryParse(col, out double d); if (!success) { - throw new LPGException("Double Trouble"); + throw new LPGException("Could not parse entry " + col + " from result file '" + srcEntry.FullFileName + "'" ); } entries[index].Values.Add(d); } diff --git a/Common.Tests/Common.Tests.csproj b/Common.Tests/Common.Tests.csproj index 5d7c2538..5561ebb6 100644 --- a/Common.Tests/Common.Tests.csproj +++ b/Common.Tests/Common.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 enable @@ -11,23 +11,23 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Common/Common.csproj b/Common/Common.csproj index adf5531e..620d0b68 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows Full disable @@ -10,18 +10,18 @@ x64 - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Database.Tests/ConsistencyTests.cs b/Database.Tests/ConsistencyTests.cs new file mode 100644 index 00000000..d0286b35 --- /dev/null +++ b/Database.Tests/ConsistencyTests.cs @@ -0,0 +1,85 @@ +using Automation; +using Common; +using Database.Tables; +using FluentAssertions; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Common.Tests; +using Xunit.Abstractions; + +namespace Database.Tests +{ + /// + /// A class for tests that check the consistency and validity of the database. + /// + public class ConsistencyTests : UnitTestBaseClass + { + public ConsistencyTests([JetBrains.Annotations.NotNull] ITestOutputHelper testOutputHelper) : base(testOutputHelper) + { + } + + /// + /// This test checks whether all GUIDs of database objects are unique. This shall detect errors + /// + [Fact] + [Trait(UnitTestCategories.Category, UnitTestCategories.BasicTest)] + public void UniqueGUIDsTest() + { + using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass())) + { + Dictionary>> items_by_guid = new Dictionary>>(); + var sim = new Simulator(db.ConnectionString); + + // collect and sort all database objects by GUID + foreach (var category in sim.Categories) + { + // most category objects are of type CategoryDBBase, with different T + // Cast to dynamic type to be able to obtain all contained DBBase objects. + dynamic cat = category; + List items; + try + { + // defined for CategoryDBBase objects + items = cat.CollectAllDBBaseItems(); + } + catch (LPGNotImplementedException) + { + // another type of object collection, not relevant for this test + continue; + } + // collect name and type of each database object, by GUID + foreach (DBBase item in items) + { + var entry = new Tuple(item.Name, item.GetType()); + if (!items_by_guid.ContainsKey(item.Guid)) { + // first item with this GUID, create a new list with only this item + items_by_guid[item.Guid] = new List> { entry }; + } else + { + // This case means that a GUID was not unique. Instead of failing the test now, all + // objects are checked first to provide a summary of all faulty objects in the end. + items_by_guid[item.Guid].Add(entry); + } + } + } + // filter all GUIDs which occurred more than once + var nonunique_guids = items_by_guid.Where(pair => pair.Value.Count > 1); + if (nonunique_guids.Any()) + { + string output = ""; + // generate a summary of non-unique GUIDs and the objects that use them + foreach (var entry in nonunique_guids) + { + output += entry.Key + ": "; + output += string.Join(", ", entry.Value.Select(tpl => tpl.Item1 + " (" + tpl.Item2.Name + ")")) + "\n"; + } + Assert.Fail("Found non-unique GUIDs:\n" + output); + } + + db.Cleanup(); + } + } + } +} diff --git a/Database.Tests/Database.Tests.csproj b/Database.Tests/Database.Tests.csproj index dd035a25..0d3e7c75 100644 --- a/Database.Tests/Database.Tests.csproj +++ b/Database.Tests/Database.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 disable @@ -18,23 +18,23 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Database/Database.csproj b/Database/Database.csproj index b19213ae..6ba11613 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows @@ -13,16 +13,16 @@ 9.0 - + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/Database/Helpers/CategoryDBBase.cs b/Database/Helpers/CategoryDBBase.cs index 8118e659..44b649ff 100644 --- a/Database/Helpers/CategoryDBBase.cs +++ b/Database/Helpers/CategoryDBBase.cs @@ -75,6 +75,7 @@ public T FindByJsonReference([CanBeNull] JsonReference reference) // ReSharper disable twice HeuristicUnreachableCode if (reference.Guid != null && reference.Guid != StrGuid.Empty) { + // find the object with the same GUID foreach (var x in Items) { if (x.Guid == reference.Guid) @@ -82,8 +83,8 @@ public T FindByJsonReference([CanBeNull] JsonReference reference) return x; } } - } - if (reference.Name != null) + Logger.Warning("No object with GUID " + reference.Guid + " found."); + } else if (reference.Name != null) { return FindFirstByName(reference.Name); } diff --git a/Database/Tables/ModularHouseholds/HouseholdTemplate.cs b/Database/Tables/ModularHouseholds/HouseholdTemplate.cs index 0a9a0134..5e036218 100644 --- a/Database/Tables/ModularHouseholds/HouseholdTemplate.cs +++ b/Database/Tables/ModularHouseholds/HouseholdTemplate.cs @@ -520,9 +520,11 @@ public HouseholdTemplate MakeCopy([JetBrains.Annotations.NotNull] Simulator sim) var newtemplate = sim.HouseholdTemplates.CreateNewItem(sim.ConnectionString); jsonTemplate.Name = jsonTemplate.Name + " (copy)"; newtemplate.ImportFromJsonTemplate(jsonTemplate,sim); + // assign a new GUID + newtemplate.Guid = StrGuid.New(); return newtemplate; - } + public void ImportFromJsonTemplate([JetBrains.Annotations.NotNull] JsonDto jsonTemplate, [JetBrains.Annotations.NotNull] Simulator sim) { DateBasedProfile dbp = null; diff --git a/Database/Tables/ModularHouseholds/LivingPatternTag.cs b/Database/Tables/ModularHouseholds/LivingPatternTag.cs index 0eb82c77..0b078d4c 100644 --- a/Database/Tables/ModularHouseholds/LivingPatternTag.cs +++ b/Database/Tables/ModularHouseholds/LivingPatternTag.cs @@ -11,30 +11,47 @@ namespace Database.Tables.ModularHouseholds { public class LivingPatternTag : DBBaseElement { public const string TableName = "tblLivingPatternTags"; - public LivingPatternTag([JetBrains.Annotations.NotNull] string pName, [JetBrains.Annotations.NotNull] string connectionString, + + private double _weight; + + public const double DefaultWeight = 1.0; + + public LivingPatternTag([JetBrains.Annotations.NotNull] string pName, double weight, [JetBrains.Annotations.NotNull] string connectionString, [NotNull] StrGuid guid, [CanBeNull]int? pID = null) : base(pName, TableName, connectionString, guid) { + _weight = weight; ID = pID; TypeDescription = "Living Pattern Tag"; } + /// + /// Weight for varying LivingPatternTags when creating households from templates + /// + public double Weight + { + get => _weight; + [UsedImplicitly] + set => SetValueWithNotify(value, ref _weight, nameof(Weight)); + } + [JetBrains.Annotations.NotNull] private static LivingPatternTag AssignFields([JetBrains.Annotations.NotNull] DataReader dr, [JetBrains.Annotations.NotNull] string connectionString, bool ignoreMissingFields, [JetBrains.Annotations.NotNull] AllItemCollections aic) { var name = dr.GetString("Name","No name"); + var weight = dr.GetDouble("Weight", defaultvalue: DefaultWeight); var id = dr.GetIntFromLong("ID"); var guid = GetGuid(dr, ignoreMissingFields); - var d = new LivingPatternTag(name, connectionString,guid, id); + var d = new LivingPatternTag(name, weight, connectionString,guid, id); return d; } [JetBrains.Annotations.NotNull] [UsedImplicitly] public static DBBase CreateNewItem([JetBrains.Annotations.NotNull] Func isNameTaken, [JetBrains.Annotations.NotNull] string connectionString) => new LivingPatternTag( - FindNewName(isNameTaken, "New Living Pattern Tag "), connectionString, System.Guid.NewGuid().ToStrGuid()); + FindNewName(isNameTaken, "New Living Pattern Tag "), DefaultWeight, connectionString, System.Guid.NewGuid().ToStrGuid()); public override DBBase ImportFromGenericItem(DBBase toImport, Simulator dstSim) => ImportFromItem((LivingPatternTag)toImport,dstSim); @@ -71,12 +88,10 @@ public override List CalculateUsedIns(Simulator sim) [JetBrains.Annotations.NotNull] [UsedImplicitly] -#pragma warning disable RCS1163 // Unused parameter. public static DBBase ImportFromItem([JetBrains.Annotations.NotNull] LivingPatternTag item, [JetBrains.Annotations.NotNull] Simulator dstSim) -#pragma warning restore RCS1163 // Unused parameter. { //TODO: finish this - var tt = new LivingPatternTag(item.Name,dstSim.ConnectionString, + var tt = new LivingPatternTag(item.Name, item._weight, dstSim.ConnectionString, item.Guid); tt.SaveToDB(); return tt; @@ -98,6 +113,7 @@ public static void LoadFromDatabase([ItemNotNull] [JetBrains.Annotations.NotNull protected override void SetSqlParameters(Command cmd) { cmd.AddParameter("Name", Name); + cmd.AddParameter("Weight", _weight); } } } \ No newline at end of file diff --git a/Database/Tables/ModularHouseholds/TraitTag.cs b/Database/Tables/ModularHouseholds/TraitTag.cs index 42708c9a..39d4c3f3 100644 --- a/Database/Tables/ModularHouseholds/TraitTag.cs +++ b/Database/Tables/ModularHouseholds/TraitTag.cs @@ -127,7 +127,7 @@ public override DBBase ImportFromGenericItem(DBBase toImport, Simulator dstSim) public override List CalculateUsedIns(Simulator sim) { var used = new List(); - + // collect the household traits that have this tag foreach (var t in sim.HouseholdTraits.Items) { foreach (var hhtTag in t.Tags) @@ -138,6 +138,17 @@ public override List CalculateUsedIns(Simulator sim) } } } + // collect the templates that use this tag + foreach (var template in sim.HouseholdTemplates.Items) + { + foreach (var entry in template.Entries) + { + if (entry.TraitTag == this) + { + used.Add(new UsedIn(template, "Household Template")); + } + } + } return used; } diff --git a/Database/Tables/SingleSetting.cs b/Database/Tables/SingleSetting.cs index 357cb402..1dae031b 100644 --- a/Database/Tables/SingleSetting.cs +++ b/Database/Tables/SingleSetting.cs @@ -109,7 +109,7 @@ public override void SaveToDB() { } cmd.AddParameter("myid", ID); - cmd.AddParameter("Guid", Guid.StrVal); + cmd.AddParameter("guid", Guid.StrVal); cmd.ExecuteNonQuery( "UPDATE tblSettings SET Settingname = @myname, Settingvalue = @myval, Guid=@guid WHERE ID = @myid"); NeedsUpdate = false; diff --git a/Database/Templating/HouseholdTemplateExecutor.cs b/Database/Templating/HouseholdTemplateExecutor.cs index 5caf97c7..bccfc8d5 100644 --- a/Database/Templating/HouseholdTemplateExecutor.cs +++ b/Database/Templating/HouseholdTemplateExecutor.cs @@ -424,6 +424,42 @@ private static void CheckTraitAssigment([JetBrains.Annotations.NotNull] List + /// If the specified LivingPatternTag consists of three components (separated by '/'), randomly vary the last component based + /// on the weights of all possible tags. + /// + /// the originally specified LivingPatternTag + /// All LivingPatternTags in the LPG + /// Random number generator + /// the new, possibly changed LivingPatternTag + private static LivingPatternTag VaryLivingPatternTag(LivingPatternTag livingpattern, Collection allLivingPatternTags, Random r) + { + string[] components = livingpattern?.Name.Split('/'); + if (components?.Length < 3) + { + // don't change the livingpattern + return livingpattern; + } + // get the base name without the last component, e.g., "Living Patttern / Office Job / " + string basename = livingpattern.Name.Substring(0, livingpattern.Name.Length - components[2].Length); + List possibleTags = allLivingPatternTags.Where(x => x.Name.StartsWith(basename, StringComparison.InvariantCultureIgnoreCase)).ToList(); + if (possibleTags.Count > 1) + { + // randomly select one of the possible tags based on their weight + double totalWeight =possibleTags.Select(x => x.Weight).Sum(); + double randomNumber = r.NextDouble() * totalWeight; + foreach (var tag in possibleTags) + { + if (randomNumber < tag.Weight) + { + return tag; + } + randomNumber -= tag.Weight; + } + } + return livingpattern; + } + [JetBrains.Annotations.NotNull] private static ModularHousehold GenerateEmptyHousehold([JetBrains.Annotations.NotNull] Simulator sim, [JetBrains.Annotations.NotNull] HouseholdTemplate template, @@ -458,19 +494,9 @@ private static ModularHousehold GenerateEmptyHousehold([JetBrains.Annotations.No chh.GeneratorID = template.IntID; //add persons - //TODO: fix this + // vary LivingPatternTags for each person foreach (var person in template.Persons) { - var livingpattern = person.LivingPatternTag; - string[] components = livingpattern?.Name.Split('/'); - if (components?.Length == 3) { - string basename = livingpattern.Name.Substring(0, livingpattern.Name.Length - components[2].Length); - List possibleTags = sim.LivingPatternTags.Items - .Where(x => x.Name.StartsWith(basename, StringComparison.InvariantCultureIgnoreCase)).ToList(); - if (possibleTags.Count > 1) { - livingpattern = possibleTags[r.Next(possibleTags.Count)]; - } - } - + var livingpattern = VaryLivingPatternTag(person.LivingPatternTag, sim.LivingPatternTags.Items, r); chh.AddPerson(person.Person, livingpattern); } diff --git a/Directory.Build.props b/Directory.Build.props index 3d459524..d8337922 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - 10.9.0.1 - 10.9.0.1 + 10.10.0.5 + 10.10.0.5 diff --git a/IntegrationTests/IntegrationTests.csproj b/IntegrationTests/IntegrationTests.csproj index de45f2d4..1dd55637 100644 --- a/IntegrationTests/IntegrationTests.csproj +++ b/IntegrationTests/IntegrationTests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 disable Library @@ -13,17 +13,17 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/LoadProfileGenerator.Tests/LoadProfileGenerator.Tests.csproj b/LoadProfileGenerator.Tests/LoadProfileGenerator.Tests.csproj index b81d1075..0555a5bf 100644 --- a/LoadProfileGenerator.Tests/LoadProfileGenerator.Tests.csproj +++ b/LoadProfileGenerator.Tests/LoadProfileGenerator.Tests.csproj @@ -1,7 +1,7 @@  - net6.0-windows + net8.0-windows enable 9.0 @@ -11,20 +11,20 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ReleaseMaker/LinuxFileCopier.cs b/ReleaseMaker/LinuxFileCopier.cs index a3550822..9b29f1cc 100644 --- a/ReleaseMaker/LinuxFileCopier.cs +++ b/ReleaseMaker/LinuxFileCopier.cs @@ -23,7 +23,6 @@ public static void CopySimEngineLinuxFiles([JetBrains.Annotations.NotNull] strin Copy(programFiles, srcDi, src, dst, @"libclrjit.so"); Copy(programFiles, srcDi, src, dst, @"libcoreclr.so"); Copy(programFiles, srcDi, src, dst, @"libcoreclrtraceptprovider.so"); - Copy(programFiles, srcDi, src, dst, @"libdbgshim.so"); Copy(programFiles, srcDi, src, dst, @"libhostfxr.so"); Copy(programFiles, srcDi, src, dst, @"libhostpolicy.so"); Copy(programFiles, srcDi, src, dst, @"libmscordaccore.so"); @@ -256,6 +255,10 @@ public static void CopySimEngineLinuxFiles([JetBrains.Annotations.NotNull] strin Copy(programFiles, srcDi, src, dst, @"Microsoft.Bcl.AsyncInterfaces.dll"); Copy(programFiles, srcDi, src, dst, @"Microsoft.Extensions.ObjectPool.dll"); Copy(programFiles, srcDi, src, dst, @"System.Web.Services.Description.dll"); + Copy(programFiles, srcDi, src, dst, @"libclrgc.so"); + Copy(programFiles, srcDi, src, dst, @"System.Formats.Tar.dll"); + Copy(programFiles, srcDi, src, dst, @"System.Runtime.InteropServices.JavaScript.dll"); + Copy(programFiles, srcDi, src, dst, @"System.Security.Cryptography.dll"); CheckIfFilesAreCompletelyCopied(src, programFiles); } diff --git a/ReleaseMaker/ReleaseBuilderTests.cs b/ReleaseMaker/ReleaseBuilderTests.cs index b9f162d5..1ecab427 100644 --- a/ReleaseMaker/ReleaseBuilderTests.cs +++ b/ReleaseMaker/ReleaseBuilderTests.cs @@ -459,7 +459,7 @@ public void MakeRelease([System.Runtime.CompilerServices.CallerFilePath] string Logger.Info("Release name: " + releasename); //return; var baseReleasePath = @"C:\LPGReleaseMakerResults\"; - var dstWin = baseReleasePath + @"LPGReleases\releases" + releasename + "\\net48"; + var dstWin = baseReleasePath + @"LPGReleases\releases" + releasename + "\\windows"; var dstLinux = baseReleasePath + @"LPGReleases\releases" + releasename + "\\linux"; var dstWinCore = baseReleasePath + @"LPGReleases\releases" + releasename + "\\netCore"; //const string srcsim = @"v:\Dropbox\LPG\SimulationEngine\bin\x64\Debug"; @@ -482,15 +482,15 @@ public void MakeRelease([System.Runtime.CompilerServices.CallerFilePath] string baseDevelopPath += sepChar; } Logger.Info("Using base development path '" + baseDevelopPath + "'"); - string srclpg = baseDevelopPath + @"WpfApplication1\bin\Debug\net6.0-windows"; + string srclpg = baseDevelopPath + @"WpfApplication1\bin\Debug\net8.0-windows"; Logger.Info("### Copying win lpg files"); var filesForSetup = WinLpgCopier.CopyLpgFiles(srclpg, dstWin); - string srcsim = baseDevelopPath + @"SimulationEngine\bin\Debug\net6.0-windows"; + string srcsim = baseDevelopPath + @"SimulationEngine\bin\Debug\net8.0-windows"; var filesForSetup2 = SimEngineCopier.CopySimEngineFiles(srcsim, dstWin); - string srcsim2 = baseDevelopPath + @"SimEngine2\bin\Release\net6.0-windows\win10-x64\publish"; + string srcsim2 = baseDevelopPath + @"SimEngine2\bin\Release\net8.0-windows\win-x64\publish"; SimEngine2Copier.CopySimEngine2Files(srcsim2, dstWinCore); - string srcsimLinux = baseDevelopPath + @"SimEngine2\bin\Release\net6.0\linux-x64\publish"; + string srcsimLinux = baseDevelopPath + @"SimEngine2\bin\Release\net8.0\linux-x64\publish"; LinuxFileCopier.CopySimEngineLinuxFiles(srcsimLinux, dstLinux); Logger.Info("### Finished copying lpg files"); // CopyFiles(src, dst); diff --git a/ReleaseMaker/ReleaseMaker.csproj b/ReleaseMaker/ReleaseMaker.csproj index d936afb2..2a64a4d9 100644 --- a/ReleaseMaker/ReleaseMaker.csproj +++ b/ReleaseMaker/ReleaseMaker.csproj @@ -1,6 +1,6 @@  - net6.0-windows + net8.0-windows Exe diff --git a/ReleaseMaker/SimEngineCopier.cs b/ReleaseMaker/SimEngineCopier.cs index 56c88ee2..201e408f 100644 --- a/ReleaseMaker/SimEngineCopier.cs +++ b/ReleaseMaker/SimEngineCopier.cs @@ -45,40 +45,37 @@ public static List CopySimEngineFiles([JetBrains.Annotations.NotNull] st Copy(programFiles, srcDi, src, dst, @"runtimes\win-x86\native\sni.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\win-x86\native\SQLite.Interop.dll"); - // added for .net6.0 + // added for .net8.0 Copy(programFiles, srcDi, src, dst, @"runtimes\osx-arm64\native\libSystem.IO.Ports.Native.dylib"); - Copy(programFiles, srcDi, src, dst, @"runtimes\freebsd\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\illumos\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\ios\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\solaris\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\tvos\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\net6.0\System.Drawing.Common.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\net6.0\System.IO.Ports.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\freebsd\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\illumos\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\ios\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\solaris\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\tvos\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\net8.0\System.IO.Ports.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\netcoreapp2.1\System.Data.SqlClient.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\Microsoft.Win32.Registry.AccessControl.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\Microsoft.Win32.SystemEvents.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Data.OleDb.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Diagnostics.EventLog.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Diagnostics.EventLog.Messages.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Diagnostics.PerformanceCounter.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.DirectoryServices.AccountManagement.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.DirectoryServices.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Drawing.Common.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.IO.Ports.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Management.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Runtime.Caching.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Security.Cryptography.Pkcs.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Security.Cryptography.ProtectedData.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.ServiceProcess.ServiceController.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Speech.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Threading.AccessControl.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Windows.Extensions.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\Microsoft.Win32.Registry.AccessControl.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\Microsoft.Win32.SystemEvents.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Data.OleDb.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Diagnostics.EventLog.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Diagnostics.EventLog.Messages.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Diagnostics.PerformanceCounter.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.DirectoryServices.AccountManagement.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.DirectoryServices.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.IO.Ports.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Management.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Runtime.Caching.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Security.Cryptography.Pkcs.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.ServiceProcess.ServiceController.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Speech.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Threading.AccessControl.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Windows.Extensions.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll"); diff --git a/ReleaseMaker/WinLpgCopier.cs b/ReleaseMaker/WinLpgCopier.cs index 42ce893e..1a0df7f8 100644 --- a/ReleaseMaker/WinLpgCopier.cs +++ b/ReleaseMaker/WinLpgCopier.cs @@ -49,29 +49,28 @@ public static List CopyLpgFiles([JetBrains.Annotations.NotNull] string s Copy(programFiles, srcDi, src, dst, @"runtimes\win-x86\native\sni.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\win-x86\native\SQLite.Interop.dll"); - // added for .net6.0 + // added for .net8.0 Copy(programFiles, srcDi, src, dst, @"runtimes\osx-arm64\native\libSystem.IO.Ports.Native.dylib"); - Copy(programFiles, srcDi, src, dst, @"runtimes\freebsd\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\illumos\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\ios\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\solaris\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\tvos\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\net6.0\System.IO.Ports.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\freebsd\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\illumos\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\ios\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\linux\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\osx\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\solaris\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\tvos\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\net8.0\System.IO.Ports.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\unix\lib\netcoreapp2.1\System.Data.SqlClient.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Data.Odbc.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Data.OleDb.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Diagnostics.EventLog.Messages.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.DirectoryServices.AccountManagement.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.DirectoryServices.Protocols.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.IO.Ports.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Management.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Runtime.Caching.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.ServiceProcess.ServiceController.dll"); - Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net6.0\System.Speech.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Data.Odbc.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Data.OleDb.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.DirectoryServices.AccountManagement.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.DirectoryServices.Protocols.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.IO.Ports.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Management.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Runtime.Caching.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.ServiceProcess.ServiceController.dll"); + Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\net8.0\System.Speech.dll"); Copy(programFiles, srcDi, src, dst, @"runtimes\win\lib\netcoreapp2.1\System.Data.SqlClient.dll"); CheckIfFilesAreCompletelyCopied(src, programFiles); diff --git a/SimEngine2/SimEngine2.csproj b/SimEngine2/SimEngine2.csproj index 6c31d708..f2b3484f 100644 --- a/SimEngine2/SimEngine2.csproj +++ b/SimEngine2/SimEngine2.csproj @@ -2,7 +2,7 @@ Exe - net6.0;net6.0-windows + net8.0;net8.0-windows enable en @@ -12,9 +12,9 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SimulationEngine.Tests/SimulationEngine.Tests.csproj b/SimulationEngine.Tests/SimulationEngine.Tests.csproj index 67af8760..9ec15d86 100644 --- a/SimulationEngine.Tests/SimulationEngine.Tests.csproj +++ b/SimulationEngine.Tests/SimulationEngine.Tests.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows 9.0 enable @@ -18,23 +18,23 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SimulationEngine/SimulationEngine.csproj b/SimulationEngine/SimulationEngine.csproj index ffd56453..d255c929 100644 --- a/SimulationEngine/SimulationEngine.csproj +++ b/SimulationEngine/SimulationEngine.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows Exe @@ -18,10 +18,10 @@ false - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SimulationEngineLib/HouseJobProcessor/HouseGenerator.cs b/SimulationEngineLib/HouseJobProcessor/HouseGenerator.cs index 1957f618..54442824 100644 --- a/SimulationEngineLib/HouseJobProcessor/HouseGenerator.cs +++ b/SimulationEngineLib/HouseJobProcessor/HouseGenerator.cs @@ -492,11 +492,15 @@ private static JsonReference CreateSingleHouse( // ReSharper disable once RedundantToStringCall throw new LPGPBadParameterException("Could not find charging station set: " + householdData.ChargingStationSet?.ToString()); } - var travelrouteset = sim.TravelRouteSets.FindByJsonReference(householdData.TravelRouteSet); - if (hj.CalcSpec.EnableTransportation && travelrouteset == null) + TravelRouteSet travelrouteset; + if (householdData.TravelRouteSet != null) + { + // try to load the specified TravelRouteSet + travelrouteset = sim.TravelRouteSets.FindByJsonReference(householdData.TravelRouteSet); + } else { - // Alternative transport specification: for each person transportation preferences can be specified. These are used - // to create a new TravelRouteSet. + // no TravelRouteSet specified: use alternative travel specification (if available) + // For each person, transportation preferences can be specified. These are used to create a new TravelRouteSet. travelrouteset = CreateTravelRouteSetFromPersonPreferences(householdData, sim); } if (hj.CalcSpec.EnableTransportation && travelrouteset == null) diff --git a/SimulationEngineLib/SimulationEngineLib.csproj b/SimulationEngineLib/SimulationEngineLib.csproj index 8def0450..e54656b6 100644 --- a/SimulationEngineLib/SimulationEngineLib.csproj +++ b/SimulationEngineLib/SimulationEngineLib.csproj @@ -1,7 +1,7 @@  - net6.0;net6.0-windows + net8.0;net8.0-windows disable 9.0 @@ -17,9 +17,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/VersionInfo.cs b/VersionInfo.cs index 5b53d1fe..cc9a07bf 100644 --- a/VersionInfo.cs +++ b/VersionInfo.cs @@ -1,3 +1,3 @@ -[assembly: AssemblyVersion("10.9.0.1")] +[assembly: AssemblyVersion("10.10.0.5")] -[assembly: AssemblyFileVersion("10.9.0.1")] +[assembly: AssemblyFileVersion("10.10.0.5")] diff --git a/WpfApplication1/LoadProfileGenerator.csproj b/WpfApplication1/LoadProfileGenerator.csproj index 71ab73ea..cf78a592 100644 --- a/WpfApplication1/LoadProfileGenerator.csproj +++ b/WpfApplication1/LoadProfileGenerator.csproj @@ -1,7 +1,7 @@  - net6.0-windows + net8.0-windows winexe Resources\lpgicon4b.ico winexe @@ -55,18 +55,18 @@ - - + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/WpfApplication1/Presenters/Houses/HouseTypePresenter.cs b/WpfApplication1/Presenters/Houses/HouseTypePresenter.cs index 2a12908e..719dac32 100644 --- a/WpfApplication1/Presenters/Houses/HouseTypePresenter.cs +++ b/WpfApplication1/Presenters/Houses/HouseTypePresenter.cs @@ -30,6 +30,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; +using Automation; using Common; using Database.Helpers; using Database.Tables.BasicElements; @@ -334,6 +335,8 @@ private void ThisHouseTypePropertyChanged([NotNull] object sender, [NotNull] Pro public void MakeACopy() { var newht = (HouseType) HouseType.ImportFromItem(ThisHouseType, Sim); + // assign a new GUID + newht.Guid = StrGuid.New(); newht.Name = newht.Name + " (Copy)"; newht.SaveToDB(); Sim.HouseTypes.Items.Add(newht); diff --git a/WpfApplication1/Presenters/Houses/TransformationDevicePresenter.cs b/WpfApplication1/Presenters/Houses/TransformationDevicePresenter.cs index bb4ffad5..e4360b29 100644 --- a/WpfApplication1/Presenters/Houses/TransformationDevicePresenter.cs +++ b/WpfApplication1/Presenters/Houses/TransformationDevicePresenter.cs @@ -31,6 +31,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using Automation; using Database.Tables.BasicElements; using Database.Tables.BasicHouseholds; using Database.Tables.Houses; @@ -218,6 +219,8 @@ public void RemoveOutputDeviceLoadType([NotNull] TransformationDeviceLoadType td public void MakeACopy() { var newht = TransformationDevice.ImportFromItem(ThisTrafo, Sim); + // assign a new GUID + newht.Guid = StrGuid.New(); newht.Name = newht.Name + " (Copy)"; newht.SaveToDB(); Sim.TransformationDevices.Items.Add(newht); diff --git a/WpfApplication1/ScreenshotHelper.cs b/WpfApplication1/ScreenshotHelper.cs index bbe90d38..3375b093 100644 --- a/WpfApplication1/ScreenshotHelper.cs +++ b/WpfApplication1/ScreenshotHelper.cs @@ -390,7 +390,13 @@ private void ScreenshotElement([CanBeNull] object lt) } SnapshotExpanders(_tab); - Logger.Get().SafeExecuteWithWait(() => _tabControl.Items.RemoveAt(0)); + + // Provisionary fix for the screenshot helper + // Removing the opened tab in the next line led to the wrong tab being screenshotted, + // so this part is commented out for now. + //Logger.Get().SafeExecuteWithWait(() => _tabControl.Items.RemoveAt(0)); + // Sleep for 1s to ensure the screenshot is taken of the correct tab + Thread.Sleep(1000); _itemCount++; } @@ -493,4 +499,4 @@ private void WriteTexBlock([JetBrains.Annotations.NotNull] StreamWriter sw, [Jet } } } -} \ No newline at end of file +} diff --git a/WpfApplication1/Shell.xaml.cs b/WpfApplication1/Shell.xaml.cs index 3fa1a154..01e856e7 100644 --- a/WpfApplication1/Shell.xaml.cs +++ b/WpfApplication1/Shell.xaml.cs @@ -933,7 +933,11 @@ private void AllScreenshotter_OnClick([CanBeNull] object sender, [CanBeNull] Rou WindowGrid.ColumnDefinitions[2].Width = new GridLength(1000); var ssh = new ScreenshotHelper(Sim, Presenter, Tabs); ssh.Run(); - ssh.RunOthers(); + + // Workaround for the screenshot helper + // The following method produces exceptions when trying to create screenshots of all tabs. The screenshot image + // files can be created without this method, so it is commented out for now. + //ssh.RunOthers(); } else { Logger.Warning("canceled."); @@ -1525,4 +1529,4 @@ public static void ConvertAllTraitTagsToLivingPatternTags([JetBrains.Annotations } } } -} \ No newline at end of file +} diff --git a/WpfApplication1/Views/Households/LivingPatternTagView.xaml b/WpfApplication1/Views/Households/LivingPatternTagView.xaml index 89bde0a9..5a9019bc 100644 --- a/WpfApplication1/Views/Households/LivingPatternTagView.xaml +++ b/WpfApplication1/Views/Households/LivingPatternTagView.xaml @@ -47,6 +47,16 @@ Grid.Column="1" Style="{StaticResource TextBoxStyle}" Text="{Binding ThisTag.Name}" /> +