public void SetPCToSelect(FilePath fileName, int lineNumber) { CalcLocation value = _symbolService.ListTable.GetCalcLocation(fileName, lineNumber); if (value == null) { throw new Exception("Unable to set statement here!"); } _debugger.CPU.PC = value.Address; byte page = value.Page; if (IsAnApp) { page = (byte)(_appPage - page); _debugger.Memory.Bank[1] = _debugger.Memory.Flash[page]; } else { _debugger.Memory.Bank[2] = _debugger.Memory.RAM[1]; } if (DebuggerStep != null) { DebuggerStep(this, new DebuggerStepEventArgs(new DocumentLocation(fileName, lineNumber))); } }
private void MakeSubAffordances([NotNull] DtoCalcLocationDict locations, [NotNull] CalcVariableRepository variableRepository, [NotNull] CalcAffordanceDto affordancedto, [NotNull] CalcAffordance caff) { foreach (CalcSubAffordanceDto sdto in affordancedto.SubAffordance) { CalcLocation subaffLocation = locations.GetCalcLocationByGuid(sdto.LocGuid); List <CalcDesire> satisfactionValues = MakeCalcDesires(sdto.Satisfactionvalues); var varOps = MakeVariableOps(locations, sdto.VariableOps, variableRepository); //subaffordances have no time limits BitArray isBusySub = new BitArray(_calcRepo.CalcParameters.InternalTimesteps, false); CalcSubAffordance csuf = new CalcSubAffordance(sdto.Name, subaffLocation, satisfactionValues, sdto.MiniumAge, sdto.MaximumAge, sdto.Delaytimesteps, sdto.PermittedGender, sdto.AffCategory, sdto.IsInterruptable, sdto.IsInterrupting, caff, varOps, sdto.Weight, sdto.SourceTrait, sdto.Guid, isBusySub, variableRepository, caff.BodilyActivityLevel, _calcRepo); caff.SubAffordances.Add(csuf); } }
public bool SetBreakpoint(WabbitcodeBreakpoint newBreakpoint) { if (_debugger == null || newBreakpoint == null) { return(false); } CalcLocation location = _symbolService.ListTable.GetCalcLocation(newBreakpoint.File, newBreakpoint.LineNumber + 1); if (location == null) { // move the breakpoint to the nearest location FilePath fileName = newBreakpoint.File; int lineNumber = newBreakpoint.LineNumber; CalcLocation value = _symbolService.ListTable.GetNextNearestCalcLocation(fileName, lineNumber + 1); if (value == null) { return(false); } DocumentLocation newLocation = _symbolService.ListTable.GetFileLocation(value.Page, value.Address, value.IsRam); WabbitcodeBreakpointManager.RemoveBreakpoint(fileName, lineNumber); WabbitcodeBreakpointManager.AddBreakpoint(newLocation.FileName, newLocation.LineNumber - 1); return(true); } newBreakpoint.Page = location.Page; newBreakpoint.Address = location.Address; newBreakpoint.IsRam = location.IsRam; byte page = location.IsRam ? location.Page : (byte)(_appPage - newBreakpoint.Page); newBreakpoint.WabbitemuBreakpoint = _debugger.SetBreakpoint(newBreakpoint.IsRam, page, newBreakpoint.Address); return(false); }
private void Caret_PositionChanged(object sender, EventArgs e) { if (Document.TextLength == 0) { return; } Document.MarkerStrategy.RemoveAll(marker => marker is ReferenceMarker); if (_updateRefsTimer.Enabled) { _updateRefsTimer.Stop(); } _updateRefsTimer.Start(); _statusBarService.SetCaretPosition(ActiveTextAreaControl.Caret.Line, ActiveTextAreaControl.Caret.Column); UpdateCodeCountInfo(); CalcLocation label = _symbolService.ListTable.GetCalcLocation(new FilePath(FileName), ActiveTextAreaControl.Caret.Line + 1); if (label == null) { return; } string assembledInfo = string.Format("Page: {0} Address: {1}", label.Page, label.Address.ToString("X4")); _statusBarService.SetText(assembledInfo); }
public void CalcAffordanceVariableTestSet() { var deviceCategoryGuid = Guid.NewGuid().ToStrGuid(); //var r = new Random(0); //var nr = new NormalRandom(0, 0.1, r); const int stepcount = 150; Config.IsInUnitTesting = true; DateTime startdate = new DateTime(2018, 1, 1); DateTime enddate = startdate.AddMinutes(stepcount); //_calcParameters.InitializeTimeSteps(startdate, enddate, new TimeSpan(0, 1, 0), 3, false); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate); var timeStep = new TimeSpan(0, 1, 0); var cp = new CalcProfile("profile", Guid.NewGuid().ToStrGuid(), timeStep, ProfileType.Absolute, "blub"); cp.AddNewTimepoint(new TimeSpan(0), 100); cp.AddNewTimepoint(new TimeSpan(0, 10, 0), 0); cp.ConvertToTimesteps(); var variables = new List <CalcAffordanceVariableOp>(); var variableReqs = new List <VariableRequirement>(); var loc = new CalcLocation("loc", Guid.NewGuid().ToStrGuid()); CalcVariableRepository calcVariableRepository = new CalcVariableRepository(); var variableGuid = Guid.NewGuid().ToStrGuid(); HouseholdKey key = new HouseholdKey("hh1"); CalcVariable cv = new CalcVariable("varname", variableGuid, 0, loc.Name, loc.Guid, key); calcVariableRepository.RegisterVariable(cv); variables.Add(new CalcAffordanceVariableOp(cv.Name, 1, loc, VariableAction.SetTo, VariableExecutionTime.Beginning, variableGuid)); BitArray isBusy = new BitArray(100, false); Random rnd = new Random(); NormalRandom nr = new NormalRandom(0, 1, rnd); using CalcRepo calcRepo = new CalcRepo(calcParameters: calcParameters, odap: new Mock <IOnlineDeviceActivationProcessor>().Object, normalRandom: nr, rnd: rnd); var aff = new CalcAffordance("bla", cp, loc, false, new List <CalcDesire>(), 0, 99, PermittedGender.All, false, 0.1, new ColorRGB(0, 0, 0), "bla", false, false, variables, variableReqs, ActionAfterInterruption.GoBackToOld, "bla", 100, false, "", Guid.NewGuid().ToStrGuid(), calcVariableRepository, new List <CalcAffordance.DeviceEnergyProfileTuple>(), isBusy, BodilyActivityLevel.Low, calcRepo); var lt = new CalcLoadType("load", "unit1", "unit2", 1, true, Guid.NewGuid().ToStrGuid()); var cdl = new CalcDeviceLoad("cdl", 1, lt, 1, 0.1); var devloads = new List <CalcDeviceLoad> { cdl }; CalcDeviceDto cdd = new CalcDeviceDto("device", deviceCategoryGuid, key, OefcDeviceType.Device, "category", string.Empty, Guid.NewGuid().ToStrGuid(), loc.Guid, loc.Name); var cd = new CalcDevice(devloads, loc, cdd, calcRepo); //loc.Variables.Add("Variable1", 0); aff.AddDeviceTuple(cd, cp, lt, 0, timeStep, 10, 1); TimeStep ts = new TimeStep(0, 0, false); aff.IsBusy(ts, loc, "name"); //var variableOperator = new VariableOperator(); aff.Activate(ts, "blub", loc, out var _); calcVariableRepository.GetValueByGuid(variableGuid).Should().Be(1); }
public List <CalcPerson> MakeCalcPersons([NotNull][ItemNotNull] List <CalcPersonDto> persons, [NotNull] CalcLocation startLocation, [NotNull] string householdName) { var calcPersons = new List <CalcPerson>(); Dictionary <string, SharedDesireValue> sharedDesireValues = new Dictionary <string, SharedDesireValue>(); foreach (var hhPerson in persons) { var isSick = SetBitArrayWithDateSpans(hhPerson.SicknessSpans); var vacationTimes = SetBitArrayWithDateSpans(hhPerson.VacationSpans); var cp = new CalcPerson(hhPerson, startLocation, isSick, vacationTimes, _calcRepo); /* repetitionCount, _random,hhPerson.Person.Age, hhPerson.Person.Gender, _logFile, * householdKey, startLocation, traitTagName, householdName, _calcParameters, isSick, * Guid.NewGuid().ToStrGuid());*/ // vacations setzen foreach (PersonDesireDto desire in hhPerson.Desires) { AddDesireToPerson(desire, cp, sharedDesireValues, householdName); } calcPersons.Add(cp); } return(calcPersons); }
public void SetAllAffordaces([NotNull][ItemNotNull] List <CalcAffordanceDto> affordances, [NotNull] DtoCalcLocationDict locations, [NotNull] CalcVariableRepository variableRepository, [ItemNotNull][NotNull] List <CalcDevice> devices) { if (affordances.Count == 0) { throw new LPGException("No Affordances found."); } foreach (CalcAffordanceDto affordancedto in affordances) { CalcProfile personProfile = CalcDeviceFactory.MakeCalcProfile(affordancedto.PersonProfile, _calcRepo.CalcParameters); CalcLocation calcLocation = locations.GetCalcLocationByGuid(affordancedto.CalcLocationGuid); var calcDesires = MakeCalcDesires(affordancedto.Satisfactionvalues); var color = new ColorRGB(affordancedto.ColorR, affordancedto.ColorG, affordancedto.ColorB); var variableOps = MakeVariableOps(locations, affordancedto.VariableOps, variableRepository); List <VariableRequirement> requirements = new List <VariableRequirement>(); foreach (VariableRequirementDto requirementDto in affordancedto.VariableRequirements) { VariableRequirement vrq = new VariableRequirement(requirementDto.Name, requirementDto.Value, requirementDto.CalcLocationName, requirementDto.LocationGuid, requirementDto.VariableCondition, variableRepository, requirementDto.VariableGuid); requirements.Add(vrq); } var deviceEnergyProfiles = MakeDeviceEnergyProfileTuples(devices, affordancedto); var busyarr = _availabilityDtoRepository.GetByGuid(affordancedto.IsBusyArray.Guid); CalcAffordance caff = new CalcAffordance( affordancedto.Name, personProfile, calcLocation, affordancedto.RandomEffect, calcDesires, affordancedto.MiniumAge, affordancedto.MaximumAge, affordancedto.PermittedGender, affordancedto.NeedsLight, affordancedto.TimeStandardDeviation, color, affordancedto.AffCategory, affordancedto.IsInterruptable, affordancedto.IsInterrupting, variableOps, requirements, affordancedto.ActionAfterInterruption, affordancedto.TimeLimitName, affordancedto.Weight, affordancedto.RequireAllDesires, affordancedto.SrcTrait, affordancedto.Guid, variableRepository, deviceEnergyProfiles, busyarr, affordancedto.BodilyActivityLevel, _calcRepo); MakeSubAffordances(locations, variableRepository, affordancedto, caff); calcLocation.AddAffordance(caff); } }
public void SetTimeprofileTest() { DateTime startdate = new DateTime(2018, 1, 1); DateTime enddate = startdate.AddMinutes(10); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate); CalcLoadType clt = MakeCalcLoadType(); CalcLocation cloc = new CalcLocation("blub", Guid.NewGuid().ToStrGuid()); CalcDeviceLoad cdl = new CalcDeviceLoad("cdl1", 1, clt, 1, 0.1); List <CalcDeviceLoad> cdls = new List <CalcDeviceLoad>(); using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { wd.InputDataLogger.AddSaver(new ColumnEntryLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService)); using (FileFactoryAndTracker fft = new FileFactoryAndTracker(wd.WorkingDirectory, "hh1", wd.InputDataLogger)) { fft.RegisterHousehold(Constants.GeneralHouseholdKey, "General", HouseholdKeyType.General, "desc", null, null); //SqlResultLoggingService srls = new SqlResultLoggingService(wd.WorkingDirectory); DateStampCreator dsc = new DateStampCreator(calcParameters); using (IOnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters)) { cdls.Add(cdl); OnlineDeviceActivationProcessor odap = new OnlineDeviceActivationProcessor(old, calcParameters, fft); var deviceCategoryGuid = Guid.NewGuid().ToStrGuid(); CalcDeviceDto cdd = new CalcDeviceDto("bla", deviceCategoryGuid , new HouseholdKey("HH-6"), OefcDeviceType.Device, "category", string.Empty, Guid.NewGuid().ToStrGuid(), cloc.Guid, cloc.Name); using CalcRepo calcRepo = new CalcRepo(odap: odap, calcParameters: calcParameters, normalRandom: NormalRandom); CalcDevice cd = new CalcDevice(cdls, cloc, cdd, calcRepo); CalcProfile cp = MakeCalcProfile5Min100(); TimeStep ts1 = new TimeStep(1, calcParameters); cd.SetAllLoadTypesToTimeprofile(cp, ts1, "test", "name1", 1); TimeStep ts = new TimeStep(0, calcParameters); cd.IsBusyDuringTimespan(ts, 1, 1, clt).Should().BeFalse(); cd.IsBusyDuringTimespan(ts.AddSteps(1), 1, 1, clt).Should().BeTrue(); cd.IsBusyDuringTimespan(ts.AddSteps(2), 1, 1, clt).Should().BeTrue(); cd.IsBusyDuringTimespan(ts.AddSteps(3), 1, 1, clt).Should().BeTrue(); cd.IsBusyDuringTimespan(ts.AddSteps(4), 1, 1, clt).Should().BeTrue(); cd.IsBusyDuringTimespan(ts.AddSteps(5), 1, 1, clt).Should().BeTrue(); cd.IsBusyDuringTimespan(ts.AddSteps(6), 0, 1, clt).Should().BeFalse(); } } wd.CleanUp(); } }
public void VariableLogfileTests1() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { wd.InputDataLogger.AddSaver(new VariableEntryLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService)); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().EnableShowSettlingPeriod(); using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger)) { HouseholdKey key = new HouseholdKey("hh1"); fft.RegisterGeneralHouse(); fft.RegisterHousehold(key, "householdname", HouseholdKeyType.Household, "desc", null, null); DateStampCreator dsc = new DateStampCreator(calcParameters); using (IOnlineLoggingData old = new OnlineLoggingData(dsc, wd.InputDataLogger, calcParameters)) { CalcVariableRepository cvr = new CalcVariableRepository(); //using (LogFile lf = new LogFile(calcParameters,fft, old,wd.SqlResultLoggingService, true)) CalcLocation cloc = new CalcLocation("loc1", Guid.NewGuid().ToStrGuid()); CalcVariable cv = new CalcVariable("mycalcvar", Guid.NewGuid().ToStrGuid(), 0, cloc.Name, cloc.Guid, key); cvr.RegisterVariable(cv); TimeStep ts = new TimeStep(0, calcParameters); old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 1, cv.LocationName, cv.LocationGuid, cv.HouseholdKey, ts)); old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 2, cv.LocationName, cv.LocationGuid, cv.HouseholdKey, ts)); old.AddVariableStatus(new CalcVariableEntry(cv.Name, cv.Guid, 3, cv.LocationName, cv.LocationGuid, cv.HouseholdKey, ts)); old.FinalSaveToDatabase(); } VariableEntryLogger vel = new VariableEntryLogger(wd.SqlResultLoggingService); var varEntries = vel.Read(key); foreach (CalcVariableEntry entry in varEntries) { Logger.Info(entry.Value.ToString(CultureInfo.InvariantCulture)); } varEntries[0].Value.Should().Be(1); varEntries[1].Value.Should().Be(2); varEntries[2].Value.Should().Be(3); } /*old. * cloc.Add(); * cloc[0].Variables.Add("trig1", 1.0); * tlf.WriteLine(0, cloc); * cloc[0].Variables["trig1"] = 2.0; * tlf.WriteLine(1, cloc); * lf.Close(null);*/ wd.CleanUp(); } }
private static void CheckForBusyness([NotNull] CalcLocation loc, [NotNull] CalcAffordance aff, [NotNull] CalcDevice cd, [NotNull] CalcLoadType lt) { Logger.Info("------------"); TimeStep ts1 = new TimeStep(0, 0, true); Logger.Info("aff.isbusy 0: " + aff.IsBusy(ts1, loc, "person", false)); var prevstate = false; for (var i = 0; i < 100; i++) { TimeStep ts2 = new TimeStep(i, 0, true); if (aff.IsBusy(ts2, loc, "person", false) != prevstate) { prevstate = aff.IsBusy(ts2, loc, "name", false); Logger.Info("aff.isbusy:" + i + ": " + prevstate); } } Logger.Info("aff.isbusy 100: " + aff.IsBusyArray[100]); prevstate = false; Logger.Info("aff.isbusyarray 0: " + aff.IsBusyArray[0]); for (var i = 0; i < 100; i++) { if (aff.IsBusyArray[i] != prevstate) { prevstate = aff.IsBusyArray[i]; Logger.Info("aff.isbusyarray: " + i + ": " + prevstate); } } Logger.Info("aff.isbusyarray 100: " + aff.IsBusyArray[100]); prevstate = false; TimeStep ts3 = new TimeStep(0, 0, false); Logger.Info("cd.isbusyarray 0: " + cd.GetIsBusyForTesting(ts3, lt)); for (var i = 0; i < 100; i++) { TimeStep ts4 = new TimeStep(i, 0, false); if (cd.GetIsBusyForTesting(ts4, lt) != prevstate) { prevstate = cd.GetIsBusyForTesting(ts4, lt); Logger.Info("cd.isbusyarray: " + i + ": " + prevstate); } } TimeStep ts5 = new TimeStep(100, 0, false); Logger.Info("cd.isbusyarray 100: " + cd.GetIsBusyForTesting(ts5, lt)); }
public bool IsBusy(TimeStep time, CalcLocation srcLocation, string calcPersonName, bool clearDictionaries = true) { if (_myLastTimeEntry.TimeOfLastEvalulation != time || _myLastTimeEntry.PersonName != calcPersonName) { _myLastTimeEntry = new LastTimeEntry(calcPersonName, time); } CalcTravelRoute route; if (_myLastTimeEntry.PreviouslySelectedRoutes.ContainsKey(srcLocation)) { route = _myLastTimeEntry.PreviouslySelectedRoutes[srcLocation]; } else { route = _transportationHandler.GetTravelRouteFromSrcLoc(srcLocation, Site, time, calcPersonName, _calcRepo); _myLastTimeEntry.PreviouslySelectedRoutes.Add(srcLocation, route); } if (route == null) { return(true); } // ReSharper disable once PossibleInvalidOperationException int?travelDurationN = (int)route.GetDuration(time, calcPersonName, _transportationHandler.AllMoveableDevices); if (travelDurationN == null) { throw new LPGException("Bug: couldn't calculate travel duration for route."); } TimeStep dstStartTime = time.AddSteps(travelDurationN.Value); if (dstStartTime.InternalStep > _calcRepo.CalcParameters.InternalTimesteps) { //if the end of the activity is after the simulation, everything is ok. return(false); } bool result = _sourceAffordance.IsBusy(dstStartTime, srcLocation, calcPersonName, clearDictionaries); _calcRepo.OnlineLoggingData.AddTransportationStatus(new TransportationStatus( time, _householdkey, "\t\t" + time + " @" + srcLocation + " by " + calcPersonName + "Checking " + Name + " for busyness: " + result + " @time " + dstStartTime + " with the route " + route.Name + " and a travel duration of " + travelDurationN)); return(result); }
private List <CalcAutoDev> MakeCalcAutoDevsFromHouse([NotNull] CalcHouseDto house, [NotNull][ItemNotNull] List <CalcLocation> houseLocations) { var autodevs = new List <CalcAutoDev>(house.AutoDevs.Count); // zur kategorien zuordnung foreach (var hhautodev in house.AutoDevs) { CalcProfile calcProfile = CalcDeviceFactory.MakeCalcProfile(hhautodev.CalcProfile, _calcRepo.CalcParameters); CalcLoadType clt = _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid); List <CalcDeviceLoad> loads = new List <CalcDeviceLoad>(); foreach (CalcDeviceLoadDto loadDto in hhautodev.Loads) { CalcDeviceLoad load = new CalcDeviceLoad(loadDto.Name, loadDto.MaxPower, _ltDict.GetLoadtypeByGuid(loadDto.LoadTypeGuid), loadDto.AverageYearlyConsumption, loadDto.PowerStandardDeviation); loads.Add(load); } List <VariableRequirement> requirements = new List <VariableRequirement>(); foreach (var reqDto in hhautodev.Requirements) { VariableRequirement rq = new VariableRequirement(reqDto.Name, reqDto.Value, reqDto.CalcLocationName, reqDto.LocationGuid, reqDto.VariableCondition, _variableRepository, reqDto.VariableGuid); requirements.Add(rq); } CalcLocation houseLocation = houseLocations.Single(x => x.Guid == hhautodev.CalcLocationGuid); var cautodev = new CalcAutoDev( calcProfile, clt, loads, hhautodev.TimeStandardDeviation, hhautodev.Multiplier, houseLocation, requirements, hhautodev, _calcRepo); var busyarr = _availabilityDtoRepository.GetByGuid(hhautodev.BusyArr.Guid); cautodev.ApplyBitArry(busyarr, _ltDict.GetLoadtypeByGuid(hhautodev.LoadtypeGuid)); autodevs.Add(cautodev); } return(autodevs); }
internal void UpdateAddress(CalcLocation location) { if (location != null) { Page = location.Page; Address = location.Address; IsRam = location.IsRam; _isAddressValid = true; } else { _isAddressValid = false; } }
public CalcAirConditioning( [NotNull][ItemNotNull] List <CalcDeviceLoad> powerUsage, [NotNull] Dictionary <Tuple <int, int, int, int>, CalcDegreeHour> calcDegreeHours, [NotNull] CalcLocation cloc, [NotNull] CalcDeviceDto calcDeviceDto, [NotNull] CalcRepo calcRepo) : base( powerUsage, cloc, calcDeviceDto, calcRepo) { if (powerUsage.Count != 1) { throw new LPGException("there should be exactly one loadtype for air conditioning, not more or less."); } _calcDegreeHours = calcDegreeHours; }
public CalcSpaceHeating( [NotNull][ItemNotNull] List <CalcDeviceLoad> powerUsage, [NotNull] Dictionary <Tuple <int, int, int>, CalcDegreeDay> calcDegreeDays, [NotNull] CalcLocation cloc, [NotNull] CalcDeviceDto deviceDto, [NotNull] CalcRepo calcRepo) : base( powerUsage, cloc, deviceDto, calcRepo) { if (powerUsage.Count != 1) { throw new LPGException("there should be exactly one loadtype for space heating, not more or less."); } _calcDegreeDays = calcDegreeDays; }
public CalcHouse MakeCalcHouse([NotNull] CalcHouseDto calcHouseDto, CalcRepo calcRepo) { HouseholdKey houseKey = Constants.HouseKey; var calchouse = new CalcHouse(calcHouseDto.HouseName, calcHouseDto.HouseKey, calcRepo); List <CalcLocation> houseLocations = new List <CalcLocation>(); foreach (var houseLoc in calcHouseDto.HouseLocations) { CalcLocation cl = new CalcLocation(houseLoc.Name, houseLoc.Guid); houseLocations.Add(cl); } var calcAbleObjects = new List <ICalcAbleObject>(); //var globalLocationDict = new Dictionary<CalcLocationDto, CalcLocation>(); foreach (var householddto in calcHouseDto.Households) { var hh = _cmhf.MakeCalcModularHousehold(householddto, out var _, calcHouseDto.HouseName, calcHouseDto.Description, _calcRepo); calcAbleObjects.Add(hh); // foreach (var pair in dtoCalcLocationDict.LocationDtoDict) { // if (!globalLocationDict.ContainsKey(pair.Key)) { // globalLocationDict.Add(pair.Key, pair.Value); // } //} } calchouse.SetHouseholds(calcAbleObjects); MakeHeating(calcHouseDto, calchouse, houseKey, houseLocations); //, taggingSets); SetAirConditioningOnHouse(calcHouseDto, calchouse, houseLocations); var autodevs2 = MakeCalcAutoDevsFromHouse(calcHouseDto, houseLocations); calchouse.SetAutoDevs(autodevs2); // energy Storage SetEnergyStoragesOnHouse(calcHouseDto.EnergyStorages, houseKey, calchouse, _variableRepository); //, taggingSets); // transformation devices MakeAllTransformationDevices(calcHouseDto, calchouse, houseKey); //taggingSets, // generators calchouse.SetGenerators(MakeGenerators(calcHouseDto.Generators, houseKey)); //taggingSets, return(calchouse); }
public void FileFactoryAndTrackerTest() { Config.IsInUnitTesting = true; using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService)); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults(); var clt = new CalcLoadType("calcloadtype", "kwh", "kW", 0.001, true, Guid.NewGuid().ToStrGuid()); BitArray isSick = new BitArray(calcParameters.InternalTimesteps); BitArray isOnVacation = new BitArray(calcParameters.InternalTimesteps); var personDto = CalcPersonDto.MakeExamplePerson(); Random r = new Random(); Mock <ILogFile> lf = new Mock <ILogFile>(); using (CalcRepo calcRepo = new CalcRepo(rnd: r, lf: lf.Object, calcParameters: calcParameters)) { CalcLocation cloc = new CalcLocation("blub", Guid.NewGuid().ToStrGuid()); var cp = new CalcPerson(personDto, cloc, isSick, isOnVacation, calcRepo); /*"personname", 1, 1, null, 1, PermittedGender.Female, lf: null, * householdKey: "hh1", startingLocation: null, traitTag: "traittag", * householdName: "hhname0",calcParameters:calcParameters,isSick:isSick, guid:Guid.NewGuid().ToStrGuid()); */ var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "testhh", wd.InputDataLogger); fft.RegisterHousehold(new HouseholdKey("hh1"), "test key", HouseholdKeyType.Household, "desc", null, null); fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general key", HouseholdKeyType.General, "desc", null, null); fft.MakeFile <StreamWriter>("file1", "desc", true, ResultFileID.Actions, new HouseholdKey("hh1"), TargetDirectory.Charts, TimeSpan.FromMinutes(1), CalcOption.HouseholdContents, clt.ConvertToLoadTypeInformation(), cp.MakePersonInformation()); //fft.ResultFileList.WriteResultEntries(wd.WorkingDirectory); ResultFileEntryLogger rfel = new ResultFileEntryLogger(wd.SqlResultLoggingService); var rfes = rfel.Load(); rfes.Count.Should().BeGreaterThan(0); //ResultFileList.ReadResultEntries(wd.WorkingDirectory); fft.GetResultFileEntry(ResultFileID.Actions, clt.Name, new HouseholdKey("hh1"), cp.MakePersonInformation(), null); fft.Dispose(); } wd.CleanUp(); } }
public void BasicTest() { using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) { wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService)); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().EnableShowSettlingPeriod().SetSettlingDays(5); using (FileFactoryAndTracker fft = new FileFactoryAndTracker(wd.WorkingDirectory, "blub", wd.InputDataLogger)) { fft.RegisterGeneralHouse(); fft.RegisterHousehold(new HouseholdKey("HH1"), "test", HouseholdKeyType.Household, "desc", null, null); ThoughtsLogFile tlf = new ThoughtsLogFile(fft, calcParameters); Random rnd = new Random(); //NormalRandom nr = new NormalRandom(0, 0.1, rnd); // this array is pure nonsense and only to make it stop crashing the unit test //_calcParameters.InternalDateTimeForSteps = new List<DateTime>(4); //for (int i = 0; i < 4; i++) //{ // _calcParameters.InternalDateTimeForSteps.Add(DateTime.Now); //} CalcLocation cloc = new CalcLocation("cloc", Guid.NewGuid().ToStrGuid()); BitArray isSick = new BitArray(calcParameters.InternalTimesteps); BitArray isOnVacation = new BitArray(calcParameters.InternalTimesteps); CalcPersonDto dto = CalcPersonDto.MakeExamplePerson(); Mock <ILogFile> lf = new Mock <ILogFile>(); NormalRandom nr = new NormalRandom(0, 0.1, rnd); using (CalcRepo calcRepo = new CalcRepo(rnd: rnd, lf: lf.Object, calcParameters: calcParameters, normalRandom: nr)) { CalcPerson cp = new CalcPerson(dto, cloc, isSick, isOnVacation, calcRepo); //"personName", 0, 1, rnd, 1, PermittedGender.Male, null, "HH1" ,cloc,"traittag", "hhname0",calcParameters,isSick,Guid.NewGuid().ToStrGuid()); TimeStep ts = new TimeStep(0, 0, false); ThoughtEntry te = new ThoughtEntry(cp, ts, "blua"); calcParameters.SetSettlingDays(0); tlf.WriteEntry(te, new HouseholdKey("HH1")); } tlf.Dispose(); } wd.CleanUp(); } }
public void TestBasics() { // needs major redesign of calcperson class using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass())) {// StreamFactory sf = new StreamFactory(); DateTime startdate = new DateTime(2018, 1, 1); DateTime enddate = startdate.AddMinutes(100); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate).EnableShowSettlingPeriod().SetSettlingDays(0); wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(wd.SqlResultLoggingService)); wd.InputDataLogger.AddSaver(new ResultFileEntryLogger(wd.SqlResultLoggingService)); using (var fft = new FileFactoryAndTracker(wd.WorkingDirectory, "test1", wd.InputDataLogger)) { fft.RegisterHousehold(Constants.GeneralHouseholdKey, "general", HouseholdKeyType.General, "desc", null, null); //SqlResultLoggingService srls = new SqlResultLoggingService(wd.WorkingDirectory); CalculationProfiler profiler = new CalculationProfiler(); CalcRepo calcRepo = CalcRepo.Make(calcParameters, wd.InputDataLogger, wd.WorkingDirectory, "name", profiler); DesiresLogFile dlf = new DesiresLogFile(fft, calcParameters); CalcDesire cd1 = new CalcDesire("desire1", 1, 0.5m, 12, 1, 1, 60, -1, null, "", ""); //NormalRandom nr = new NormalRandom(0, 0.1, r); CalcLocation cloc = new CalcLocation("cloc", Guid.NewGuid().ToStrGuid()); BitArray isSick = new BitArray(calcParameters.InternalTimesteps); BitArray isOnVacation = new BitArray(calcParameters.InternalTimesteps); CalcPersonDto calcPerson = CalcPersonDto.MakeExamplePerson(); CalcPerson cp = new CalcPerson(calcPerson, cloc, isSick, isOnVacation, calcRepo); //"bla", 1, 5, r, 48, PermittedGender.Male, lf, "HH1", cloc, "traittag", "hhname0",calcParameters,isSick,Guid.NewGuid().ToStrGuid()); cp.PersonDesires.AddDesires(cd1); dlf.RegisterDesires(cp.PersonDesires.Desires.Values); TimeStep ts = new TimeStep(0, 0, true); DesireEntry de = new DesireEntry(cp, ts, cp.PersonDesires, dlf, calcParameters); fft.RegisterHousehold(new HouseholdKey("hh1"), "bla", HouseholdKeyType.Household, "desc", null, null); dlf.WriteEntry(de, new HouseholdKey("hh1")); dlf.Dispose(); } wd.CleanUp(); } }
private void SetupInternalBreakpoints() { if (_debugger == null) { return; } // this is the start _JForceCmdNoChar const ushort jforceCmdNoChar = 0x4027; const ushort insertMem = 0x42F7; const ushort delMem = 0x4357; CalcLocation location = LookupBcallAddress(jforceCmdNoChar); _jforceBreakpoint = _debugger.SetBreakpoint(location.IsRam, location.Page, location.Address); // most likely location that a crash will end up _ramClearBreakpoint = _debugger.SetBreakpoint(false, 0, 0x0000); // for restarts we want to manually delmem location = LookupBcallAddress(insertMem); _insertMemBreakpoint = _debugger.SetBreakpoint(location.IsRam, location.Page, location.Address); // we need to track any memory freed as well location = LookupBcallAddress(delMem); _delMemBreakpoint = _debugger.SetBreakpoint(location.IsRam, location.Page, location.Address); }
public void StepOut() { if (_isStepping) { return; } _isStepping = true; DocumentLocation lastCallLocation = CallStack.Last().CallLocation; CalcLocation calcLocation = _symbolService.ListTable.GetCalcLocation(lastCallLocation.FileName, lastCallLocation.LineNumber); DocumentLocation docLocation = null; ushort address = calcLocation.Address; while (docLocation == null) { address++; docLocation = _symbolService.ListTable.GetFileLocation(calcLocation.Page, address, calcLocation.IsRam); } _stepOutBreakpoint = _debugger.SetBreakpoint(calcLocation.IsRam, (byte)(_appPage - calcLocation.Page), address); _debugger.OnBreakpoint += StepOutBreakpointEvent; _debugger.Step(); _debugger.Running = true; }
private static List <CalcAffordanceVariableOp> MakeVariableOps([NotNull] DtoCalcLocationDict locations, [NotNull][ItemNotNull] List <CalcAffordanceVariableOpDto> affordancedto, [NotNull] CalcVariableRepository repository) { List <CalcAffordanceVariableOp> variableOps = new List <CalcAffordanceVariableOp>(); foreach (CalcAffordanceVariableOpDto variableOpDto in affordancedto) { if (!repository.IsVariableRegistered(variableOpDto.VariableGuid)) { throw new LPGException("Variable " + variableOpDto.Name + " was not registered."); } CalcLocation variableLocation = locations.GetCalcLocationByGuid(variableOpDto.LocationGuid); var variableOp = new CalcAffordanceVariableOp(variableOpDto.Name, variableOpDto.Value, variableLocation, variableOpDto.VariableAction, variableOpDto.ExecutionTime, variableOpDto.VariableGuid); variableOps.Add(variableOp); } return(variableOps); }
public CalcTravelRoute GetTravelRouteFromSrcLoc([NotNull] CalcLocation srcLocation, [NotNull] CalcSite dstSite, [NotNull] TimeStep startTimeStep, [NotNull] string personName, CalcRepo calcRepo) { CalcSite srcSite = LocationSiteLookup[srcLocation]; if (srcSite == dstSite) { return(SameSiteRoutes[srcSite]); } //first get the routes, no matter if busy var devicesAtSrc = AllMoveableDevices.Where(x => x.Currentsite == srcSite).ToList(); var possibleRoutes = srcSite.GetAllRoutesTo(dstSite, devicesAtSrc); if (possibleRoutes.Count == 0) { return(null); } //check if the route is busy by calculating the duration. If busy, duration will be null int? dur = null; CalcTravelRoute ctr = null; while (dur == null && possibleRoutes.Count > 0) { ctr = possibleRoutes[calcRepo.Rnd.Next(possibleRoutes.Count)]; possibleRoutes.Remove(ctr); dur = ctr.GetDuration(startTimeStep, personName, AllMoveableDevices); } if (dur == null) { ctr = null; } return(ctr); }
public List <CalcAutoDev> MakeCalcAutoDevs( [NotNull][ItemNotNull] List <CalcAutoDevDto> autoDevices, [NotNull] DtoCalcLocationDict locationDict) { var autodevs = new List <CalcAutoDev>(autoDevices.Count); foreach (var autoDevDto in autoDevices) { if (_loadTypeDictionary.SimulateLoadtype(autoDevDto.LoadtypeGuid)) { var deviceLoads = MakeCalcDeviceLoads(autoDevDto, _loadTypeDictionary); CalcProfile cp = MakeCalcProfile(autoDevDto.CalcProfile, _calcRepo.CalcParameters); var loadtype = _loadTypeDictionary.GetLoadtypeByGuid(autoDevDto.LoadtypeGuid); CalcLocation calcLocation = locationDict.GetCalcLocationByGuid(autoDevDto.CalcLocationGuid); List <VariableRequirement> requirements = new List <VariableRequirement>(); foreach (var req in autoDevDto.Requirements) { VariableRequirement vreq = new VariableRequirement(req.Name, req.Value, req.CalcLocationName, req.LocationGuid, req.VariableCondition, _calcVariableRepository, req.VariableGuid); requirements.Add(vreq); } autoDevDto.AdditionalName = " (autonomous)"; var cautodev = new CalcAutoDev(cp, loadtype, deviceLoads, autoDevDto.TimeStandardDeviation, 1, calcLocation, requirements, autoDevDto, _calcRepo); var busyarr = _availabilityDtoRepository.GetByGuid(autoDevDto.BusyArr.Guid); cautodev.ApplyBitArry(busyarr, loadtype); autodevs.Add(cautodev); } } return(autodevs); }
public List <CalcLocation> MakeCalcLocations([NotNull][ItemNotNull] List <CalcLocationDto> locations, [NotNull] DtoCalcLocationDict locdict, CalcRepo calcRepo) { var locs = new List <CalcLocation>(); foreach (var t in locations) { // loc anlegen var cloc = new CalcLocation(t.Name, t.Guid); foreach (var locdev in t.LightDevices) { var deviceLoads = CalcDeviceFactory.MakeCalcDeviceLoads(locdev, _calcLoadTypeDict); var deviceName = CalcAffordanceFactory.FixAffordanceName(locdev.Name, _calcRepo.CalcParameters.CSVCharacter); locdev.Name = deviceName; var clightdevice = new CalcDevice(deviceLoads, cloc, locdev, calcRepo); cloc.AddLightDevice(clightdevice); } //deviceLocationDict.Add(cloc, new List<IAssignableDevice>()); locs.Add(cloc); locdict.LocationDtoDict.Add(t, cloc); } return(locs); }
private List <CalcSite> MakeCalcSites([NotNull] CalcHouseholdDto household, [NotNull] DtoCalcLocationDict locDict, [NotNull] CalcLoadTypeDictionary ltDict, [NotNull] TransportationHandler th ) { List <CalcSite> sites = new List <CalcSite>(); //Dictionary<string, CalcSite> siteDictByGuid = new Dictionary<string, CalcSite>(); if (household.CalcSites == null) { throw new LPGException("CalcSites was null"); //for the bug in the null checking } foreach (var siteDto in household.CalcSites) { var calcSite = new CalcSite(siteDto.Name, siteDto.Guid, household.HouseholdKey); sites.Add(calcSite); //siteDictByGuid.Add(siteDto.Guid, calcSite); foreach (var locGuid in siteDto.LocationGuid) { CalcLocation calcLoc = locDict.GetCalcLocationByGuid(locGuid); calcLoc.CalcSite = calcSite; calcSite.Locations.Add(calcLoc); } foreach (var chargingStation in siteDto.ChargingStations) { var gridLt = ltDict.GetLoadtypeByGuid(chargingStation.GridChargingLoadType.Guid); var carLt = ltDict.GetLoadtypeByGuid(chargingStation.CarChargingLoadType.Guid); var cat = th.GetCategory(chargingStation.DeviceCategory); calcSite.AddChargingStation(gridLt, cat, chargingStation.MaxChargingPower, carLt, _calcRepo); } } return(sites); }
//BitArray ICalcAffordanceBase.IsBusyArray { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public void Activate(TimeStep startTime, string activatorName, CalcLocation personSourceLocation, out ICalcProfile personTimeProfile) { if (_myLastTimeEntry.TimeOfLastEvalulation != startTime) { throw new LPGException("trying to activate without first checking if the affordance is busy is a bug. Please report."); } CalcTravelRoute route = _myLastTimeEntry.PreviouslySelectedRoutes[personSourceLocation]; int routeduration = route.Activate(startTime, activatorName, out var usedDevices); if (routeduration == 0) { _calcRepo.OnlineLoggingData.AddTransportationStatus( new TransportationStatus(startTime, _householdkey, "\tActivating " + Name + " at " + startTime + " with no transportation and moving from " + personSourceLocation + " to " + _sourceAffordance.ParentLocation.Name + " for affordance " + _sourceAffordance.Name)); } else { _calcRepo.OnlineLoggingData.AddTransportationStatus(new TransportationStatus( startTime, _householdkey, "\tActivating " + Name + " at " + startTime + " with a transportation duration of " + routeduration + " for moving from " + personSourceLocation + " to " + _sourceAffordance.ParentLocation.Name)); } TimeStep affordanceStartTime = startTime.AddSteps(routeduration); if (affordanceStartTime.InternalStep < _calcRepo.CalcParameters.InternalTimesteps) { _sourceAffordance.Activate(affordanceStartTime, activatorName, personSourceLocation, out var sourcePersonProfile); CalcProfile newPersonProfile = new CalcProfile( "Travel Profile for Route " + route.Name + " to affordance " + _sourceAffordance.Name, System.Guid.NewGuid().ToStrGuid(), CalcProfile.MakeListwithValue1AndCustomDuration(routeduration), ProfileType.Absolute, sourcePersonProfile.DataSource); newPersonProfile.AppendProfile(sourcePersonProfile); personTimeProfile = newPersonProfile; string usedDeviceNames = String.Join(", ", usedDevices.Select(x => x.Device.Name + "(" + x.DurationInSteps + ")")); _calcRepo.OnlineLoggingData.AddTransportationEvent(_householdkey, activatorName, startTime, personSourceLocation.CalcSite?.Name ?? "", Site.Name, route.Name, usedDeviceNames, routeduration, sourcePersonProfile.StepValues.Count, _sourceAffordance.Name, usedDevices); } else { //this is if the simulation ends during a transport CalcProfile newPersonProfile = new CalcProfile( "Travel Profile for Route " + route.Name + " to affordance " + _sourceAffordance.Name, System.Guid.NewGuid().ToStrGuid(), CalcProfile.MakeListwithValue1AndCustomDuration(routeduration), ProfileType.Absolute, _sourceAffordance.Name); personTimeProfile = newPersonProfile; string usedDeviceNames = String.Join(", ", usedDevices.Select(x => x.Device.Name + "(" + x.DurationInSteps + ")")); _calcRepo.OnlineLoggingData.AddTransportationEvent(_householdkey, activatorName, startTime, personSourceLocation.CalcSite?.Name ?? "", Site.Name, route.Name, usedDeviceNames, routeduration, newPersonProfile.StepValues.Count, _sourceAffordance.Name, usedDevices); } }
private void map_refresh() { try { listView1.Items.Clear(); if (all_anch_list.Count > 0) { foreach (KeyValuePair <String, Int32> item in all_anch_list.OrderByDescending(i => i.Value)) { String[] im = { item.Key, item.Value.ToString() }; ListViewItem a = listView1.Items.Add(new ListViewItem(im)); foreach (DataRow row in anchor_table.Rows) { if (row["addr"].ToString() == item.Key.ToString()) { row["rssi"] = item.Value; } } } } listView2.Items.Clear(); if (anchor_table.Rows.Count > 0) { for (int i = 0; i < anchor_table.Rows.Count; i++) { DataRow row = anchor_table.Rows[i]; String[] im = { row["addr"].ToString(), row["rssi"].ToString(), row["x"].ToString(), row["y"].ToString() }; ListViewItem s = listView2.Items.Add(new ListViewItem(im)); if (s.Index == SelectedAnchorIndex) { s.Focused = true; s.Selected = true; } } } Graphics grp = Graphics.FromImage(img2); Bitmap red = new Bitmap(redLoc.Image, new Size(18, 26)); Bitmap blue = new Bitmap(blueLoc.Image, new Size(18, 26)); Bitmap green = new Bitmap(greenLoc.Image, new Size(18, 26)); grp.DrawImage(img, 0, 0); Brush bg = new SolidBrush(Color.WhiteSmoke); Brush sbg = new SolidBrush(Color.Red); Brush br = new SolidBrush(Color.Black); Pen border = new Pen(br, 1); grp.DrawImage(red, SelectedLocation.image_x - 9, SelectedLocation.image_y - 26); foreach (DataRow row in anchor_table.Rows) { Double x = row.Field <Double>(2); Double y = row.Field <Double>(3); CalcLocation.fromReal(x, y); grp.DrawImage(blue, CalcLocation.image_x - 9, CalcLocation.image_y - 26); RectangleF rectf = new RectangleF(CalcLocation.image_x + 1, CalcLocation.image_y + 1, 90, 50); grp.DrawRectangle(border, CalcLocation.image_x - 1, CalcLocation.image_y - 1, 62, 42); grp.FillRectangle(bg, CalcLocation.image_x, CalcLocation.image_y, 60, 40); grp.DrawString(row.Field <String>(0) + "\n" + row.Field <Int32>(1).ToString(), new Font("Tahoma", 11), Brushes.Black, rectf); grp.Flush(); } foreach (DataRow row in fp_table.Rows) { Double x = row.Field <Double>(1); Double y = row.Field <Double>(2); Int32 id = row.Field <Int32>(0); CalcLocation.fromReal(x, y); grp.DrawImage(green, CalcLocation.image_x - 9, CalcLocation.image_y - 26); RectangleF rectf = new RectangleF(CalcLocation.image_x, CalcLocation.image_y, 90, 20); grp.DrawRectangle(border, CalcLocation.image_x - 1, CalcLocation.image_y - 1, 32, 22); if (SelectedFingerprintIndex > -1 && listView3.Items[SelectedFingerprintIndex].SubItems[0].Text == id.ToString()) { grp.FillRectangle(sbg, CalcLocation.image_x, CalcLocation.image_y, 30, 20); grp.DrawString(id.ToString(), new Font("Tahoma", 11), Brushes.White, rectf); } else { grp.FillRectangle(bg, CalcLocation.image_x, CalcLocation.image_y, 30, 20); grp.DrawString(id.ToString(), new Font("Tahoma", 11), Brushes.Black, rectf); } grp.Flush(); } map.Image = img2; }catch (DataException n) { } }
public void MatchAutonomousDevicesWithNormalDevicesTest() { // make different devices at different locations // only a single one should be matched. var startdate = new DateTime(2018, 1, 1); var enddate = startdate.AddMinutes(100); var calcParameters = CalcParametersFactory.MakeGoodDefaults().SetStartDate(startdate).SetEndDate(enddate); //_calcParameters.InitializeTimeSteps(startdate, enddate, new TimeSpan(0, 1, 0), 3, false); Config.IsInUnitTesting = true; var cloc1 = new CalcLocation("loc1", Guid.NewGuid().ToStrGuid()); var cloc2 = new CalcLocation("loc1", Guid.NewGuid().ToStrGuid()); var cdevload = new List <CalcDeviceLoad>(); var clt = new CalcLoadType("calcloadtype", "power", "sum", 1, true, Guid.NewGuid().ToStrGuid()); cdevload.Add(new CalcDeviceLoad("load", 100, clt, 0, 0)); var devCategoryGuid = Guid.NewGuid().ToStrGuid(); IMock <IOnlineDeviceActivationProcessor> iodap = new Mock <IOnlineDeviceActivationProcessor>(); using (var calcRepo = new CalcRepo(iodap.Object, calcParameters: calcParameters)) { var cdd1 = new CalcDeviceDto("cdevice1", devCategoryGuid, new HouseholdKey("HH1"), OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(), cloc1.Guid, cloc1.Name); var cdLoc1 = new CalcDevice(new List <CalcDeviceLoad>(), cloc1, cdd1, calcRepo); var cdd2 = new CalcDeviceDto("cdevice1", devCategoryGuid, new HouseholdKey("HH1"), OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(), cloc1.Guid, cloc1.Name); var cdLoc1B = new CalcDevice(new List <CalcDeviceLoad>(), cloc1, cdd2, calcRepo); var cdd3 = new CalcDeviceDto("cdevice1", devCategoryGuid, new HouseholdKey("HH1"), OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(), cloc2.Guid, cloc2.Name); var cdLoc2 = new CalcDevice(new List <CalcDeviceLoad>(), cloc2, cdd3, calcRepo); var cp = new CalcProfile("cp1", Guid.NewGuid().ToStrGuid(), TimeSpan.FromMilliseconds(1), ProfileType.Absolute, "blub"); //CalcVariableRepository crv = new CalcVariableRepository(); //VariableRequirement vr = new VariableRequirement(""); var requirements = new List <VariableRequirement>(); var cdd4 = new CalcDeviceDto("cdevice1", devCategoryGuid, new HouseholdKey("HH1"), OefcDeviceType.Device, "category", "", Guid.NewGuid().ToStrGuid(), cloc1.Guid, cloc1.Name); var cadLoc1 = new CalcAutoDev(cp, clt, cdevload, 0, 1, cloc1, requirements, cdd4, calcRepo); var autodevs = new List <CalcAutoDev> { cadLoc1 }; var normalDevices = new List <CalcDevice> { cdLoc1, cdLoc1B, cdLoc2 }; CalcHousehold.MatchAutonomousDevicesWithNormalDevices(autodevs, normalDevices); //var totalmatchcount = 0; foreach (var device in normalDevices) { Logger.Info(device.Name); foreach (var matchingAutoDev in device.MatchingAutoDevs) { // totalmatchcount++; Logger.Info("\t" + matchingAutoDev.Name); } } cdLoc1.MatchingAutoDevs.Count.Should().Be(1); } //(totalmatchcount).Should().Be(1); }
//public ICalcProfile CollectPersonProfile() => _sourceAffordance.CollectPersonProfile(); public List <CalcSubAffordance> CollectSubAffordances(TimeStep time, bool onlyInterrupting, CalcLocation srcLocation) => _sourceAffordance.CollectSubAffordances(time, onlyInterrupting, srcLocation);