Class: URBANopt::Reporting::DefaultReports::PowerDistribution
- Inherits:
-
Object
- Object
- URBANopt::Reporting::DefaultReports::PowerDistribution
- Defined in:
- lib/urbanopt/reporting/default_reports/power_distribution.rb
Overview
power_distributio include eletrical power distribution systems information.
Instance Attribute Summary collapse
-
#max_power_kw ⇒ Object
Returns the value of attribute max_power_kw.
-
#max_reactive_power_kvar ⇒ Object
Returns the value of attribute max_reactive_power_kvar.
-
#nominal_capacity ⇒ Object
Returns the value of attribute nominal_capacity.
-
#nominal_voltage ⇒ Object
Returns the value of attribute nominal_voltage.
-
#over_voltage_hours ⇒ Object
Returns the value of attribute over_voltage_hours.
-
#reactance_resistance_ratio ⇒ Object
Returns the value of attribute reactance_resistance_ratio.
-
#under_voltage_hours ⇒ Object
Returns the value of attribute under_voltage_hours.
Instance Method Summary collapse
-
#defaults ⇒ Object
Assigns default values if attribute values do not exist.
-
#initialize(hash = {}) ⇒ PowerDistribution
constructor
PowerDistribution class initialize all power_distribution attributes:
:under_voltage_hours,:over_voltage_hours,:nominal_capacity,:reactance_resistance_ratio. -
#merge_power_distribution ⇒ Object
Merges muliple power distribution results together.
-
#to_hash ⇒ Object
Converts to a Hash equivalent for JSON serialization.
Constructor Details
#initialize(hash = {}) ⇒ PowerDistribution
PowerDistribution class initialize all power_distribution attributes: :under_voltage_hours , :over_voltage_hours, :nominal_capacity, :reactance_resistance_ratio
- parameters:
-
hash- Hash - A hash which may contain a deserialized power_distribution.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 63 def initialize(hash = {}) hash.delete_if { |k, v| v.nil? } hash = defaults.merge(hash) @under_voltage_hours = hash[:under_voltage_hours] @over_voltage_hours = hash[:over_voltage_hours] @nominal_capacity = hash[:nominal_capacity] @reactance_resistance_ratio = hash[:reactance_resistance_ratio] @nominal_voltage = hash[:nominal_voltage] # in V @max_power_kw = hash[:max_power_kw] @max_reactive_power_kvar = hash[:max_reactive_power_kvar] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema end |
Instance Attribute Details
#max_power_kw ⇒ Object
Returns the value of attribute max_power_kw.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def max_power_kw @max_power_kw end |
#max_reactive_power_kvar ⇒ Object
Returns the value of attribute max_reactive_power_kvar.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def max_reactive_power_kvar @max_reactive_power_kvar end |
#nominal_capacity ⇒ Object
Returns the value of attribute nominal_capacity.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def nominal_capacity @nominal_capacity end |
#nominal_voltage ⇒ Object
Returns the value of attribute nominal_voltage.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def nominal_voltage @nominal_voltage end |
#over_voltage_hours ⇒ Object
Returns the value of attribute over_voltage_hours.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def over_voltage_hours @over_voltage_hours end |
#reactance_resistance_ratio ⇒ Object
Returns the value of attribute reactance_resistance_ratio.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def reactance_resistance_ratio @reactance_resistance_ratio end |
#under_voltage_hours ⇒ Object
Returns the value of attribute under_voltage_hours.
53 54 55 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 53 def under_voltage_hours @under_voltage_hours end |
Instance Method Details
#defaults ⇒ Object
Assigns default values if attribute values do not exist.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 82 def defaults hash = {} hash[:under_voltage_hours] = nil hash[:over_voltage_hours] = nil hash[:nominal_capacity] = nil hash[:reactance_resistance_ratio] = nil hash[:nominal_voltage] = nil hash[:max_power_kw] = nil hash[:max_reactive_power_kvar] = nil return hash end |
#merge_power_distribution ⇒ Object
Merges muliple power distribution results together.
new_costs - Array - An array of ConstructionCost objects.
123 124 125 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 123 def merge_power_distribution # method to be developed for any attributes to be aggregated or merged end |
#to_hash ⇒ Object
Converts to a Hash equivalent for JSON serialization.
-
Exclude attributes with nil values.
-
Validate power_distribution hash properties against schema.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/urbanopt/reporting/default_reports/power_distribution.rb', line 101 def to_hash result = {} result[:under_voltage_hours] = @under_voltage_hours if @under_voltage_hours result[:over_voltage_hours] = @over_voltage_hours if @over_voltage_hours result[:nominal_capacity] = @nominal_capacity if @nominal_capacity result[:reactance_resistance_ratio] = @reactance_resistance_ratio if @reactance_resistance_ratio result[:nominal_voltage] = @nominal_voltage if @nominal_voltage result[:max_power_kw] = @max_power_kw if @max_power_kw result[:max_reactive_power_kvar] = @max_reactive_power_kvar if @max_reactive_power_kvar # validate power_distribution properties against schema if @@validator.validate(@@schema[:definitions][:PowerDistribution][:properties], result).any? raise "power_distribution properties does not match schema: #{@@validator.validate(@@schema[:definitions][:PowerDistribution][:properties], result)}" end return result end |