Measures/m_5_example_5_computed_schedule/resources/util.rb
# Facilitates creating and assigning an OpenStudio construction (with accompanying 
# OpenStudio Materials) from Material objects. Handles parallel paths as well.
Facilitates creating and assigning an OpenStudio construction (with accompanying
OpenStudio Materials) from Material objects. Handles parallel paths as well.
Facilitates creating and assigning an OpenStudio construction ( with accompanying OpenStudio Materials ) from Material objects . Handles parallel paths as well .
def validated?(runner)
            if @sum_path_fracs <= 0.99 or @sum_path_fracs >= 1.01
                runner.registerError("Invalid construction: Sum of path fractions (#{@sum_path_fracs.to_s}) is not 1.")
                return false
            end
            @path_fracs.each do |path_frac|
                if path_frac < 0
                    runner.registerError("Invalid construction: Path fraction (#{path_frac.to_s}) must be greater than or equal to 0.")
                    return false
                end
            end
            all_glazing = true
            @layers_materials.each do |layer_materials|
                layer_materials.each do |mat|
                    if not mat.is_a? GlazingMaterial
                        all_glazing = false
                    end
                end
            end
            if all_glazing
                @layers_materials.each do |layer_materials|
                    if layer_materials.size > 1
                        runner.registerError("Invalid construction: Cannot have multiple GlazingMaterials in a single layer.")
                        return false
                    end
                end
                return true
            end
            @layers_materials.each do |layer_materials|
                layer_materials.each do |mat|
                    if not mat.is_a? SimpleMaterial and not mat.is_a? Material
                        runner.registerError("Invalid construction: Materials must be instances of SimpleMaterial or Material classes.")
                        return false
                    end
                end
            end
            @layers_materials.each do |layer_materials|
                if layer_materials.size > 1 and layer_materials.size < @path_fracs.size
                    runner.registerError("Invalid construction: Layer must either have one material or same number of materials as paths.")
                    return false
                end
            end
            @layers_materials.each do |layer_materials|
                if layer_materials.size > 1
                    thick_in = nil
                    layer_materials.each do |mat|
                        if thick_in.nil?
                            thick_in = mat.thick_in
                        elsif thick_in != mat.thick_in
                            runner.registerError("Invalid construction: Materials in a layer have different thicknesses.")
                            return false
                        end
                    end
                end
            end
            found_parallel = false
            last_parallel = false
            @layers_materials.each do |layer_materials|
                if layer_materials.size > 1
                    if not found_parallel
                        found_parallel = true
                    elsif not last_parallel
                        runner.registerError("Invalid construction: Non-contiguous parallel layers found.")
                        return false
                    end
                end
                last_parallel = (layer_materials.size > 1)
            end
            @layers_materials.each_with_index do |layer_materials,layer_num|
                next if not @layers_includes[layer_num]
                if layer_materials.size > 1
                    if @layers_names[layer_num].nil?
                        runner.registerError("Invalid construction: No layer name provided for parallel layer.")
                        return false
                    end
                else
                    if @layers_names[layer_num].nil? and layer_materials[0].name.nil?
                        runner.registerError("Invalid construction: Neither layer name nor material name provided for non-parallel layer.")
                        return false
                    end
                end
            end
            return true
        end
def validated? ( runner ) if @sum_path_fracs <= 0.99 or @sum_path_fracs >= 1.01 runner . registerError ( "Invalid construction: Sum of path fractions (#{@sum_path_fracs.to_s}) is not 1." ) return false end @path_fracs . each do | path_frac | if path_frac < 0 runner . registerError ( "Invalid construction: Path fraction (#{path_frac.to_s}) must be greater than or equal to 0." ) return false end end all_glazing = true @layers_materials . each do | layer_materials | layer_materials . each do | mat | if not mat . is_a? GlazingMaterial all_glazing = false end end end if all_glazing @layers_materials . each do | layer_materials | if layer_materials . size > 1 runner . registerError ( "Invalid construction: Cannot have multiple GlazingMaterials in a single layer." ) return false end end return true end @layers_materials . each do | layer_materials | layer_materials . each do | mat | if not mat . is_a? SimpleMaterial and not mat . is_a? Material runner . registerError ( "Invalid construction: Materials must be instances of SimpleMaterial or Material classes." ) return false end end end @layers_materials . each do | layer_materials | if layer_materials . size > 1 and layer_materials . size < @path_fracs . size runner . registerError ( "Invalid construction: Layer must either have one material or same number of materials as paths." ) return false end end @layers_materials . each do | layer_materials | if layer_materials . size > 1 thick_in = nil layer_materials . each do | mat | if thick_in . nil? thick_in = mat . thick_in elsif thick_in != mat . thick_in runner . registerError ( "Invalid construction: Materials in a layer have different thicknesses." ) return false end end end end found_parallel = false last_parallel = false @layers_materials . each do | layer_materials | if layer_materials . size > 1 if not found_parallel found_parallel = true elsif not last_parallel runner . registerError ( "Invalid construction: Non-contiguous parallel layers found." ) return false end end last_parallel = ( layer_materials . size > 1 ) end @layers_materials . each_with_index do | layer_materials , layer_num | next if not @layers_includes [ layer_num ] if layer_materials . size > 1 if @layers_names [ layer_num ] . nil? runner . registerError ( "Invalid construction: No layer name provided for parallel layer." ) return false end else if @layers_names [ layer_num ] . nil? and layer_materials [ 0 ] . name . nil? runner . registerError ( "Invalid construction: Neither layer name nor material name provided for non-parallel layer." ) return false end end end return true end
Facilitates creating and assigning an OpenStudio construction (with accompanying
OpenStudio Materials) from Material objects.
Facilitates creating and assigning an OpenStudio construction ( with accompanying OpenStudio Materials ) from Material objects .
# Check that sum of path fracs equal 1 # Check that all path fractions are not negative # Check if all materials are GlazingMaterial # Check that no parallel materials # Check for valid object types # Check if invalid number of materials in a layer # Check if multiple materials in a given layer have differing thicknesses # Check if multiple non-contiguous parallel layers # Check if name not provided for a parallel layer # Check if name not provided for non-parallel layer # If we got this far, we're good
runner
<not_specific>