public CalcPersonDesires(CalcRepo calcRepo)
 {
     _calcRepo = calcRepo;
     Desires   = new Dictionary <int, CalcDesire>();
     _persons.Clear();
     _dsc = new DateStampCreator(_calcRepo.CalcParameters);
 }
 //TODO: figure out if this is still needed
 public VacationAffordance(StrGuid guid,
                           [ItemNotNull][NotNull] BitArray isBusy, [NotNull] CalcRepo calcRepo)
     : base(
         Constants.TakingAVacationString, new CalcLocation("Vacation", System.Guid.NewGuid().ToStrGuid()),
         new List <CalcDesire>(), 0, 99, PermittedGender.All, false,
         false, "Vacation", false, false, ActionAfterInterruption.GoBackToOld, 0, false,
         CalcAffordanceType.Vacation, guid, isBusy, BodilyActivityLevel.Outside, calcRepo)
 {
 }
Пример #3
0
        public static CalcRepo Make([NotNull] CalcParameters calcParameters, [NotNull] IInputDataLogger idl,
                                    [NotNull] string resultPath, [NotNull] string calcObjectName,
                                    CalculationProfiler calculationProfiler)
        {
            DateStampCreator      dsc = new DateStampCreator(calcParameters);
            OnlineLoggingData     old = new OnlineLoggingData(dsc, idl, calcParameters);
            FileFactoryAndTracker fft = new FileFactoryAndTracker(resultPath, calcObjectName, idl);
            LogFile lf = new LogFile(calcParameters, fft);
            OnlineDeviceActivationProcessor odap = new OnlineDeviceActivationProcessor(old, calcParameters, fft);
            Random                  rnd          = new Random(calcParameters.ActualRandomSeed);
            NormalRandom            nr           = new NormalRandom(0, 0.1, rnd);
            SqlResultLoggingService srls         = new SqlResultLoggingService(resultPath);
            CalcRepo                cr           = new CalcRepo(odap, rnd, calcParameters, old, nr, lf, srls,
                                                                idl, calculationProfiler, fft, dsc);

            return(cr);
        }
Пример #4
0
        //[CanBeNull] private VariableLogfile _variableLogfile;

        public CalcHousehold([NotNull] string pName, [NotNull] string locationname,
                             [NotNull] string temperatureprofileName, [NotNull] HouseholdKey householdkey,
                             StrGuid guid,
                             [NotNull] CalcVariableRepository calcVariableRepository,
                             [ItemNotNull][NotNull] List <CalcLocation> locations,
                             [ItemNotNull][NotNull] List <CalcPerson> persons,
                             [NotNull] string description, CalcRepo calcRepo) : base(pName, guid)
        {
            _locations   = locations;
            _persons     = persons;
            _description = description;
            _calcRepo    = calcRepo;
            //_cleanName = AutomationUtili.CleanFileName(pName);
            _name                   = pName;
            _locationname           = locationname;
            _temperatureprofileName = temperatureprofileName;
            _householdKey           = householdkey;
            _calcVariableRepository = calcVariableRepository;
        }
Пример #5
0
        protected CalcAffordanceBase([NotNull] string pName, [NotNull] CalcLocation loc,
                                     [NotNull][ItemNotNull] List <CalcDesire> satisfactionvalues,
                                     int miniumAge, int maximumAge, PermittedGender permittedGender, bool needsLight,
                                     bool randomEffect,
                                     [NotNull] string pAffCategory, bool isInterruptable, bool isInterrupting,
                                     ActionAfterInterruption actionAfterInterruption, int weight,
                                     bool requireAllAffordances,
                                     CalcAffordanceType calcAffordanceType,
                                     StrGuid guid,
                                     [ItemNotNull][NotNull] BitArray isBusyArray,
                                     BodilyActivityLevel bodilyActivityLevel, [NotNull] CalcRepo calcRepo,
                                     [CanBeNull] CalcSite site = null) : base(pName, guid)
        {
            CalcAffordanceType  = calcAffordanceType;
            BodilyActivityLevel = bodilyActivityLevel;
            CalcRepo            = calcRepo;
            Site               = site;
            ParentLocation     = loc;
            Satisfactionvalues = satisfactionvalues;
            _isBusyArray       = new BitArray(calcRepo.CalcParameters.InternalTimesteps);
            //copy to make sure that it is a separate instance
            for (var i = 0; i < isBusyArray.Length; i++)
            {
                _isBusyArray[i] = isBusyArray[i];
            }
            Weight = weight;
            RequireAllAffordances    = requireAllAffordances;
            MiniumAge                = miniumAge;
            MaximumAge               = maximumAge;
            PermittedGender          = permittedGender;
            NeedsLight               = needsLight;
            RandomEffect             = randomEffect;
            AffCategory              = pAffCategory;
            IsInterruptable          = isInterruptable;
            IsInterrupting           = isInterrupting;
            _actionAfterInterruption = actionAfterInterruption;
            CalcAffordanceSerial     = _calcAffordanceBaseSerialTracker;
#pragma warning disable S3010 // Static fields should not be updated in constructors
            _calcAffordanceBaseSerialTracker++;
#pragma warning restore S3010 // Static fields should not be updated in constructors
        }
        public CalcDevice([NotNull][ItemNotNull] List <CalcDeviceLoad> powerUsage,
                          [NotNull] CalcLocation calcLocation,
                          [NotNull] CalcDeviceDto calcDeviceDto,
                          [NotNull] CalcRepo calcRepo) : base(calcDeviceDto.Name, calcDeviceDto.Guid)
        {
            _calcDeviceDto = calcDeviceDto;
            _calcRepo      = calcRepo;
            if (_calcDeviceDto.LocationGuid != calcLocation.Guid)
            {
                throw new LPGException("Inconsistent locations. This is a bug.");
            }
            _calcLocation = calcLocation;
            foreach (var load in powerUsage)
            {
                _deviceLoadsBy.Add(load.LoadType, load);
                Loads.Add(load);
            }

            /*foreach (var load in powerUsage) {
             *  if (Math.Abs(load.Value) < 0.0000001 && load.Name.ToLower(CultureInfo.InvariantCulture) != "none") {
             *      throw new LPGException("Trying to run the device " + calcDeviceDto.Name + " with a power load factor for " + load.LoadType.Name + " of 0. This is not going to work.");
             *  }
             * }*/
            if (calcRepo.CalcParameters.InternalTimesteps == 0)
            {
                throw new LPGException("Can't run with 0 timesteps");
            }
            _isBusyForLoadType = new Dictionary <CalcLoadType, BitArray>();
            foreach (var calcDeviceLoad in powerUsage)
            {
                _isBusyForLoadType.Add(calcDeviceLoad.LoadType,
                                       new BitArray(calcRepo.CalcParameters.InternalTimesteps));
                _isBusyForLoadType[calcDeviceLoad.LoadType].SetAll(false);
                //var key = new OefcKey(calcDeviceDto.HouseholdKey, calcDeviceDto.DeviceType,calcDeviceDto.Guid, calcDeviceDto.LocationGuid,calcDeviceLoad.LoadType.Guid, calcDeviceDto.DeviceCategoryName);
                var key = calcRepo.Odap.RegisterDevice(calcDeviceLoad.LoadType.ConvertToDto(), calcDeviceDto);
                _keyByLoad.Add(calcDeviceLoad.LoadType, key);
            }
        }
 public CalcAutoDev([NotNull] CalcProfile pCalcProfile, [NotNull] CalcLoadType loadType,
                    [NotNull][ItemNotNull] List <CalcDeviceLoad> loads, double timeStandardDeviation,
                    double multiplier,
                    [NotNull] CalcLocation calclocation,
                    [NotNull][ItemNotNull] List <VariableRequirement> requirements, [NotNull] CalcDeviceDto autoDevDto, [NotNull] CalcRepo calcRepo)
     : base(
         loads, calclocation, autoDevDto, calcRepo)
 {
     _earliestNextStart     = new TimeStep(-1, 0, true);
     _calcProfile           = pCalcProfile;
     LoadType               = loadType;
     _timeStandardDeviation = timeStandardDeviation;
     _multiplier            = multiplier;
     _calcLocation          = calclocation;
     if (requirements.Count > 0) // initialize the whole variable thing
     {
         _requirements.AddRange(requirements);
     }
 }
 public CalcSubAffordance([NotNull] string pName, [NotNull] CalcLocation loc, [NotNull][ItemNotNull] List <CalcDesire> satisfactionvalues,
                          int miniumAge, int maximumAge, int delaytimesteps, PermittedGender permittedGender, [NotNull] string pAffCategory,
                          bool isInterruptable, bool isInterrupting, [NotNull] CalcAffordance parentAffordance,
                          [NotNull][ItemNotNull] List <CalcAffordanceVariableOp> variableOps, int weight,
                          [NotNull] string sourceTrait,
                          StrGuid guid, [ItemNotNull][NotNull] BitArray isBusy,
                          [NotNull] CalcVariableRepository repository, BodilyActivityLevel bodilyActivityLevel, [NotNull] CalcRepo calcRepo)
     : base(
         pName, loc, satisfactionvalues, miniumAge, maximumAge, permittedGender, false, false, pAffCategory,
         isInterruptable, isInterrupting, ActionAfterInterruption.GoBackToOld, weight, false,
         CalcAffordanceType.Subaffordance, guid, isBusy, bodilyActivityLevel, calcRepo)
 {
     Delaytimesteps   = delaytimesteps;
     _variableOps     = variableOps;
     _repository      = repository;
     SubAffordances   = new List <CalcSubAffordance>();
     Energyprofiles   = new List <CalcAffordance.DeviceEnergyProfileTuple>();
     AffordanceColor  = LPGColors.Black;
     SourceTrait      = sourceTrait;
     TimeLimitName    = null;
     ParentAffordance = parentAffordance;
 }
Пример #9
0
        public CalcAffordance([NotNull] string pName,
                              [NotNull] CalcProfile personProfile,
                              [NotNull] CalcLocation loc,
                              bool randomEffect,
                              [NotNull][ItemNotNull] List <CalcDesire> satisfactionvalues,
                              int miniumAge,
                              int maximumAge,
                              PermittedGender permittedGender,
                              bool needsLight,
                              double timeStandardDeviation,
                              ColorRGB affordanceColor,
                              [NotNull] string pAffCategory,
                              bool isInterruptable,
                              bool isInterrupting,
                              [NotNull][ItemNotNull] List <CalcAffordanceVariableOp> variableOps,
                              [NotNull][ItemNotNull] List <VariableRequirement> variableRequirements,
                              ActionAfterInterruption actionAfterInterruption,
                              [NotNull] string timeLimitName,
                              int weight,
                              bool requireAllDesires,
                              [NotNull] string srcTrait,
                              StrGuid guid,
                              [NotNull] CalcVariableRepository variableRepository,
                              [NotNull][ItemNotNull] List <DeviceEnergyProfileTuple> energyprofiles,
                              [ItemNotNull][NotNull] BitArray isBusy, BodilyActivityLevel bodilyActivityLevel,
                              [NotNull] CalcRepo calcRepo) : base(pName,
                                                                  loc,
                                                                  satisfactionvalues,
                                                                  miniumAge,
                                                                  maximumAge,
                                                                  permittedGender,
                                                                  needsLight,
                                                                  randomEffect,
                                                                  pAffCategory,
                                                                  isInterruptable,
                                                                  isInterrupting,
                                                                  actionAfterInterruption,
                                                                  weight,
                                                                  requireAllDesires,
                                                                  CalcAffordanceType.Affordance,
                                                                  guid,
                                                                  isBusy, bodilyActivityLevel, calcRepo)
        {
            _variableOps          = variableOps;
            _variableRequirements = variableRequirements;
            _variableRepository   = variableRepository;
            Energyprofiles        = energyprofiles;
            SourceTrait           = srcTrait;
            if (personProfile == null)
            {
#pragma warning disable IDE0016 // Use 'throw' expression
                throw new DataIntegrityException("The affordance " + Name + " has no person profile!");
#pragma warning restore IDE0016 // Use 'throw' expression
            }

            _timeStandardDeviation = timeStandardDeviation;
            SubAffordances         = new List <CalcSubAffordance>();
            _personProfile         = personProfile;
            AffordanceColor        = affordanceColor;
            TimeLimitName          = timeLimitName;
        }