Class: BTAP::Resources::Schedules::SchedulesTests

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/openstudio-standards/btap/schedules.rb

Instance Method Summary collapse

Instance Method Details

#test_create_all_schedule_typesObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# 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