-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGPU.java
More file actions
54 lines (47 loc) · 1.63 KB
/
GPU.java
File metadata and controls
54 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package components;
import com.profesorfalken.jsensors.JSensors;
import com.profesorfalken.jsensors.model.components.Components;
import com.profesorfalken.jsensors.model.components.Gpu;
import com.profesorfalken.jsensors.model.sensors.Load;
import oshi.hardware.GraphicsCard;
import java.util.List;
public class GPU extends Component{
private long vramTotal;
private transient GraphicsCard graphicsCard;
private transient Gpu jgpu;
public GPU(GraphicsCard gpu, Gpu gpu2)
{
graphicsCard = gpu;
vramTotal = graphicsCard.getVRam();
componentName = graphicsCard.getName();
componentType = "GPU";
jgpu = gpu2;
}
public void update()
{
try {
if (jgpu != null && jgpu.sensors != null && jgpu.sensors.temperatures != null && !jgpu.sensors.temperatures.isEmpty()) {
temperature = jgpu.sensors.temperatures.get(0).value;
} else {
temperature = 0; // No temperature data available
}
}
catch (Exception e){
temperature = 0; // Fallback if temperature reading fails
}
try {
if (jgpu != null && jgpu.sensors != null && jgpu.sensors.loads != null && !jgpu.sensors.loads.isEmpty()) {
usage = jgpu.sensors.loads.get(0).value;
} else {
usage = 0; // No usage data available
}
}
catch (Exception e){
usage = 0; // Fallback if usage reading fails
}
lastUpdated = System.currentTimeMillis();
}
public long getVramTotal() {
return vramTotal;
}
}