You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
68 lines
1.7 KiB
package model;
|
|
|
|
import javafx.application.Platform;
|
|
import javafx.beans.property.DoubleProperty;
|
|
import javafx.beans.property.SimpleDoubleProperty;
|
|
import javafx.beans.property.SimpleStringProperty;
|
|
import javafx.beans.value.ObservableValue;
|
|
|
|
import java.io.*;
|
|
|
|
public class CPUTemp implements GenererTemperature, Runnable {
|
|
|
|
DoubleProperty temperature = new SimpleDoubleProperty(0.0);
|
|
|
|
String name ;
|
|
|
|
public CPUTemp(String nom) throws IOException {
|
|
this.name=nom;
|
|
genererTemperature();
|
|
}
|
|
@Override
|
|
public void genererTemperature() throws IOException {
|
|
File temp = new File("/sys/devices/virtual/thermal/thermal_zone6/temp");
|
|
BufferedReader br = new BufferedReader(new FileReader(temp));
|
|
setTemperature((double) (Float.parseFloat(br.readLine())/1000));
|
|
}
|
|
|
|
public void setTemperature(Double temperature){
|
|
this.temperature.set(temperature);
|
|
}
|
|
|
|
public DoubleProperty getTemperatureProperty(){
|
|
return this.temperature;
|
|
}
|
|
|
|
public String getTemperature(){
|
|
return this.temperature.get()+"";
|
|
}
|
|
|
|
@Override
|
|
public void run(){
|
|
while (true){
|
|
Platform.runLater(()-> {
|
|
try {
|
|
genererTemperature();
|
|
} catch (IOException ignored) {
|
|
}
|
|
});
|
|
try{
|
|
Thread.sleep(100);
|
|
}
|
|
catch (InterruptedException e){
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void startThread(){
|
|
Thread threadCaptor = new Thread(this);
|
|
threadCaptor.setDaemon(true);
|
|
threadCaptor.start();
|
|
}
|
|
|
|
public String getName() {
|
|
return this.name;
|
|
}
|
|
}
|