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); }
// "2004::ClimateZone1::SteelFramed" public static (ConstructionSetAbridged constructionSet, IEnumerable <IConstruction> constructions, IEnumerable <IMaterial> materials) GetStandardConstructionSetByIdentifier(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 opaqueNames = new List <string>() { cSet.WallSet?.ExteriorConstruction, cSet.WallSet?.GroundConstruction, cSet.WallSet?.InteriorConstruction, cSet.FloorSet?.ExteriorConstruction, cSet.FloorSet?.GroundConstruction, cSet.FloorSet?.InteriorConstruction, cSet.RoofCeilingSet?.ExteriorConstruction, cSet.RoofCeilingSet?.GroundConstruction, cSet.RoofCeilingSet?.InteriorConstruction, cSet.DoorSet?.ExteriorConstruction, cSet.DoorSet?.InteriorConstruction, cSet.DoorSet?.OverheadConstruction, }; opaqueNames.RemoveAll(string.IsNullOrWhiteSpace); var windowNames = new List <string>() { cSet.ApertureSet?.OperableConstruction, cSet.ApertureSet?.WindowConstruction, cSet.ApertureSet?.SkylightConstruction, cSet.ApertureSet?.InteriorConstruction, cSet.DoorSet?.ExteriorGlassConstruction, cSet.DoorSet?.InteriorGlassConstruction, }; windowNames.RemoveAll(string.IsNullOrWhiteSpace); var shadeNames = new List <string>() { cSet.ShadeConstruction }; shadeNames.RemoveAll(string.IsNullOrWhiteSpace); var airBoundaryNames = new List <string>() { cSet.AirBoundaryConstruction }; airBoundaryNames.RemoveAll(string.IsNullOrWhiteSpace); var opaqueConstructions = opaqueNames.Select(_ => StandardsOpaqueConstructions[_]); var windConstructions = windowNames.Select(_ => StandardsWindowConstructions[_]); //TODO: Shade, AirBoundary // get materials var opaMaterials = opaqueConstructions.SelectMany(_ => _.Layers).Select(_ => StandardsOpaqueMaterials[_]); var winMaterials = windConstructions.SelectMany(_ => _.Layers).Select(_ => StandardsWindowMaterials[_]); var constrs = opaqueConstructions.OfType <IConstruction>().Concat(windConstructions); var mats = opaMaterials.Concat(winMaterials); return(cSet, constrs, mats); }