Class: InjectIDFObjects
- Inherits:
-
OpenStudio::Measure::EnergyPlusMeasure
- Object
- OpenStudio::Measure::EnergyPlusMeasure
- InjectIDFObjects
- Defined in:
- lib/measures/inject_idf_objects/measure.rb
Overview
start the measure
Instance Method Summary collapse
-
#arguments(workspace) ⇒ Object
define the arguments that the user will input.
-
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml.
-
#run(workspace, runner, user_arguments) ⇒ Object
define what happens when the measure is run.
Instance Method Details
#arguments(workspace) ⇒ Object
define the arguments that the user will input
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/measures/inject_idf_objects/measure.rb', line 27 def arguments(workspace) args = OpenStudio::Ruleset::OSArgumentVector.new # make an argument for external idf source_idf_path = OpenStudio::Ruleset::OSArgument.makeStringArgument('source_idf_path', true) source_idf_path.setDisplayName('External IDF File Name') source_idf_path.setDescription('Name of the IDF file to inject objects from. This is the filename with the extension (e.g. MyModel.idf). Optionally this can inclucde the full file path, but for most use cases should just be file name.') args << source_idf_path return args end |
#name ⇒ Object
define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml
22 23 24 |
# File 'lib/measures/inject_idf_objects/measure.rb', line 22 def name return ' Inject IDF Objects' end |
#run(workspace, runner, user_arguments) ⇒ Object
define what happens when the measure is run
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/measures/inject_idf_objects/measure.rb', line 40 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 # assign the user inputs to variables source_idf_path = runner.getStringArgumentValue('source_idf_path', user_arguments) # report initial condition runner.registerInitialCondition("The initial IDF file had #{workspace.objects.size} objects.") # find source_idf_path osw_file = runner.workflow.findFile(source_idf_path) if osw_file.is_initialized source_idf_path = osw_file.get.to_s else runner.registerError("Did not find #{source_idf_path} in paths described in OSW file.") return false end # load IDF source_idf = OpenStudio::IdfFile.load(OpenStudio::Path.new(source_idf_path)).get # add everything from the file workspace.addObjects(source_idf.objects) # report final condition runner.registerFinalCondition("The final IDF file had #{workspace.objects.size} objects.") return true end |