lib/ekm-omnimeter/meter.rb in ekm-omnimeter-0.2.1 vs lib/ekm-omnimeter/meter.rb in ekm-omnimeter-0.2.2
- old
+ new
@@ -158,11 +158,10 @@
# iSerial v4 Spec From http://documents.ekmmetering.com/Omnimeter-Pulse-v.4-Protocol.pdf
# %w(01 52 31 02 30 30 31 31 28 29 03 13 16).map{|a| a.to_i(16).chr}.join
# Returns the correct measurement for voltage, current, and power based on the corresponding power_configuration
def calculate_measurement(m1, m2, m3)
- puts "****** #{power_configuration.inspect} #{m1}, #{m2}, #{m3}"
if power_configuration == :single_phase_2wire
m1
elsif power_configuration == :single_phase_3wire
(m1 + m2)
elsif power_configuration == :three_phase_3wire
@@ -192,11 +191,10 @@
[:kwh_data_decimal_places,
:watts_l1,
:watts_l2,
:watts_l3,
:watts_total,
- :maximum_demand,
:ct_ratio,
:pulse_1_count,
:pulse_1_ratio,
:pulse_2_count,
:pulse_2_ratio,
@@ -216,11 +214,12 @@
[:volts_l1,
:volts_l2,
:volts_l3,
:amps_l1,
:amps_l2,
- :amps_l3
+ :amps_l3,
+ :maximum_demand
].each do |k|
logger.debug "Casting #{k}"
d[k] = to_f_with_decimal_places(d[k], 1) if d.has_key?(k)
end
@@ -274,11 +273,11 @@
read_bytes = 255
logger.debug "Socket write #{request}" unless logger.nil?
response = get_remote_meter_data(request, read_bytes)
if response.nil?
- log.error "No response to request_a from meter #{address}"
+ logger.error "No response to request_a from meter #{meter_number}"
raise EkmOmnimeter, "No response from meter."
end
# Split the response string into an array and prepare a hash to store the values
a = response.split('')
@@ -368,10 +367,10 @@
request = "/?" + meter_number + "01!\r\n"
read_bytes = 255
logger.debug "Socket write #{request}" unless logger.nil?
response = get_remote_meter_data(request, read_bytes)
if response.nil?
- log.error "No response to request_a from meter #{address}"
+ logger.error "No response to request_a from meter #{meter_number}"
raise EkmOmnimeter, "No response from meter."
end
# Split the response string into an array and prepare a hash to store the values
a = response.split('')