Class: Honeybee::OpaqueConstructionAbridged

Inherits:
ModelObject
  • Object
show all
Defined in:
lib/honeybee/construction/opaque.rb,
lib/to_openstudio/construction/opaque.rb,
lib/from_openstudio/construction/opaque.rb

Instance Attribute Summary

Attributes inherited from ModelObject

#errors, #openstudio_object, #warnings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ModelObject

#allowable_types, clean_identifier, clean_name, #initialize, #method_missing, read_from_disk, truncate

Constructor Details

This class inherits a constructor from Honeybee::ModelObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Honeybee::ModelObject

Class Method Details

.from_construction(construction) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/from_openstudio/construction/opaque.rb', line 38

def self.from_construction(construction)
    # create an empty hash
    hash = {}
    hash[:type] = 'OpaqueConstructionAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(construction.nameString)
    unless construction.displayName.empty?
      hash[:display_name] = (construction.displayName.get).force_encoding("UTF-8")
    end
    hash[:materials] = []
    # get construction layers
    layers = construction.layers
    layers.each do |layer|
      name = clean_name(layer.nameString)
      hash[:materials] << name
    end

    hash
end

Instance Method Details

#defaultsObject



37
38
39
# File 'lib/honeybee/construction/opaque.rb', line 37

def defaults
  @@schema[:components][:schemas][:OpaqueConstructionAbridged][:properties]
end

#find_existing_openstudio_object(openstudio_model) ⇒ Object



39
40
41
42
43
# File 'lib/to_openstudio/construction/opaque.rb', line 39

def find_existing_openstudio_object(openstudio_model)
  object = openstudio_model.getConstructionByName(@hash[:identifier])
  return object.get if object.is_initialized
  nil
end

#to_openstudio(openstudio_model) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/to_openstudio/construction/opaque.rb', line 45

def to_openstudio(openstudio_model)
  # create construction and set identifier
  os_construction = OpenStudio::Model::Construction.new(openstudio_model)
  os_construction.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_construction.setDisplayName(@hash[:display_name])
  end

  # create material vector
  os_materials = OpenStudio::Model::MaterialVector.new
  # loop through each layer and add to material vector
  if @hash.key?(:layers)
    mat_key = :layers
  else
    mat_key = :materials
  end
  @hash[mat_key].each do |material_identifier|
    material = openstudio_model.getMaterialByName(material_identifier)
    unless material.empty?
      os_material = material.get
      os_materials << os_material
    end
  end
  os_construction.setLayers(os_materials)

  os_construction
end