Class: Honeybee::WindowConstructionDynamicAbridged
- Inherits:
-
ModelObject
- Object
- ModelObject
- Honeybee::WindowConstructionDynamicAbridged
show all
- Defined in:
- lib/honeybee/construction/dynamic.rb,
lib/to_openstudio/construction/dynamic.rb
Constant Summary
collapse
- @@program_manager =
nil
- @@sensor_count =
1
- @@actuator_count =
1
- @@program_count =
1
- @@state_count =
1
Instance Attribute Summary collapse
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, #find_existing_openstudio_object, #initialize, #method_missing, read_from_disk, truncate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Honeybee::ModelObject
Instance Attribute Details
#constructions ⇒ Object
Returns the value of attribute constructions.
39
40
41
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 39
def constructions
@constructions
end
|
#schedule ⇒ Object
Returns the value of attribute schedule.
39
40
41
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 39
def schedule
@schedule
end
|
Class Method Details
.add_sub_faces_to_window_dynamic_hash(openstudio_model) ⇒ Object
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 159
def self.add_sub_faces_to_window_dynamic_hash(openstudio_model)
constr_names = Hash.new
$window_dynamic_hash.each do |constr_id, constr_obj|
first_constr = constr_obj.constructions[0]
first_constr_name_ref = first_constr.name
unless first_constr_name_ref.empty?
first_constr_name = first_constr_name_ref.get
constr_names[first_constr_name] = constr_id
end
end
sub_faces = openstudio_model.getSubSurfaces()
sub_faces.each do |sub_face|
constr_ref = sub_face.construction
unless constr_ref.empty?
constr = constr_ref.get
constr_name_ref = constr.name
unless constr_name_ref.empty?
constr_name = constr_name_ref.get
unless constr_names[constr_name].nil?
dyn_constr_name = constr_names[constr_name]
$window_dynamic_hash[dyn_constr_name].sub_faces << sub_face
end
end
end
end
end
|
Instance Method Details
#defaults ⇒ Object
38
39
40
41
|
# File 'lib/honeybee/construction/dynamic.rb', line 38
def defaults
@@schema[:components][:schemas][:WindowConstructionDynamicAbridged][:properties]
nil
end
|
#ems_program_to_openstudio(openstudio_model) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 102
def ems_program_to_openstudio(openstudio_model)
actuator_names = []
@sub_faces.each do |dyn_window|
window_act = OpenStudio::Model::EnergyManagementSystemActuator.new(
dyn_window, 'Surface', 'Construction State')
act_name = replace_ems_special_characters(dyn_window.nameString) + 'Actuator' + @@actuator_count.to_s
@@actuator_count = @@actuator_count + 1
window_act.setName(act_name)
actuator_names << act_name
end
ems_program = OpenStudio::Model::EnergyManagementSystemProgram.new(openstudio_model)
prog_name = replace_ems_special_characters(@hash[:identifier]) + 'StateChange' + @@program_count.to_s
@@program_count = @@program_count + 1
ems_program.setName(prog_name)
max_state_count = @constructions.length() - 1
@constructions.each_with_index do |construction, i|
cond_op = 'IF'
if i != 0
cond_op = 'ELSEIF'
end
state_count = i + 1
if i == max_state_count
cond_stmt = 'ELSE'
else
cond_stmt = cond_op + ' (' + @sch_sensor_name + ' < ' + state_count.to_s + ')'
end
ems_program.addLine(cond_stmt)
constr_i = OpenStudio::Model::EnergyManagementSystemConstructionIndexVariable.new(
openstudio_model, construction)
constr_i_name = replace_ems_special_characters(construction.nameString) + 'State' + @@state_count.to_s
@@state_count = @@state_count + 1
constr_i.setName(constr_i_name)
actuator_names.each do |act_name|
ems_program.addLine('SET ' + act_name + ' = ' + constr_i_name)
end
end
ems_program.addLine('ENDIF')
prog_manager = get_program_manager(openstudio_model)
prog_manager.addProgram(ems_program)
end
|
#get_program_manager(openstudio_model) ⇒ Object
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 65
def get_program_manager(openstudio_model)
if @@program_manager.nil?
@@program_manager = OpenStudio::Model::EnergyManagementSystemProgramCallingManager.new(
openstudio_model)
@@program_manager.setName('Dynamic_Window_Constructions')
@@program_manager.setCallingPoint('BeginTimestepBeforePredictor')
end
@@program_manager
end
|
#replace_ems_special_characters(ems_variable_name) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 57
def replace_ems_special_characters(ems_variable_name)
new_name = ems_variable_name.to_s
new_name = new_name.dup new_name.gsub!(/[^A-Za-z]/, '')
new_name
end
|
#sub_faces ⇒ Object
52
53
54
55
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 52
def sub_faces
@sub_faces
end
|
#to_openstudio(openstudio_model) ⇒ Object
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
|
# File 'lib/to_openstudio/construction/dynamic.rb', line 76
def to_openstudio(openstudio_model)
@sub_faces = []
@constructions = []
@hash[:constructions].each do |win_con|
constr_obj = WindowConstructionAbridged.new(win_con)
@constructions << constr_obj.to_openstudio(openstudio_model)
end
state_sch = openstudio_model.getScheduleByName(@hash[:schedule])
@sch_sensor_name = replace_ems_special_characters(@hash[:identifier]) + 'Sensor' + @@sensor_count.to_s
@@sensor_count = @@sensor_count + 1
unless state_sch.empty? sch_var = OpenStudio::Model::OutputVariable.new('Schedule Value', openstudio_model)
sch_var.setReportingFrequency('Timestep')
sch_var.setKeyValue(@hash[:schedule])
sch_sens = OpenStudio::Model::EnergyManagementSystemSensor.new(openstudio_model, sch_var)
sch_sens.setName(@sch_sensor_name)
end
end
|