From 75749b8b2a2c5904be8cd8c1fbdc336c3adec4a6 Mon Sep 17 00:00:00 2001 From: TShapinsky Date: Thu, 9 May 2024 11:55:18 -0600 Subject: [PATCH] Scrape Building Name from EnergyPlus output --- .../measures/alfalfa_metadata/measure.rb | 54 +++++++++++++++++++ .../measures/alfalfa_metadata/measure.xml | 39 ++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.rb create mode 100644 alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.xml diff --git a/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.rb b/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.rb new file mode 100644 index 00000000..d2d6261f --- /dev/null +++ b/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.rb @@ -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 diff --git a/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.xml b/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.xml new file mode 100644 index 00000000..53891c88 --- /dev/null +++ b/alfalfa_worker/jobs/openstudio/lib/workflow/measures/alfalfa_metadata/measure.xml @@ -0,0 +1,39 @@ + + + 3.1 + alfalfa_metadata + 870213d3-36a2-4da2-9a04-c377a37fd4fe + ca01ac21-1a57-4190-a834-5a41dbb63f1a + 2024-05-03T20:06:06Z + 70995EFB + AlfalfaMetadata + Alfalfa Metadata + Generate metadata report for Alfalfa + Generate metadata report for Alfalfa + + + + + HVAC.HVAC Controls + + + + Measure Type + EnergyPlusMeasure + string + + + + + + OpenStudio + 3.1.0 + 3.1.0 + + measure.rb + rb + script + D2F3FCF2 + + +