class BTAP::Resources::Schedules::SchedulesTests

Public Instance Methods

test_create_all_schedule_types() click to toggle source
# File lib/openstudio-standards/btap/schedules.rb, line 38
def test_create_all_schedule_types()
  model = OpenStudio::Model::Model.new()
  schedule_struct =
    [
    [
      #Start and stop date of schedule in gregorian format.
      ["Jan-01","May-31"],
      # Days of the week that it applies
      ["M","T","W","TH","F","S","SN"],# Days of the week are "M","T","W","TH","F","S","SN", or wild cards for weekend and weekdays "WKD","WKE"
      # value up until the hour and minute for each block.
      [
        [ "9:00",  13.0], #time, value_until_this_time
        [ "17:00", 21.0]  #time, value_until_this_time
      ]
    ],
    [
      #Start and stop date of schedule in gregorian format.
      ["Jun-01","Sep-30"],
      # Days of the week that it applies
      ["M","T","W","TH","F","S","SN"], # Days of the week are "M","T","W","TH","F","S","SN", or wild cards for weekend and weekdays "WKD","WKE"
      # value up until the hour and minute for each block.
      [
        ["24:00", 13.0]  #time, value_until_this_time
      ]
    ],
    [
      #Period for schedule in gregorian format.
      [ "Oct-01","Dec-31"],
      # Days of the week that it applies
      ["M","T","W","TH","F","S","SN"], # Days of the week are "M","T","W","TH","F","S","SN", or wild cards for weekend and weekdays "WKD","WKE"
      # value up until the hour and minute for each block.
      [
        [ "9:00",  1], #time, value_until_this_time
        [ "17:00", 2]  #time, value_until_this_time
      ]
    ]
  ]


  temperature_array =
    [
    Array.new(24){21}, #Weekday
    Array.new(24){21}, #Sat
    Array.new(24){21}, #Sun
  ]

  fraction_array =
    [
    Array.new(24){0.5}, #Weekday
    Array.new(24){0.5}, #Sat
    Array.new(24){0.5}, #Sun
  ]

  on_off_array =
    [
    Array.new(24){1}, #Weekday
    Array.new(24){0}, #Sat
    Array.new(24){0}, #Sun
  ]
  #Check to see if the objects were really created.
  temperature_ruleset_sched = BTAP::Resources::Schedules::create_annual_ruleset_schedule(model,"test schedule ruleset","TEMPERATURE",temperature_array)
  assert( !(temperature_ruleset_sched.to_ScheduleRuleset.empty?))

  BTAP::Resources::Schedules::modify_schedule!(model, temperature_ruleset_sched, 0.90 , "*")
  temperature_ruleset_sched.scheduleRules.each do |week_rule|
    week_rule.daySchedule().values.each do |value|
      assert_in_delta(21.0 * 0.90,value,0.000001)
    end
  end
  fraction_ruleset_sched = BTAP::Resources::Schedules::create_annual_ruleset_schedule(model,"test schedule ruleset","FRACTION",fraction_array)
  assert( !(fraction_ruleset_sched.to_ScheduleRuleset.empty?))

  on_off_ruleset_sched = BTAP::Resources::Schedules::create_annual_ruleset_schedule(model,"test schedule ruleset","ON_OFF",on_off_array)
  assert( !(on_off_ruleset_sched.to_ScheduleRuleset.empty?))

  constant_ruleset_sched = BTAP::Resources::Schedules::create_annual_constant_ruleset_schedule(model,"test constant schedule","TEMPERATURE",21)
  assert( !(constant_ruleset_sched.to_ScheduleRuleset.empty?))
  dual_setpoint_schedule = BTAP::Resources::Schedules::create_annual_thermostat_setpoint_dual_setpoint(model,"dual setpoint test",constant_ruleset_sched,constant_ruleset_sched)
  assert( !(dual_setpoint_schedule.to_ThermostatSetpointDualSetpoint.empty?))

  detailed_ruleset_schedule = BTAP::Resources::Schedules::create_annual_ruleset_schedule_detailed(model,"test detailed schedule","FRACTION",schedule_struct  )
  assert( !(detailed_ruleset_schedule.to_ScheduleRuleset.empty?))

end