Class: AmdgpuFan::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/amdgpu_fan/watcher.rb

Overview

Keep track of stats over time.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amdgpu_service) ⇒ Watcher

Returns a new instance of Watcher.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/amdgpu_fan/watcher.rb', line 13

def initialize(amdgpu_service)
  @amdgpu_service = amdgpu_service
  @num_measurements = 0

  @core_clock = StatSet.new 'MHz'
  @memory_clock = StatSet.new 'MHz'
  @fan_speed_rpm = StatSet.new 'RPM'
  @busy_percent = StatSet.new '%'
  @power_draw = StatSet.new 'W'
  @temperature = StatSet.new '°C'
end

Instance Attribute Details

#busy_percentObject (readonly)

Returns the value of attribute busy_percent.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def busy_percent
  @busy_percent
end

#core_clockObject (readonly)

Returns the value of attribute core_clock.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def core_clock
  @core_clock
end

#fan_speed_rpmObject (readonly)

Returns the value of attribute fan_speed_rpm.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def fan_speed_rpm
  @fan_speed_rpm
end

#memory_clockObject (readonly)

Returns the value of attribute memory_clock.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def memory_clock
  @memory_clock
end

#num_measurementsObject (readonly)

Returns the value of attribute num_measurements.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def num_measurements
  @num_measurements
end

#power_drawObject (readonly)

Returns the value of attribute power_draw.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def power_draw
  @power_draw
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



10
11
12
# File 'lib/amdgpu_fan/watcher.rb', line 10

def temperature
  @temperature
end

Instance Method Details

#measureObject

Take a new set of measurements and adjust the stats.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/amdgpu_fan/watcher.rb', line 28

def measure
  @num_measurements += 1

  Async do |task|
    i[busy_percent core_clock fan_speed_rpm memory_clock power_draw temperature].each do |stat|
      task.async do
        send(stat).now = amdgpu_service.send(stat)
        calculate_stats(send(stat))
      end
    end
  end
end