class URBANopt::Reporting::DefaultReports::PowerDistribution
power_distributio include eletrical power distribution systems information.
Public Class Methods
new(hash = {})
click to toggle source
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.
# File lib/urbanopt/reporting/default_reports/power_distribution.rb, line 29 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] @tx_incoming_voltage = hash[:tx_incoming_voltage] @tx_outgoing_voltage = hash[:tx_outgoing_voltage] # initialize class variables @@validator and @@schema @@validator ||= Validator.new @@schema ||= @@validator.schema end
Public Instance Methods
defaults()
click to toggle source
Assigns default values if attribute values do not exist.
# File lib/urbanopt/reporting/default_reports/power_distribution.rb, line 50 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 hash[:tx_incoming_voltage] = nil hash[:tx_outgoing_voltage] = nil return hash end
merge_power_distribution()
click to toggle source
Merges muliple power distribution results together.
new_costs
- Array - An array of ConstructionCost
objects.
# File lib/urbanopt/reporting/default_reports/power_distribution.rb, line 95 def merge_power_distribution # method to be developed for any attributes to be aggregated or merged end
to_hash()
click to toggle source
Converts to a Hash equivalent for JSON serialization.
-
Exclude attributes with nil values.
-
Validate power_distribution hash properties against schema.
# File lib/urbanopt/reporting/default_reports/power_distribution.rb, line 71 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 result[:tx_incoming_voltage] = @tx_incoming_voltage if @tx_incoming_voltage result[:tx_outgoing_voltage] = @tx_outgoing_voltage if @tx_outgoing_voltage # 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