18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/hive/diagnostic/android/battery.rb', line 18
def diagnose
data = {}
battery_info = battery
result = "pass"
config.keys.each do |c|
raise InvalidParameterError.new("Battery Parameter should be any of #{battery_info.keys}") if !battery_info.has_key? c
begin
battery_info[c] = battery_info[c].to_i/10 if c == "temperature"
data[:"#{c}"] = { :value => battery_info[c], :unit => units[:"#{c}"] }
result = "fail" if battery_info[c].to_i > config[c].to_i
rescue => e
Hive.logger.error "Incorrect battery parameter => #{e}"
return self.fail("Incorrect parameter #{c} specified. Battery Parameter can be any of #{battery_info.keys}", "Battery")
end
end
if result != "fail"
self.pass("Battery", data)
else
self.fail("Battery", data)
end
end
|