Class: Honeybee::ProcessAbridged

Inherits:
ModelObject show all
Defined in:
lib/honeybee/load/process.rb,
lib/to_openstudio/load/process.rb,
lib/from_openstudio/load/process.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
61
62
# File 'lib/from_openstudio/load/process.rb', line 38

def self.from_load(load)
    # create an empty hash
    hash = {}
    hash[:type] = 'ProcessAbridged'
    # set hash values from OpenStudio Object
    hash[:identifier] = clean_name(load.nameString)
    load_def = load.otherEquipmentDefinition
    unless load_def.displayName.empty?
        hash[:display_name] = (load_def.displayName.get).force_encoding("UTF-8")
    end
    unless load_def.designLevel.empty?
        hash[:watts] = load_def.designLevel.get
    end
    unless load.schedule.empty?
        schedule = load.schedule.get
        hash[:schedule] = schedule.nameString
    end
    hash[:end_use_category] = load.endUseSubcategory
    hash[:fuel_type] = load.fuelType
    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/process.rb', line 37

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

#find_existing_openstudio_object(openstudio_model) ⇒ Object



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

def find_existing_openstudio_object(openstudio_model)
  model_other_equipment = openstudio_model.getOtherEquipmentByName(@hash[:identifier])
  return model_other_equipment.get unless model_other_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
91
92
93
94
95
96
97
# File 'lib/to_openstudio/load/process.rb', line 45

def to_openstudio(openstudio_model)
  # create process load and set identifier
  os_other_equip_def = OpenStudio::Model::OtherEquipmentDefinition.new(openstudio_model)
  os_other_equip = OpenStudio::Model::OtherEquipment.new(os_other_equip_def)
  os_other_equip_def.setName(@hash[:identifier])
  unless @hash[:display_name].nil?
    os_other_equip_def.setDisplayName(@hash[:display_name])
  end
  os_other_equip.setName(@hash[:identifier])

  # assign watts
  os_other_equip_def.setDesignLevel(@hash[:watts])

  # assign schedule
  other_equipment_schedule = openstudio_model.getScheduleByName(@hash[:schedule])
  unless other_equipment_schedule.empty?
    other_equipment_schedule_object = other_equipment_schedule.get
    os_other_equip.setSchedule(other_equipment_schedule_object)
  end

  # assign the fuel type
  os_other_equip.setFuelType(@hash[:fuel_type])

  # assign the end use category if it exists
  if @hash[:end_use_category]
    os_other_equip.setEndUseSubcategory(@hash[:end_use_category])
  else
    os_other_equip.setEndUseSubcategory(defaults[:end_use_category][:default])
  end

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

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

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

  os_other_equip
end