Skip to content

Commit 37821f5

Browse files
authored
Scrape Building Name from EnergyPlus output (#492)
1 parent 3ec8f41 commit 37821f5

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# start the measure
2+
class AlfalfaMetadata < OpenStudio::Measure::EnergyPlusMeasure
3+
4+
# human readable name
5+
def name
6+
# Measure name should be the title case of the class name.
7+
return 'Alfalfa Metadata'
8+
end
9+
10+
# human readable description
11+
def description
12+
return 'Generate metadata report for Alfalfa'
13+
end
14+
15+
# human readable description of modeling approach
16+
def modeler_description
17+
return 'Generate metadata report for Alfalfa'
18+
end
19+
20+
# define the arguments that the user will input
21+
def arguments(workspace)
22+
args = OpenStudio::Measure::OSArgumentVector.new
23+
24+
return args
25+
end
26+
27+
# define what happens when the measure is run
28+
def run(workspace, runner, user_arguments)
29+
super(workspace, runner, user_arguments)
30+
31+
# use the built-in error checking
32+
if !runner.validateUserArguments(arguments(workspace), user_arguments)
33+
return false
34+
end
35+
36+
metadata_dict = {}
37+
38+
buildings = workspace.getObjectsByType('Building'.to_IddObjectType)
39+
buildings.each do |building|
40+
metadata_dict['building_name'] = building.name.get
41+
end
42+
43+
File.open('./report_metadata.json', 'w') do |f|
44+
JSON.dump(metadata_dict, f)
45+
end
46+
47+
runner.registerFinalCondition("Done")
48+
49+
return true
50+
end
51+
end
52+
53+
# register the measure to be used by the application
54+
AlfalfaMetadata.new.registerWithApplication
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0"?>
2+
<measure>
3+
<schema_version>3.1</schema_version>
4+
<name>alfalfa_metadata</name>
5+
<uid>870213d3-36a2-4da2-9a04-c377a37fd4fe</uid>
6+
<version_id>ca01ac21-1a57-4190-a834-5a41dbb63f1a</version_id>
7+
<version_modified>2024-05-03T20:06:06Z</version_modified>
8+
<xml_checksum>70995EFB</xml_checksum>
9+
<class_name>AlfalfaMetadata</class_name>
10+
<display_name>Alfalfa Metadata</display_name>
11+
<description>Generate metadata report for Alfalfa</description>
12+
<modeler_description>Generate metadata report for Alfalfa</modeler_description>
13+
<arguments />
14+
<outputs />
15+
<provenances />
16+
<tags>
17+
<tag>HVAC.HVAC Controls</tag>
18+
</tags>
19+
<attributes>
20+
<attribute>
21+
<name>Measure Type</name>
22+
<value>EnergyPlusMeasure</value>
23+
<datatype>string</datatype>
24+
</attribute>
25+
</attributes>
26+
<files>
27+
<file>
28+
<version>
29+
<software_program>OpenStudio</software_program>
30+
<identifier>3.1.0</identifier>
31+
<min_compatible>3.1.0</min_compatible>
32+
</version>
33+
<filename>measure.rb</filename>
34+
<filetype>rb</filetype>
35+
<usage_type>script</usage_type>
36+
<checksum>D2F3FCF2</checksum>
37+
</file>
38+
</files>
39+
</measure>

0 commit comments

Comments
 (0)