private void SetEnergyStoragesOnHouse([NotNull][ItemNotNull] List <CalcEnergyStorageDto> energyStorages,
                                              [NotNull] HouseholdKey householdKey,
                                              [NotNull] CalcHouse calchouse, CalcVariableRepository calcVariableRepository
                                              ) //, List<CalcDeviceTaggingSet> deviceTaggingSets)
        {
            var cess           = new List <CalcEnergyStorage>();
            var esCategoryGuid = Guid.NewGuid().ToStrGuid();
            var esLocGuid      = Guid.NewGuid().ToStrGuid();

            foreach (var es in energyStorages)
            {
                //foreach (DeviceTaggingSet set in deviceTaggingSets) {
                //set.AddTag(es.Name,"House Device");
                //}
                var           lti       = _ltDict.GetCalcLoadTypeByLoadtype(es.InputLoadType).ConvertToDto();
                CalcDeviceDto deviceDto = new CalcDeviceDto(es.Name, esCategoryGuid, householdKey, OefcDeviceType.Storage,
                                                            "Energy Storage", "", es.Guid, esLocGuid, "Energy Storages");
                var ces = new CalcEnergyStorage(_calcRepo.Odap,
                                                lti,
                                                es.MaximumStorageRate,
                                                es.MaximumWithdrawRate,
                                                es.MinimumStorageRate,
                                                es.MinimumWithdrawRate,
                                                es.InitialFill,
                                                es.StorageCapacity,
                                                _calcRepo.Logfile.EnergyStorageLogfile,
                                                deviceDto
                                                );
                foreach (var signal in es.Signals)
                {
                    CalcVariable cv     = calcVariableRepository.GetVariableByGuid(signal.CalcVariableDto.Guid);
                    var          cessig = new CalcEnergyStorageSignal(signal.Name,
                                                                      signal.TriggerOffPercent,
                                                                      signal.TriggerOnPercent,
                                                                      signal.Value,
                                                                      cv,
                                                                      signal.Guid);
                    ces.AddSignal(cessig);
                }

                cess.Add(ces);
                if (ces.Signals.Count != es.Signals.Count)
                {
                    throw  new LPGException("Signal not initialized correctly");
                }
            }

            var calcEnergyStorages = cess; //,deviceTaggingSets);

            calchouse.SetStorages(calcEnergyStorages);
            //return calcEnergyStorages;
        }
        private void MakeAllTransformationDevices([NotNull] CalcHouseDto house,
                                                  [NotNull] CalcHouse calchouse,
                                                  [NotNull] HouseholdKey householdKey) //List<CalcDeviceTaggingSet> taggingSets,
        {
            var ctds            = new List <CalcTransformationDevice>();
            var devcategoryGuid = Guid.NewGuid().ToStrGuid();
            var trafolocGuid    = Guid.NewGuid().ToStrGuid();

            foreach (var trafo in house.TransformationDevices)
            {
                foreach (var set in _calcDeviceTaggingSets.AllCalcDeviceTaggingSets)
                {
                    set.AddTag(trafo.Name, "House Device");
                }
                CalcDeviceDto cdd = new CalcDeviceDto(trafo.Name, devcategoryGuid, householdKey,
                                                      OefcDeviceType.Transformation, "Transformation Devices", "", trafo.Guid, trafolocGuid, "Transformation Devices");
                var ctd = new CalcTransformationDevice(_calcRepo.Odap,
                                                       trafo.MinValue,
                                                       trafo.MaxValue,
                                                       trafo.MinPower,
                                                       trafo.MaxPower,
                                                       cdd, _ltDict.GetLoadtypeByGuid(trafo.InputLoadType.Guid));
                foreach (var outlt in trafo.OutputLoadTypes)
                {
                    ctd.AddOutputLoadType(_ltDict.GetLoadtypeByGuid(outlt.LoadType.Guid), outlt.ValueScalingFactor, outlt.FactorType);
                }

                if (ctd.OutputLoadTypes.Count > 0)
                {
                    if (trafo.Datapoints != null)
                    {
                        foreach (var datapoint in trafo.Datapoints)
                        {
                            ctd.AddDatapoint(datapoint.Ref, datapoint.Val);
                        }
                    }

                    foreach (var condition in trafo.Conditions)
                    {
                        var variable = _variableRepository.GetVariableByGuid(condition.CalcVariableDto.Guid);
                        ctd.AddCondition(condition.Name, variable, condition.MinValue, condition.MaxValue, condition.Guid);
                    }

                    ctds.Add(ctd);
                }
            }

            calchouse.SetTransformationDevices(ctds);
        }