Ejemplo n.º 1
0
        public static ModelEnergyProperties GetResourcesByStandardConstructionSetIdentifier(string standardConstructionSet)
        {
            var year = standardConstructionSet.Split(':').First();

            if (string.IsNullOrEmpty(year))
            {
                throw new ArgumentException($"Invalid {standardConstructionSet}");
            }

            var found = StandardsConstructionSets.TryGetValue(standardConstructionSet, out ConstructionSetAbridged cSet);

            if (!found)
            {
                throw new ArgumentException($"Cannot find {standardConstructionSet}");
            }

            // get constructions
            var cNames = cSet.GetAllConstructions();

            var constructions = cNames.Select(_ =>
            {
                IConstruction con = null;
                if (StandardsOpaqueConstructions.TryGetValue(_, out var opaque))
                {
                    con = opaque;
                }
                else if (StandardsWindowConstructions.TryGetValue(_, out var window))
                {
                    con = window;
                }
                //TODO: Shade, AirBoundary, WindowDynamic
                return(con);
            });

            var materials = constructions
                            .SelectMany(_ => _.GetAbridgedConstructionMaterials())
                            .Select(_ =>
            {
                IMaterial mat = null;
                if (StandardsOpaqueMaterials.TryGetValue(_, out var opaque))
                {
                    mat = opaque;
                }
                else if (StandardsWindowMaterials.TryGetValue(_, out var window))
                {
                    mat = window;
                }
                return(mat);
            });

            var res = new ModelEnergyProperties();

            res.AddConstructionSet(cSet);
            res.AddConstructions(constructions);
            res.AddMaterials(materials);

            return(res);
        }
        internal HB.ModelEnergyProperties CheckResources(HB.ModelEnergyProperties systemLibSource)
        {
            var eng = new ModelEnergyProperties();

            eng.AddConstructionSet(this.ConstructionSet);

            var cSet = this.ConstructionSet;
            // get constructions
            var cNames = cSet.GetAllConstructions();
            var cons   = cNames.Select(_ => systemLibSource.ConstructionList.FirstOrDefault(c => c.Identifier == _)).Where(_ => _ != null);

            eng.AddConstructions(cons);

            // get all materials
            var mats = cons
                       .SelectMany(_ => _.GetAbridgedConstructionMaterials())
                       .Select(_ => systemLibSource.MaterialList.FirstOrDefault(m => m.Identifier == _)).Where(_ => _ != null);

            eng.AddMaterials(mats);

            return(eng);
        }