-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(idf): Add measure to inject an IDF into the workflow
This will be used to support additional strings.
- Loading branch information
1 parent
b3967c2
commit 1256157
Showing
5 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted | ||
provided that the following conditions are met: | ||
|
||
(1) Redistributions of source code must retain the above copyright notice, this list of conditions | ||
and the following disclaimer. | ||
|
||
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions | ||
and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
(3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse | ||
or promote products derived from this software without specific prior written permission from the | ||
respective party. | ||
|
||
(4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other | ||
derivative works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar | ||
designation without specific prior written permission from Alliance for Sustainable Energy, LLC. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED | ||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, | ||
OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, | ||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,32 @@ | ||
|
||
|
||
###### (Automatically generated documentation) | ||
|
||
# Inject IDF Objects | ||
|
||
## Description | ||
|
||
|
||
## Modeler Description | ||
|
||
|
||
## Measure Type | ||
EnergyPlusMeasure | ||
|
||
## Taxonomy | ||
|
||
|
||
## Arguments | ||
|
||
|
||
### External IDF File Name | ||
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. | ||
**Name:** source_idf_path, | ||
**Type:** String, | ||
**Units:** , | ||
**Required:** true, | ||
**Model Dependent:** false | ||
|
||
|
||
|
||
|
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,42 @@ | ||
<%#= README.md.erb is used to auto-generate README.md. %> | ||
<%#= To manually maintain README.md throw away README.md.erb and manually edit README.md %> | ||
###### (Automatically generated documentation) | ||
|
||
# <%= name %> | ||
|
||
## Description | ||
<%= description %> | ||
|
||
## Modeler Description | ||
<%= modelerDescription %> | ||
|
||
## Measure Type | ||
<%= measureType %> | ||
|
||
## Taxonomy | ||
<%= taxonomy %> | ||
|
||
## Arguments | ||
|
||
<% arguments.each do |argument| %> | ||
### <%= argument[:display_name] %> | ||
<%= argument[:description] %> | ||
**Name:** <%= argument[:name] %>, | ||
**Type:** <%= argument[:type] %>, | ||
**Units:** <%= argument[:units] %>, | ||
**Required:** <%= argument[:required] %>, | ||
**Model Dependent:** <%= argument[:model_dependent] %> | ||
<% end %> | ||
<% if arguments.size == 0 %> | ||
<%= "This measure does not have any user arguments" %> | ||
<% end %> | ||
<% if outputs.size > 0 %> | ||
## Outputs | ||
<% output_names = [] %> | ||
<% outputs.each do |output| %> | ||
<% output_names << output[:display_name] %> | ||
<% end %> | ||
<%= output_names.join(", ") %> | ||
<% end %> |
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,107 @@ | ||
# ******************************************************************************* | ||
# OpenStudio(R), Copyright (c) 2008-2021, Alliance for Sustainable Energy, LLC. | ||
# All rights reserved. | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# (1) Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# | ||
# (2) Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# (3) Neither the name of the copyright holder nor the names of any contributors | ||
# may be used to endorse or promote products derived from this software without | ||
# specific prior written permission from the respective party. | ||
# | ||
# (4) Other than as required in clauses (1) and (2), distributions in any form | ||
# of modifications or other derivative works may not use the "OpenStudio" | ||
# trademark, "OS", "os", or any other confusingly similar designation without | ||
# specific prior written permission from Alliance for Sustainable Energy, LLC. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE | ||
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF | ||
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
# ******************************************************************************* | ||
|
||
# see the URL below for information on how to write OpenStudio measures | ||
# http://openstudio.nrel.gov/openstudio-measure-writing-guide | ||
|
||
# see your EnergyPlus installation or the URL below for information on EnergyPlus objects | ||
# http://apps1.eere.energy.gov/buildings/energyplus/pdfs/inputoutputreference.pdf | ||
|
||
# see the URL below for information on using life cycle cost objects in OpenStudio | ||
# http://openstudio.nrel.gov/openstudio-life-cycle-examples | ||
|
||
# see the URL below for access to C++ documentation on workspace objects (click on "workspace" in the main window to view workspace objects) | ||
# http://openstudio.nrel.gov/sites/openstudio.nrel.gov/files/nv_data/cpp_documentation_it/utilities/html/idf_page.html | ||
|
||
# start the measure | ||
class InjectIDFObjects < OpenStudio::Measure::EnergyPlusMeasure | ||
# 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 | ||
def name | ||
return ' Inject IDF Objects' | ||
end | ||
|
||
# define the arguments that the user will input | ||
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 | ||
|
||
# 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 | ||
|
||
# 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 | ||
end | ||
|
||
# this allows the measure to be use by the application | ||
InjectIDFObjects.new.registerWithApplication |
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,114 @@ | ||
<measure xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://bcl.nrel.gov/xsd/measures/version/1.0.xsd"> | ||
<schema_version>3.0</schema_version> | ||
<name>inject_idf_objects</name> | ||
<uid>f567dfbc-d280-4d68-b061-019ab2630cd0</uid> | ||
<version_id>27bc8e62-185b-4670-b5ce-548ee42ec4e7</version_id> | ||
<version_modified>20210406T220305Z</version_modified> | ||
<xml_checksum>A8BAB05F</xml_checksum> | ||
<class_name>InjectIDFObjects</class_name> | ||
<display_name> Inject IDF Objects</display_name> | ||
<description>This measure allows you to inject IDF objects into an OSM generated IDF prior to passing the IDF off to EnergyPlus.</description> | ||
<modeler_description>This provides a stepping stone between exporting an IDF from OpenStudio and hand editing the IDF and writing fully functional OpenStudio EnergyPlus measures. | ||
|
||
This measure works for when you just need to add new IDF objects. If you need to interact with or alter IDF objects made by the OpenStudio forward translator, you will want to write an EnergyPlus measure wtih more use-case specific logic.</modeler_description> | ||
<arguments> | ||
<argument> | ||
<name>source_idf_path</name> | ||
<display_name>External IDF File Name</display_name> | ||
<description>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.</description> | ||
<type>String</type> | ||
<required>true</required> | ||
<model_dependent>false</model_dependent> | ||
</argument> | ||
</arguments> | ||
<tags> | ||
<tag>Whole Building.Space Types</tag> | ||
</tags> | ||
<attributes> | ||
<attribute> | ||
<name>Uses SketchUp API</name> | ||
<value>false</value> | ||
<datatype>boolean</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Measure Type</name> | ||
<value>EnergyPlusMeasure</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Intended Software Tool</name> | ||
<value>OpenStudio Application</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Intended Software Tool</name> | ||
<value>Parametric Analysis Tool</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Intended Software Tool</name> | ||
<value>Analysis Spreadsheet</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
<attribute> | ||
<name>Intended Use Case</name> | ||
<value>Model Articulation</value> | ||
<datatype>string</datatype> | ||
</attribute> | ||
</attributes> | ||
<files> | ||
<file> | ||
<filename>EnvelopeAndLoadTestModel_01.osm</filename> | ||
<filetype>osm</filetype> | ||
<usage_type>test</usage_type> | ||
<checksum>E11F67BD</checksum> | ||
</file> | ||
<file> | ||
<filename>Example B - BlockEnergyCharge.idf</filename> | ||
<filetype>idf</filetype> | ||
<usage_type>test</usage_type> | ||
<checksum>F90DD242</checksum> | ||
</file> | ||
<file> | ||
<filename>model_test.osw</filename> | ||
<filetype>osw</filetype> | ||
<usage_type>test</usage_type> | ||
<checksum>F5FABCCF</checksum> | ||
</file> | ||
<file> | ||
<filename>README.md.erb</filename> | ||
<filetype>erb</filetype> | ||
<usage_type>readmeerb</usage_type> | ||
<checksum>703C9964</checksum> | ||
</file> | ||
<file> | ||
<filename>README.md</filename> | ||
<filetype>md</filetype> | ||
<usage_type>readme</usage_type> | ||
<checksum>3D0882F2</checksum> | ||
</file> | ||
<file> | ||
<filename>LICENSE.md</filename> | ||
<filetype>md</filetype> | ||
<usage_type>license</usage_type> | ||
<checksum>A21A3ED2</checksum> | ||
</file> | ||
<file> | ||
<version> | ||
<software_program>OpenStudio</software_program> | ||
<identifier>2.0.0</identifier> | ||
<min_compatible>2.0.0</min_compatible> | ||
</version> | ||
<filename>measure.rb</filename> | ||
<filetype>rb</filetype> | ||
<usage_type>script</usage_type> | ||
<checksum>FFC40353</checksum> | ||
</file> | ||
<file> | ||
<filename>measure_Test.rb</filename> | ||
<filetype>rb</filetype> | ||
<usage_type>test</usage_type> | ||
<checksum>BCA08D25</checksum> | ||
</file> | ||
</files> | ||
</measure> |