openstudio-workflow 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -72
  3. data/README.md +93 -93
  4. data/Rakefile +36 -36
  5. data/lib/openstudio-workflow.rb +65 -49
  6. data/lib/openstudio/workflow/adapters/input/local.rb +324 -301
  7. data/lib/openstudio/workflow/adapters/output/local.rb +161 -97
  8. data/lib/openstudio/workflow/adapters/output/socket.rb +107 -91
  9. data/lib/openstudio/workflow/adapters/output/web.rb +82 -66
  10. data/lib/openstudio/workflow/adapters/output_adapter.rb +163 -147
  11. data/lib/openstudio/workflow/job.rb +57 -22
  12. data/lib/openstudio/workflow/jobs/resources/monthly_report.idf +222 -222
  13. data/lib/openstudio/workflow/jobs/run_energyplus.rb +70 -54
  14. data/lib/openstudio/workflow/jobs/run_ep_measures.rb +73 -57
  15. data/lib/openstudio/workflow/jobs/run_initialization.rb +203 -171
  16. data/lib/openstudio/workflow/jobs/run_os_measures.rb +89 -73
  17. data/lib/openstudio/workflow/jobs/run_postprocess.rb +73 -57
  18. data/lib/openstudio/workflow/jobs/run_preprocess.rb +104 -80
  19. data/lib/openstudio/workflow/jobs/run_reporting_measures.rb +118 -102
  20. data/lib/openstudio/workflow/jobs/run_translation.rb +84 -68
  21. data/lib/openstudio/workflow/multi_delegator.rb +62 -46
  22. data/lib/openstudio/workflow/registry.rb +172 -137
  23. data/lib/openstudio/workflow/run.rb +328 -312
  24. data/lib/openstudio/workflow/time_logger.rb +96 -53
  25. data/lib/openstudio/workflow/util.rb +49 -14
  26. data/lib/openstudio/workflow/util/energyplus.rb +605 -570
  27. data/lib/openstudio/workflow/util/io.rb +68 -33
  28. data/lib/openstudio/workflow/util/measure.rb +650 -615
  29. data/lib/openstudio/workflow/util/model.rb +151 -100
  30. data/lib/openstudio/workflow/util/post_process.rb +238 -187
  31. data/lib/openstudio/workflow/util/weather_file.rb +143 -108
  32. data/lib/openstudio/workflow/version.rb +40 -24
  33. data/lib/openstudio/workflow_json.rb +476 -443
  34. data/lib/openstudio/workflow_runner.rb +268 -252
  35. metadata +23 -23
@@ -1,73 +1,89 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # Run any OpenStudio measures contained in the OSW
21
- class RunOpenStudioMeasures < OpenStudio::Workflow::Job
22
- # Mixin the required util modules
23
- require 'openstudio/workflow/util'
24
- include OpenStudio::Workflow::Util::Measure
25
- include OpenStudio::Workflow::Util::Model
26
-
27
- def initialize(input_adapter, output_adapter, registry, options = {})
28
- super
29
- end
30
-
31
- def perform
32
- @logger.debug "Calling #{__method__} in the #{self.class} class"
33
-
34
- # halted workflow is handled in apply_measures
35
-
36
- # set weather file
37
- if @registry[:wf] && @registry[:model]
38
- epwFile = OpenStudio::EpwFile.load(@registry[:wf])
39
- if !epwFile.empty?
40
- OpenStudio::Model::WeatherFile.setWeatherFile(@registry[:model], epwFile.get)
41
- else
42
- @logger.warn "Could not load weather file from '#{weather_full_path.to_s}'"
43
- end
44
- end
45
-
46
- # Ensure output_attributes is initialized in the registry
47
- @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
48
-
49
- # Execute the OpenStudio measures
50
- @options[:output_adapter] = @output_adapter
51
- @logger.info 'Beginning to execute OpenStudio measures.'
52
- apply_measures('ModelMeasure'.to_MeasureType, @registry, @options)
53
- @logger.info('Finished applying OpenStudio measures.')
54
-
55
- # Send the measure output attributes to the output adapter
56
- @logger.debug 'Communicating measure output attributes to the output adapter'
57
- @output_adapter.communicate_measure_attributes @registry[:output_attributes]
58
-
59
- # save the final OSM
60
- if !@options[:fast]
61
- save_osm(@registry[:model], @registry[:run_dir])
62
- end
63
-
64
- # Save the OSM if the :debug option is true
65
- return nil unless @options[:debug]
66
- @registry[:time_logger].start('Saving OSM') if @registry[:time_logger]
67
- osm_name = save_osm(@registry[:model], @registry[:root_dir])
68
- @registry[:time_logger].stop('Saving OSM') if @registry[:time_logger]
69
- @logger.debug "Saved model as #{osm_name}"
70
-
71
- nil
72
- end
73
- end
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2018, 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
+ # Run any OpenStudio measures contained in the OSW
37
+ class RunOpenStudioMeasures < OpenStudio::Workflow::Job
38
+ # Mixin the required util modules
39
+ require 'openstudio/workflow/util'
40
+ include OpenStudio::Workflow::Util::Measure
41
+ include OpenStudio::Workflow::Util::Model
42
+
43
+ def initialize(input_adapter, output_adapter, registry, options = {})
44
+ super
45
+ end
46
+
47
+ def perform
48
+ @logger.debug "Calling #{__method__} in the #{self.class} class"
49
+
50
+ # halted workflow is handled in apply_measures
51
+
52
+ # set weather file
53
+ if @registry[:wf] && @registry[:model]
54
+ epwFile = OpenStudio::EpwFile.load(@registry[:wf])
55
+ if !epwFile.empty?
56
+ OpenStudio::Model::WeatherFile.setWeatherFile(@registry[:model], epwFile.get)
57
+ else
58
+ @logger.warn "Could not load weather file from '#{@registry[:wf].to_s}'"
59
+ end
60
+ end
61
+
62
+ # Ensure output_attributes is initialized in the registry
63
+ @registry.register(:output_attributes) { {} } unless @registry[:output_attributes]
64
+
65
+ # Execute the OpenStudio measures
66
+ @options[:output_adapter] = @output_adapter
67
+ @logger.info 'Beginning to execute OpenStudio measures.'
68
+ apply_measures('ModelMeasure'.to_MeasureType, @registry, @options)
69
+ @logger.info('Finished applying OpenStudio measures.')
70
+
71
+ # Send the measure output attributes to the output adapter
72
+ @logger.debug 'Communicating measure output attributes to the output adapter'
73
+ @output_adapter.communicate_measure_attributes @registry[:output_attributes]
74
+
75
+ # save the final OSM
76
+ if !@options[:fast]
77
+ save_osm(@registry[:model], @registry[:run_dir])
78
+ end
79
+
80
+ # Save the OSM if the :debug option is true
81
+ return nil unless @options[:debug]
82
+ @registry[:time_logger].start('Saving OSM') if @registry[:time_logger]
83
+ osm_name = save_osm(@registry[:model], @registry[:root_dir])
84
+ @registry[:time_logger].stop('Saving OSM') if @registry[:time_logger]
85
+ @logger.debug "Saved model as #{osm_name}"
86
+
87
+ nil
88
+ end
89
+ end
@@ -1,57 +1,73 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # Clean up the run directory. Currently this class does nothing else, although eventually cleanup should become driven
21
- # and responsive to options
22
- class RunPostprocess < OpenStudio::Workflow::Job
23
- require 'openstudio/workflow/util/post_process'
24
- include OpenStudio::Workflow::Util::PostProcess
25
-
26
- def initialize(input_adapter, output_adapter, registry, options = {})
27
- defaults = {
28
- cleanup: true
29
- }
30
- options = defaults.merge(options)
31
- super
32
- end
33
-
34
- def perform
35
- @logger.debug "Calling #{__method__} in the #{self.class} class"
36
-
37
- # do not skip post_process if halted
38
-
39
- if !@options[:fast]
40
- @logger.info 'Gathering reports'
41
- gather_reports(@registry[:run_dir], @registry[:root_dir], @registry[:workflow_json], @logger)
42
- @logger.info 'Finished gathering reports'
43
- end
44
-
45
- if @options[:cleanup]
46
- @logger.info 'Beginning cleanup of the run directory'
47
- cleanup(@registry[:run_dir], @registry[:root_dir], @logger)
48
- @logger.info 'Finished cleanup of the run directory'
49
- else
50
- @logger.info 'Flag for cleanup in options set to false. Moving to next step.'
51
- end
52
-
53
- @logger.info 'Finished postprocess'
54
-
55
- nil
56
- end
57
- end
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2018, 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
+ # Clean up the run directory. Currently this class does nothing else, although eventually cleanup should become driven
37
+ # and responsive to options
38
+ class RunPostprocess < OpenStudio::Workflow::Job
39
+ require 'openstudio/workflow/util/post_process'
40
+ include OpenStudio::Workflow::Util::PostProcess
41
+
42
+ def initialize(input_adapter, output_adapter, registry, options = {})
43
+ defaults = {
44
+ cleanup: true
45
+ }
46
+ options = defaults.merge(options)
47
+ super
48
+ end
49
+
50
+ def perform
51
+ @logger.debug "Calling #{__method__} in the #{self.class} class"
52
+
53
+ # do not skip post_process if halted
54
+
55
+ if !@options[:fast]
56
+ @logger.info 'Gathering reports'
57
+ gather_reports(@registry[:run_dir], @registry[:root_dir], @registry[:workflow_json], @logger)
58
+ @logger.info 'Finished gathering reports'
59
+ end
60
+
61
+ if @options[:cleanup]
62
+ @logger.info 'Beginning cleanup of the run directory'
63
+ cleanup(@registry[:run_dir], @registry[:root_dir], @logger)
64
+ @logger.info 'Finished cleanup of the run directory'
65
+ else
66
+ @logger.info 'Flag for cleanup in options set to false. Moving to next step.'
67
+ end
68
+
69
+ @logger.info 'Finished postprocess'
70
+
71
+ nil
72
+ end
73
+ end
@@ -1,80 +1,104 @@
1
- ######################################################################
2
- # Copyright (c) 2008-2014, Alliance for Sustainable Energy.
3
- # All rights reserved.
4
- #
5
- # This library is free software; you can redistribute it and/or
6
- # modify it under the terms of the GNU Lesser General Public
7
- # License as published by the Free Software Foundation; either
8
- # version 2.1 of the License, or (at your option) any later version.
9
- #
10
- # This library is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- # Lesser General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU Lesser General Public
16
- # License along with this library; if not, write to the Free Software
17
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
- ######################################################################
19
-
20
- # Prepares the directory for the EnergyPlus simulation
21
- class RunPreprocess < OpenStudio::Workflow::Job
22
- require 'openstudio/workflow/util'
23
- include OpenStudio::Workflow::Util::EnergyPlus
24
- include OpenStudio::Workflow::Util::Model
25
- include OpenStudio::Workflow::Util::Measure
26
-
27
- def initialize(input_adapter, output_adapter, registry, options = {})
28
- super
29
- end
30
-
31
- def perform
32
- @logger.debug "Calling #{__method__} in the #{self.class} class"
33
-
34
- # halted workflow is handled in apply_measures
35
-
36
- # Ensure that the directory is created (but it should already be at this point)
37
- FileUtils.mkdir_p(@registry[:run_dir])
38
-
39
- # save the pre-preprocess file
40
- if !@options[:skip_energyplus_preprocess]
41
- File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') { |f| f << @registry[:model_idf].to_s }
42
- end
43
-
44
- # Add any EnergyPlus Output Requests from Reporting Measures
45
- @logger.info 'Beginning to collect output requests from Reporting measures.'
46
- energyplus_output_requests = true
47
- apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
48
- @logger.info('Finished collect output requests from Reporting measures.')
49
-
50
- # Skip the pre-processor if halted
51
- halted = @registry[:runner].halted
52
- @logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
53
- return nil if halted
54
-
55
- # Perform pre-processing on in.idf to capture logic in RunManager
56
- if !@options[:skip_energyplus_preprocess]
57
- @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
58
- energyplus_preprocess(@registry[:model_idf], @logger)
59
- @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
60
- @logger.info 'Finished preprocess job for EnergyPlus simulation'
61
- end
62
-
63
- # Save the model objects in the registry to the run directory
64
- if File.exist?("#{@registry[:run_dir]}/in.idf")
65
- # DLM: why is this here?
66
- @logger.warn 'IDF (in.idf) already exists in the run directory. Will simulate using this file'
67
- else
68
- save_idf(@registry[:model_idf], @registry[:run_dir])
69
- end
70
-
71
- # Save the generated IDF file if the :debug option is true
72
- return nil unless @options[:debug]
73
- @registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
74
- idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
75
- @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
76
- @logger.debug "Saved IDF as #{idf_name}"
77
-
78
- nil
79
- end
80
- end
1
+ # *******************************************************************************
2
+ # OpenStudio(R), Copyright (c) 2008-2018, 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
+ # Prepares the directory for the EnergyPlus simulation
37
+ class RunPreprocess < OpenStudio::Workflow::Job
38
+ require 'openstudio/workflow/util'
39
+ include OpenStudio::Workflow::Util::EnergyPlus
40
+ include OpenStudio::Workflow::Util::Model
41
+ include OpenStudio::Workflow::Util::Measure
42
+
43
+ def initialize(input_adapter, output_adapter, registry, options = {})
44
+ super
45
+ end
46
+
47
+ def perform
48
+ @logger.debug "Calling #{__method__} in the #{self.class} class"
49
+
50
+ # halted workflow is handled in apply_measures
51
+
52
+ # Ensure that the directory is created (but it should already be at this point)
53
+ FileUtils.mkdir_p(@registry[:run_dir])
54
+
55
+ # save the pre-preprocess file
56
+ if !@options[:skip_energyplus_preprocess]
57
+ File.open("#{@registry[:run_dir]}/pre-preprocess.idf", 'w') do |f|
58
+ f << @registry[:model_idf].to_s
59
+ # make sure data is written to the disk one way or the other
60
+ begin
61
+ f.fsync
62
+ rescue
63
+ f.flush
64
+ end
65
+ end
66
+ end
67
+
68
+ # Add any EnergyPlus Output Requests from Reporting Measures
69
+ @logger.info 'Beginning to collect output requests from Reporting measures.'
70
+ energyplus_output_requests = true
71
+ apply_measures('ReportingMeasure'.to_MeasureType, @registry, @options, energyplus_output_requests)
72
+ @logger.info('Finished collect output requests from Reporting measures.')
73
+
74
+ # Skip the pre-processor if halted
75
+ halted = @registry[:runner].halted
76
+ @logger.info 'Workflow halted, skipping the EnergyPlus pre-processor' if halted
77
+ return nil if halted
78
+
79
+ # Perform pre-processing on in.idf to capture logic in RunManager
80
+ if !@options[:skip_energyplus_preprocess]
81
+ @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
82
+ energyplus_preprocess(@registry[:model_idf], @logger)
83
+ @registry[:time_logger].start('Running EnergyPlus Preprocess') if @registry[:time_logger]
84
+ @logger.info 'Finished preprocess job for EnergyPlus simulation'
85
+ end
86
+
87
+ # Save the model objects in the registry to the run directory
88
+ if File.exist?("#{@registry[:run_dir]}/in.idf")
89
+ # DLM: why is this here?
90
+ @logger.warn 'IDF (in.idf) already exists in the run directory. Will simulate using this file'
91
+ else
92
+ save_idf(@registry[:model_idf], @registry[:run_dir])
93
+ end
94
+
95
+ # Save the generated IDF file if the :debug option is true
96
+ return nil unless @options[:debug]
97
+ @registry[:time_logger].start('Saving IDF') if @registry[:time_logger]
98
+ idf_name = save_idf(@registry[:model_idf], @registry[:root_dir])
99
+ @registry[:time_logger].stop('Saving IDF') if @registry[:time_logger]
100
+ @logger.debug "Saved IDF as #{idf_name}"
101
+
102
+ nil
103
+ end
104
+ end