lib/measures/from_honeybee_model/measure.rb in honeybee-openstudio-2.10.4 vs lib/measures/from_honeybee_model/measure.rb in honeybee-openstudio-2.11.0
- old
+ new
@@ -58,10 +58,23 @@
# Make an argument for the honyebee model json
model_json = OpenStudio::Measure::OSArgument.makeStringArgument('model_json', true)
model_json.setDisplayName('Path to the Honeybee Model JSON file')
args << model_json
+ # Make an argument for schedule csv dir
+ schedule_csv_dir = OpenStudio::Measure::OSArgument.makeStringArgument('schedule_csv_dir', false)
+ schedule_csv_dir.setDisplayName('Directory for exported CSV Schedules')
+ schedule_csv_dir.setDescription('If set, Fixed Interval Schedules will be translated to CSV Schedules in this directory')
+ schedule_csv_dir.setDefaultValue('')
+ args << schedule_csv_dir
+
+ # Make an argument for include datetimes
+ include_datetimes = OpenStudio::Measure::OSArgument.makeBoolArgument('include_datetimes', false)
+ include_datetimes.setDisplayName('Include date time column in exported CSV Schedules')
+ include_datetimes.setDefaultValue(false)
+ args << include_datetimes
+
return args
end
# define what happens when the measure is run
def run(model, runner, user_arguments)
@@ -70,16 +83,26 @@
if !runner.validateUserArguments(arguments(model), user_arguments)
return false
end
model_json = runner.getStringArgumentValue('model_json', user_arguments)
+ schedule_csv_dir = runner.getStringArgumentValue('schedule_csv_dir', user_arguments)
+ include_datetimes = runner.getBoolArgumentValue('include_datetimes', user_arguments)
if !File.exist?(model_json)
runner.registerError("Cannot find file '#{model_json}'")
return false
end
honeybee_model = Honeybee::Model.read_from_disk(model_json)
+
+ if schedule_csv_dir && !schedule_csv_dir.empty?
+ if !Dir.exist?(schedule_csv_dir)
+ runner.registerError("Directory for exported CSV Schedules does not exist '#{schedule_csv_dir}'")
+ return false
+ end
+ honeybee_model.set_schedule_csv_dir(schedule_csv_dir, include_datetimes)
+ end
STDOUT.flush
honeybee_model.to_openstudio_model(model)
STDOUT.flush
return true