Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question
2

Define scheduleRuleset by measure

asked 2016-03-16 05:03:07 -0600

dani71 gravatar image

updated 2016-03-16 07:11:28 -0600

Hi,

I'm defining a new scheduleRuleset and when I ask for the activeRuleIndices got an array of -1 and this error:

[utilities.time.Date] <1> Comparing Dates with improper base years

I've try using the year in the Date definition but I've got the same error.

This is the code I'm using:

scheduleRuleset = OpenStudio::Model::ScheduleRuleset.new(model)
scheduleDay     = OpenStudio::Model::ScheduleDay.new(model, 18.5)
scheduleRule    = OpenStudio::Model::ScheduleRule.new(scheduleRuleset, scheduleDay)
monthOfTheYear  = OpenStudio::MonthOfYear.new(1)
startDate       = OpenStudio::Date.new(monthOfTheYear, 1)
endDate         = OpenStudio::Date.new(monthOfTheYear, 7)

scheduleRule.setStartDate(startDate)
scheduleRule.setEndDate(endDate)
msg(f, "scheduleRule.ruleIndex: #{scheduleRule.ruleIndex}\n")
activeIndices = scheduleRuleset.getActiveRuleIndices(startDate, endDate)
msg(f, "#{activeIndices}\n")

The stdout sais 14 times:

[utilities.time.Date] <1> Comparing Dates with improper base years

And that's the output:

scheduleRule.ruleIndex: 0

[-1, -1, -1, -1, -1, -1, -1]

I've tried also defining the days like this:

startDate  = OpenStudio::Date.new(monthOfTheYear, 1, 2009)
endDate    = OpenStudio::Date.new(monthOfTheYear, 7, 2009)

But with the same result.

Is that the way to define a scheduleRuleset by measure?

How should I manage the year to avoid improper base year comparing dates?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

@dani71 please use existing tags whenever possible and always include a tag for the software you're asking about. Thanks.

MatthewSteen gravatar image MatthewSteen  ( 2016-03-16 07:10:38 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-28 15:54:15 -0600

Looks like when a ScheduleRule is created, by default, it doesn't apply to any days of the week:

OS:Schedule:Rule,
  {ea8d5c2b-8374-4bc2-a856-09ff6929d7dc}, !- Handle
  Schedule Rule 1,                        !- Name
  {3a2377af-5752-4cff-9d44-3f7959130ccc}, !- Schedule Ruleset Name
  0,                                      !- Rule Order
  {219ae30c-5d3e-40db-af25-94c7365d0a73}, !- Day Schedule Name
  ,                                       !- Apply Sunday
  ,                                       !- Apply Monday
  ,                                       !- Apply Tuesday
  ,                                       !- Apply Wednesday
  ,                                       !- Apply Thursday
  ,                                       !- Apply Friday
  ,                                       !- Apply Saturday
  ,                                       !- Apply Holiday
  DateRange,                              !- Date Specification Type
  1,                                      !- Start Month
  1,                                      !- Start Day
  1,                                      !- End Month
  7;                                      !- End Day

So you need to tell it which days of the week it applies to like this:

scheduleRule.setApplyMonday(true)
scheduleRule.setApplyTuesday(true)
scheduleRule.setApplyWednesday(true)
scheduleRule.setApplyThursday(true)
scheduleRule.setApplyFriday(true)
scheduleRule.setApplySaturday(true)
scheduleRule.setApplySunday(true)

Once you do that, the ScheduleRule looks like this:

OS:Schedule:Rule,
  {ea8d5c2b-8374-4bc2-a856-09ff6929d7dc}, !- Handle
  Schedule Rule 1,                        !- Name
  {3a2377af-5752-4cff-9d44-3f7959130ccc}, !- Schedule Ruleset Name
  0,                                      !- Rule Order
  {219ae30c-5d3e-40db-af25-94c7365d0a73}, !- Day Schedule Name
  Yes,                                    !- Apply Sunday
  Yes,                                    !- Apply Monday
  Yes,                                    !- Apply Tuesday
  Yes,                                    !- Apply Wednesday
  Yes,                                    !- Apply Thursday
  Yes,                                    !- Apply Friday
  Yes,                                    !- Apply Saturday
  ,                                       !- Apply Holiday
  DateRange,                              !- Date Specification Type
  1,                                      !- Start Month
  1,                                      !- Start Day
  1,                                      !- End Month
  7;                                      !- End Day

and the result of your code looks like this:

scheduleRule.ruleIndex: 0
[0, 0, 0, 0, 0, 0, 0]

I don't know what the deal is with the messages about comparing dates, but I've been using code almost exactly like yours on models for a while and haven't seen any simulation issues.

edit flag offensive delete link more

Comments

Thanks, works perfectly.

dani71 gravatar image dani71  ( 2016-04-06 03:36:00 -0600 )edit

Sorry it didn't work for me. I am trying to get the values of schedule that is defined using the OpenStudioApp (v2.9) and the app leaves blank the fields for the non apply days:

mapascual gravatar image mapascual  ( 2020-05-14 07:06:28 -0600 )edit

(From @mapascual) OS:Schedule:Rule, ... , !- Apply Sunday , !- Apply Monday , !- Apply Tuesday , !- Apply Wednesday , !- Apply Thursday , !- Apply Friday Yes; !- Apply Saturday

I have also followed the indicated steps and created a ScheduleRuleSet by the SDK and it didn't work

Aaron Boranian gravatar image Aaron Boranian  ( 2020-05-14 08:31:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

 

Question Tools

2 followers

Stats

Asked: 2016-03-16 05:03:07 -0600

Seen: 237 times

Last updated: May 14 '20