/// <summary> /// starter for real calcs /// </summary> public CalcStartParameterSet( [NotNull] Func <bool, string, ObservableCollection <ResultFileEntry>, bool> reportFinishFuncForHouseAndSettlement, [NotNull] Func <bool, string, string, bool> reportFinishFuncForHousehold, [NotNull] Func <object, bool> openTabFunc, [CanBeNull] ILPGDispatcher dispatcher, [NotNull] GeographicLocation geographicLocation, [NotNull] TemperatureProfile temperatureProfile, [NotNull] ICalcObject calcTarget, EnergyIntensityType energyIntensity, [NotNull] Func <bool> reportCancelFunc, bool resumeSettlement, [CanBeNull] DeviceSelection deviceSelection, LoadTypePriority loadTypePriority, [CanBeNull] TransportationDeviceSet transportationDeviceSet, [CanBeNull] TravelRouteSet travelRouteSet, [NotNull] List <CalcOption> calcOptions, DateTime officialSimulationStartTime, DateTime officialSimulationEndTime, TimeSpan internalTimeResolution, [NotNull] string csvCharacter, int selectedRandomSeed, TimeSpan externalTimeResolution, bool deleteDatFiles, bool writeExcelColumn, bool showSettlingPeriod, int settlingDays, int affordanceRepetitionCount, [NotNull] CalculationProfiler calculationProfiler, [CanBeNull] ChargingStationSet chargingStationSet, [CanBeNull][ItemNotNull] List <string> loadTypesToProcess, DeviceProfileHeaderMode deviceProfileHeaderMode, bool ignorePreviousActivitiesWhenNeeded, string resultPath, bool transportationEnabled) { IgnorePreviousActivitiesWhenNeeded = ignorePreviousActivitiesWhenNeeded; ResultPath = resultPath; LoadTypesToProcess = loadTypesToProcess; ExternalTimeResolution = externalTimeResolution; DeleteDatFiles = deleteDatFiles; WriteExcelColumn = writeExcelColumn; ShowSettlingPeriod = showSettlingPeriod; SettlingDays = settlingDays; AffordanceRepetitionCount = affordanceRepetitionCount; CalculationProfiler = calculationProfiler; SelectedRandomSeed = selectedRandomSeed; OfficialSimulationStartTime = officialSimulationStartTime; OfficialSimulationEndTime = officialSimulationEndTime; InternalTimeResolution = internalTimeResolution; CsvCharacter = csvCharacter; ReportFinishFuncForHouseAndSettlement = reportFinishFuncForHouseAndSettlement; ReportFinishFuncForHousehold = reportFinishFuncForHousehold; OpenTabFunc = openTabFunc; Dispatcher = dispatcher; GeographicLocation = geographicLocation; TemperatureProfile = temperatureProfile; CalcTarget = calcTarget; EnergyIntensity = energyIntensity; ReportCancelFunc = reportCancelFunc; ResumeSettlement = resumeSettlement; LPGVersion = Utili.GetCurrentAssemblyVersion(); DeviceSelection = deviceSelection; LoadTypePriority = loadTypePriority; TransportationDeviceSet = transportationDeviceSet; TravelRouteSet = travelRouteSet; CalcOptions = calcOptions; ChargingStationSet = chargingStationSet; DeviceProfileHeaderMode = deviceProfileHeaderMode; CalculationStartTime = DateTime.Now; TransportationEnabled = transportationEnabled; }
public bool CheckSettings([NotNull] string connectionString) { ConnectionString = connectionString; if (!string.IsNullOrWhiteSpace(Database)) { var fi = new FileInfo(Database); if (!fi.Exists) { throw new LPGException("Database was not found."); } ConnectionString = "Data Source=" + Database; } if (CalcObjectNumber == null) { Logger.Error("No calc object number was set. Can't continue."); return(false); } if (StartDate == null) { StartDate = new DateTime(DateTime.Now.Year, 1, 1); } if (EndDate == null) { EndDate = new DateTime(DateTime.Now.Year, 12, 31); } if (OutputDirectory == null) { OutputDirectory = CalcObjectType + "_" + CalcObjectNumber; } if (TemperatureProfileIndex == null) { TemperatureProfileIndex = 0; } if (GeographicLocationIndex == null) { GeographicLocationIndex = 0; } Logger.Info("Output File Setting is: " + OutputFileDefault.ToString()); Logger.Info("The used LoadTypePriority Default was: " + LoadTypePriority.ToString()); if (LoadTypePriority == LoadTypePriority.Undefined) { Logger.Info("LoadTypePriority was not set. Determing setting..."); if (CalcObjectType == CalcObjectType.ModularHousehold) { LoadTypePriority = LoadTypePriority.RecommendedForHouseholds; Logger.Info("LoadTypePriority for households was selected"); } else { LoadTypePriority = LoadTypePriority.RecommendedForHouses; Logger.Info("LoadTypePriority for houses was selected"); } } return(true); }
//public const string TableName = "CalcStartParameterSet"; /// <summary> /// starter for unit tests /// </summary> public CalcStartParameterSet( [NotNull] GeographicLocation geographicLocation, [NotNull] TemperatureProfile temperatureProfile, [NotNull] ICalcObject calcTarget, EnergyIntensityType energyIntensity, bool resumeSettlement, [CanBeNull] DeviceSelection deviceSelection, LoadTypePriority loadTypePriority, [CanBeNull] TransportationDeviceSet transportationDeviceSet, [CanBeNull] ChargingStationSet chargingStationSet, [CanBeNull] TravelRouteSet travelRouteSet, [NotNull] List <CalcOption> calcOptions, DateTime officialSimulationStartTime, DateTime officialSimulationEndTime, TimeSpan internalTimeResolution, [NotNull] string csvCharacter, int selectedRandomSeed, TimeSpan externalTimeResolution, bool deleteDatFiles, bool writeExcelColumn, bool showSettlingPeriod, int settlingDays, int affordanceRepetitionCount, [NotNull] CalculationProfiler calculationProfiler, string resultPath, bool transportationEnabled) { OfficialSimulationStartTime = officialSimulationStartTime; OfficialSimulationEndTime = officialSimulationEndTime; InternalTimeResolution = internalTimeResolution; CsvCharacter = csvCharacter; SelectedRandomSeed = selectedRandomSeed; ExternalTimeResolution = externalTimeResolution; DeleteDatFiles = deleteDatFiles; WriteExcelColumn = writeExcelColumn; ShowSettlingPeriod = showSettlingPeriod; SettlingDays = settlingDays; AffordanceRepetitionCount = affordanceRepetitionCount; CalculationProfiler = calculationProfiler; GeographicLocation = geographicLocation; TemperatureProfile = temperatureProfile; CalcTarget = calcTarget; EnergyIntensity = energyIntensity; ResumeSettlement = resumeSettlement; LPGVersion = Utili.GetCurrentAssemblyVersion(); DeviceSelection = deviceSelection; LoadTypePriority = loadTypePriority; TransportationDeviceSet = transportationDeviceSet; TravelRouteSet = travelRouteSet; CalcOptions = calcOptions; ChargingStationSet = chargingStationSet; DeviceProfileHeaderMode = DeviceProfileHeaderMode.Standard; ResultPath = resultPath; CalculationStartTime = DateTime.Now; TransportationEnabled = transportationEnabled; }
public static CalcLoadTypeDtoDictionary MakeLoadTypes( [NotNull][ItemNotNull] ObservableCollection <VLoadType> loadTypes, TimeSpan internalTimeResolution, LoadTypePriority priority) { var ltDtoDict = new Dictionary <VLoadType, CalcLoadTypeDto>(); foreach (var lt in loadTypes) { // ReSharper disable once ReplaceWithSingleAssignment.True if (lt.Priority <= priority) { var guid = Guid.NewGuid().ToStrGuid(); var calcLoadTypeDto = new CalcLoadTypeDto(lt.Name, lt.UnitOfPower, lt.UnitOfSum, lt.ConvertPowerValueWithTime(1, internalTimeResolution), lt.ShowInCharts, guid); ltDtoDict.Add(lt, calcLoadTypeDto); } } return(new CalcLoadTypeDtoDictionary(ltDtoDict)); }
//[CanBeNull] JsonReference calcObject, public JsonCalcSpecification(bool deleteAllButPDF, [CanBeNull] JsonReference?deviceSelection, [CanBeNull] DateTime?endDate, [CanBeNull] string?externalTimeResolution, [CanBeNull] string?internalTimeResolution, [CanBeNull] JsonReference?geographicLocation, LoadTypePriority loadTypePriorityEnum, [CanBeNull] string?outputDirectory, bool showSettlingPeriod, [CanBeNull] DateTime?startDate, [CanBeNull] JsonReference?temperatureProfile ) { //CalcObject = calcObject; DeleteAllButPDF = deleteAllButPDF; DeviceSelection = deviceSelection; EndDate = endDate; ExternalTimeResolution = externalTimeResolution; InternalTimeResolution = internalTimeResolution; GeographicLocation = geographicLocation; LoadTypePriority = loadTypePriorityEnum; OutputDirectory = outputDirectory; ShowSettlingPeriod = showSettlingPeriod; StartDate = startDate; TemperatureProfile = temperatureProfile; }
public VLoadType([NotNull] string pName, [NotNull] string description, [NotNull] string unitOfPower, [NotNull] string unitOfSum, double exampleOfPower, double exampleOfSum, TimeSpan timeSpanForSum, double loadTypeWeight, [NotNull] string connectionString, LoadTypePriority priority, bool showInCharts, StrGuid guid, [CanBeNull] int?pID = null) : base(pName, TableName, connectionString, guid) { if (pID == 0 || pID == -1) { throw new LPGException("Loadtype ID should never be 0 or negative!"); } ID = pID; TypeDescription = "Loadtype"; _description = description; _unitOfPower = unitOfPower; _unitOfSum = unitOfSum; _exampleOfPower = exampleOfPower; _exampleOfSum = exampleOfSum; _timeSpanForSum = timeSpanForSum; _loadTypeWeight = loadTypeWeight; _priority = priority; _showInCharts = showInCharts; }
public CalcParameters SetLoadTypePriority(LoadTypePriority loadTypePriority) { LoadTypePriority = loadTypePriority; return(this); }
public CalcDataRepository StartHousehold(int householdNumber, [JetBrains.Annotations.NotNull] string csvCharacter, LoadTypePriority priority = LoadTypePriority.Mandatory, [CanBeNull] DateTime?enddate = null, [CanBeNull] Action <GeneralConfig> configSetter = null, EnergyIntensityType energyIntensity = EnergyIntensityType.EnergyIntensive, bool useHouse = false) #pragma warning restore RCS1141 // Add parameter to documentation comment. { Config.IsInUnitTesting = true; //string dstDirName;// = "Household" + householdNumber; //if (useHouse) { // dstDirName = "House" + householdNumber; //} //if (directoryName != null) { _db = new DatabaseSetup("CalcStarterTests." + _directoryName); var sim = new Simulator(_db.ConnectionString) { MyGeneralConfig = { StartDateDateTime = new DateTime(2012, 1, 1), EndDateDateTime = new DateTime(2012, 1, 31) } }; if (enddate != null) { sim.MyGeneralConfig.EndDateDateTime = enddate.Value; } sim.MyGeneralConfig.RandomSeed = -1; sim.MyGeneralConfig.CSVCharacter = csvCharacter; sim.MyGeneralConfig.ExternalTimeResolution = "00:15:00"; sim.MyGeneralConfig.InternalTimeResolution = "00:01:00"; sim.MyGeneralConfig.ApplyOptionDefault(OutputFileDefault.NoFiles); configSetter?.Invoke(sim.MyGeneralConfig); Logger.Info("Enabled options are:"); foreach (var option in sim.MyGeneralConfig.AllEnabledOptions()) { Logger.Info(option.ToString()); } Logger.Info("External time resolution is: " + sim.MyGeneralConfig.ExternalTimeResolution); var cs = new CalcStarter(sim); Logger.Info("Number of modular households:" + sim.ModularHouseholds.MyItems.Count); if (sim.ModularHouseholds.MyItems.Count <= householdNumber) { return(null); } if ( sim.ModularHouseholds[householdNumber].Description.ToLower(CultureInfo.CurrentCulture) .StartsWith("only for modular", StringComparison.Ordinal)) { return(null); } string workingDir = Wd.WorkingDirectory; CalculationProfiler calculationProfiler = new CalculationProfiler(); if (useHouse) { var house = sim.Houses.It[householdNumber]; Logger.Info("CHH Device selection:" + house.Name); var cspsHouse = new CalcStartParameterSet(ReportFinishFuncForHouseAndSettlement, ReportFinishFuncForHousehold, OpenTabFunc, null, sim.GeographicLocations[0], sim.TemperatureProfiles[0], house, energyIntensity, ReportCancelFunc, false, null, priority, null, null, sim.MyGeneralConfig.AllEnabledOptions(), sim.MyGeneralConfig.StartDateDateTime, sim.MyGeneralConfig.EndDateDateTime, sim.MyGeneralConfig.InternalStepSize, ";", -1, new TimeSpan(0, 15, 0), false, false, false, 3, 3, calculationProfiler, null, null, DeviceProfileHeaderMode.Standard, false, workingDir, false); var duration = cspsHouse.OfficialSimulationEndTime - cspsHouse.OfficialSimulationStartTime; if (duration.TotalDays > 370) { throw new LPGException("Trying to test with more than 1 year"); } cs.Start(cspsHouse); return(null); } var chh = sim.ModularHouseholds[householdNumber]; Logger.Info("Modular Household Device selection:" + chh.DeviceSelection?.Name); var csps = new CalcStartParameterSet(ReportFinishFuncForHouseAndSettlement, ReportFinishFuncForHousehold, OpenTabFunc, null, sim.GeographicLocations[0], sim.TemperatureProfiles[0], chh, energyIntensity, ReportCancelFunc, false, null, priority, null, null, sim.MyGeneralConfig.AllEnabledOptions(), sim.MyGeneralConfig.StartDateDateTime, sim.MyGeneralConfig.EndDateDateTime, sim.MyGeneralConfig.InternalStepSize, ";", -1, new TimeSpan(0, 15, 0), false, false, false, 3, 3, calculationProfiler, null, null, DeviceProfileHeaderMode.Standard, false, workingDir, false); var simduration = csps.OfficialSimulationEndTime - csps.OfficialSimulationStartTime; if (simduration.TotalDays > 370) { throw new LPGException("Trying to test with more than 1 year"); } cs.Start(csps); CalcDataRepository cdr = new CalcDataRepository(Wd.SqlResultLoggingService); //sim.ModularHouseholds[householdNumber].Name return(cdr); }