openstudio-analysis 1.0.2 → 1.1.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +24 -0
- data/Gemfile +1 -5
- data/LICENSE.md +1 -1
- data/Rakefile +1 -1
- data/lib/openstudio-analysis.rb +2 -1
- data/lib/openstudio/analysis.rb +23 -27
- data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +8 -14
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +24 -38
- data/lib/openstudio/analysis/translator/excel.rb +2 -2
- data/lib/openstudio/analysis/translator/workflow.rb +12 -15
- data/lib/openstudio/analysis/version.rb +4 -2
- data/lib/openstudio/analysis/workflow.rb +28 -36
- data/lib/openstudio/analysis/workflow_step.rb +67 -78
- data/lib/openstudio/helpers/hash.rb +1 -1
- data/lib/openstudio/helpers/string.rb +1 -1
- data/{spec/openstudio/server_api_spec.rb → lib/openstudio/helpers/utils.rb} +26 -28
- data/lib/openstudio/weather/epw.rb +1 -1
- data/openstudio-analysis.gemspec +17 -14
- data/update_license.rb +3 -3
- metadata +57 -194
- data/spec/files/0_1_09_no_variables.xlsx +0 -0
- data/spec/files/0_1_09_outputvars.xlsx +0 -0
- data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
- data/spec/files/0_1_09_small_list.xlsx +0 -0
- data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
- data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
- data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
- data/spec/files/0_1_10_proxy.xlsx +0 -0
- data/spec/files/0_1_10_proxy_user.xlsx +0 -0
- data/spec/files/0_1_10_template_input.xlsx +0 -0
- data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
- data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
- data/spec/files/0_2_0_template.xlsx +0 -0
- data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
- data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
- data/spec/files/0_3_0_measure_existence.xlsx +0 -0
- data/spec/files/0_3_0_outputs.xlsx +0 -0
- data/spec/files/0_3_3_short_names.xlsx +0 -0
- data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
- data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
- data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
- data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
- data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
- data/spec/files/0_4_0_pivot_test.xlsx +0 -0
- data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
- data/spec/files/analysis/examples/medium_office_example.json +0 -1674
- data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
- data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
- data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
- data/spec/files/measures/ExampleMeasure/measure.json +0 -3
- data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
- data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
- data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
- data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
- data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
- data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
- data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
- data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
- data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
- data/spec/files/measures/rotate_building/measure.rb +0 -5
- data/spec/files/measures/rotate_building/measure.xml +0 -1
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
- data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
- data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
- data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
- data/spec/files/partial_weather.epw +0 -32
- data/spec/files/partial_weather_2.epw +0 -32
- data/spec/files/small_seed.osm +0 -4622
- data/spec/files/worker_init/first_file.rb +0 -15
- data/spec/files/worker_init/second_file.sh +0 -4
- data/spec/files/workflow/analysis.osa +0 -1334
- data/spec/files/workflow/datapoint_0.osd +0 -65
- data/spec/files/workflow/datapoint_1.osd +0 -65
- data/spec/files/workflow/datapoint_2.osd +0 -65
- data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
- data/spec/integration/server_api_spec.rb +0 -83
- data/spec/openstudio/excel_spec.rb +0 -606
- data/spec/openstudio/formulation_spec.rb +0 -200
- data/spec/openstudio/hash_spec.rb +0 -56
- data/spec/openstudio/osw_spec.rb +0 -129
- data/spec/openstudio/string_spec.rb +0 -34
- data/spec/openstudio/support_files_spec.rb +0 -89
- data/spec/openstudio/weather_spec.rb +0 -80
- data/spec/openstudio/workflow_spec.rb +0 -126
- data/spec/openstudio/workflow_step_spec.rb +0 -158
- data/spec/schema/osa.json +0 -613
- data/spec/schema/osa.png +0 -0
- data/spec/schema/osd.json +0 -110
- data/spec/schema/osd.png +0 -0
- data/spec/spec_helper.rb +0 -56
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -53,8 +53,7 @@ module OpenStudio
|
|
53
53
|
@items.clear
|
54
54
|
end
|
55
55
|
|
56
|
-
# Add a measure to the workflow from a path.
|
57
|
-
# if not, the BCL gem is used to create the measure.json file.
|
56
|
+
# Add a measure to the workflow from a path. This will parse the measure.xml which must exist.
|
58
57
|
#
|
59
58
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with uni que names
|
60
59
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
@@ -69,19 +68,11 @@ module OpenStudio
|
|
69
68
|
end
|
70
69
|
|
71
70
|
if Dir.exist?(local_path_to_measure) && File.directory?(local_path_to_measure)
|
72
|
-
# Watch out for namespace conflicts (use ::BCL)
|
73
|
-
b = ::BCL::ComponentMethods.new
|
74
71
|
measure_hash = nil
|
75
|
-
|
76
|
-
measure_hash =
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
if measure_hash.nil? && File.exist?(File.join(local_path_to_measure, 'measure.json'))
|
82
|
-
measure_hash = JSON.parse(File.read(File.join(local_path_to_measure, 'measure.json')), symbolize_names: true)
|
83
|
-
elsif measure_hash.nil?
|
84
|
-
raise 'measure.json was not found and was not automatically created'
|
72
|
+
if File.exist?(File.join(local_path_to_measure, 'measure.xml'))
|
73
|
+
measure_hash = parse_measure_xml(File.join(local_path_to_measure, 'measure.xml'))
|
74
|
+
else
|
75
|
+
raise 'Could not find measure.xml'
|
85
76
|
end
|
86
77
|
|
87
78
|
add_measure(instance_name, instance_display_name, local_path_to_measure, measure_hash)
|
@@ -92,12 +83,12 @@ module OpenStudio
|
|
92
83
|
@items.last
|
93
84
|
end
|
94
85
|
|
95
|
-
# Add a measure from the custom hash format without reading the measure.rb or measure.
|
86
|
+
# Add a measure from the custom hash format without reading the measure.rb or measure.xml file
|
96
87
|
#
|
97
88
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
98
89
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
99
90
|
# @param local_path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
100
|
-
# @param measure_metadata [Hash] Format of the measure.
|
91
|
+
# @param measure_metadata [Hash] Format of the measure.xml in JSON format
|
101
92
|
# @return [Object] Returns the measure that was added as an OpenStudio::AnalysisWorkflowStep object
|
102
93
|
def add_measure(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
103
94
|
@items << OpenStudio::Analysis::WorkflowStep.from_measure_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
@@ -110,7 +101,7 @@ module OpenStudio
|
|
110
101
|
# @params instance_name [String] The name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
111
102
|
# @params instance_display_name [String] The display name of the instance. This allows for multiple measures to be added to the workflow with unique names
|
112
103
|
# @param local_path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
113
|
-
# @param measure_metadata [Hash] Format of the measure.
|
104
|
+
# @param measure_metadata [Hash] Format of the measure.xml in JSON format
|
114
105
|
# @return [Object] Returns the measure that was added as an OpenStudio::AnalysisWorkflowStep object
|
115
106
|
def add_measure_from_analysis_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
116
107
|
@items << OpenStudio::Analysis::WorkflowStep.from_analysis_hash(instance_name, instance_display_name, local_path_to_measure, measure_metadata)
|
@@ -271,29 +262,30 @@ module OpenStudio
|
|
271
262
|
|
272
263
|
o = OpenStudio::Analysis::Workflow.new
|
273
264
|
|
274
|
-
h[:workflow]
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
265
|
+
if h[:workflow]
|
266
|
+
h[:workflow].each do |wf|
|
267
|
+
puts "Adding measure #{wf[:name]}"
|
268
|
+
|
269
|
+
# Go though the defined measure paths and try and find the local measure
|
270
|
+
local_measure_dir = nil
|
271
|
+
if wf[:measure_definition_directory_local] && Dir.exist?(wf[:measure_definition_directory_local])
|
272
|
+
local_measure_dir = wf[:measure_definition_directory_local]
|
273
|
+
else
|
274
|
+
# search in the measure paths for the measure
|
275
|
+
OpenStudio::Analysis.measure_paths.each do |p|
|
276
|
+
test_dir = File.join(p, File.basename(wf[:measure_definition_directory]))
|
277
|
+
if Dir.exist?(test_dir)
|
278
|
+
local_measure_dir = test_dir
|
279
|
+
break
|
280
|
+
end
|
288
281
|
end
|
289
282
|
end
|
290
|
-
end
|
291
283
|
|
292
|
-
|
284
|
+
raise "Could not find local measure when loading workflow for #{wf[:measure_definition_class_name]} in #{File.basename(wf[:measure_definition_directory])}. You may have to add measure paths to OpenStudio::Analysis.measure_paths" unless local_measure_dir
|
293
285
|
|
294
|
-
|
286
|
+
o.add_measure_from_analysis_hash(wf[:name], wf[:display_name], local_measure_dir, wf)
|
287
|
+
end
|
295
288
|
end
|
296
|
-
|
297
289
|
o
|
298
290
|
end
|
299
291
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -60,7 +60,7 @@ module OpenStudio
|
|
60
60
|
@name = ''
|
61
61
|
@display_name = ''
|
62
62
|
|
63
|
-
# The type of item being added (
|
63
|
+
# The type of item being added (ModelMeasure, EnergyPlusMeasure, ...)
|
64
64
|
@type = nil
|
65
65
|
|
66
66
|
@measure_definition_class_name = nil
|
@@ -267,15 +267,12 @@ module OpenStudio
|
|
267
267
|
#
|
268
268
|
# @param instance_name [String] Machine name of the instance
|
269
269
|
# @param instance_display_name [String] Display name of the instance
|
270
|
-
# @param path_to_measure [String] This is the local path to the measure
|
271
|
-
# @param hash [Hash] Measure hash in the format of
|
270
|
+
# @param path_to_measure [String] This is the local path to the measure directory, relative or absolute. It is used when zipping up all the measures.
|
271
|
+
# @param hash [Hash] Measure hash in the format of a converted measure.xml hash (from the Analysis Spreadsheet project)
|
272
272
|
# @param options [Hash] Optional arguments
|
273
273
|
# @option options [Boolean] :ignore_not_found Do not raise an exception if the measure could not be found on the machine
|
274
274
|
# @return [Object] Returns the OpenStudio::Analysis::WorkflowStep
|
275
275
|
def self.from_measure_hash(instance_name, instance_display_name, path_to_measure, hash, options = {})
|
276
|
-
# TODO: Validate the hash
|
277
|
-
# TODO: validate that the measure exists?
|
278
|
-
|
279
276
|
if File.directory? path_to_measure
|
280
277
|
path_to_measure = File.join(path_to_measure, 'measure.rb')
|
281
278
|
end
|
@@ -312,40 +309,36 @@ module OpenStudio
|
|
312
309
|
# do not allow the choice variable_type
|
313
310
|
|
314
311
|
s.type = hash[:measure_type] # this is actually the measure type
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
|
319
|
-
|
320
|
-
if var_type == 'choice'
|
321
|
-
# WARN the user that the measure had a "choice data type"
|
322
|
-
var_type = 'string'
|
323
|
-
end
|
312
|
+
hash[:arguments]&.each do |arg|
|
313
|
+
# warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
|
314
|
+
var_type = arg[:variable_type] ? arg[:variable_type].downcase : arg[:value_type]
|
324
315
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
name: arg[:name],
|
329
|
-
value_type: var_type,
|
330
|
-
default_value: arg[:default_value],
|
331
|
-
value: arg[:default_value]
|
332
|
-
}
|
316
|
+
if var_type == 'choice'
|
317
|
+
# WARN the user that the measure had a "choice data type"
|
318
|
+
var_type = 'string'
|
333
319
|
end
|
320
|
+
|
321
|
+
s.arguments << {
|
322
|
+
display_name: arg[:display_name],
|
323
|
+
display_name_short: arg[:display_name_short],
|
324
|
+
name: arg[:name],
|
325
|
+
value_type: var_type,
|
326
|
+
default_value: arg[:default_value],
|
327
|
+
value: arg[:default_value]
|
328
|
+
}
|
334
329
|
end
|
335
330
|
|
336
331
|
# Load the arguments of variables, but do not make them variables. This format is more about arugments, than variables
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
}
|
348
|
-
end
|
332
|
+
hash[:variables]&.each do |variable|
|
333
|
+
# add the arguments first
|
334
|
+
s.arguments << {
|
335
|
+
display_name: variable[:argument][:display_name],
|
336
|
+
display_name_short: variable[:argument][:display_name_short],
|
337
|
+
name: variable[:argument][:name],
|
338
|
+
value_type: variable[:argument][:value_type],
|
339
|
+
default_value: variable[:argument][:default_value],
|
340
|
+
value: variable[:argument][:default_value]
|
341
|
+
}
|
349
342
|
end
|
350
343
|
|
351
344
|
s
|
@@ -356,7 +349,7 @@ module OpenStudio
|
|
356
349
|
# @param instance_name [String] Machine name of the instance
|
357
350
|
# @param instance_display_name [String] Display name of the instance
|
358
351
|
# @param path_to_measure [String] This is the local path to the measure directroy, relative or absolute. It is used when zipping up all the measures.
|
359
|
-
# @param hash [Hash] Measure hash in the format of the measure.
|
352
|
+
# @param hash [Hash] Measure hash in the format of the measure.xml converted to JSON (from the Analysis Spreadsheet project)
|
360
353
|
# @param options [Hash] Optional arguments
|
361
354
|
# @option options [Boolean] :ignore_not_found Do not raise an exception if the measure could not be found on the machine
|
362
355
|
# @return [Object] Returns the OpenStudio::Analysis::WorkflowStep
|
@@ -398,51 +391,47 @@ module OpenStudio
|
|
398
391
|
s.measure_definition_version_uuid = hash[:measure_definition_version_uuid]
|
399
392
|
|
400
393
|
s.type = hash[:measure_type] # this is actually the measure type
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
var_type = arg[:value_type]
|
405
|
-
|
406
|
-
if var_type == 'choice'
|
407
|
-
# WARN the user that the measure had a "choice data type"
|
408
|
-
var_type = 'string'
|
409
|
-
end
|
394
|
+
hash[:arguments]&.each do |arg|
|
395
|
+
# warn the user to we need to deprecate variable_type and use value_type (which is what os server uses)
|
396
|
+
var_type = arg[:value_type]
|
410
397
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
name: arg[:name],
|
415
|
-
value_type: var_type,
|
416
|
-
default_value: arg[:default_value],
|
417
|
-
value: arg[:value]
|
418
|
-
}
|
398
|
+
if var_type == 'choice'
|
399
|
+
# WARN the user that the measure had a "choice data type"
|
400
|
+
var_type = 'string'
|
419
401
|
end
|
402
|
+
|
403
|
+
s.arguments << {
|
404
|
+
display_name: arg[:display_name],
|
405
|
+
display_name_short: arg[:display_name_short],
|
406
|
+
name: arg[:name],
|
407
|
+
value_type: var_type,
|
408
|
+
default_value: arg[:default_value],
|
409
|
+
value: arg[:value]
|
410
|
+
}
|
420
411
|
end
|
421
412
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
|
445
|
-
end
|
413
|
+
hash[:variables]&.each do |variable|
|
414
|
+
# add the arguments first
|
415
|
+
s.arguments << {
|
416
|
+
display_name: variable[:argument][:display_name],
|
417
|
+
display_name_short: variable[:argument][:display_name_short],
|
418
|
+
name: variable[:argument][:name],
|
419
|
+
value_type: variable[:argument][:value_type],
|
420
|
+
default_value: variable[:argument][:default_value],
|
421
|
+
value: variable[:argument][:default_value]
|
422
|
+
}
|
423
|
+
|
424
|
+
var_options = {}
|
425
|
+
var_options[:variable_type] = variable[:variable_type]
|
426
|
+
var_options[:variable_display_name_short] = variable[:display_name_short]
|
427
|
+
var_options[:static_value] = variable[:static_value]
|
428
|
+
distribution = variable[:uncertainty_description]
|
429
|
+
distribution[:minimum] = variable[:minimum]
|
430
|
+
distribution[:mean] = distribution[:attributes].find { |a| a[:name] == 'modes' }[:value]
|
431
|
+
distribution[:maximum] = variable[:maximum]
|
432
|
+
distribution[:standard_deviation] = distribution[:attributes].find { |a| a[:name] == 'stddev' }[:value]
|
433
|
+
distribution[:step_size] = distribution[:attributes].find { |a| a[:name] == 'delta_x' }[:value]
|
434
|
+
s.make_variable(variable[:argument][:name], variable[:display_name], distribution, var_options)
|
446
435
|
end
|
447
436
|
|
448
437
|
s
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
@@ -33,36 +33,34 @@
|
|
33
33
|
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34
34
|
# *******************************************************************************
|
35
35
|
|
36
|
-
require '
|
36
|
+
require 'rexml/document'
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
context 'create a new object instance' do
|
44
|
-
before(:all) do
|
45
|
-
@api = OpenStudio::Analysis::ServerApi.new
|
46
|
-
end
|
38
|
+
def parse_measure_xml(measure_xml_filename)
|
39
|
+
measure_hash = {}
|
40
|
+
xml_to_parse = File.open(measure_xml_filename)
|
41
|
+
xml_root = REXML::Document.new(xml_to_parse).root
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
# pull out some information
|
44
|
+
measure_hash[:classname] = xml_root.elements['//measure/class_name'].text
|
45
|
+
measure_hash[:name] = xml_root.elements['//measure/name'].text
|
46
|
+
measure_hash[:display_name] = xml_root.elements['//measure/display_name'].text
|
47
|
+
measure_hash[:display_name_titleized] = measure_hash[:name].titleize
|
48
|
+
measure_hash[:measure_type] = xml_root.elements['//measure/attributes/attribute[name="Measure Type"]/value'].text
|
49
|
+
measure_hash[:description] = xml_root.elements['//measure/description'].text
|
50
|
+
measure_hash[:modeler_description] = xml_root.elements['//measure/modeler_description'].text
|
51
|
+
measure_hash[:uid] = xml_root.elements['//measure/uid'].text
|
52
|
+
measure_hash[:version_id] = xml_root.elements['//measure/version_id'].text
|
53
|
+
measure_hash[:arguments] = []
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
REXML::XPath.each(xml_root, '//measure/arguments/argument') do |arg|
|
56
|
+
measure_hash[:arguments] << {
|
57
|
+
name: arg.elements['name'].text,
|
58
|
+
display_name: arg.elements['display_name'].text,
|
59
|
+
variable_type: arg.elements['type'].text.downcase,
|
60
|
+
default_value: arg.elements['default_value'].text,
|
61
|
+
units: arg.elements['units'] ? arg.elements['units'].text : ''
|
62
|
+
}
|
59
63
|
end
|
60
64
|
|
61
|
-
|
62
|
-
it 'should have a not localhost URL' do
|
63
|
-
options = { hostname: 'http://abc.def.ghi' }
|
64
|
-
api = OpenStudio::Analysis::ServerApi.new(options)
|
65
|
-
expect(api.hostname).to eq(options[:hostname])
|
66
|
-
end
|
67
|
-
end
|
65
|
+
measure_hash
|
68
66
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# *******************************************************************************
|
2
|
-
# OpenStudio(R), Copyright (c) 2008-
|
2
|
+
# OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
|
3
3
|
# All rights reserved.
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
5
5
|
# modification, are permitted provided that the following conditions are met:
|
data/openstudio-analysis.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
lib = File.expand_path('lib', __dir__)
|
2
|
-
$LOAD_PATH.unshift
|
3
|
-
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'openstudio/analysis/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
@@ -9,26 +8,30 @@ Gem::Specification.new do |s|
|
|
9
8
|
s.platform = Gem::Platform::RUBY
|
10
9
|
s.authors = ['Nicholas Long']
|
11
10
|
s.email = ['Nicholas.Long@nrel.gov']
|
11
|
+
|
12
12
|
s.homepage = 'http://openstudio.nrel.gov'
|
13
13
|
s.summary = 'Create JSON, ZIP to communicate with OpenStudio Distributed Analysis in the Cloud'
|
14
14
|
s.description = 'Basic classes for generating the files needed for OpenStudio-Server'
|
15
15
|
s.license = 'BSD'
|
16
16
|
|
17
|
-
s.
|
18
|
-
|
19
|
-
|
20
|
-
s.
|
21
|
-
s.executables
|
22
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
s.bindir = 'exe'
|
21
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
22
|
s.require_paths = ['lib']
|
24
23
|
|
25
|
-
s.
|
24
|
+
s.required_ruby_version = '~> 2.5.0'
|
25
|
+
|
26
|
+
s.add_dependency 'bcl', '~> 0.6.1'
|
26
27
|
s.add_dependency 'dencity', '~> 0.1.0'
|
27
|
-
s.add_dependency 'faraday', '~> 0.
|
28
|
-
s.add_dependency '
|
29
|
-
s.add_dependency '
|
30
|
-
s.add_dependency 'rubyzip', '~> 1.2'
|
28
|
+
s.add_dependency 'faraday', '~> 1.0.1'
|
29
|
+
s.add_dependency 'roo', '~> 2.8.3'
|
30
|
+
s.add_dependency 'rubyzip', '~> 2.3.0'
|
31
31
|
s.add_dependency 'semantic', '~> 1.4'
|
32
32
|
|
33
|
-
s.add_development_dependency 'rake', '~>
|
33
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
34
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
35
|
+
s.add_development_dependency 'rubocop', '~> 0.54.0'
|
36
|
+
s.add_development_dependency 'rubocop-checkstyle_formatter', '~> 0.4.0'
|
34
37
|
end
|