Class: AddOutputDiagnostics

Inherits:
OpenStudio::Measure::EnergyPlusMeasure
  • Object
show all
Defined in:
lib/measures/AddOutputDiagnostics/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
# File 'lib/measures/AddOutputDiagnostics/measure.rb', line 37

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

  # make choice argument for output diagnostic value
  choices = OpenStudio::StringVector.new
  choices << 'DisplayAllWarnings'
  choices << 'DisplayExtraWarnings'
  choices << 'DisplayUnusedSchedules'
  choices << 'DisplayUnusedObjects'
  choices << 'DisplayAdvancedReportVariables'
  choices << 'DisplayZoneAirHeatBalanceOffBalance'
  choices << 'DoNotMirrorDetachedShading'
  choices << 'DisplayWeatherMissingDataWarnings'
  choices << 'ReportDuringWarmup'
  choices << 'ReportDetailedWarmupConvergence'
  outputDiagnostic = OpenStudio::Measure::OSArgument.makeChoiceArgument('outputDiagnostic', choices, true)
  outputDiagnostic.setDisplayName('Output Diagnostic Value')
  outputDiagnostic.setDefaultValue('DisplayExtraWarnings')
  args << outputDiagnostic

  return args
end

#descriptionObject

human readable description



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

def description
  return 'Often the eplusout.err file may request output diagnostics. This measure can be used to add this to the IDF file. Re-run your project to see the requested output.'
end

#modeler_descriptionObject

human readable description of modeling approach



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

def modeler_description
  return 'Makes Output:Diagnostics object with choice list for optional values:, DisplayAllWarnings, DisplayExtraWarnings, DisplayUnusedSchedules, DisplayUnusedObjects, DisplayAdvancedReportVariables, DisplayZoneAirHeatBalanceOffBalance, DoNotMirrorDetachedShading, DisplayWeatherMissingDataWarnings, ReportDuringWarmup, ReportDetailedWarmupConvergence.'
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/AddOutputDiagnostics/measure.rb', line 22

def name
  return 'Add Output Diagnostics'
end

#run(workspace, runner, user_arguments) ⇒ Object

define what happens when the measure is run



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

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
  outputDiagnostic = runner.getStringArgumentValue('outputDiagnostic', user_arguments)

  # reporting initial condition of model
  starting_objects = workspace.getObjectsByType('Output:Diagnostics'.to_IddObjectType)
  runner.registerInitialCondition("The model started with #{starting_objects.size} Output:Diagnostic objects.")

  # loop through existing objects to see if value of any already matches the requested value.
  object_exists = false
  starting_objects.each do |object|
    if object.getString(0).to_s == outputDiagnostic
      object_exists = true
    end
  end

  # adding a new Output:Diagnostic object of requested value if it doesn't already exist
  if object_exists == false

    # make new string
    new_diagnostic_string = "
    Output:Diagnostics,
      #{outputDiagnostic};    !- Key 1
      "

    # make new object from string
    idfObject = OpenStudio::IdfObject.load(new_diagnostic_string)
    object = idfObject.get
    wsObject = workspace.addObject(object)
    new_diagnostic = wsObject.get

    runner.registerInfo("An output diagnostic object with a value of #{new_diagnostic.getString(0)} has been added to your model.")

  else
    runner.registerAsNotApplicable("An output diagnostic object with a value of #{outputDiagnostic} already existed in your model. Nothing was changed.")
    return true

  end

  # reporting final condition of model
  finishing_objects = workspace.getObjectsByType('Output:Diagnostics'.to_IddObjectType)
  runner.registerFinalCondition("The model finished with #{finishing_objects.size} Output:Diagnostic objects.")

  return true
end