openstudio-workflow 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -77
- data/README.md +67 -93
- data/Rakefile +36 -36
- data/lib/openstudio-workflow.rb +65 -65
- data/lib/openstudio/workflow/adapters/input/local.rb +311 -324
- data/lib/openstudio/workflow/adapters/output/local.rb +158 -161
- data/lib/openstudio/workflow/adapters/output/socket.rb +106 -107
- data/lib/openstudio/workflow/adapters/output/web.rb +82 -82
- data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -163
- data/lib/openstudio/workflow/job.rb +57 -57
- data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
- data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -70
- data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -203
- data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -89
- data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -73
- data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -104
- data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -118
- data/lib/openstudio/workflow/jobs/run_translation.rb +84 -84
- data/lib/openstudio/workflow/multi_delegator.rb +62 -62
- data/lib/openstudio/workflow/registry.rb +172 -172
- data/lib/openstudio/workflow/run.rb +342 -328
- data/lib/openstudio/workflow/time_logger.rb +96 -96
- data/lib/openstudio/workflow/util.rb +49 -49
- data/lib/openstudio/workflow/util/energyplus.rb +575 -605
- data/lib/openstudio/workflow/util/io.rb +68 -68
- data/lib/openstudio/workflow/util/measure.rb +658 -650
- data/lib/openstudio/workflow/util/model.rb +151 -151
- data/lib/openstudio/workflow/util/post_process.rb +235 -238
- data/lib/openstudio/workflow/util/weather_file.rb +143 -143
- data/lib/openstudio/workflow/version.rb +40 -40
- data/lib/openstudio/workflow_json.rb +475 -476
- data/lib/openstudio/workflow_runner.rb +263 -268
- metadata +24 -24
@@ -1,143 +1,143 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
3
|
-
# All rights reserved.
|
4
|
-
# Redistribution and use in source and binary forms, with or without
|
5
|
-
# modification, are permitted provided that the following conditions are met:
|
6
|
-
#
|
7
|
-
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer.
|
9
|
-
#
|
10
|
-
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer in the documentation
|
12
|
-
# and/or other materials provided with the distribution.
|
13
|
-
#
|
14
|
-
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
-
# may be used to endorse or promote products derived from this software without
|
16
|
-
# specific prior written permission from the respective party.
|
17
|
-
#
|
18
|
-
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
-
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
-
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
-
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
-
#
|
23
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
module OpenStudio
|
37
|
-
module Workflow
|
38
|
-
module Util
|
39
|
-
# The current precedence rules for weather files are defined in this module. Best practice is to only use the
|
40
|
-
# #get_weather_file method, as it will be forward compatible
|
41
|
-
#
|
42
|
-
module WeatherFile
|
43
|
-
# Returns the weather file with precedence
|
44
|
-
#
|
45
|
-
# @param [String] directory The directory to append all relative directories to, see #get_weather_file_from_fs
|
46
|
-
# @param [String] wf The weather file being searched for. If not the name of the file this parameter should be
|
47
|
-
# the absolute path specifying it's location
|
48
|
-
# @param [Array] wf_search_array The set of precedence ordered relative directories to search for the wf in. A
|
49
|
-
# typical entry might look like `['files', '../../files', '../../weather']`
|
50
|
-
# @param [Object] model The OpenStudio::Model object to parse, see #get_weather_file_from_osm
|
51
|
-
# @return [String, nil] The weather file with precedence if defined, nil if not, and a failure if the wf is
|
52
|
-
# defined but not in the filesystem
|
53
|
-
#
|
54
|
-
def get_weather_file(directory, wf, wf_search_array, model, logger = nil)
|
55
|
-
# TODO: this logic needs some updating, weather file should come from current model, found using search paths
|
56
|
-
logger ||= ::Logger.new(STDOUT) unless logger
|
57
|
-
if wf
|
58
|
-
weather_file = get_weather_file_from_fs(directory, wf, wf_search_array, logger)
|
59
|
-
raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false
|
60
|
-
end
|
61
|
-
weather_file = get_weather_file_from_osm(model, logger) if weather_file.nil?
|
62
|
-
raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false
|
63
|
-
logger.warn 'The weather file could not be determined. Please see the log for details' unless weather_file
|
64
|
-
weather_file
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
# Returns the weather file from the model. If the weather file is defined in the model, then
|
70
|
-
# it checks the file paths to check if the model exists. This allows for a user to upload a
|
71
|
-
# weather file in a measure and then have the measure's path be used for the weather file.
|
72
|
-
#
|
73
|
-
# @todo (rhorsey) verify the description of this method, as it seems suspect
|
74
|
-
# @param [Object] model The OpenStudio::Model object to retrieve the weather file from
|
75
|
-
# @return [nil,false, String] If the result is nil the weather file was not defined in the model, if the result
|
76
|
-
# is false the weather file was set but could not be found on the filesystem, if a string the weather file was
|
77
|
-
# defined and it's existence verified
|
78
|
-
#
|
79
|
-
def get_weather_file_from_osm(model, logger)
|
80
|
-
wf = nil
|
81
|
-
# grab the weather file out of the OSM if it exists
|
82
|
-
if model.weatherFile.empty?
|
83
|
-
logger.warn 'No weather file defined in the model'
|
84
|
-
else
|
85
|
-
p = model.weatherFile.get.path.get.to_s.gsub('file://', '')
|
86
|
-
wf = if File.exist? p
|
87
|
-
File.absolute_path(p)
|
88
|
-
else
|
89
|
-
# this is the weather file from the OSM model
|
90
|
-
File.absolute_path(@model.weatherFile.get.path.get.to_s)
|
91
|
-
end
|
92
|
-
logger.info "The weather file path found in the model object: #{wf}"
|
93
|
-
unless File.exist? wf
|
94
|
-
logger.warn 'The weather file could not be found on the filesystem.'
|
95
|
-
wf = false
|
96
|
-
end
|
97
|
-
end
|
98
|
-
wf
|
99
|
-
end
|
100
|
-
|
101
|
-
# Returns the weather file defined in the OSW
|
102
|
-
#
|
103
|
-
# @param [String] directory The base directory to append all relative directories to
|
104
|
-
# @param [String] wf The weather file being searched for. If not the name of the file this parameter should be
|
105
|
-
# the absolute path specifying it's location
|
106
|
-
# @param [Array] wf_search_array The set of precedence ordered relative directories to search for the wf in. A
|
107
|
-
# typical entry might look like `['files', '../../files', '../../weather']`
|
108
|
-
# @return [nil, false, String] If the result is nil the weather file was not defined in the workflow, if the
|
109
|
-
# result is false the weather file was set but could not be found on the filesystem, if a string the weather
|
110
|
-
# file was defined and it's existence verified. The order of precedence for paths is as follows: 1 - an
|
111
|
-
# absolute path defined in wf, 2 - the wf_search_array, should it be defined, joined with the weather file and
|
112
|
-
# appended to the directory, with each entry in the array searched until the wf is found
|
113
|
-
#
|
114
|
-
def get_weather_file_from_fs(directory, wf, wf_search_array, logger)
|
115
|
-
raise "wf was defined as #{wf}. Please correct" unless wf
|
116
|
-
weather_file = nil
|
117
|
-
if Pathname.new(wf).absolute?
|
118
|
-
weather_file = wf
|
119
|
-
else
|
120
|
-
wf_search_array.each do |wf_dir|
|
121
|
-
logger.warn "The path #{wf_dir} does not exist" unless File.exist? File.join(directory, wf_dir)
|
122
|
-
next unless File.exist? File.join(directory, wf_dir)
|
123
|
-
if Dir.entries(File.join(directory, wf_dir)).include? File.basename(wf)
|
124
|
-
weather_file = File.absolute_path(File.join(directory, wf_dir, wf))
|
125
|
-
break
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
unless weather_file
|
130
|
-
logger.warn 'The weather file was not found on the filesystem'
|
131
|
-
return nil
|
132
|
-
end
|
133
|
-
logger.info "Weather file with precedence in the file system is #{weather_file}"
|
134
|
-
unless File.exist? weather_file
|
135
|
-
logger.warn 'The weather file could not be found on the filesystem'
|
136
|
-
weather_file = false
|
137
|
-
end
|
138
|
-
weather_file
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission from the respective party.
|
17
|
+
#
|
18
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
+
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
# *******************************************************************************
|
35
|
+
|
36
|
+
module OpenStudio
|
37
|
+
module Workflow
|
38
|
+
module Util
|
39
|
+
# The current precedence rules for weather files are defined in this module. Best practice is to only use the
|
40
|
+
# #get_weather_file method, as it will be forward compatible
|
41
|
+
#
|
42
|
+
module WeatherFile
|
43
|
+
# Returns the weather file with precedence
|
44
|
+
#
|
45
|
+
# @param [String] directory The directory to append all relative directories to, see #get_weather_file_from_fs
|
46
|
+
# @param [String] wf The weather file being searched for. If not the name of the file this parameter should be
|
47
|
+
# the absolute path specifying it's location
|
48
|
+
# @param [Array] wf_search_array The set of precedence ordered relative directories to search for the wf in. A
|
49
|
+
# typical entry might look like `['files', '../../files', '../../weather']`
|
50
|
+
# @param [Object] model The OpenStudio::Model object to parse, see #get_weather_file_from_osm
|
51
|
+
# @return [String, nil] The weather file with precedence if defined, nil if not, and a failure if the wf is
|
52
|
+
# defined but not in the filesystem
|
53
|
+
#
|
54
|
+
def get_weather_file(directory, wf, wf_search_array, model, logger = nil)
|
55
|
+
# TODO: this logic needs some updating, weather file should come from current model, found using search paths
|
56
|
+
logger ||= ::Logger.new(STDOUT) unless logger
|
57
|
+
if wf
|
58
|
+
weather_file = get_weather_file_from_fs(directory, wf, wf_search_array, logger)
|
59
|
+
raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false
|
60
|
+
end
|
61
|
+
weather_file = get_weather_file_from_osm(model, logger) if weather_file.nil?
|
62
|
+
raise 'Could not locate the weather file in the filesystem. Please see the log' if weather_file == false
|
63
|
+
logger.warn 'The weather file could not be determined. Please see the log for details' unless weather_file
|
64
|
+
weather_file
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
# Returns the weather file from the model. If the weather file is defined in the model, then
|
70
|
+
# it checks the file paths to check if the model exists. This allows for a user to upload a
|
71
|
+
# weather file in a measure and then have the measure's path be used for the weather file.
|
72
|
+
#
|
73
|
+
# @todo (rhorsey) verify the description of this method, as it seems suspect
|
74
|
+
# @param [Object] model The OpenStudio::Model object to retrieve the weather file from
|
75
|
+
# @return [nil,false, String] If the result is nil the weather file was not defined in the model, if the result
|
76
|
+
# is false the weather file was set but could not be found on the filesystem, if a string the weather file was
|
77
|
+
# defined and it's existence verified
|
78
|
+
#
|
79
|
+
def get_weather_file_from_osm(model, logger)
|
80
|
+
wf = nil
|
81
|
+
# grab the weather file out of the OSM if it exists
|
82
|
+
if model.weatherFile.empty?
|
83
|
+
logger.warn 'No weather file defined in the model'
|
84
|
+
else
|
85
|
+
p = model.weatherFile.get.path.get.to_s.gsub('file://', '')
|
86
|
+
wf = if File.exist? p
|
87
|
+
File.absolute_path(p)
|
88
|
+
else
|
89
|
+
# this is the weather file from the OSM model
|
90
|
+
File.absolute_path(@model.weatherFile.get.path.get.to_s)
|
91
|
+
end
|
92
|
+
logger.info "The weather file path found in the model object: #{wf}"
|
93
|
+
unless File.exist? wf
|
94
|
+
logger.warn 'The weather file could not be found on the filesystem.'
|
95
|
+
wf = false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
wf
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns the weather file defined in the OSW
|
102
|
+
#
|
103
|
+
# @param [String] directory The base directory to append all relative directories to
|
104
|
+
# @param [String] wf The weather file being searched for. If not the name of the file this parameter should be
|
105
|
+
# the absolute path specifying it's location
|
106
|
+
# @param [Array] wf_search_array The set of precedence ordered relative directories to search for the wf in. A
|
107
|
+
# typical entry might look like `['files', '../../files', '../../weather']`
|
108
|
+
# @return [nil, false, String] If the result is nil the weather file was not defined in the workflow, if the
|
109
|
+
# result is false the weather file was set but could not be found on the filesystem, if a string the weather
|
110
|
+
# file was defined and it's existence verified. The order of precedence for paths is as follows: 1 - an
|
111
|
+
# absolute path defined in wf, 2 - the wf_search_array, should it be defined, joined with the weather file and
|
112
|
+
# appended to the directory, with each entry in the array searched until the wf is found
|
113
|
+
#
|
114
|
+
def get_weather_file_from_fs(directory, wf, wf_search_array, logger)
|
115
|
+
raise "wf was defined as #{wf}. Please correct" unless wf
|
116
|
+
weather_file = nil
|
117
|
+
if Pathname.new(wf).absolute?
|
118
|
+
weather_file = wf
|
119
|
+
else
|
120
|
+
wf_search_array.each do |wf_dir|
|
121
|
+
logger.warn "The path #{wf_dir} does not exist" unless File.exist? File.join(directory, wf_dir)
|
122
|
+
next unless File.exist? File.join(directory, wf_dir)
|
123
|
+
if Dir.entries(File.join(directory, wf_dir)).include? File.basename(wf)
|
124
|
+
weather_file = File.absolute_path(File.join(directory, wf_dir, wf))
|
125
|
+
break
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
unless weather_file
|
130
|
+
logger.warn 'The weather file was not found on the filesystem'
|
131
|
+
return nil
|
132
|
+
end
|
133
|
+
logger.info "Weather file with precedence in the file system is #{weather_file}"
|
134
|
+
unless File.exist? weather_file
|
135
|
+
logger.warn 'The weather file could not be found on the filesystem'
|
136
|
+
weather_file = false
|
137
|
+
end
|
138
|
+
weather_file
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -1,40 +1,40 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
3
|
-
# All rights reserved.
|
4
|
-
# Redistribution and use in source and binary forms, with or without
|
5
|
-
# modification, are permitted provided that the following conditions are met:
|
6
|
-
#
|
7
|
-
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer.
|
9
|
-
#
|
10
|
-
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer in the documentation
|
12
|
-
# and/or other materials provided with the distribution.
|
13
|
-
#
|
14
|
-
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
-
# may be used to endorse or promote products derived from this software without
|
16
|
-
# specific prior written permission from the respective party.
|
17
|
-
#
|
18
|
-
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
-
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
-
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
-
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
-
#
|
23
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
module OpenStudio
|
37
|
-
module Workflow
|
38
|
-
VERSION = '1.3.
|
39
|
-
end
|
40
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission from the respective party.
|
17
|
+
#
|
18
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
+
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
# *******************************************************************************
|
35
|
+
|
36
|
+
module OpenStudio
|
37
|
+
module Workflow
|
38
|
+
VERSION = '1.3.5'.freeze # Suffixes must have periods (not dashes)
|
39
|
+
end
|
40
|
+
end
|
@@ -1,476 +1,475 @@
|
|
1
|
-
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
3
|
-
# All rights reserved.
|
4
|
-
# Redistribution and use in source and binary forms, with or without
|
5
|
-
# modification, are permitted provided that the following conditions are met:
|
6
|
-
#
|
7
|
-
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
-
# this list of conditions and the following disclaimer.
|
9
|
-
#
|
10
|
-
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
-
# this list of conditions and the following disclaimer in the documentation
|
12
|
-
# and/or other materials provided with the distribution.
|
13
|
-
#
|
14
|
-
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
-
# may be used to endorse or promote products derived from this software without
|
16
|
-
# specific prior written permission from the respective party.
|
17
|
-
#
|
18
|
-
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
-
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
-
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
-
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
-
#
|
23
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
-
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
-
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
-
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
-
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
-
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
-
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
-
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
-
# *******************************************************************************
|
35
|
-
|
36
|
-
require 'pathname'
|
37
|
-
|
38
|
-
# Optional_Shim provides a wrapper that looks like an OpenStudio Optional
|
39
|
-
class Optional_Shim
|
40
|
-
def initialize(obj)
|
41
|
-
@obj = obj
|
42
|
-
end
|
43
|
-
|
44
|
-
def empty?
|
45
|
-
@obj.nil?
|
46
|
-
end
|
47
|
-
|
48
|
-
def is_initialized
|
49
|
-
!@obj.nil?
|
50
|
-
end
|
51
|
-
|
52
|
-
def get
|
53
|
-
raise 'Uninitialized Optional_Shim' if @obj.nil?
|
54
|
-
@obj
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
s = ''
|
59
|
-
unless s.respond_to?(:to_StepResult)
|
60
|
-
class String
|
61
|
-
def to_StepResult
|
62
|
-
self
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
unless s.respond_to?(:to_VariantType)
|
67
|
-
class String
|
68
|
-
def to_VariantType
|
69
|
-
self
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
unless s.respond_to?(:valueName)
|
74
|
-
class String
|
75
|
-
def valueName
|
76
|
-
self
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# WorkflowStepResultValue_Shim provides a shim interface to the WorkflowStepResultValue class in OpenStudio 2.X when running in OpenStudio 1.X
|
82
|
-
class WorkflowStepResultValue_Shim
|
83
|
-
def initialize(name, value, type)
|
84
|
-
@name = name
|
85
|
-
@value = value
|
86
|
-
@type = type
|
87
|
-
end
|
88
|
-
|
89
|
-
attr_reader :name
|
90
|
-
|
91
|
-
attr_reader :value
|
92
|
-
|
93
|
-
def variantType
|
94
|
-
@type
|
95
|
-
end
|
96
|
-
|
97
|
-
def valueAsString
|
98
|
-
@value.to_s
|
99
|
-
end
|
100
|
-
|
101
|
-
def valueAsDouble
|
102
|
-
@value.to_f
|
103
|
-
end
|
104
|
-
|
105
|
-
def valueAsInteger
|
106
|
-
@value.to_i
|
107
|
-
end
|
108
|
-
|
109
|
-
def valueAsBoolean
|
110
|
-
@value
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# WorkflowStepResult_Shim provides a shim interface to the WorkflowStepResult class in OpenStudio 2.X when running in OpenStudio 1.X
|
115
|
-
class WorkflowStepResult_Shim
|
116
|
-
def initialize(result)
|
117
|
-
@result = result
|
118
|
-
end
|
119
|
-
|
120
|
-
def stepInitialCondition
|
121
|
-
if @result[:initial_condition]
|
122
|
-
return Optional_Shim.new(@result[:initial_condition])
|
123
|
-
end
|
124
|
-
return Optional_Shim.new(nil)
|
125
|
-
end
|
126
|
-
|
127
|
-
def stepFinalCondition
|
128
|
-
if @result[:final_condition]
|
129
|
-
return Optional_Shim.new(@result[:final_condition])
|
130
|
-
end
|
131
|
-
return Optional_Shim.new(nil)
|
132
|
-
end
|
133
|
-
|
134
|
-
def stepErrors
|
135
|
-
return @result[:step_errors]
|
136
|
-
end
|
137
|
-
|
138
|
-
def stepWarnings
|
139
|
-
return @result[:step_warnings]
|
140
|
-
end
|
141
|
-
|
142
|
-
def stepInfo
|
143
|
-
return @result[:step_info]
|
144
|
-
end
|
145
|
-
|
146
|
-
def stepValues
|
147
|
-
result = []
|
148
|
-
@result[:step_values].each do |step_value|
|
149
|
-
result << WorkflowStepResultValue_Shim.new(step_value[:name], step_value[:value], step_value[:type])
|
150
|
-
end
|
151
|
-
return result
|
152
|
-
end
|
153
|
-
|
154
|
-
def stepResult
|
155
|
-
Optional_Shim.new(@result[:step_result])
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
@result[:step_result] = step_result
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
@
|
204
|
-
@
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
#
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
#
|
258
|
-
|
259
|
-
|
260
|
-
@
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
#
|
271
|
-
# openstudio::path
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
#
|
286
|
-
# openstudio::path
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
#
|
313
|
-
# std::vector<openstudio::path>
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
result << OpenStudio.toPath('./
|
323
|
-
result << OpenStudio.toPath('
|
324
|
-
result << OpenStudio.toPath('../../
|
325
|
-
result << OpenStudio.toPath('
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
#
|
351
|
-
# boost::optional<openstudio::path> findFile(const
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
#
|
376
|
-
# std::vector<openstudio::path>
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
result << OpenStudio.toPath('
|
386
|
-
result << OpenStudio.toPath('
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
#
|
401
|
-
# boost::optional<openstudio::path> findMeasure(const
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
#
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
#
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
#
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
@workflow[:
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
end
|
1
|
+
# *******************************************************************************
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
|
+
# All rights reserved.
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
#
|
7
|
+
# (1) Redistributions of source code must retain the above copyright notice,
|
8
|
+
# this list of conditions and the following disclaimer.
|
9
|
+
#
|
10
|
+
# (2) Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
12
|
+
# and/or other materials provided with the distribution.
|
13
|
+
#
|
14
|
+
# (3) Neither the name of the copyright holder nor the names of any contributors
|
15
|
+
# may be used to endorse or promote products derived from this software without
|
16
|
+
# specific prior written permission from the respective party.
|
17
|
+
#
|
18
|
+
# (4) Other than as required in clauses (1) and (2), distributions in any form
|
19
|
+
# of modifications or other derivative works may not use the "OpenStudio"
|
20
|
+
# trademark, "OS", "os", or any other confusingly similar designation without
|
21
|
+
# specific prior written permission from Alliance for Sustainable Energy, LLC.
|
22
|
+
#
|
23
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES
|
27
|
+
# GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
28
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
29
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30
|
+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32
|
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
33
|
+
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
|
+
# *******************************************************************************
|
35
|
+
|
36
|
+
require 'pathname'
|
37
|
+
|
38
|
+
# Optional_Shim provides a wrapper that looks like an OpenStudio Optional
|
39
|
+
class Optional_Shim
|
40
|
+
def initialize(obj)
|
41
|
+
@obj = obj
|
42
|
+
end
|
43
|
+
|
44
|
+
def empty?
|
45
|
+
@obj.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def is_initialized
|
49
|
+
!@obj.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
def get
|
53
|
+
raise 'Uninitialized Optional_Shim' if @obj.nil?
|
54
|
+
@obj
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
s = ''
|
59
|
+
unless s.respond_to?(:to_StepResult)
|
60
|
+
class String
|
61
|
+
def to_StepResult
|
62
|
+
self
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
unless s.respond_to?(:to_VariantType)
|
67
|
+
class String
|
68
|
+
def to_VariantType
|
69
|
+
self
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
unless s.respond_to?(:valueName)
|
74
|
+
class String
|
75
|
+
def valueName
|
76
|
+
self
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# WorkflowStepResultValue_Shim provides a shim interface to the WorkflowStepResultValue class in OpenStudio 2.X when running in OpenStudio 1.X
|
82
|
+
class WorkflowStepResultValue_Shim
|
83
|
+
def initialize(name, value, type)
|
84
|
+
@name = name
|
85
|
+
@value = value
|
86
|
+
@type = type
|
87
|
+
end
|
88
|
+
|
89
|
+
attr_reader :name
|
90
|
+
|
91
|
+
attr_reader :value
|
92
|
+
|
93
|
+
def variantType
|
94
|
+
@type
|
95
|
+
end
|
96
|
+
|
97
|
+
def valueAsString
|
98
|
+
@value.to_s
|
99
|
+
end
|
100
|
+
|
101
|
+
def valueAsDouble
|
102
|
+
@value.to_f
|
103
|
+
end
|
104
|
+
|
105
|
+
def valueAsInteger
|
106
|
+
@value.to_i
|
107
|
+
end
|
108
|
+
|
109
|
+
def valueAsBoolean
|
110
|
+
@value
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# WorkflowStepResult_Shim provides a shim interface to the WorkflowStepResult class in OpenStudio 2.X when running in OpenStudio 1.X
|
115
|
+
class WorkflowStepResult_Shim
|
116
|
+
def initialize(result)
|
117
|
+
@result = result
|
118
|
+
end
|
119
|
+
|
120
|
+
def stepInitialCondition
|
121
|
+
if @result[:initial_condition]
|
122
|
+
return Optional_Shim.new(@result[:initial_condition])
|
123
|
+
end
|
124
|
+
return Optional_Shim.new(nil)
|
125
|
+
end
|
126
|
+
|
127
|
+
def stepFinalCondition
|
128
|
+
if @result[:final_condition]
|
129
|
+
return Optional_Shim.new(@result[:final_condition])
|
130
|
+
end
|
131
|
+
return Optional_Shim.new(nil)
|
132
|
+
end
|
133
|
+
|
134
|
+
def stepErrors
|
135
|
+
return @result[:step_errors]
|
136
|
+
end
|
137
|
+
|
138
|
+
def stepWarnings
|
139
|
+
return @result[:step_warnings]
|
140
|
+
end
|
141
|
+
|
142
|
+
def stepInfo
|
143
|
+
return @result[:step_info]
|
144
|
+
end
|
145
|
+
|
146
|
+
def stepValues
|
147
|
+
result = []
|
148
|
+
@result[:step_values].each do |step_value|
|
149
|
+
result << WorkflowStepResultValue_Shim.new(step_value[:name], step_value[:value], step_value[:type])
|
150
|
+
end
|
151
|
+
return result
|
152
|
+
end
|
153
|
+
|
154
|
+
def stepResult
|
155
|
+
Optional_Shim.new(@result[:step_result])
|
156
|
+
end
|
157
|
+
|
158
|
+
def setStepResult(step_result)
|
159
|
+
@result[:step_result] = step_result
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# WorkflowStep_Shim provides a shim interface to the WorkflowStep class in OpenStudio 2.X when running in OpenStudio 1.X
|
164
|
+
class WorkflowStep_Shim
|
165
|
+
def initialize(step)
|
166
|
+
@step = step
|
167
|
+
end
|
168
|
+
|
169
|
+
attr_reader :step
|
170
|
+
|
171
|
+
def name
|
172
|
+
if @step[:name]
|
173
|
+
Optional_Shim.new(@step[:name])
|
174
|
+
else
|
175
|
+
Optional_Shim.new(nil)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def result
|
180
|
+
if @step[:result]
|
181
|
+
Optional_Shim.new(WorkflowStepResult_Shim.new(@step[:result]))
|
182
|
+
else
|
183
|
+
Optional_Shim.new(nil)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# std::string measureDirName() const;
|
188
|
+
def measureDirName
|
189
|
+
@step[:measure_dir_name]
|
190
|
+
end
|
191
|
+
|
192
|
+
# std::map<std::string, Variant> arguments() const;
|
193
|
+
def arguments
|
194
|
+
# TODO: match C++
|
195
|
+
@step[:arguments]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# WorkflowJSON_Shim provides a shim interface to the WorkflowJSON class in OpenStudio 2.X when running in OpenStudio 1.X
|
200
|
+
class WorkflowJSON_Shim
|
201
|
+
def initialize(workflow, osw_dir)
|
202
|
+
@workflow = workflow
|
203
|
+
@osw_dir = osw_dir
|
204
|
+
@current_step_index = 0
|
205
|
+
end
|
206
|
+
|
207
|
+
# std::string string(bool includeHash=true) const;
|
208
|
+
def string
|
209
|
+
JSON.fast_generate(@workflow)
|
210
|
+
end
|
211
|
+
|
212
|
+
def timeString
|
213
|
+
::Time.now.utc.strftime('%Y%m%dT%H%M%SZ')
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns the absolute path to the directory this workflow was loaded from or saved to. Returns current working dir for new WorkflowJSON.
|
217
|
+
# openstudio::path oswDir() const;
|
218
|
+
def oswDir
|
219
|
+
OpenStudio.toPath(@osw_dir)
|
220
|
+
end
|
221
|
+
|
222
|
+
def saveAs(path)
|
223
|
+
File.open(path.to_s, 'w') do |f|
|
224
|
+
f << JSON.pretty_generate(@workflow)
|
225
|
+
# make sure data is written to the disk one way or the other
|
226
|
+
begin
|
227
|
+
f.fsync
|
228
|
+
rescue StandardError
|
229
|
+
f.flush
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# Sets the started at time.
|
235
|
+
def start
|
236
|
+
@workflow[:started_at] = timeString
|
237
|
+
end
|
238
|
+
|
239
|
+
# Get the current step index.
|
240
|
+
def currentStepIndex
|
241
|
+
@current_step_index
|
242
|
+
end
|
243
|
+
|
244
|
+
# Get the current step.
|
245
|
+
# boost::optional<WorkflowStep> currentStep() const;
|
246
|
+
def currentStep
|
247
|
+
steps = @workflow[:steps]
|
248
|
+
|
249
|
+
step = nil
|
250
|
+
if @current_step_index < steps.size
|
251
|
+
step = WorkflowStep_Shim.new(steps[@current_step_index])
|
252
|
+
end
|
253
|
+
return Optional_Shim.new(step)
|
254
|
+
end
|
255
|
+
|
256
|
+
# Increments current step, returns true if there is another step.
|
257
|
+
# bool incrementStep();
|
258
|
+
def incrementStep
|
259
|
+
@current_step_index += 1
|
260
|
+
@workflow[:current_step] = @current_step_index
|
261
|
+
|
262
|
+
if @current_step_index < @workflow[:steps].size
|
263
|
+
return true
|
264
|
+
end
|
265
|
+
|
266
|
+
return false
|
267
|
+
end
|
268
|
+
|
269
|
+
# Returns the root directory, default value is '.'. Evaluated relative to oswDir if not absolute.
|
270
|
+
# openstudio::path rootDir() const;
|
271
|
+
# openstudio::path absoluteRootDir() const;
|
272
|
+
def rootDir
|
273
|
+
if @workflow[:root_dir]
|
274
|
+
OpenStudio.toPath(@workflow[:root_dir])
|
275
|
+
else
|
276
|
+
OpenStudio.toPath(@osw_dir)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def absoluteRootDir
|
281
|
+
OpenStudio.toPath(File.absolute_path(rootDir.to_s, @osw_dir.to_s))
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns the run directory, default value is './run'. Evaluated relative to rootDir if not absolute.
|
285
|
+
# openstudio::path runDir() const;
|
286
|
+
# openstudio::path absoluteRunDir() const;
|
287
|
+
def runDir
|
288
|
+
if @workflow[:run_directory]
|
289
|
+
OpenStudio.toPath(@workflow[:run_directory])
|
290
|
+
else
|
291
|
+
OpenStudio.toPath('./run')
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def absoluteRunDir
|
296
|
+
OpenStudio.toPath(File.absolute_path(runDir.to_s, rootDir.to_s))
|
297
|
+
end
|
298
|
+
|
299
|
+
def outPath
|
300
|
+
if @workflow[:out_name]
|
301
|
+
OpenStudio.toPath(@workflow[:out_name])
|
302
|
+
else
|
303
|
+
OpenStudio.toPath('./out.osw')
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def absoluteOutPath
|
308
|
+
OpenStudio.toPath(File.absolute_path(outPath.to_s, oswDir.to_s))
|
309
|
+
end
|
310
|
+
|
311
|
+
# Returns the paths that will be searched in order for files, default value is './files/'. Evaluated relative to rootDir if not absolute.
|
312
|
+
# std::vector<openstudio::path> filePaths() const;
|
313
|
+
# std::vector<openstudio::path> absoluteFilePaths() const;
|
314
|
+
def filePaths
|
315
|
+
result = OpenStudio::PathVector.new
|
316
|
+
if @workflow[:file_paths]
|
317
|
+
@workflow[:file_paths].each do |file_path|
|
318
|
+
result << OpenStudio.toPath(file_path)
|
319
|
+
end
|
320
|
+
else
|
321
|
+
result << OpenStudio.toPath('./files')
|
322
|
+
result << OpenStudio.toPath('./weather')
|
323
|
+
result << OpenStudio.toPath('../../files')
|
324
|
+
result << OpenStudio.toPath('../../weather')
|
325
|
+
result << OpenStudio.toPath('./')
|
326
|
+
end
|
327
|
+
result
|
328
|
+
end
|
329
|
+
|
330
|
+
def absoluteFilePaths
|
331
|
+
result = OpenStudio::PathVector.new
|
332
|
+
filePaths.each do |file_path|
|
333
|
+
result << OpenStudio.toPath(File.absolute_path(file_path.to_s, rootDir.to_s))
|
334
|
+
end
|
335
|
+
result
|
336
|
+
end
|
337
|
+
|
338
|
+
def addFilePath(path)
|
339
|
+
if !@workflow[:file_paths]
|
340
|
+
@workflow[:file_paths] = []
|
341
|
+
end
|
342
|
+
@workflow[:file_paths] << path
|
343
|
+
end
|
344
|
+
|
345
|
+
def resetFilePaths
|
346
|
+
@workflow[:file_paths] = []
|
347
|
+
end
|
348
|
+
|
349
|
+
# Attempts to find a file by name, searches through filePaths in order and returns first match.
|
350
|
+
# boost::optional<openstudio::path> findFile(const openstudio::path& file);
|
351
|
+
# boost::optional<openstudio::path> findFile(const std::string& fileName);
|
352
|
+
def findFile(file)
|
353
|
+
file = file.to_s
|
354
|
+
|
355
|
+
# check if absolute and exists
|
356
|
+
if Pathname.new(file).absolute?
|
357
|
+
if File.exist?(file)
|
358
|
+
return OpenStudio::OptionalPath.new(OpenStudio.toPath(file))
|
359
|
+
end
|
360
|
+
|
361
|
+
# absolute path does not exist
|
362
|
+
return OpenStudio::OptionalPath.new
|
363
|
+
end
|
364
|
+
|
365
|
+
absoluteFilePaths.each do |file_path|
|
366
|
+
result = File.join(file_path.to_s, file)
|
367
|
+
if File.exist?(result)
|
368
|
+
return OpenStudio::OptionalPath.new(OpenStudio.toPath(result))
|
369
|
+
end
|
370
|
+
end
|
371
|
+
OpenStudio::OptionalPath.new
|
372
|
+
end
|
373
|
+
|
374
|
+
# Returns the paths that will be searched in order for measures, default value is './measures/'. Evaluated relative to rootDir if not absolute.
|
375
|
+
# std::vector<openstudio::path> measurePaths() const;
|
376
|
+
# std::vector<openstudio::path> absoluteMeasurePaths() const;
|
377
|
+
def measurePaths
|
378
|
+
result = OpenStudio::PathVector.new
|
379
|
+
if @workflow[:measure_paths]
|
380
|
+
@workflow[:measure_paths].each do |measure_path|
|
381
|
+
result << OpenStudio.toPath(measure_path)
|
382
|
+
end
|
383
|
+
else
|
384
|
+
result << OpenStudio.toPath('./measures')
|
385
|
+
result << OpenStudio.toPath('../../measures')
|
386
|
+
result << OpenStudio.toPath('./')
|
387
|
+
end
|
388
|
+
result
|
389
|
+
end
|
390
|
+
|
391
|
+
def absoluteMeasurePaths
|
392
|
+
result = OpenStudio::PathVector.new
|
393
|
+
measurePaths.each do |measure_path|
|
394
|
+
result << OpenStudio.toPath(File.absolute_path(measure_path.to_s, rootDir.to_s))
|
395
|
+
end
|
396
|
+
result
|
397
|
+
end
|
398
|
+
|
399
|
+
# Attempts to find a measure by name, searches through measurePaths in order and returns first match. */
|
400
|
+
# boost::optional<openstudio::path> findMeasure(const openstudio::path& measureDir);
|
401
|
+
# boost::optional<openstudio::path> findMeasure(const std::string& measureDirName);
|
402
|
+
def findMeasure(measureDir)
|
403
|
+
measureDir = measureDir.to_s
|
404
|
+
|
405
|
+
# check if absolute and exists
|
406
|
+
if Pathname.new(measureDir).absolute?
|
407
|
+
if File.exist?(measureDir)
|
408
|
+
return OpenStudio::OptionalPath.new(OpenStudio.toPath(measureDir))
|
409
|
+
end
|
410
|
+
|
411
|
+
# absolute path does not exist
|
412
|
+
return OpenStudio::OptionalPath.new
|
413
|
+
end
|
414
|
+
|
415
|
+
absoluteMeasurePaths.each do |measure_path|
|
416
|
+
result = File.join(measure_path.to_s, measureDir)
|
417
|
+
if File.exist?(result)
|
418
|
+
return OpenStudio::OptionalPath.new(OpenStudio.toPath(result))
|
419
|
+
end
|
420
|
+
end
|
421
|
+
OpenStudio::OptionalPath.new
|
422
|
+
end
|
423
|
+
|
424
|
+
# Returns the seed file path. Evaluated relative to filePaths if not absolute.
|
425
|
+
# boost::optional<openstudio::path> seedFile() const;
|
426
|
+
def seedFile
|
427
|
+
result = OpenStudio::OptionalPath.new
|
428
|
+
if @workflow[:seed_file]
|
429
|
+
result = OpenStudio::OptionalPath.new(OpenStudio.toPath(@workflow[:seed_file]))
|
430
|
+
end
|
431
|
+
result
|
432
|
+
end
|
433
|
+
|
434
|
+
# Returns the weather file path. Evaluated relative to filePaths if not absolute.
|
435
|
+
# boost::optional<openstudio::path> weatherFile() const;
|
436
|
+
def weatherFile
|
437
|
+
result = OpenStudio::OptionalPath.new
|
438
|
+
if @workflow[:weather_file]
|
439
|
+
result = OpenStudio::OptionalPath.new(OpenStudio.toPath(@workflow[:weather_file]))
|
440
|
+
end
|
441
|
+
result
|
442
|
+
end
|
443
|
+
|
444
|
+
# Returns the workflow steps. */
|
445
|
+
# std::vector<WorkflowStep> workflowSteps() const;
|
446
|
+
def workflowSteps
|
447
|
+
result = []
|
448
|
+
@workflow[:steps].each do |step|
|
449
|
+
result << WorkflowStep_Shim.new(step)
|
450
|
+
end
|
451
|
+
result
|
452
|
+
end
|
453
|
+
|
454
|
+
def completedStatus
|
455
|
+
if @workflow[:completed_status]
|
456
|
+
Optional_Shim.new(@workflow[:completed_status])
|
457
|
+
else
|
458
|
+
Optional_Shim.new(nil)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
def setCompletedStatus(status)
|
463
|
+
@workflow[:completed_status] = status
|
464
|
+
@workflow[:completed_at] = timeString
|
465
|
+
end
|
466
|
+
|
467
|
+
def setEplusoutErr(eplusout_err)
|
468
|
+
@workflow[:eplusout_err] = eplusout_err
|
469
|
+
end
|
470
|
+
|
471
|
+
# return empty optional
|
472
|
+
def runOptions
|
473
|
+
return Optional_Shim.new(nil)
|
474
|
+
end
|
475
|
+
end
|