57 lines
1.5 KiB
Java
57 lines
1.5 KiB
Java
package net.metaunix.controllers;
|
|
|
|
import javafx.fxml.FXML;
|
|
import javafx.scene.control.Label;
|
|
import javafx.util.Duration;
|
|
import org.apache.commons.math3.util.Precision;
|
|
|
|
import net.metaunix.SysInfo;
|
|
import net.metaunix.services.UpdateSystemInfoService;
|
|
|
|
public class HomeController {
|
|
|
|
@FXML
|
|
private Label osInfo;
|
|
@FXML
|
|
private Label overCpuUsage;
|
|
@FXML
|
|
private Label overCpuTemp;
|
|
@FXML
|
|
private Label overMemoryUsage;
|
|
@FXML
|
|
private Label overGpuTemp;
|
|
@FXML
|
|
private Label cpuCpuTemp;
|
|
@FXML
|
|
private Label cpuCpuFreq;
|
|
@FXML
|
|
private Label cpuCpuMaxFreq;
|
|
|
|
@FXML
|
|
public void initialize() {
|
|
UpdateSystemInfoService usis = new UpdateSystemInfoService();
|
|
usis.setOnSucceeded((e) -> {
|
|
updateLabels();
|
|
});
|
|
usis.setPeriod(Duration.seconds(3));
|
|
usis.start();
|
|
}
|
|
|
|
private void updateLabels() {
|
|
osInfo.setText(SysInfo.osString);
|
|
overCpuUsage.setText(String.valueOf(Precision.round(SysInfo.cpuUsage * 100, 1)) + "%");
|
|
overCpuTemp.setText(String.valueOf(SysInfo.cpuTemp));
|
|
overMemoryUsage.setText(
|
|
String.valueOf(Precision.round((double) SysInfo.memoryUsed / (1024*1024*1024), 2)) +
|
|
"GB / " +
|
|
String.valueOf(Precision.round((double) SysInfo.memoryTotal / (1024*1024*1024), 2)) +
|
|
"GB"
|
|
);
|
|
overGpuTemp.setText(String.valueOf(SysInfo.gpuName));
|
|
cpuCpuTemp.setText(String.valueOf(SysInfo.cpuTemp));
|
|
cpuCpuFreq.setText(String.valueOf(SysInfo.cpuFreq));
|
|
cpuCpuMaxFreq.setText(String.valueOf(SysInfo.cpuMaxFreq));
|
|
}
|
|
|
|
}
|