public static bool UpdateInternalCondition_HDD(this TBD.InternalCondition internalCondition_TBD, InternalCondition internalCondition, ProfileLibrary profileLibrary)
        {
            if (internalCondition_TBD == null || internalCondition == null)
            {
                return(false);
            }

            internalCondition_TBD.description = internalCondition.Name + " - HDD";

            internalCondition_TBD.includeSolarInMRT = 0;

            TBD.Emitter emitter = null;
            double      value   = double.NaN;

            emitter = internalCondition_TBD.GetHeatingEmitter();
            if (emitter != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            emitter = internalCondition_TBD.GetCoolingEmitter();
            if (emitter != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain();
            internalGain.name = internalCondition.Name + " - HDD";

            Profile profile = null;

            profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary);
            if (profile != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value))
                {
                    TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI);
                    if (profile_TBD != null)
                    {
                        profile_TBD.name   = profile.Name;
                        profile_TBD.type   = TBD.ProfileTypes.ticValueProfile;
                        profile_TBD.factor = 1;
                        profile_TBD.value  = System.Convert.ToSingle(value);
                    }
                }
            }

            TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat();
            if (thermostat != null)
            {
                thermostat.controlRange        = 0;
                thermostat.proportionalControl = 0;

                profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary);
                if (profile != null)
                {
                    thermostat.name = profile.Name;

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL);
                    if (profile_TBD != null)
                    {
                        value = profile.MaxValue;
                        if (!double.IsNaN(value))
                        {
                            profile_TBD.name   = profile.Name;
                            profile_TBD.type   = TBD.ProfileTypes.ticValueProfile;
                            profile_TBD.factor = 1;
                            profile_TBD.value  = System.Convert.ToSingle(value);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        public static bool UpdateInternalCondition(this TBD.InternalCondition internalCondition_TBD, Space space, ProfileLibrary profileLibrary)
        {
            if (space == null || internalCondition_TBD == null)
            {
                return(false);
            }

            InternalCondition internalCondition = space.InternalCondition;

            if (internalCondition == null)
            {
                return(false);
            }

            internalCondition_TBD.name        = space.Name;
            internalCondition_TBD.description = internalCondition.Name;

            internalCondition_TBD.includeSolarInMRT = 1;

            TBD.Emitter emitter = null;
            double      value   = double.NaN;

            emitter = internalCondition_TBD.GetHeatingEmitter();
            if (emitter != null)
            {
                emitter.name = internalCondition.GetSystemTypeName <HeatingSystemType>();

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            emitter = internalCondition_TBD.GetCoolingEmitter();
            if (emitter != null)
            {
                emitter.name = internalCondition.GetSystemTypeName <CoolingSystemType>();

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain();

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingRadiantProportion, out value))
            {
                internalGain.lightingRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyRadiantProportion, out value))
            {
                internalGain.occupantRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentRadiantProportion, out value))
            {
                internalGain.equipmentRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingViewCoefficient, out value))
            {
                internalGain.lightingViewCoefficient = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyViewCoefficient, out value))
            {
                internalGain.occupantViewCoefficient = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentViewCoefficient, out value))
            {
                internalGain.equipmentViewCoefficient = System.Convert.ToSingle(value);
            }

            internalGain.domesticHotWater = (float)0.197;

            internalGain.name        = internalCondition.Name;
            internalGain.description = internalCondition.GetSystemTypeName <VentilationSystemType>();

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingLevel, out value))
            {
                internalGain.targetIlluminance = System.Convert.ToSingle(value);
            }

            internalGain.personGain = 0;
            double occupancyGainPerPerson = Analytical.Query.OccupancyGainPerPerson(space);

            if (!double.IsNaN(occupancyGainPerPerson))
            {
                internalGain.personGain = System.Convert.ToSingle(occupancyGainPerPerson);
            }

            Profile profile = null;

            profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary);
            if (profile != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value))
                {
                    TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, value);
                    }
                }
            }

            double area = double.NaN;

            if (!space.TryGetValue(SpaceParameter.Area, out area))
            {
                area = double.NaN;
            }

            profile = internalCondition.GetProfile(ProfileType.Lighting, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticLG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedLightingGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.Occupancy, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = null;

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOLG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.OccupancyLatentGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOSG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.OccupancySensibleGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.EquipmentSensible, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticESG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedEquipmentSensibleGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.EquipmentLatent, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticELG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedEquipmentLatentGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.Pollutant, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticCOG);
                if (profile_TBD != null)
                {
                    double generation = Analytical.Query.CalculatedPollutantGeneration(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(generation))
                    {
                        generation = 0;
                    }
                    else
                    {
                        generation = generation / area;
                    }

                    Update(profile_TBD, profile, generation);
                }
            }

            TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat();
            if (thermostat != null)
            {
                List <string> names = new List <string>();

                thermostat.controlRange        = 0;
                thermostat.proportionalControl = 0;

                profile = internalCondition.GetProfile(ProfileType.Cooling, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticUL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Humidification, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHLL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Dehumidification, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHUL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                names.RemoveAll(x => string.IsNullOrWhiteSpace(x));

                if (names.Count != 0)
                {
                    thermostat.name = string.Join(" & ", names);
                }
            }

            return(true);
        }