Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes with assigning Summer/Winter Schedule #613

Closed
Ski90Moo opened this issue Jul 20, 2023 · 9 comments · Fixed by #614
Closed

Crashes with assigning Summer/Winter Schedule #613

Ski90Moo opened this issue Jul 20, 2023 · 9 comments · Fixed by #614

Comments

@Ski90Moo
Copy link

Issue overview

Program crashes when creating a new summer/winter design day schedule for a fractional schedule type.

Current Behavior

OpenStudioApp_S08A5MKcnU

Expected Behavior

Steps to Reproduce

Possible Solution

I think there is a timing or pause error. If I select the drop down and select a "new profile based on", and then click out, such as the schedule name, and then click the add button, it works.

Details

Environment

Some additional details about your environment for this issue (if relevant):

  • Platform (Operating system, version):
  • Version of OpenStudioApplication (if using an intermediate build, include SHA):
    2023-07-20 (1)

Context

@Ski90Moo Ski90Moo added the Triage Issue needs to be assessed and labeled, further information on reported might be needed label Jul 20, 2023
@Ski90Moo
Copy link
Author

Ok, most of the time it just crashes. I'm not sure what the trick is to make it work.

@macumber
Copy link
Collaborator

Yeah, I can reproduce this. I'll see if I can figure it out.

@macumber macumber added severity - Major Bug 💥 and removed Triage Issue needs to be assessed and labeled, further information on reported might be needed labels Jul 23, 2023
@macumber
Copy link
Collaborator

@Ski90Moo would you mind trying https://github.com/openstudiocoalition/OpenStudioApplication/suites/14505073196/artifacts/820150340 to verify that the issue is fixed?

@Ski90Moo
Copy link
Author

Yes, this fixed it.

@jordibrunet
Copy link

Is there any way -or trick- to avoid this bug using OpenStudio Application 1.5 (without having to change app version)?

@jmarrec
Copy link
Collaborator

jmarrec commented Aug 29, 2023

@jordibrunet yes, create the DD Summer and/or Winter schedule via the API, then reload your model. Example

m = exampleModel  # here you would load your model instead
sch_ruleset = m.getScheduleRulesets.first
# setSummer/WinterDesignDaySchedule clones the ScheduleDay passed as argument
sch_ruleset.setSummerDesignDaySchedule(sch_ruleset.defaultDaySchedule)
sch_ruleset.setWinterDesignDaySchedule(sch_ruleset.defaultDaySchedule)

@jordibrunet
Copy link

Thanks, @jmarrec

Is there any tutorial explaining how to access to OpenStudio API?

@jmarrec
Copy link
Collaborator

jmarrec commented Aug 30, 2023

https://nrel.github.io/OpenStudio-user-documentation/getting_started/getting_started/

See "Optional - Install Ruby" to setup an interactive prompt.

You can also write a script.rb file and launch the openstudio CLI on it directly if you don't want the hassle of setting up ruby.

example script.rb, place it next to your file, assuming it's called model.osm, and that the schedule you want to add winter/summer DD schedules if not already explicitly set is called My Schedule

require 'openstudio'
include OpenStudio::Model

# Helper to load a model in one line
# It will raise if the path (or the model) isn't valid
#
# @param path [String] The path to the osm
# @return [OpenStudio::Model::Model] the resulting model.
def osload(path)
  translator = OpenStudio::OSVersion::VersionTranslator.new
  ospath = OpenStudio::Path.new(path)
  model = translator.loadModel(ospath)
  if model.empty?
      raise "Path '#{path}' is not a valid path to an OpenStudio Model"
  else
      model = model.get
  end
  return model
end

# Load
m = osload('model.osm')

# DO STUFF
sch_ruleset = m.getScheduleRulesetByName("My Schedule")
# setSummer/WinterDesignDaySchedule clones the ScheduleDay passed as argument
if sch_ruleset.isSummerDesignDayScheduleDefaulted
  sch_ruleset.setSummerDesignDaySchedule(sch_ruleset.defaultDaySchedule)
end
if sch_ruleset.isWinterDesignDayScheduleDefaulted
  sch_ruleset.setWinterDesignDaySchedule(sch_ruleset.defaultDaySchedule)
end

# Save
m.save('model.osm', true)

Usage: in a terminal (cmd/powershell on windows), cd to the directory you have put it in and do openstudio script.rb or C:\openstudioapplication-1.6.0\bin\openstudio script.rb

Then reload your OSM in the OS App.

If you want to do it for all schedule rulesets, replace the "DO STUFF" section above with a for loop

m.getScheduleRulesets.each do |sch_ruleset|
  if sch_ruleset.isSummerDesignDayScheduleDefaulted
    sch_ruleset.setSummerDesignDaySchedule(sch_ruleset.defaultDaySchedule)
  end
  if sch_ruleset.isWinterDesignDayScheduleDefaulted
    sch_ruleset.setWinterDesignDaySchedule(sch_ruleset.defaultDaySchedule)
  end
end

@jordibrunet
Copy link

Thank you very much @jmarrec !

I had some problems with "isSummerDesignDayScheduleDefaulted", but modifing the code as above works! Maybe is something related to OS 1.5.0?

# DO STUFF
sch_ruleset = model.getScheduleRulesetByName("My Schedule")
if sch_ruleset.is_initialized
  sch_ruleset = sch_ruleset.get
  default_day_schedule = sch_ruleset.defaultDaySchedule
  if sch_ruleset.isSummerDesignDayScheduleDefaulted
    sch_ruleset.setSummerDesignDaySchedule(default_day_schedule)
  end
  if sch_ruleset.isWinterDesignDayScheduleDefaulted
    sch_ruleset.setWinterDesignDaySchedule(default_day_schedule)
  end
else
  puts "Schedule 'My Schedule' not found in the model."
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants