Skip to content

Commit

Permalink
Bugfix.
Browse files Browse the repository at this point in the history
  • Loading branch information
shorowit committed Oct 5, 2024
1 parent f601761 commit 7e241ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions HPXMLtoOpenStudio/measure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<schema_version>3.1</schema_version>
<name>hpxm_lto_openstudio</name>
<uid>b1543b30-9465-45ff-ba04-1d1f85e763bc</uid>
<version_id>31166cea-42c7-4143-991c-abc8ee2ef483</version_id>
<version_modified>2024-10-05T03:49:12Z</version_modified>
<version_id>5ae03fb1-a496-41f9-8da5-4e85a23550d1</version_id>
<version_modified>2024-10-05T04:07:26Z</version_modified>
<xml_checksum>D8922A73</xml_checksum>
<class_name>HPXMLtoOpenStudio</class_name>
<display_name>HPXML to OpenStudio Translator</display_name>
Expand Down Expand Up @@ -591,7 +591,7 @@
<filename>schedules.rb</filename>
<filetype>rb</filetype>
<usage_type>resource</usage_type>
<checksum>9B7CFB4D</checksum>
<checksum>1F088023</checksum>
</file>
<file>
<filename>simcontrols.rb</filename>
Expand Down
18 changes: 9 additions & 9 deletions HPXMLtoOpenStudio/resources/schedules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -699,15 +699,15 @@ def self.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
schedule,
start_date: date_s,
end_date: date_e,
hourly_values: [0..23].map { |h| (h < period.begin_hour) || (h >= period.end_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
hourly_values: (0..23).map { |h| (h < period.begin_hour) || (h >= period.end_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
)
else # outage is at least 1 calendar day
if period.begin_hour == 0 && period.end_hour == 24 # 1 outage rule
Model.add_schedule_ruleset_rule(
schedule,
start_date: date_s,
end_date: date_e,
hourly_values: [h] * 24
hourly_values: [value] * 24
)
elsif (period.begin_hour == 0 && period.end_hour != 24) || (period.begin_hour != 0 && period.end_hour == 24) # 2 outage rules
if period.begin_hour == 0 && period.end_hour != 24
Expand All @@ -716,31 +716,31 @@ def self.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
schedule,
start_date: date_e,
end_date: date_e,
hourly_values: [0..23].map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
hourly_values: (0..23).map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
)

# all other days
Model.add_schedule_ruleset_rule(
schedule,
start_date: date_s,
end_date: OpenStudio::Date::fromDayOfYear(day_e - 1, year),
hourly_values: [h] * 24
hourly_values: [value] * 24
)
elsif period.begin_hour != 0 && period.end_hour == 24
# first day
Model.add_schedule_ruleset_rule(
schedule,
start_date: date_s,
end_date: date_s,
hourly_values: [0..23].map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
hourly_values: (0..23).map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
)

# all other days
Model.add_schedule_ruleset_rule(
schedule,
start_date: OpenStudio::Date::fromDayOfYear(day_s + 1, year),
end_date: date_e,
hourly_values: [h] * 24
hourly_values: [value] * 24
)
end
else # 3 outage rules
Expand All @@ -749,23 +749,23 @@ def self.set_unavailable_periods(schedule, sch_name, unavailable_periods, year)
schedule,
start_date: date_s,
end_date: date_s,
hourly_values: [0..23].map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
hourly_values: (0..23).map { |h| (h < period.begin_hour) ? begin_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
)

# all other days
Model.add_schedule_ruleset_rule(
schedule,
start_date: OpenStudio::Date::fromDayOfYear(day_s + 1, year),
end_date: OpenStudio::Date::fromDayOfYear(day_e - 1, year),
hourly_values: [h] * 24
hourly_values: [value] * 24
)

# last day
Model.add_schedule_ruleset_rule(
schedule,
start_date: date_e,
end_date: date_e,
hourly_values: [0..23].map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
hourly_values: (0..23).map { |h| (h >= period.end_hour) ? end_day_schedule.getValue(OpenStudio::Time.new(0, h + 1, 0, 0)) : value }
)
end
end
Expand Down

0 comments on commit 7e241ad

Please sign in to comment.