Class: Honeybee::ProgramTypeAbridged
- Inherits:
-
ModelObject
- Object
- ModelObject
- Honeybee::ProgramTypeAbridged
- Defined in:
- lib/honeybee/program_type.rb,
lib/to_openstudio/program_type.rb,
lib/from_openstudio/program_type.rb
Instance Attribute Summary
Attributes inherited from ModelObject
#errors, #openstudio_object, #warnings
Class Method Summary collapse
Instance Method Summary collapse
- #defaults ⇒ Object
- #find_existing_openstudio_object(openstudio_model) ⇒ Object
- #to_openstudio(openstudio_model) ⇒ Object
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_programtype(programtype) ⇒ 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 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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/from_openstudio/program_type.rb', line 38 def self.from_programtype(programtype) # create an empty hash hash = {} hash[:type] = 'ProgramTypeAbridged' # set hash values from OpenStudio Object hash[:identifier] = clean_name(programtype.nameString) unless programtype.displayName.empty? hash[:display_name] = (programtype.displayName.get).force_encoding("UTF-8") end unless programtype.people.empty? programtype.people.each do |people| people_def = people.peopleDefinition # Only translate if people per floor area is specified # Check if schedule exists and is of the correct type if !people_def.peopleperSpaceFloorArea.empty? && !people.numberofPeopleSchedule.empty? sch = people.numberofPeopleSchedule.get if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized hash[:people] = Honeybee::PeopleAbridged.from_load(people) break end end end end unless programtype.lights.empty? programtype.lights.each do |light| light_def = light.lightsDefinition # Only translate if watts per floor area is specified # Check if schedule exists and is of the correct type if !light_def.wattsperSpaceFloorArea.empty? && !light.schedule.empty? sch = light.schedule.get if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized hash[:lighting] = Honeybee::LightingAbridged.from_load(light) break end end end end unless programtype.electricEquipment.empty? programtype.electricEquipment.each do |electric_eq| electric_eq_def = electric_eq.electricEquipmentDefinition # Only translate if watts per floor area is specified # Check if schedule exists and is of the correct type if !electric_eq_def.wattsperSpaceFloorArea.empty? && !electric_eq.schedule.empty? sch = electric_eq.schedule.get if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized hash[:electric_equipment] = Honeybee::ElectricEquipmentAbridged.from_load(electric_eq) break end end end end unless programtype.gasEquipment.empty? programtype.gasEquipment.each do |gas_eq| gas_eq_def = gas_eq.gasEquipmentDefinition # Only translate if watts per floor area is specified # Check if schedule exists and is of the correct type if !gas_eq_def.wattsperSpaceFloorArea.empty? && !gas_eq.schedule.empty? sch = gas_eq.schedule.get if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized hash[:gas_equipment] = Honeybee::GasEquipmentAbridged.from_load(gas_eq) break end end end end unless programtype.spaceInfiltrationDesignFlowRates.empty? programtype.spaceInfiltrationDesignFlowRates.each do |infiltration| # Only translate if flow per exterior area is specified # Check if schedule exists and is of the correct type if !infiltration.flowperExteriorSurfaceArea.empty? && !infiltration.schedule.empty? sch = infiltration.schedule.get if sch.to_ScheduleRuleset.is_initialized or sch.to_ScheduleFixedInterval.is_initialized hash[:infiltration] = Honeybee::InfiltrationAbridged.from_load(infiltration) break end end end end unless programtype.designSpecificationOutdoorAir.empty? hash[:ventilation] = Honeybee::VentilationAbridged.from_load(programtype.designSpecificationOutdoorAir.get) end hash end |
Instance Method Details
#defaults ⇒ Object
48 49 50 |
# File 'lib/honeybee/program_type.rb', line 48 def defaults @@schema[:components][:schemas][:ProgramTypeAbridged][:properties] end |
#find_existing_openstudio_object(openstudio_model) ⇒ Object
39 40 41 42 43 |
# File 'lib/to_openstudio/program_type.rb', line 39 def find_existing_openstudio_object(openstudio_model) model_space_type = openstudio_model.getSpaceTypeByName(@hash[:identifier]) return model_space_type.get unless model_space_type.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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/to_openstudio/program_type.rb', line 45 def to_openstudio(openstudio_model) # create openstudio space type object os_space_type = OpenStudio::Model::SpaceType.new(openstudio_model) os_space_type.setName(@hash[:identifier]) unless @hash[:display_name].nil? os_space_type.setDisplayName(@hash[:display_name]) end # if the program is from honeybee-energy-standards, also set the measure tag id_str = @hash[:identifier].to_s if id_str.scan(/(?=::)/).count == 2 std_spc_type = id_str.split('::')[2] std_spc_type = std_spc_type.split('_')[0] os_space_type.setStandardsSpaceType(std_spc_type) end # assign people if @hash[:people] people = PeopleAbridged.new(@hash[:people]) os_people = people.to_openstudio(openstudio_model) os_people.setSpaceType(os_space_type) end # assign lighting if @hash[:lighting] lights = LightingAbridged.new(@hash[:lighting]) os_lights = lights.to_openstudio(openstudio_model) os_lights.setSpaceType(os_space_type) end # assign electric equipment if @hash[:electric_equipment] electric_equipment = ElectricEquipmentAbridged.new(@hash[:electric_equipment]) os_electric_equipment = electric_equipment.to_openstudio(openstudio_model) os_electric_equipment.setSpaceType(os_space_type) end # assign gas equipment if @hash[:gas_equipment] gas_equipment = GasEquipmentAbridged.new(@hash[:gas_equipment]) os_gas_equipment = gas_equipment.to_openstudio(openstudio_model) os_gas_equipment.setSpaceType(os_space_type) end # add hot water from to a global hash that will be used to assign them to rooms if @hash[:service_hot_water] $programtype_shw_hash[@hash[:identifier]] = @hash[:service_hot_water] end # assign infiltration if @hash[:infiltration] && $use_simple_vent # only use infiltration with simple ventilation infiltration = InfiltrationAbridged.new(@hash[:infiltration]) os_infiltration = infiltration.to_openstudio(openstudio_model) os_infiltration.setSpaceType(os_space_type) end # assign ventilation if @hash[:ventilation] ventilation = VentilationAbridged.new(@hash[:ventilation]) os_ventilation = ventilation.to_openstudio(openstudio_model) os_space_type.setDesignSpecificationOutdoorAir(os_ventilation) end # add setpoints from to a global hash that will be used to assign them to rooms if @hash[:setpoint] $programtype_setpoint_hash[@hash[:identifier]] = @hash[:setpoint] end os_space_type end |