Skip to content

Commit

Permalink
Scrape Building Name from EnergyPlus output
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed May 10, 2024
1 parent d12bf42 commit d719e67
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# start the measure
class AlfalfaMetadata < OpenStudio::Measure::EnergyPlusMeasure

# human readable name
def name
# Measure name should be the title case of the class name.
return 'Alfalfa Metadata'
end

# human readable description
def description
return 'Generate metadata report for Alfalfa'
end

# human readable description of modeling approach
def modeler_description
return 'Generate metadata report for Alfalfa'
end

# define the arguments that the user will input
def arguments(workspace)
args = OpenStudio::Measure::OSArgumentVector.new

return args
end

# define what happens when the measure is run
def run(workspace, runner, user_arguments)
super(workspace, runner, user_arguments)

# use the built-in error checking
if !runner.validateUserArguments(arguments(workspace), user_arguments)
return false
end

metadata_dict = {}

buildings = workspace.getObjectsByType('Building'.to_IddObjectType)
buildings.each do |building|
metadata_dict['building_name'] = building.name.get
end

File.open('./report_metadata.json', 'w') do |f|
JSON.dump(metadata_dict, f)
end

runner.registerFinalCondition("Done")

return true
end
end

# register the measure to be used by the application
AlfalfaMetadata.new.registerWithApplication
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<measure>
<schema_version>3.1</schema_version>
<name>alfalfa_metadata</name>
<uid>870213d3-36a2-4da2-9a04-c377a37fd4fe</uid>
<version_id>ca01ac21-1a57-4190-a834-5a41dbb63f1a</version_id>
<version_modified>2024-05-03T20:06:06Z</version_modified>
<xml_checksum>70995EFB</xml_checksum>
<class_name>AlfalfaMetadata</class_name>
<display_name>Alfalfa Metadata</display_name>
<description>Generate metadata report for Alfalfa</description>
<modeler_description>Generate metadata report for Alfalfa</modeler_description>
<arguments />
<outputs />
<provenances />
<tags>
<tag>HVAC.HVAC Controls</tag>
</tags>
<attributes>
<attribute>
<name>Measure Type</name>
<value>EnergyPlusMeasure</value>
<datatype>string</datatype>
</attribute>
</attributes>
<files>
<file>
<version>
<software_program>OpenStudio</software_program>
<identifier>3.1.0</identifier>
<min_compatible>3.1.0</min_compatible>
</version>
<filename>measure.rb</filename>
<filetype>rb</filetype>
<usage_type>script</usage_type>
<checksum>D2F3FCF2</checksum>
</file>
</files>
</measure>

0 comments on commit d719e67

Please sign in to comment.