Class: URBANopt::Reporting::DefaultReports::ThermalStorage

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

Overview

Ice Thermal Storage Systems

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ ThermalStorage



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 51

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

  @its_size = hash[:its_size]
  @ptes_size = hash[:ptes_size]

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

  # initialize @@logger
  @@logger ||= URBANopt::Reporting::DefaultReports.logger
end

Instance Attribute Details

#its_sizeObject

Float - Total ice storage capacity on central plant loop in kWh



45
46
47
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 45

def its_size
  @its_size
end

#ptes_sizeObject

Float - Total ice storage capacity distributed to packaged systems in kWh



49
50
51
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 49

def ptes_size
  @ptes_size
end

Class Method Details

.add_values(existing_value, new_value) ⇒ Object

Add up old and new values



90
91
92
93
94
95
96
97
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 90

def self.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

.merge_thermal_storage(existing_tes, new_tes) ⇒ Object

Merge thermal storage



102
103
104
105
106
107
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 102

def self.merge_thermal_storage(existing_tes, new_tes)
  existing_tes.its_size = add_values(existing_tes.its_size, new_tes.its_size)
  existing_tes.ptes_size = add_values(existing_tes.ptes_size, new_tes.ptes_size)

  return existing_tes
end

Instance Method Details

#defaultsObject

Assigns default values if attribute values do not exist.



68
69
70
71
72
73
74
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 68

def defaults
  hash = {}
  hash[:its_size] = nil
  hash[:ptes_size] = nil

  return hash
end

#to_hashObject

Convert to hash equivalent for JSON serialization



79
80
81
82
83
84
85
# File 'lib/urbanopt/reporting/default_reports/thermal_storage.rb', line 79

def to_hash
  result = {}
  result[:its_size] = @its_size if @its_size
  result[:ptes_size] = @ptes_size if @ptes_size

  return result
end