Class: Honeybee::ElectricEquipmentAbridged

Inherits:
ModelObject
  • Object
show all
Defined in:
lib/honeybee/load/electric_equipment.rb,
lib/to_openstudio/load/electric_equipment.rb,
lib/from_openstudio/load/electric_equipment.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_load(load) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/from_openstudio/load/electric_equipment.rb', line 38

def self.from_load(load)
    # create an empty hash
    hash = {}
    hash[:type] = 'ElectricEquipmentAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(load.nameString)
    unless load.displayName.empty?
        hash[:display_name] = (load.displayName.get).force_encoding("UTF-8")
    end
    unless load.schedule.empty?
        schedule = load.schedule.get
        hash[:schedule] = schedule.nameString
    end
    load_def = load.electricEquipmentDefinition
    unless load_def.wattsperSpaceFloorArea.empty?
        hash[:watts_per_area] = load_def.wattsperSpaceFloorArea.get
    end
    hash[:radiant_fraction] = load_def.fractionRadiant
    hash[:latent_fraction] = load_def.fractionLatent
    hash[:lost_fraction] = load_def.fractionLost

    hash
end

Instance Method Details

#defaultsObject



37
38
39
# File 'lib/honeybee/load/electric_equipment.rb', line 37

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



39
40
41
42
43
# File 'lib/to_openstudio/load/electric_equipment.rb', line 39

def find_existing_openstudio_object(openstudio_model)
  model_electric_equipment = openstudio_model.getElectricEquipmentByName(@hash[:identifier])
  return model_electric_equipment.get unless model_electric_equipment.empty?
  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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/to_openstudio/load/electric_equipment.rb', line 45

def to_openstudio(openstudio_model)
  # create electrical equipment and set identifier
  os_electric_equip_def = OpenStudio::Model::ElectricEquipmentDefinition.new(openstudio_model)
  os_electric_equip = OpenStudio::Model::ElectricEquipment.new(os_electric_equip_def)
  os_electric_equip_def.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_electric_equip_def.setDisplayName(@hash[:display_name])
  end
  os_electric_equip.setName(@hash[:identifier])

  # assign watts per area
  os_electric_equip_def.setWattsperSpaceFloorArea(@hash[:watts_per_area])

  # assign schedule
  electric_equipment_schedule = openstudio_model.getScheduleByName(@hash[:schedule])
  unless electric_equipment_schedule.empty?
    electric_equipment_schedule_object = electric_equipment_schedule.get
    os_electric_equip.setSchedule(electric_equipment_schedule_object)
  end

  # ensure that it's always reported under electric equipment
  os_electric_equip.setEndUseSubcategory('Electric Equipment')

  # assign radiant fraction if it exists
  if @hash[:radiant_fraction]
    os_electric_equip_def.setFractionRadiant(@hash[:radiant_fraction])
  else
    os_electric_equip_def.setFractionRadiant(defaults[:radiant_fraction][:default])
  end

  # assign latent fraction if it exists
  if @hash[:latent_fraction]
    os_electric_equip_def.setFractionLatent(@hash[:latent_fraction])
  else
    os_electric_equip_def.setFractionLatent(defaults[:latent_fraction][:default])
  end

  # assign lost fraction if it exists
  if @hash[:lost_fraction]
    os_electric_equip_def.setFractionLost(@hash[:lost_fraction])
  else
    os_electric_equip_def.setFractionLost(defaults[:lost_fraction][:default])
  end

  os_electric_equip
end