Class: BuildingSync::Report
- Inherits:
-
Object
- Object
- BuildingSync::Report
- Defined in:
- lib/buildingsync/report.rb
Overview
Report class
Instance Attribute Summary collapse
-
#cb_measured ⇒ Object
readonly
Returns the value of attribute cb_measured.
-
#cb_modeled ⇒ Object
readonly
Returns the value of attribute cb_modeled.
-
#poms ⇒ Object
readonly
Returns the value of attribute poms.
-
#scenarios ⇒ Object
readonly
Returns the value of attribute scenarios.
-
#utilities ⇒ Object
readonly
Returns the value of attribute utilities.
Instance Method Summary collapse
-
#add_cb_modeled(id = 'Scenario-Baseline') ⇒ NilClass
add a current building modeled scenario and set the @cb_modeled attribute.
- #get_all_utility_meter_numbers ⇒ Object
- #get_all_utility_names ⇒ Object
- #get_auditor_contact_id ⇒ Object
-
#get_first_benchmark_site_eui ⇒ Object
Get the SiteEnergyUseIntensity for the benchmark scenario.
-
#get_first_cb_modeled_site_eui ⇒ Object
Get the SiteEnergyUseIntensity for the cb_modeled scenario.
-
#get_first_scenario_site_eui(scenario) ⇒ Float?
Get the AllResourceTotal/SiteEnergyUseIntensity value as a float.
- #get_newest_audit_date ⇒ Object
- #get_oldest_audit_date ⇒ Object
-
#initialize(base_xml, ns) ⇒ Report
constructor
A new instance of Report.
- #read_scenarios ⇒ Object
- #read_xml ⇒ Object
Methods included from XmlGetSet
#get_prefix, #xget_attribute_for_element, #xget_element, #xget_id, #xget_idrefs, #xget_linked_premises, #xget_name, #xget_or_create, #xget_plurals_text_value, #xget_text, #xget_text_as_bool, #xget_text_as_date, #xget_text_as_dt, #xget_text_as_float, #xget_text_as_integer, #xset_or_create, #xset_text
Methods included from Helper
#help_calculate_hours, #help_convert, #help_count_number_of_days, #help_element_class_type_check, #help_get_attribute_value, #help_get_default_schedule_set, #help_get_duration, #help_get_end_time, #help_get_end_time_sat, #help_get_end_time_sun, #help_get_end_time_weekday, #help_get_or_create, #help_get_schedule_rule_set_from_schedule, #help_get_start_time, #help_get_start_time_sat, #help_get_start_time_sun, #help_get_start_time_weekday, #help_get_text_value, #help_get_text_value_as_bool, #help_get_text_value_as_date, #help_get_text_value_as_datetime, #help_get_text_value_as_float, #help_get_text_value_as_integer, #help_get_zone_name_list, #help_load_doc, #help_print_all_schedules, #help_print_schedule, #help_write_profile
Constructor Details
#initialize(base_xml, ns) ⇒ Report
Returns a new instance of Report.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/buildingsync/report.rb', line 51 def initialize(base_xml, ns) @base_xml = base_xml @ns = ns help_element_class_type_check(base_xml, 'Report') @scenarios = [] @audit_dates = [] @utilities = [] # Special scenarios @cb_modeled = nil @cb_measured = [] @poms = [] read_xml end |
Instance Attribute Details
#cb_measured ⇒ Object (readonly)
Returns the value of attribute cb_measured.
215 216 217 |
# File 'lib/buildingsync/report.rb', line 215 def cb_measured @cb_measured end |
#cb_modeled ⇒ Object (readonly)
Returns the value of attribute cb_modeled.
215 216 217 |
# File 'lib/buildingsync/report.rb', line 215 def cb_modeled @cb_modeled end |
#poms ⇒ Object (readonly)
Returns the value of attribute poms.
215 216 217 |
# File 'lib/buildingsync/report.rb', line 215 def poms @poms end |
#scenarios ⇒ Object (readonly)
Returns the value of attribute scenarios.
215 216 217 |
# File 'lib/buildingsync/report.rb', line 215 def scenarios @scenarios end |
#utilities ⇒ Object (readonly)
Returns the value of attribute utilities.
215 216 217 |
# File 'lib/buildingsync/report.rb', line 215 def utilities @utilities end |
Instance Method Details
#add_cb_modeled(id = 'Scenario-Baseline') ⇒ NilClass
add a current building modeled scenario and set the @cb_modeled attribute
202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/buildingsync/report.rb', line 202 def add_cb_modeled(id = 'Scenario-Baseline') if @cb_modeled.nil? || @cb_modeled.empty? g = BuildingSync::Generator.new scenario_xml = g.add_scenario_to_report(@base_xml, 'CBModeled', id) scenario = BuildingSync::Scenario.new(scenario_xml, @ns) @scenarios.push(scenario) @cb_modeled = scenario OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.WorkflowMaker.add_cb_modeled', "A Current Building Modeled scenario was added (Scenario ID: #{@cb_modeled.xget_id}).") else OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.WorkflowMaker.add_cb_modeled', "A Current Building Modeled scenario already exists (Scenario ID: #{@cb_modeled.xget_id}). A new one was not added.") end end |
#get_all_utility_meter_numbers ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/buildingsync/report.rb', line 113 def get_all_utility_meter_numbers all = [] @utilities.each do |utility| all += utility.get_utility_meter_numbers end return all end |
#get_all_utility_names ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/buildingsync/report.rb', line 121 def get_all_utility_names all = [] @utilities.each do |utility| all += utility.get_utility_meter_numbers end return all end |
#get_auditor_contact_id ⇒ Object
129 130 131 |
# File 'lib/buildingsync/report.rb', line 129 def get_auditor_contact_id return xget_attribute_for_element('AuditorContactID', 'IDref') end |
#get_first_benchmark_site_eui ⇒ Object
Get the SiteEnergyUseIntensity for the benchmark scenario. Where multiple benchmark scenarios exist, the value from the first is returned
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/buildingsync/report.rb', line 152 def get_first_benchmark_site_eui eui = [] ids = [] @scenarios.each do |scenario| if scenario.benchmark? eui << get_first_scenario_site_eui(scenario) ids << scenario.xget_id end end if eui.size == 1 return eui[0] elsif eui.empty? OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_benchmark_site_eui', 'No Benchmark Scenarios exist with SiteEnergyUseIntensity defined') return nil elsif eui.size > 1 OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_benchmark_site_eui', "Multiple Benchmark Scenarios exist with SiteEnergyUseIntensity defined. Returning the value for Scenario ID: #{ids[0]}") return eui[0] end end |
#get_first_cb_modeled_site_eui ⇒ Object
Get the SiteEnergyUseIntensity for the cb_modeled scenario.
174 175 176 |
# File 'lib/buildingsync/report.rb', line 174 def get_first_cb_modeled_site_eui return get_first_scenario_site_eui(@cb_modeled) end |
#get_first_scenario_site_eui(scenario) ⇒ Float?
Get the AllResourceTotal/SiteEnergyUseIntensity value as a float. Where multiple AllResourceTotals exist with the value defined, the first is returned.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/buildingsync/report.rb', line 183 def get_first_scenario_site_eui(scenario) eui = [] scenario.get_all_resource_totals.each do |art| eui << art.xget_text_as_float('SiteEnergyUseIntensity') end if eui.size == 1 return eui[0] elsif eui.empty? OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_scenario_site_eui', "Scenario ID: #{@cb_modeled.xget_id} does not have a SiteEnergyUseIntensity defined in any of the AllResourceTotal elements.") return nil elsif eui.size > 1 OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.get_scenario_site_eui', "Scenario ID: #{@cb_modeled.xget_id} has more thant 1 (#{eui.size}) SiteEnergyUseIntensity defined in the AllResourceTotal elements. Returning the first.") return eui[0] end end |
#get_newest_audit_date ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/buildingsync/report.rb', line 133 def get_newest_audit_date dates = [] @audit_dates.each do |date| dates << date.xget_text_as_date('Date') end return dates.max end |
#get_oldest_audit_date ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/buildingsync/report.rb', line 141 def get_oldest_audit_date dates = [] @audit_dates.each do |date| dates << date.xget_text_as_date('Date') end return dates.min end |
#read_scenarios ⇒ Object
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 |
# File 'lib/buildingsync/report.rb', line 82 def read_scenarios # Scenarios - create and checks scenarios_xml_temp = @base_xml.get_elements("#{@ns}:Scenarios/#{@ns}:Scenario") cb_modeled = [] scenarios_xml_temp&.each do |scenario_xml| if scenario_xml.is_a? REXML::Element sc = BuildingSync::Scenario.new(scenario_xml, @ns) @scenarios.push(sc) cb_modeled << sc if sc.cb_modeled? @cb_measured << sc if sc.cb_measured? @poms << sc if sc.pom? end end # -- Issue warnings for undesirable situations if @scenarios.empty? OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.read_xml', 'No Scenario elements found') end # -- Logging for Scenarios if cb_modeled.empty? OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.read_xml', 'A Current Building Modeled Scenario is required.') elsif cb_modeled.size > 1 @cb_modeled = cb_modeled[0] OpenStudio.logFree(OpenStudio::Warn, 'BuildingSync.Facility.read_xml', "Only 1 Current Building Modeled Scenario is supported. Using Scenario with ID: #{@cb_modeled.xget_id}") else @cb_modeled = cb_modeled[0] OpenStudio.logFree(OpenStudio::Info, 'BuildingSync.Facility.read_xml', "Current Building Modeled Scenario has ID: #{@cb_modeled.xget_id}") end end |
#read_xml ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/buildingsync/report.rb', line 68 def read_xml read_scenarios # Audit dates @base_xml.elements.each("#{@ns}:AuditDates/#{@ns}:AuditDate") do |audit_date| @audit_dates << BuildingSync::AuditDate.new(audit_date, @ns) end # Utilities @base_xml.elements.each("#{@ns}:Utilities/#{@ns}:Utility") do |utility| @utilities << BuildingSync::Utility.new(utility, @ns) end end |