Class: RunPeriodMultiple

Inherits:
OpenStudio::Measure::EnergyPlusMeasure
  • Object
show all
Defined in:
lib/measures/RunPeriodMultiple/measure.rb

Overview

start the measure

Instance Method Summary collapse

Instance Method Details

#arguments(workspace) ⇒ Object

define the arguments that the user will input



37
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
# File 'lib/measures/RunPeriodMultiple/measure.rb', line 37

def arguments(workspace)
  args = OpenStudio::Ruleset::OSArgumentVector.new

  # RunPeriodName
  runPeriodName = OpenStudio::Ruleset::OSArgument.makeStringArgument('runPeriodName', false)
  runPeriodName.setDisplayName('Run Period Name')
  runPeriodName.setDefaultValue('August')
  args << runPeriodName

  # BeginMonth
  beginMonth = OpenStudio::Ruleset::OSArgument.makeIntegerArgument('beginMonth', false)
  beginMonth.setDisplayName('Begin Month (integer)')
  beginMonth.setDefaultValue(8)
  args << beginMonth

  # BeginDay
  beginDay = OpenStudio::Ruleset::OSArgument.makeIntegerArgument('beginDay', false)
  beginDay.setDisplayName('Begin Day (integer)')
  beginDay.setDefaultValue(7)
  args << beginDay

  # EndMonth
  endMonth = OpenStudio::Ruleset::OSArgument.makeIntegerArgument('endMonth', false)
  endMonth.setDisplayName('End Month (integer)')
  endMonth.setDefaultValue(8)
  args << endMonth

  # EndDay
  endDay = OpenStudio::Ruleset::OSArgument.makeIntegerArgument('endDay', false)
  endDay.setDisplayName('End Day (integer)')
  endDay.setDefaultValue(8)
  args << endDay

  return args
end

#descriptionObject

human readable description



27
28
29
# File 'lib/measures/RunPeriodMultiple/measure.rb', line 27

def description
  return 'Set Multiple Run Period Object'
end

#modeler_descriptionObject

human readable description of modeling approach



32
33
34
# File 'lib/measures/RunPeriodMultiple/measure.rb', line 32

def modeler_description
  return 'Set Multiple Run Period Object'
end

#nameObject

define the name that a user will see, this method may be deprecated as the display name in PAT comes from the name field in measure.xml



22
23
24
# File 'lib/measures/RunPeriodMultiple/measure.rb', line 22

def name
  return 'Set Multiple Run Period Object'
end

#run(workspace, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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
# File 'lib/measures/RunPeriodMultiple/measure.rb', line 74

def run(workspace, runner, user_arguments)
  super(workspace, runner, user_arguments)

  # use the built-in error checking
  if !runner.validateUserArguments(arguments(workspace), user_arguments)
    return false
  end

  # assign the user inputs to variables
  runPeriodName = runner.getStringArgumentValue('runPeriodName', user_arguments)
  beginMonth = runner.getIntegerArgumentValue('beginMonth', user_arguments)
  endMonth = runner.getIntegerArgumentValue('endMonth', user_arguments)
  beginDay = runner.getIntegerArgumentValue('beginDay', user_arguments)
  endDay = runner.getIntegerArgumentValue('endDay', user_arguments)

  runPeriod = workspace.getObjectsByType('RunPeriod'.to_IddObjectType)

  runner.registerInitialCondition("The building has #{runPeriod.size} Run Period objects.")

  new_object_string = "
  RunPeriod,
    #{runPeriodName},  !- Name
    #{beginMonth},  !- Begin Month
    #{beginDay},  !- Begin Day of Month
    #{endMonth},  !- End Month
    #{endDay},  !- End Day of Month
    UseWeatherFile,  !- Day of Week for Start Day
    No,  !- Use Weather File Holidays and Special Days
    No,  !- Use Weather File Daylight Saving Period
    No,  !- Apply Weekend Holiday Rule
    Yes,  !- Use Weather File Rain Indicators
    Yes,  !- Use Weather File Snow Indicators
    1;    !- Number of Times Runperiod to be Repeated
  "

  idfObject = OpenStudio::IdfObject.load(new_object_string)
  object = idfObject.get
  wsObject = workspace.addObject(object)
  new_object = wsObject.get

  runPeriod = workspace.getObjectsByType('RunPeriod'.to_IddObjectType)
  runner.registerFinalCondition("The building now has #{runPeriod.size} Run Period objects.")

  return true
end