-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scrape Building Name from EnergyPlus output
- Loading branch information
1 parent
3ec8f41
commit 75749b8
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
39 changes: 39 additions & 0 deletions
39
alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |