buildingsync 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/continuous_integration.yml +146 -0
- data/.gitignore +33 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/CHANGELOG.md +50 -0
- data/Gemfile +31 -0
- data/Jenkinsfile +10 -0
- data/LICENSE.md +29 -0
- data/README.md +105 -0
- data/Rakefile +77 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/buildingsync.gemspec +37 -0
- data/config.rb.in +26 -0
- data/doc_templates/LICENSE.md +29 -0
- data/doc_templates/README.md.erb +42 -0
- data/doc_templates/copyright_erb.txt +38 -0
- data/doc_templates/copyright_js.txt +5 -0
- data/doc_templates/copyright_ruby.txt +36 -0
- data/lib/buildingsync.rb +43 -0
- data/lib/buildingsync/all_resource_total.rb +54 -0
- data/lib/buildingsync/audit_date.rb +54 -0
- data/lib/buildingsync/constants.rb +49 -0
- data/lib/buildingsync/contact.rb +54 -0
- data/lib/buildingsync/extension.rb +57 -0
- data/lib/buildingsync/generator.rb +584 -0
- data/lib/buildingsync/get_bcl_weather_file.rb +326 -0
- data/lib/buildingsync/helpers/Model.hvac.rb +216 -0
- data/lib/buildingsync/helpers/helper.rb +494 -0
- data/lib/buildingsync/helpers/xml_get_set.rb +215 -0
- data/lib/buildingsync/makers/phase_zero_base.osw +178 -0
- data/lib/buildingsync/makers/workflow_maker.json +811 -0
- data/lib/buildingsync/makers/workflow_maker.rb +581 -0
- data/lib/buildingsync/makers/workflow_maker_base.rb +167 -0
- data/lib/buildingsync/model_articulation/building.rb +1119 -0
- data/lib/buildingsync/model_articulation/building_and_system_types.json +121 -0
- data/lib/buildingsync/model_articulation/building_section.rb +190 -0
- data/lib/buildingsync/model_articulation/building_system.rb +49 -0
- data/lib/buildingsync/model_articulation/envelope_system.rb +102 -0
- data/lib/buildingsync/model_articulation/exterior_floor_system_type.rb +64 -0
- data/lib/buildingsync/model_articulation/facility.rb +439 -0
- data/lib/buildingsync/model_articulation/foundation_system_type.rb +64 -0
- data/lib/buildingsync/model_articulation/hvac_system.rb +395 -0
- data/lib/buildingsync/model_articulation/lighting_system.rb +102 -0
- data/lib/buildingsync/model_articulation/loads_system.rb +287 -0
- data/lib/buildingsync/model_articulation/location_element.rb +129 -0
- data/lib/buildingsync/model_articulation/measure.rb +57 -0
- data/lib/buildingsync/model_articulation/roof_system_type.rb +64 -0
- data/lib/buildingsync/model_articulation/service_hot_water_system.rb +87 -0
- data/lib/buildingsync/model_articulation/site.rb +242 -0
- data/lib/buildingsync/model_articulation/spatial_element.rb +343 -0
- data/lib/buildingsync/model_articulation/wall_system_type.rb +64 -0
- data/lib/buildingsync/report.rb +217 -0
- data/lib/buildingsync/resource_use.rb +55 -0
- data/lib/buildingsync/scenario.rb +622 -0
- data/lib/buildingsync/selection_tool.rb +98 -0
- data/lib/buildingsync/time_series.rb +85 -0
- data/lib/buildingsync/translator.rb +167 -0
- data/lib/buildingsync/utility.rb +67 -0
- data/lib/buildingsync/version.rb +45 -0
- metadata +223 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# *******************************************************************************
|
4
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
+
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
#
|
18
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
19
|
+
# may be used to endorse or promote products derived from this software without
|
20
|
+
# specific prior written permission from the respective party.
|
21
|
+
#
|
22
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
23
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
24
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
25
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
31
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
32
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
34
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
36
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
37
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
# *******************************************************************************
|
39
|
+
require 'uri'
|
40
|
+
require 'net/http'
|
41
|
+
require 'net/http/post/multipart'
|
42
|
+
|
43
|
+
module BuildingSync
|
44
|
+
# Class for communicating with SelectionTool
|
45
|
+
class SelectionTool
|
46
|
+
# initialize the selection tools class
|
47
|
+
# @note See documentation here: https://github.com/buildingsync/selection-tool#validator
|
48
|
+
# @note Use core Net::HTTPS
|
49
|
+
# @param xml_path [String]
|
50
|
+
def initialize(xml_path, version = '2.0.0')
|
51
|
+
@hash_response = nil
|
52
|
+
version = '2.0.0' if version.nil?
|
53
|
+
url = URI.parse('https://selectiontool.buildingsync.net/api/validate')
|
54
|
+
|
55
|
+
params = { 'schema_version' => version }
|
56
|
+
params[:file] = UploadIO.new(xml_path, 'text/xml', File.basename(xml_path))
|
57
|
+
|
58
|
+
request = Net::HTTP::Post::Multipart.new(url.path, params)
|
59
|
+
http = Net::HTTP.new(url.host, url.port)
|
60
|
+
http.use_ssl = true
|
61
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
62
|
+
response = http.request(request)
|
63
|
+
|
64
|
+
@hash_response = JSON.parse(response.read_body)
|
65
|
+
end
|
66
|
+
|
67
|
+
# validate use case
|
68
|
+
# @param use_case [String]
|
69
|
+
# @return boolean
|
70
|
+
def validate_use_case(use_case)
|
71
|
+
use_cases = @hash_response['validation_results']['use_cases']
|
72
|
+
if use_cases.key?(use_case)
|
73
|
+
if !use_cases[use_case]['valid']
|
74
|
+
use_cases[use_case]['errors'].each do |error|
|
75
|
+
puts error
|
76
|
+
end
|
77
|
+
end
|
78
|
+
return use_cases[use_case]['valid']
|
79
|
+
else
|
80
|
+
puts "BuildingSync::SelectionTool.validate_use_case, Use Case #{use_case} is not an option. The available use cases to validate against are: #{use_cases}"
|
81
|
+
return false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# validate schema
|
86
|
+
# @return boolean
|
87
|
+
def validate_schema
|
88
|
+
if !@hash_response['validation_results']['schema']['valid']
|
89
|
+
@hash_response['validation_results']['schema']['errors'].each do |error|
|
90
|
+
puts error
|
91
|
+
end
|
92
|
+
end
|
93
|
+
return @hash_response['validation_results']['schema']['valid']
|
94
|
+
end
|
95
|
+
|
96
|
+
attr_reader :hash_response
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# *******************************************************************************
|
4
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
+
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
#
|
18
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
19
|
+
# may be used to endorse or promote products derived from this software without
|
20
|
+
# specific prior written permission from the respective party.
|
21
|
+
#
|
22
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
23
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
24
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
25
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
31
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
32
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
34
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
36
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
37
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
# *******************************************************************************
|
39
|
+
module BuildingSync
|
40
|
+
# TimeSeries class
|
41
|
+
class TimeSeries
|
42
|
+
include BuildingSync::Helper
|
43
|
+
include BuildingSync::XmlGetSet
|
44
|
+
# initialize
|
45
|
+
# @param @base_xml [REXML::Element]
|
46
|
+
# @param ns [String]
|
47
|
+
def initialize(base_xml, ns)
|
48
|
+
@base_xml = base_xml
|
49
|
+
@ns = ns
|
50
|
+
help_element_class_type_check(base_xml, 'TimeSeries')
|
51
|
+
|
52
|
+
# translates to: 2020-01-01T00:00:00
|
53
|
+
@timestamp_format = '%FT%T'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates monthly start and end times for the element.
|
57
|
+
# @param start_date_time [DateTime] should be the zeroth second of the month, i.e. 2020-01-01T00:00:00
|
58
|
+
def set_start_and_end_timestamps_monthly(start_date_time)
|
59
|
+
xset_or_create('StartTimestamp', start_date_time.strftime(@timestamp_format))
|
60
|
+
|
61
|
+
# >>= shifts a datetime by 1 month
|
62
|
+
end_date = start_date_time >>= 1
|
63
|
+
|
64
|
+
# += shifts a datetime by 1 day. the following shifts it by negative 1 minute
|
65
|
+
end_date += - Rational(1, 24.0 * 60)
|
66
|
+
|
67
|
+
# Always sets to last minute of the month:
|
68
|
+
# 2020-01-31T23:59:00
|
69
|
+
xset_or_create('EndTimestamp', end_date.strftime(@timestamp_format))
|
70
|
+
end
|
71
|
+
|
72
|
+
# @param start_date_time [DateTime] should be the zeroth second of the month, i.e. 2020-01-01T00:00:00
|
73
|
+
# @param interval_reading_value [Numeric] the value to use for IntervalReading
|
74
|
+
# @param resource_use_id [String] the ID of the ResourceUse to point to
|
75
|
+
def set_monthly_energy_reading(start_date_time, interval_reading_value, resource_use_id)
|
76
|
+
xset_or_create('ReadingType', 'Total')
|
77
|
+
xset_or_create('TimeSeriesReadingQuantity', 'Energy')
|
78
|
+
set_start_and_end_timestamps_monthly(start_date_time)
|
79
|
+
xset_or_create('IntervalFrequency', 'Month')
|
80
|
+
xset_or_create('IntervalReading', interval_reading_value)
|
81
|
+
ru_id_element = xget_or_create('ResourceUseID')
|
82
|
+
ru_id_element.add_attribute('IDref', resource_use_id)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# *******************************************************************************
|
4
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
+
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
#
|
18
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
19
|
+
# may be used to endorse or promote products derived from this software without
|
20
|
+
# specific prior written permission from the respective party.
|
21
|
+
#
|
22
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
23
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
24
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
25
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
31
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
32
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
34
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
36
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
37
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
# *******************************************************************************
|
39
|
+
require 'rexml/document'
|
40
|
+
require 'buildingsync/constants'
|
41
|
+
|
42
|
+
require_relative 'model_articulation/spatial_element'
|
43
|
+
require_relative 'makers/workflow_maker'
|
44
|
+
require_relative 'selection_tool'
|
45
|
+
require_relative 'extension'
|
46
|
+
|
47
|
+
module BuildingSync
|
48
|
+
# Translator class
|
49
|
+
class Translator < WorkflowMaker
|
50
|
+
include BuildingSync::Helper
|
51
|
+
# load the building sync file
|
52
|
+
# @param xml_file_path [String]
|
53
|
+
# @param output_dir [String]
|
54
|
+
# @param epw_file_path [String] if provided, full/path/to/my.epw
|
55
|
+
# @param standard_to_be_used [String]
|
56
|
+
# @param validate_xml_file_against_schema [Boolean]
|
57
|
+
def initialize(xml_file_path, output_dir, epw_file_path = nil, standard_to_be_used = ASHRAE90_1, validate_xml_file_against_schema = true)
|
58
|
+
@schema_version = nil
|
59
|
+
@xml_file_path = xml_file_path
|
60
|
+
@output_dir = output_dir
|
61
|
+
@standard_to_be_used = standard_to_be_used
|
62
|
+
@epw_path = epw_file_path
|
63
|
+
|
64
|
+
@results_gathered = false
|
65
|
+
@final_xml_prepared = false
|
66
|
+
|
67
|
+
# to further reduce the log messages we can change the log level with this command
|
68
|
+
# OpenStudio::Logger.instance.standardOutLogger.setLogLevel(OpenStudio::Error)
|
69
|
+
# Open a log for the library
|
70
|
+
log_file = OpenStudio::FileLogSink.new(OpenStudio::Path.new("#{output_dir}/in.log"))
|
71
|
+
log_file.setLogLevel(OpenStudio::Info)
|
72
|
+
|
73
|
+
# parse the xml
|
74
|
+
if !File.exist?(xml_file_path)
|
75
|
+
OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Translator.initialize', "File '#{xml_file_path}' does not exist")
|
76
|
+
raise "File '#{xml_file_path}' does not exist" unless File.exist?(xml_file_path)
|
77
|
+
end
|
78
|
+
|
79
|
+
doc = help_load_doc(xml_file_path)
|
80
|
+
|
81
|
+
@schema_version = doc.root.attributes['version']
|
82
|
+
if @schema_version.nil?
|
83
|
+
@schema_version = '2.0.0'
|
84
|
+
end
|
85
|
+
|
86
|
+
# test for the namespace
|
87
|
+
ns = 'auc'
|
88
|
+
doc.root.namespaces.each_pair do |k, v|
|
89
|
+
ns = k if /bedes-auc/.match(v)
|
90
|
+
end
|
91
|
+
|
92
|
+
if validate_xml_file_against_schema
|
93
|
+
validate_xml
|
94
|
+
else
|
95
|
+
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.initialize', "File '#{xml_file_path}' was not validated against the BuildingSync schema")
|
96
|
+
puts "File '#{xml_file_path}' was not validated against the BuildingSync schema"
|
97
|
+
end
|
98
|
+
|
99
|
+
super(doc, ns)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Validate the xml file against the schema
|
103
|
+
# using the SelectionTool
|
104
|
+
def validate_xml
|
105
|
+
# we wil try to validate the file, but if it fails, we will not cancel the process, but log an error
|
106
|
+
|
107
|
+
selection_tool = BuildingSync::SelectionTool.new(@xml_file_path, @schema_version)
|
108
|
+
if !selection_tool.validate_schema
|
109
|
+
raise "File '#{@xml_file_path}' does not valid against the BuildingSync schema"
|
110
|
+
else
|
111
|
+
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' is valid against the BuildingSync schema")
|
112
|
+
puts "File '#{@xml_file_path}' is valid against the BuildingSync schema"
|
113
|
+
end
|
114
|
+
rescue StandardError
|
115
|
+
OpenStudio.logFree(OpenStudio::Error, 'BuildingSync.Translator.initialize', "File '#{@xml_file_path}' does not valid against the BuildingSync schema")
|
116
|
+
end
|
117
|
+
|
118
|
+
# @see WorkflowMaker.setup_and_sizing_run
|
119
|
+
# @param ddy_file [String]
|
120
|
+
def setup_and_sizing_run(ddy_file = nil)
|
121
|
+
super(@output_dir, @epw_path, @standard_to_be_used, ddy_file)
|
122
|
+
end
|
123
|
+
|
124
|
+
# write osws - write all workflows into osw files
|
125
|
+
def write_osws(only_cb_modeled = false)
|
126
|
+
super(@output_dir, only_cb_modeled)
|
127
|
+
end
|
128
|
+
|
129
|
+
# gather results from simulated scenarios, for all or just the baseline scenario
|
130
|
+
# @param year_val [Integer] year to use when processing monthly results as TimeSeries elements
|
131
|
+
# @param baseline_only [Boolean] whether to only process the Baseline (or current building modeled) Scenario
|
132
|
+
def gather_results(year_val = Date.today.year, baseline_only = false)
|
133
|
+
@results_gathered = true
|
134
|
+
return super(year_val, baseline_only)
|
135
|
+
end
|
136
|
+
|
137
|
+
# run osws - running all scenario simulations
|
138
|
+
# @param runner_options [hash]
|
139
|
+
def run_osws(only_cb_modeled = false, runner_options = { run_simulations: true, verbose: false, num_parallel: 7, max_to_run: Float::INFINITY })
|
140
|
+
super(@output_dir, only_cb_modeled, runner_options)
|
141
|
+
end
|
142
|
+
|
143
|
+
# write parameters to xml file
|
144
|
+
def prepare_final_xml
|
145
|
+
if @results_gathered
|
146
|
+
super
|
147
|
+
else
|
148
|
+
OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Translator.prepare_final_xml', 'All results have not yet been gathered.')
|
149
|
+
super
|
150
|
+
end
|
151
|
+
@final_xml_prepared = true
|
152
|
+
end
|
153
|
+
|
154
|
+
# save xml that includes the results
|
155
|
+
# @param file_name [String]
|
156
|
+
def save_xml(file_name = 'results.xml')
|
157
|
+
output_file = File.join(@output_dir, file_name)
|
158
|
+
if @final_xml_prepared
|
159
|
+
super(output_file)
|
160
|
+
else
|
161
|
+
puts 'Prepare final file before attempting to save (translator.prepare_final_xml)'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
attr_accessor :doc, :results_gathered, :final_xml_prepared, :ns
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# *******************************************************************************
|
4
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
+
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
#
|
18
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
19
|
+
# may be used to endorse or promote products derived from this software without
|
20
|
+
# specific prior written permission from the respective party.
|
21
|
+
#
|
22
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
23
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
24
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
25
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
31
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
32
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
34
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
36
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
37
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
# *******************************************************************************
|
39
|
+
|
40
|
+
module BuildingSync
|
41
|
+
# Utility class
|
42
|
+
class Utility
|
43
|
+
include BuildingSync::Helper
|
44
|
+
include BuildingSync::XmlGetSet
|
45
|
+
# @param base_xml [REXML::Element]
|
46
|
+
# @param ns [String]
|
47
|
+
def initialize(base_xml, ns)
|
48
|
+
@base_xml = base_xml
|
49
|
+
@ns = ns
|
50
|
+
help_element_class_type_check(base_xml, 'Utility')
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Array<REXML::Element>]
|
54
|
+
def get_rate_schedules
|
55
|
+
rs = []
|
56
|
+
@base_xml.elements.each("#{@ns}:RateSchedules/#{@ns}:RateSchedule") do |rate_schedule|
|
57
|
+
rs << rate_schedule
|
58
|
+
end
|
59
|
+
return rs
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Array<String>]
|
63
|
+
def get_utility_meter_numbers
|
64
|
+
return xget_plurals_text_value('UtilityMeterNumber')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# *******************************************************************************
|
4
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
5
|
+
# BuildingSync(R), Copyright (c) 2015-2020, Alliance for Sustainable Energy, LLC.
|
6
|
+
# All rights reserved.
|
7
|
+
#
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
9
|
+
# modification, are permitted provided that the following conditions are met:
|
10
|
+
#
|
11
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer.
|
13
|
+
#
|
14
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
15
|
+
# this list of conditions and the following disclaimer in the documentation
|
16
|
+
# and/or other materials provided with the distribution.
|
17
|
+
#
|
18
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
19
|
+
# may be used to endorse or promote products derived from this software without
|
20
|
+
# specific prior written permission from the respective party.
|
21
|
+
#
|
22
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
23
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
24
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
25
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
|
28
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
29
|
+
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
|
31
|
+
# UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
|
32
|
+
# THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33
|
+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
34
|
+
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
35
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
36
|
+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
37
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
+
# *******************************************************************************
|
39
|
+
|
40
|
+
# BuildingSync module
|
41
|
+
# provides features for reading BldgSync XML files, generating baseline models, creating scenario workflows, running simulations and adding simulation results to the BldgSync file
|
42
|
+
module BuildingSync
|
43
|
+
# version of the BuildingSync gem
|
44
|
+
VERSION = '0.2.0'
|
45
|
+
end
|