//private readonly OefcKey _zek;

        public OnlineDeviceStateMachine([NotNull] TimeStep startTimeStep,
                                        [NotNull] CalcLoadTypeDto loadType,
                                        [NotNull] string deviceName, OefcKey deviceKey, [NotNull] string affordanceName, [NotNull] CalcParameters calcParameters,
                                        [NotNull] StepValues stepValues, int columnNumber)
        {
            //_zek = new ZeroEntryKey(deviceKey.HouseholdKey, deviceKey.ThisDeviceType,deviceKey.DeviceGuid,deviceKey.LocationGuid);
            _deviceName     = deviceName;
            _calcParameters = calcParameters;
            OefcKey         = deviceKey;
            LoadType        = loadType;
            if (loadType == null)
            {
                throw new LPGException("loadtype for an osm was null");
            }
            _startTimeStep = startTimeStep;
            // time profile einladen, zeitlich variieren, normalverteilt variieren und dann als stepvalues speichern
            ////    throw new LPGException("power usage factor was 0. this is a bug. Device " + deviceName + ", Loadtype " + loadType);
            //}
            StepValues     = stepValues;
            ColumnNumber   = columnNumber;
            AffordanceName = affordanceName;
            HouseholdKey   = deviceKey.HouseholdKey;
        }
示例#2
0
        public void AddNewStateMachine(TimeStep startTimeStep,
                                       CalcLoadTypeDto loadType, string affordanceName, string activatorName,
                                       OefcKey oefckey, [NotNull] CalcDeviceDto calcDeviceDto, [NotNull] StepValues sv)
        {
            Oefc.IsDeviceRegistered(loadType, oefckey);
            //OefcKey oefckey = new OefcKey(householdKey, deviceType, deviceID, locationID, loadType.ID);
            // this is for logging the used time profiles which gets dumped to the time profile log
            ProfileActivationEntry.ProfileActivationEntryKey key =
                new ProfileActivationEntry.ProfileActivationEntryKey(calcDeviceDto.Name, sv.Name, sv.DataSource,
                                                                     loadType.Name);
            if (!_profileEntries.ContainsKey(key))
            {
                ProfileActivationEntry entry = new ProfileActivationEntry(calcDeviceDto.Name, sv.Name, sv.DataSource,
                                                                          loadType.Name, _calcParameters);
                _profileEntries.Add(entry.GenerateKey(), entry);
            }
            _profileEntries[key].ActivationCount++;
            // do the device activiation
            var columnNumber = Oefc.GetColumnNumber(loadType, oefckey);
            var dsm          = new OnlineDeviceStateMachine(startTimeStep,
                                                            loadType, calcDeviceDto.Name, oefckey, affordanceName, _calcParameters, sv, columnNumber);

            //_statemachines.Add(dsm);
            _stateMachinesByLoadtype[loadType].Add(dsm);
            // log the affordance energy use.
            if (_calcParameters.IsSet(CalcOption.DeviceActivations))
            {
                double totalPowerSum  = dsm.CalculateOfficialEnergyUse();
                double totalEnergysum = loadType.ConversionFactor * totalPowerSum;
                var    entry          = new DeviceActivationEntry(dsm.AffordanceName,
                                                                  dsm.LoadType, totalEnergysum, activatorName, sv.Values.Count,
                                                                  startTimeStep, calcDeviceDto); // dsm.StepValues.ToArray(),
                _old.RegisterDeviceActivation(entry);
            }
        }