Class: BTAP::EQuest::DOECommand
- Inherits:
-
Object
- Object
- BTAP::EQuest::DOECommand
- Defined in:
- lib/openstudio-standards/btap/equest.rb
Overview
- Author
-
Phylroy Lopez ([email protected])
- Copyright
-
Copyright © NRCan
- License
-
GNU Public Licence
This class contains encapsulates the generic interface for the DOE2.x command set. It stores the u type, commands, and keyword pairs for each command. It also stores the parent and child command relationships w.r.t. the building envelope and the hvac systems. I have attempted to make the underlying storage of data private so, if required, we could move to a database solution in the future if required for web development..
Direct Known Subclasses
DOEConstruction, DOELayer, DOEMaterial, DOEPolygon, DOERoof, DOESpace, DOESurface, DOEZone
Instance Attribute Summary collapse
-
#building ⇒ Object
Pointer to the building obj.
-
#children ⇒ Object
An Array of all the children of this command.
-
#commandName ⇒ Object
Contains the DOE-2 command name.
-
#commandType ⇒ Object
The command type.
-
#comments ⇒ Object
Comments.
-
#exempt ⇒ Object
Flag to see if this component is exempt.
-
#keywordPairs ⇒ Object
Contains the Keyword Pairs.
-
#non_utype_commands ⇒ Object
A list of all the non_utype_commands.
-
#one_line_commands ⇒ Object
A list of all the one line commands (no keyword pairs).
-
#parents ⇒ Object
Lists all ancestors in increasing order.
-
#utype ⇒ Object
Contains the user specified name.
-
#uvalue ⇒ Object
Contains the u-value.
Instance Method Summary collapse
-
#basic_output ⇒ Object
Outputs the command in DOE 2.2 format.
-
#check_keyword?(keyword) ⇒ Boolean
Check if keyword exists.
-
#depth ⇒ Object
Determines the DOE scope depth (Window, Wall, Space Floor) or (System->Plant) Hierarchy).
-
#doe_scope ⇒ Object
Determines the DOE scope, either envelope or hvac (Window, Wall, Space Floor) or (System->Plant) Hierarchy) this is required to determine parent/child relationships in the building.
-
#get_children ⇒ Object
Returns an array of the commands children.
-
#get_children_of_command(keyword) ⇒ Object
Gets children of command, if any.
-
#get_command_from_string(command_string) ⇒ Object
Creates the command informantion based on DOE 2.2 syntax.
-
#get_keyword_value(string) ⇒ Object
This method will return the value of the keyword pair if available.
-
#get_name ⇒ Object
Gets name.
-
#get_parent(keyword) ⇒ Object
Gets the parent of command…if any.
-
#get_parents ⇒ Object
Returns an array of the commands parents.
-
#initialize ⇒ DOECommand
constructor
A new instance of DOECommand.
- #name ⇒ Object
-
#output ⇒ Object
Outputs the command in DOE 2.2 format.
- #remove ⇒ Object
-
#remove_keyword_pair(string) ⇒ Object
Removes the keyword pair.
-
#set_keyword_value(keyword, value) ⇒ Object
Sets the keyword value.
- #set_parent(parent) ⇒ Object
Constructor Details
#initialize ⇒ DOECommand
Returns a new instance of DOECommand.
150 151 152 153 154 155 156 157 158 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 190 191 192 193 194 |
# File 'lib/openstudio-standards/btap/equest.rb', line 150 def initialize() @utype = String.new() @commandName= String.new() @keywordPairs=Array.new() @parents = Array.new() @children = Array.new() @commandType = String.new() @exempt = false #HVAC Hierarchry @comments =Array.new() @hvacLevel = Array.new() @hvacLevel[0] =["SYSTEM"] @hvacLevel[1] =["ZONE"] #Envelope Hierachy @envelopeLevel = Array.new() @envelopeLevel[0] = ["FLOOR"] @envelopeLevel[1] = ["SPACE"] @envelopeLevel[2] = [ "EXTERIOR-WALL", "INTERIOR-WALL", "UNDERGROUND-WALL", "ROOF" ] @envelopeLevel[3] = [ "WINDOW", "DOOR"] @non_utype_commands = Array.new() @non_utype_commands = [ "TITLE", "SITE-PARAMETERS", "BUILD-PARAMETER", "LOADS_REPORT", "SYSTEMS-REPORT", "MASTERS-METERS", "ECONOMICS-REPORT", "PLANT-REPORT", "LOADS-REPORT", "COMPLIANCE" ] @one_line_commands = Array.new() @one_line_commands = ["INPUT","RUN-PERIOD","DIAGNOSTIC","ABORT", "END", "COMPUTE", "STOP", "PROJECT-DATA"] end |
Instance Attribute Details
#building ⇒ Object
Pointer to the building obj.
62 63 64 |
# File 'lib/openstudio-standards/btap/equest.rb', line 62 def building @building end |
#children ⇒ Object
An Array of all the children of this command.
50 51 52 |
# File 'lib/openstudio-standards/btap/equest.rb', line 50 def children @children end |
#commandName ⇒ Object
Contains the DOE-2 command name.
44 45 46 |
# File 'lib/openstudio-standards/btap/equest.rb', line 44 def commandName @commandName end |
#commandType ⇒ Object
The command type.
52 53 54 |
# File 'lib/openstudio-standards/btap/equest.rb', line 52 def commandType @commandType end |
#comments ⇒ Object
Comments. To be added to the command.
56 57 58 |
# File 'lib/openstudio-standards/btap/equest.rb', line 56 def comments @comments end |
#exempt ⇒ Object
Flag to see if this component is exempt.
54 55 56 |
# File 'lib/openstudio-standards/btap/equest.rb', line 54 def exempt @exempt end |
#keywordPairs ⇒ Object
Contains the Keyword Pairs.
46 47 48 |
# File 'lib/openstudio-standards/btap/equest.rb', line 46 def keywordPairs @keywordPairs end |
#non_utype_commands ⇒ Object
A list of all the non_utype_commands.
58 59 60 |
# File 'lib/openstudio-standards/btap/equest.rb', line 58 def non_utype_commands @non_utype_commands end |
#one_line_commands ⇒ Object
A list of all the one line commands (no keyword pairs)
60 61 62 |
# File 'lib/openstudio-standards/btap/equest.rb', line 60 def one_line_commands @one_line_commands end |
#parents ⇒ Object
Lists all ancestors in increasing order.
48 49 50 |
# File 'lib/openstudio-standards/btap/equest.rb', line 48 def parents @parents end |
#utype ⇒ Object
Contains the user specified name
40 41 42 |
# File 'lib/openstudio-standards/btap/equest.rb', line 40 def utype @utype end |
#uvalue ⇒ Object
Contains the u-value
42 43 44 |
# File 'lib/openstudio-standards/btap/equest.rb', line 42 def uvalue @uvalue end |
Instance Method Details
#basic_output ⇒ Object
Outputs the command in DOE 2.2 format.
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/openstudio-standards/btap/equest.rb', line 242 def basic_output() temp_string = String.new() if (@utype != "") temp_string = temp_string + "#{@utype} = " end temp_string = temp_string + @commandName temp_string = temp_string + "\n" @keywordPairs.each {|array| temp_string = temp_string + "\t#{array[0]} = #{array[1]}\n" } temp_string = temp_string + "..\n" temp_string = temp_string + "$Parents\n" @parents.each do |array| temp_string = temp_string + "$\t#{array.utype} = #{array.commandName}\n" end temp_string = temp_string + "..\n" temp_string = temp_string + "$Children\n" @children.each {|array| temp_string = temp_string + "$\t#{array.utype} = #{array.commandName}\n" } temp_string = temp_string + "..\n" end |
#check_keyword?(keyword) ⇒ Boolean
Check if keyword exists.
353 354 355 356 357 358 359 360 |
# File 'lib/openstudio-standards/btap/equest.rb', line 353 def check_keyword?(keyword) @keywordPairs.each do |pair| if pair[0] == keyword return true end end return false end |
#depth ⇒ Object
Determines the DOE scope depth (Window, Wall, Space Floor) or (System->Plant) Hierarchy)
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/openstudio-standards/btap/equest.rb', line 218 def depth level = 0 scopelist=[] if (doe_scope == "hvac") scopelist = @hvacLevel else scopelist = @envelopeLevel end scopelist.each_index do |index| scopelist[index].each do |name| if (@commandName == name ) level = index end end end return level end |
#doe_scope ⇒ Object
Determines the DOE scope, either envelope or hvac (Window, Wall, Space Floor) or (System->Plant) Hierarchy) this is required to determine parent/child relationships in the building.
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/openstudio-standards/btap/equest.rb', line 198 def doe_scope scope = "none" @envelopeLevel.each_index do |index| @envelopeLevel[index].each do |name| if (@commandName == name ) scope = "envelope" end end end @hvacLevel.each_index do |index| @hvacLevel[index].each do |name| if (@commandName == name ) scope = "hvac" end end end return scope end |
#get_children ⇒ Object
Returns an array of the commands children.
343 344 345 |
# File 'lib/openstudio-standards/btap/equest.rb', line 343 def get_children return children end |
#get_children_of_command(keyword) ⇒ Object
Gets children of command, if any.
376 377 378 379 380 381 382 383 384 |
# File 'lib/openstudio-standards/btap/equest.rb', line 376 def get_children_of_command(keyword) array = Array.new() children.each do |findcommand| if ( findcommand.commandName == keyword) array.push(findcommand) end end return array end |
#get_command_from_string(command_string) ⇒ Object
Creates the command informantion based on DOE 2.2 syntax.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/openstudio-standards/btap/equest.rb', line 266 def get_command_from_string(command_string) #Split the command based on the equal '=' sign. remove = "" keyword="" value="" if (command_string != "") #Get command and u-value if ( command_string.match(/(^\s*(\".*?\")\s*\=\s*(\S+)\s*)/) ) @commandName=$3.strip @utype = $2.strip remove = Regexp.escape($1) else # if no u-value, get just the command. command_string.match(/(^\s*(\S*)\s)/ ) remove = Regexp.escape($1) @commandName=$2.strip end #Remove command from string. command_string.sub!(/#{remove}/,"") command_string.strip! #Loop throught the keyword values. while ( command_string.length > 0 ) #DOEMaterial, or SCHEDULES if ( command_string.match(/(^\s*(MATERIAL|DAY-SCHEDULES|WEEK-SCHEDULES)\s*(\=?)\s*(.*)\s*)/)) #puts "Bracket" keyword = $2.strip value = $4.strip remove = Regexp.escape($1) #Stars elsif ( command_string.match(/(^\s*(\S*)\s*(\=?)\s*(\*.*?\*)\s*)/)) #puts "Bracket" keyword = $2.strip value = $4.strip remove = Regexp.escape($1) #Brackets elsif ( command_string.match(/(^\s*(\S*)\s*(\=?)\s*(\(.*?\))\s*)/)) #puts "Bracket" keyword = $2.strip value = $4.strip remove = Regexp.escape($1) #Quotes elsif ( command_string.match(/(^\s*(\S*)\s*(\=?)\s*(".*?")\s*)/) ) #puts "Quotes" keyword = $2 value = $4.strip remove = Regexp.escape($1) #single command elsif command_string.match(/(^\s*(\S*)\s*(\=?)\s*(\S+)\s*)/) #puts "Other" keyword = $2 value = $4.strip remove = Regexp.escape($1) end #puts "DOE22::DOECommand: #{command_string}" #puts "K = #{keyword} V = #{value}\n" if (keyword != "") set_keyword_value(keyword,value) end command_string.sub!(/#{remove}/,"") end #puts "Keyword" #puts keywordPairs end end |
#get_keyword_value(string) ⇒ Object
This method will return the value of the keyword pair if available. Example: If you object has this data in it…
“EL1 West Perim Spc (G.W4)” = SPACE SHAPE = POLYGON ZONE-TYPE = CONDITIONED PEOPLE-SCHEDULE = “EL1 Bldg Occup Sch” LIGHTING-SCHEDUL = ( “EL1 Bldg InsLt Sch” ) EQUIP-SCHEDULE = ( “EL1 Bldg Misc Sch” )
then calling
get_keyword_value(“ZONE-TYPE”)
will return the string
“CONDITIONED”.
if the keyword does not exist, it will return a nil object. Returns the value associated with the keyword.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/openstudio-standards/btap/equest.rb', line 105 def get_keyword_value(string) return_string = String.new() found = false @keywordPairs.each do |pair| if pair[0] == string found = true return_string = pair[1] end end if found == false raise "Error: In the command #{@utype}:#{@command_name} Attempted to get a Keyword pair #{string} present in the command\n Is this keyword missing? \n#{output}" end return return_string end |
#get_name ⇒ Object
Gets name.
348 349 350 |
# File 'lib/openstudio-standards/btap/equest.rb', line 348 def get_name() return @utype end |
#get_parent(keyword) ⇒ Object
Gets the parent of command…if any.
363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/openstudio-standards/btap/equest.rb', line 363 def get_parent(keyword) get_parents().each do |findcommand| if ( findcommand.commandName == keyword) return findcommand end end return nil end |
#get_parents ⇒ Object
Returns an array of the commands parents.
338 339 340 |
# File 'lib/openstudio-standards/btap/equest.rb', line 338 def get_parents return @parents end |
#name ⇒ Object
386 387 388 |
# File 'lib/openstudio-standards/btap/equest.rb', line 386 def name() return utype end |
#output ⇒ Object
Outputs the command in DOE 2.2 format.
237 238 239 |
# File 'lib/openstudio-standards/btap/equest.rb', line 237 def output return basic_output() end |
#remove ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/openstudio-standards/btap/equest.rb', line 67 def remove() #unlink children self.children.each {|item| item.remove} #unlink from parent. self.get_parents[0].children.delete(self) #remove from command array. @building.commands.delete(self) return self end |
#remove_keyword_pair(string) ⇒ Object
Removes the keyword pair.
140 141 142 143 144 145 146 147 148 |
# File 'lib/openstudio-standards/btap/equest.rb', line 140 def remove_keyword_pair(string) return_string = String.new() @keywordPairs.each do |pair| if pair[0] == string @keywordPairs.delete(pair) end end return return_string end |
#set_keyword_value(keyword, value) ⇒ Object
Sets the keyword value.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/openstudio-standards/btap/equest.rb', line 121 def set_keyword_value(keyword, value) found = false unless @keywordPairs.empty? @keywordPairs.each do |pair| if pair[0] == keyword pair[1] = value found = true end end if (found == false) @keywordPairs.push([keyword,value]) end else #First in the array... add_keyword_pair(keyword,value) end end |
#set_parent(parent) ⇒ Object
77 78 79 80 81 |
# File 'lib/openstudio-standards/btap/equest.rb', line 77 def set_parent(parent) @parents.clear parent.get_parents().each {|parent| @parents << parent} @parents << parent end |