openstudio-analysis 1.0.2 → 1.0.3

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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +5 -0
  5. data/Gemfile +1 -5
  6. data/LICENSE.md +1 -1
  7. data/Rakefile +1 -1
  8. data/lib/openstudio-analysis.rb +1 -1
  9. data/lib/openstudio/analysis.rb +23 -27
  10. data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
  11. data/lib/openstudio/analysis/formulation.rb +1 -1
  12. data/lib/openstudio/analysis/server_api.rb +8 -14
  13. data/lib/openstudio/analysis/support_files.rb +1 -1
  14. data/lib/openstudio/analysis/translator/datapoints.rb +1 -1
  15. data/lib/openstudio/analysis/translator/excel.rb +2 -2
  16. data/lib/openstudio/analysis/translator/workflow.rb +8 -12
  17. data/lib/openstudio/analysis/version.rb +2 -2
  18. data/lib/openstudio/analysis/workflow.rb +1 -1
  19. data/lib/openstudio/analysis/workflow_step.rb +63 -71
  20. data/lib/openstudio/helpers/hash.rb +1 -1
  21. data/lib/openstudio/helpers/string.rb +1 -1
  22. data/lib/openstudio/weather/epw.rb +1 -1
  23. data/openstudio-analysis.gemspec +17 -13
  24. data/update_license.rb +3 -3
  25. metadata +57 -181
  26. data/spec/files/0_1_09_no_variables.xlsx +0 -0
  27. data/spec/files/0_1_09_outputvars.xlsx +0 -0
  28. data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
  29. data/spec/files/0_1_09_small_list.xlsx +0 -0
  30. data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
  31. data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
  32. data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
  33. data/spec/files/0_1_10_proxy.xlsx +0 -0
  34. data/spec/files/0_1_10_proxy_user.xlsx +0 -0
  35. data/spec/files/0_1_10_template_input.xlsx +0 -0
  36. data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
  37. data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
  38. data/spec/files/0_2_0_template.xlsx +0 -0
  39. data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
  40. data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
  41. data/spec/files/0_3_0_measure_existence.xlsx +0 -0
  42. data/spec/files/0_3_0_outputs.xlsx +0 -0
  43. data/spec/files/0_3_3_short_names.xlsx +0 -0
  44. data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
  45. data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
  46. data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
  47. data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
  48. data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
  49. data/spec/files/0_4_0_pivot_test.xlsx +0 -0
  50. data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
  51. data/spec/files/analysis/examples/medium_office_example.json +0 -1674
  52. data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
  53. data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
  54. data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
  55. data/spec/files/measures/ExampleMeasure/measure.json +0 -3
  56. data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
  57. data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
  58. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
  59. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
  60. data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
  61. data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
  62. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
  63. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
  64. data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
  65. data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
  66. data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
  67. data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
  68. data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
  69. data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
  70. data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
  71. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
  72. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
  73. data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
  74. data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
  75. data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
  76. data/spec/files/measures/rotate_building/measure.rb +0 -5
  77. data/spec/files/measures/rotate_building/measure.xml +0 -1
  78. data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
  79. data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
  80. data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
  81. data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
  82. data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
  83. data/spec/files/partial_weather.epw +0 -32
  84. data/spec/files/partial_weather_2.epw +0 -32
  85. data/spec/files/small_seed.osm +0 -4622
  86. data/spec/files/worker_init/first_file.rb +0 -15
  87. data/spec/files/worker_init/second_file.sh +0 -4
  88. data/spec/files/workflow/analysis.osa +0 -1334
  89. data/spec/files/workflow/datapoint_0.osd +0 -65
  90. data/spec/files/workflow/datapoint_1.osd +0 -65
  91. data/spec/files/workflow/datapoint_2.osd +0 -65
  92. data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
  93. data/spec/integration/server_api_spec.rb +0 -83
  94. data/spec/openstudio/excel_spec.rb +0 -606
  95. data/spec/openstudio/formulation_spec.rb +0 -200
  96. data/spec/openstudio/hash_spec.rb +0 -56
  97. data/spec/openstudio/osw_spec.rb +0 -129
  98. data/spec/openstudio/server_api_spec.rb +0 -68
  99. data/spec/openstudio/string_spec.rb +0 -34
  100. data/spec/openstudio/support_files_spec.rb +0 -89
  101. data/spec/openstudio/weather_spec.rb +0 -80
  102. data/spec/openstudio/workflow_spec.rb +0 -126
  103. data/spec/openstudio/workflow_step_spec.rb +0 -158
  104. data/spec/schema/osa.json +0 -613
  105. data/spec/schema/osa.png +0 -0
  106. data/spec/schema/osd.json +0 -110
  107. data/spec/schema/osd.png +0 -0
  108. data/spec/spec_helper.rb +0 -56
@@ -1,34 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2019, 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
- # *******************************************************************************
@@ -1,89 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2019, 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_relative './../spec_helper'
37
-
38
- describe OpenStudio::Analysis::SupportFiles do
39
- before :all do
40
- @s = OpenStudio::Analysis::SupportFiles.new
41
- expect(@s).to be_a OpenStudio::Analysis::SupportFiles
42
- end
43
-
44
- it 'should add files' do
45
- f = 'spec/files/worker_init/first_file.rb'
46
- @s.add(f)
47
-
48
- expect(@s.size).to eq 1
49
- expect(@s.files.first[:file]).to eq f
50
-
51
- # add some other items
52
- @s.add('spec/files/worker_init/second_file.sh')
53
-
54
- expect(@s.size).to eq 2
55
- @s.each do |f|
56
- expect(f).to_not be nil
57
- end
58
- end
59
-
60
- it 'should remove existing items' do
61
- f = 'spec/files/worker_init/second_file.sh'
62
- @s.add(f)
63
-
64
- @s.clear
65
- expect(@s.size).to eq 0
66
- end
67
-
68
- it 'should only add existing files' do
69
- f = 'spec/files/worker_init/second_file.sh'
70
- @s.add(f)
71
- @s.add(f)
72
-
73
- expect(@s.size).to eq 1
74
-
75
- f = 'non-existent.rb'
76
- expect { @s.add(f) }.to raise_error /Path or file does not exist and cannot be added.*/
77
- end
78
-
79
- it 'should add metadata data' do
80
- end
81
-
82
- it 'should add a directory' do
83
- @s.clear
84
- @s.add_files('spec/files/measures/**/*.rb', d: 'new')
85
-
86
- expect(@s.size).to eq 10
87
- expect(@s[0][:metadata][:d]).to eq 'new'
88
- end
89
- end
@@ -1,80 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2019, 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 'spec_helper'
37
-
38
- describe OpenStudio::Weather::Epw do
39
- before :all do
40
- @s = OpenStudio::Analysis::SupportFiles.new
41
- expect(@s).to be_a OpenStudio::Analysis::SupportFiles
42
- end
43
-
44
- it 'should process the header of a weather file' do
45
- epw = OpenStudio::Weather::Epw.load('spec/files/partial_weather.epw')
46
- expect(epw.valid?).to be true
47
- expect(epw.city).to eq 'Denver Intl Ap'
48
- expect(epw.state).to eq 'CO'
49
- expect(epw.country).to eq 'USA'
50
- expect(epw.data_type).to eq 'TMY3'
51
- expect(epw.wmo).to eq 725650
52
- expect(epw.lat).to eq 39.83
53
- expect(epw.lon).to eq -104.65
54
- expect(epw.gmt).to eq -7.0
55
- expect(epw.elevation).to eq 1650.0
56
-
57
- expect(epw.header_data.size).to eq 7
58
- expect(epw.weather_data.size).to eq 24
59
- end
60
-
61
- it 'should read and write the weather file' do
62
- o = 'spec/files/partial_weather.epw'
63
- epw = OpenStudio::Weather::Epw.load(o)
64
- f = 'spec/files/export/weather/weather_out.epw'
65
- File.delete(f) if File.exist? f
66
- expect(epw.save_as(f)).to eq true
67
- expect(File.exist?(f)).to eq true
68
- expect(File.size(o)).to eq File.size(f)
69
- end
70
-
71
- it 'should append weather data' do
72
- o = 'spec/files/partial_weather.epw'
73
- epw = OpenStudio::Weather::Epw.load(o)
74
-
75
- epw.append_weather_data(o)
76
-
77
- f = 'spec/files/export/weather/weather_out_appended.epw'
78
- epw.save_as(f)
79
- end
80
- end
@@ -1,126 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2019, 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 'spec_helper'
37
-
38
- describe OpenStudio::Analysis::Workflow do
39
- before :all do
40
- @w = OpenStudio::Analysis::Workflow.new
41
- end
42
-
43
- it 'should create a workflow' do
44
- expect(@w).not_to be nil
45
- expect(@w).to be_a OpenStudio::Analysis::Workflow
46
- end
47
-
48
- it 'should add a measure' do
49
- p = 'spec/files/measures/IncreaseInsulationRValueForRoofs'
50
- expect(@w.add_measure_from_path('insulation', 'Increase Insulation', p)).to be_an OpenStudio::Analysis::WorkflowStep
51
-
52
- p = 'spec/files/measures/ActualMeasureNoJson'
53
- FileUtils.remove "#{p}/measure.json" if File.exist? "#{p}/measure.json"
54
- m = @w.add_measure_from_path('a_measure', 'Actual Measure', p)
55
- expect(m).to be_a OpenStudio::Analysis::WorkflowStep
56
- expect(m.measure_definition_class_name).to eq 'RotateBuilding'
57
- end
58
-
59
- it 'should fix the path of the measure' do
60
- p = 'spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb'
61
- m = @w.add_measure_from_path('insulation', 'Increase Insulation', p)
62
- expect(m).to be_an OpenStudio::Analysis::WorkflowStep
63
- expect(m.measure_definition_directory).to eq './measures/IncreaseInsulationRValueForRoofs'
64
- expect(m.measure_definition_directory_local).to eq 'spec/files/measures/IncreaseInsulationRValueForRoofs'
65
- end
66
-
67
- it 'should clear out a workflow' do
68
- p = 'spec/files/measures/SetThermostatSchedules'
69
- @w.add_measure_from_path('thermostat', 'thermostat', p)
70
- @w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
71
-
72
- expect(@w.items.size).to be > 1
73
- @w.clear
74
- expect(@w.items.size).to eq 0
75
-
76
- @w.add_measure_from_path('thermostat', 'thermostat', p)
77
- @w.add_measure_from_path('thermostat 2', 'thermostat 2', p)
78
- expect(@w.items.size).to eq 2
79
- end
80
-
81
- it 'should find a workflow step' do
82
- @w.clear
83
-
84
- p = 'spec/files/measures/SetThermostatSchedules'
85
- @w.add_measure_from_path('thermostat', 'thermostat', p)
86
- @w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
87
-
88
- m = @w.find_measure('thermostat_2')
89
- expect(m).not_to be nil
90
- expect(m).to be_a OpenStudio::Analysis::WorkflowStep
91
- expect(m.name).to eq 'thermostat_2'
92
- end
93
-
94
- it 'should find a workflow step and make a variable' do
95
- @w.clear
96
-
97
- p = 'spec/files/measures/SetThermostatSchedules'
98
- @w.add_measure_from_path('thermostat', 'thermostat', p)
99
- @w.add_measure_from_path('thermostat_2', 'thermostat 2', p)
100
-
101
- m = @w.find_measure('thermostat_2')
102
- expect(m.argument_names).to eq ['__SKIP__', 'zones', 'cooling_sch', 'heating_sch', 'material_cost']
103
-
104
- d = {
105
- type: 'uniform',
106
- minimum: 5,
107
- maximum: 7,
108
- mean: 6.2
109
- }
110
- m.make_variable('cooling_sch', 'Change the cooling schedule', d)
111
-
112
- d = {
113
- type: 'uniform',
114
- minimum: 5,
115
- maximum: 7,
116
- mean: 6.2
117
- }
118
- m.make_variable('heating_sch', 'Change the heating schedule', d)
119
-
120
- expect(@w.measures.size).to eq 2
121
- expect(@w.items.size).to eq 2
122
- expect(@w.items.size).to eq 2
123
-
124
- expect(@w.all_variables.size).to eq 2
125
- end
126
- end
@@ -1,158 +0,0 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2019, 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 'spec_helper'
37
-
38
- describe OpenStudio::Analysis::WorkflowStep do
39
- it 'should create a workflow' do
40
- s = OpenStudio::Analysis::WorkflowStep.new
41
- expect(s).not_to be nil
42
- expect(s).to be_a OpenStudio::Analysis::WorkflowStep
43
- end
44
-
45
- it 'should add a measure' do
46
- h = 'spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json'
47
- s = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
48
- 'my_instance',
49
- 'my instance display name',
50
- h,
51
- JSON.parse(File.read(h), symbolize_names: true)
52
- )
53
- puts s
54
- end
55
-
56
- it 'should tag a discrete variable' do
57
- h = 'spec/files/measures/SetThermostatSchedules/measure.json'
58
- measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
59
- 'my_instance',
60
- 'my instance display name',
61
- h,
62
- JSON.parse(File.read(h), symbolize_names: true)
63
- )
64
-
65
- expect(measure.name).to eq 'my_instance'
66
- v = {
67
- type: 'discrete',
68
- minimum: 'low string',
69
- maximum: 'high string',
70
- mean: 'middle string',
71
- values: ['a', 'b', 'c', 'd'],
72
- weights: [0.25, 0.25, 0.25, 0.25]
73
- }
74
- r = measure.make_variable('cooling_sch', 'my variable', v)
75
- expect(r).to eq true
76
- end
77
-
78
- it 'should tag a continuous variable' do
79
- h = 'spec/files/measures/SetThermostatSchedules/measure.json'
80
- measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
81
- 'my_instance',
82
- 'my instance display name',
83
- h,
84
- JSON.parse(File.read(h), symbolize_names: true)
85
- )
86
-
87
- expect(measure.name).to eq 'my_instance'
88
- v = {
89
- type: 'triangle',
90
- minimum: 0.5,
91
- maximum: 20,
92
- mean: 10
93
- }
94
- o = {
95
- static_value: 24601
96
- }
97
- r = measure.make_variable('cooling_sch', 'my variable', v, o)
98
-
99
- h = measure.to_hash
100
-
101
- expect(h[:variables].first[:static_value]).to eq 24601
102
- expect(h[:variables].first.key?(:step_size)).to eq false
103
-
104
- expect(r).to eq true
105
- end
106
-
107
- it 'should tag a normal continuous variable' do
108
- h = 'spec/files/measures/SetThermostatSchedules/measure.json'
109
- measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
110
- 'my_instance',
111
- 'my instance display name',
112
- h,
113
- JSON.parse(File.read(h), symbolize_names: true)
114
- )
115
-
116
- expect(measure.name).to eq 'my_instance'
117
- v = {
118
- type: 'normal',
119
- minimum: 0.5,
120
- maximum: 20,
121
- mean: 10,
122
- standard_deviation: 2
123
- }
124
- r = measure.make_variable('cooling_sch', 'my variable', v)
125
-
126
- h = measure.to_hash
127
-
128
- expect(h[:variables].first.key?(:step_size)).to eq false
129
-
130
- expect(r).to eq true
131
- end
132
-
133
- it 'should tag a uniform variable' do
134
- h = 'spec/files/measures/SetThermostatSchedules/measure.json'
135
- measure = OpenStudio::Analysis::WorkflowStep.from_measure_hash(
136
- 'my_instance',
137
- 'my instance display name',
138
- h,
139
- JSON.parse(File.read(h), symbolize_names: true)
140
- )
141
-
142
- expect(measure.name).to eq 'my_instance'
143
- v = {
144
- type: 'uniform',
145
- minimum: 0.5,
146
- maximum: 20,
147
- mean: 10
148
- }
149
- r = measure.make_variable('cooling_sch', 'my variable', v)
150
-
151
- h = measure.to_hash
152
-
153
- # puts JSON.pretty_generate(h)
154
- expect(h[:variables].first.key?(:step_size)).to eq false
155
-
156
- expect(r).to eq true
157
- end
158
- end