Class: URBANopt::Reporting::DefaultReports::QAQC

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanopt/reporting/default_reports/qaqc_flags.rb

Overview

QAQC flags for each feature

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ QAQC

QAQC class initialize quaqc attributes: :eui_reasonableness,:end_use_by_category,+:mechanical_system_part_load_efficiency, :simultaneous_heating_and_cooling , :internal_loads , :schedules, :envelope_r_value, :domestic_hot_water , :mechanical_system_efficiency , :supply_and_zone_air_temperature, :total_qaqc_flags

parameters:
  • hash - Hash - A hash containing qaqc attributes listed above.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 33

def initialize(hash = {})
  hash.delete_if { |k, v| v.nil? }
  hash = defaults.merge(hash)

  @eui_reasonableness = hash[:eui_reasonableness]
  @end_use_by_category = hash[:end_use_by_category]
  @mechanical_system_part_load_efficiency = hash[:mechanical_system_part_load_efficiency]
  @simultaneous_heating_and_cooling = hash[:simultaneous_heating_and_cooling]
  @supply_and_zone_air_temperature = hash[:supply_and_zone_air_temperature]
  @internal_loads = hash[:internal_loads]
  @schedules = hash[:schedules]
  @envelope_r_value = hash[:envelope_r_value]
  @domestic_hot_water = hash[:domestic_hot_water]
  @mechanical_system_efficiency = hash[:mechanical_system_efficiency]
  @total_qaqc_flags = hash[:total_qaqc_flags]

  # initialize class variables @@validator and @@schema
  @@validator ||= Validator.new
  @@schema ||= @@validator.schema
end

Instance Attribute Details

#domestic_hot_waterObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def domestic_hot_water
  @domestic_hot_water
end

#end_use_by_categoryObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def end_use_by_category
  @end_use_by_category
end

#envelope_r_valueObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def envelope_r_value
  @envelope_r_value
end

#eui_reasonablenessObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def eui_reasonableness
  @eui_reasonableness
end

#internal_loadsObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def internal_loads
  @internal_loads
end

#mechanical_system_efficiencyObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def mechanical_system_efficiency
  @mechanical_system_efficiency
end

#mechanical_system_part_load_efficiencyObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def mechanical_system_part_load_efficiency
  @mechanical_system_part_load_efficiency
end

#schedulesObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def schedules
  @schedules
end

#simultaneous_heating_and_coolingObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def simultaneous_heating_and_cooling
  @simultaneous_heating_and_cooling
end

#supply_and_zone_air_temperatureObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def supply_and_zone_air_temperature
  @supply_and_zone_air_temperature
end

#total_qaqc_flagsObject

Hash - Hash of flags raised by QAQC measure for this feature during this reporting period



19
20
21
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 19

def total_qaqc_flags
  @total_qaqc_flags
end

Instance Method Details

#add_qaqc_flags(other) ⇒ Object

Merges qaqc_flags objects to each other by summing up values.

parameters:

other - QAQC - An object of Program class.



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 124

def add_qaqc_flags(other)
  @eui_reasonableness = add_values(@eui_reasonableness, other.eui_reasonableness)
  @end_use_by_category = add_values(@end_use_by_category, other.end_use_by_category)
  @mechanical_system_part_load_efficiency = add_values(@mechanical_system_part_load_efficiency, other.mechanical_system_part_load_efficiency)
  @simultaneous_heating_and_cooling = add_values(@simultaneous_heating_and_cooling, other.simultaneous_heating_and_cooling)
  @supply_and_zone_air_temperature = add_values(@supply_and_zone_air_temperature, other.supply_and_zone_air_temperature)
  @internal_loads = add_values(@internal_loads, other.internal_loads)
  @schedules = add_values(@schedules, other.schedules)
  @envelope_r_value = add_values(@envelope_r_value, other.envelope_r_value)
  @domestic_hot_water = add_values(@domestic_hot_water, other.domestic_hot_water)
  @mechanical_system_efficiency = add_values(@mechanical_system_efficiency, other.mechanical_system_efficiency)
  @total_qaqc_flags = add_values(@total_qaqc_flags, other.total_qaqc_flags)
end

#add_values(existing_value, new_value) ⇒ Object

Adds up existing_value and new_values if not nill.

parameters:

existing_value - Float - A value corresponding to a qaqc_flags attribute.

new_value - Float - A value corresponding to a qaqc_flags attribute.



109
110
111
112
113
114
115
116
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 109

def add_values(existing_value, new_value) #:nodoc:
  if existing_value && new_value
    existing_value += new_value
  elsif new_value
    existing_value = new_value
  end
  return existing_value
end

#defaultsObject

Assigns default values if values do not exist.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 57

def defaults
  hash = {}

  hash[:eui_reasonableness] = nil
  hash[:end_use_by_category] = nil
  hash[:mechanical_system_part_load_efficiency] = nil
  hash[:simultaneous_heating_and_cooling] = nil
  hash[:supply_and_zone_air_temperature] = nil
  hash[:internal_loads] = nil
  hash[:schedules] = nil
  hash[:envelope_r_value] = nil
  hash[:domestic_hot_water] = nil
  hash[:mechanical_system_efficiency] = nil
  hash[:total_qaqc_flags] = nil

  return hash
end

#to_hashObject

Convert to a Hash equivalent for JSON serialization



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/urbanopt/reporting/default_reports/qaqc_flags.rb', line 78

def to_hash
  result = {}

  result[:eui_reasonableness] = @eui_reasonableness
  result[:end_use_by_category] = @end_use_by_category
  result[:mechanical_system_part_load_efficiency] = @mechanical_system_part_load_efficiency
  result[:simultaneous_heating_and_cooling] = @simultaneous_heating_and_cooling
  result[:supply_and_zone_air_temperature] = @supply_and_zone_air_temperature
  result[:internal_loads] = @internal_loads
  result[:schedules] = @schedules
  result[:envelope_r_value] = @envelope_r_value
  result[:domestic_hot_water] = @domestic_hot_water
  result[:mechanical_system_efficiency] = @mechanical_system_efficiency
  result[:total_qaqc_flags] = @total_qaqc_flags

  # validate program properties against schema
  if @@validator.validate(@@schema[:definitions][:qaqc_flags][:properties], result).any?
    raise "qaqc properties does not match schema: #{@@validator.validate(@@schema[:definitions][:qaqc_flags][:properties], result)}"
  end

  return result
end