Class: Hive::Diagnostic::Android::Battery

Inherits:
Hive::Diagnostic show all
Defined in:
lib/hive/diagnostic/android/battery.rb

Instance Method Summary collapse

Instance Method Details

#batteryObject



7
8
9
# File 'lib/hive/diagnostic/android/battery.rb', line 7

def battery
  self.device_api.battery_info
end

#diagnoseObject



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

#repair(result) ⇒ Object



42
43
44
# File 'lib/hive/diagnostic/android/battery.rb', line 42

def repair(result)
  self.fail("Unplug device from hive")
end

#unitsObject



11
12
13
14
15
16
# File 'lib/hive/diagnostic/android/battery.rb', line 11

def units
  {
    :temperature => "ºC",
    :voltage => "mV"
  }
end