parent
e72c751ee6
commit
400b810204
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import java.util.*?>
|
||||||
|
<?import javafx.scene.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<AnchorPane xmlns="http://javafx.com/javafx"
|
||||||
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="view.VueCapteurCompose"
|
||||||
|
prefHeight="400.0" prefWidth="600.0">
|
||||||
|
|
||||||
|
</AnchorPane>
|
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
|
<?import java.util.*?>
|
||||||
|
<?import javafx.scene.*?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
<BorderPane xmlns="http://javafx.com/javafx"
|
||||||
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
|
fx:controller="view.VueCapteurSimple"
|
||||||
|
prefHeight="400.0" prefWidth="600.0">
|
||||||
|
<TextArea fx:id="nomCapteur"/>
|
||||||
|
<Text fx:id="idCapteur"/>
|
||||||
|
</BorderPane>
|
@ -0,0 +1,17 @@
|
|||||||
|
package Launcher;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class Launch extends Application {
|
||||||
|
@Override
|
||||||
|
public void start(Stage stage) throws Exception {
|
||||||
|
Parent root = FXMLLoader.load(getClass().getResource("/views/CapteurSimple.fxml"));
|
||||||
|
Scene scene = new Scene(root);
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
import javafx.beans.property.Property;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
|
||||||
|
public abstract class Capteur {
|
||||||
|
protected StringProperty id;
|
||||||
|
public String getId() {
|
||||||
|
return id.get();
|
||||||
|
}
|
||||||
|
public StringProperty idProperty(){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(String i){
|
||||||
|
this.id.set(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected StringProperty nom;
|
||||||
|
public String getNom() {
|
||||||
|
return nom.get();
|
||||||
|
}
|
||||||
|
public StringProperty nomProperty(){
|
||||||
|
return nom;
|
||||||
|
}
|
||||||
|
public void setNom(String n){
|
||||||
|
this.nom.set(n);
|
||||||
|
}
|
||||||
|
protected StringProperty valeur;
|
||||||
|
public int getValeur(){
|
||||||
|
return Integer.parseInt(valeur.get());
|
||||||
|
}
|
||||||
|
public StringProperty valeurProperty() {
|
||||||
|
return valeur;
|
||||||
|
}
|
||||||
|
public void setValeur(int v) {
|
||||||
|
this.valeur.set(Integer.toString(v));
|
||||||
|
}
|
||||||
|
protected Property<Integer> tpsGen;
|
||||||
|
public int getTpsGen(){
|
||||||
|
return tpsGen.getValue();
|
||||||
|
}
|
||||||
|
public Property<Integer> tpsGenProperty() {
|
||||||
|
return tpsGen;
|
||||||
|
}
|
||||||
|
public void setTpsGen(int t) {
|
||||||
|
this.tpsGen.setValue(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
abstract void start();
|
||||||
|
abstract void stop();
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public class CapteurCompose {
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public class CapteurSimple extends Capteur{
|
||||||
|
private StratGeneration strategie;
|
||||||
|
private void setStrategie(StratGeneration s){
|
||||||
|
strategie=s;
|
||||||
|
}
|
||||||
|
public CapteurSimple(String i, String n){
|
||||||
|
setId(i);
|
||||||
|
setNom(n);/*
|
||||||
|
setValeur(0);
|
||||||
|
strategie=new StratGenerationCPU();*/
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
void start() {
|
||||||
|
//tant que pas stop, attendre tps gen
|
||||||
|
//puis faire valeur=strategie.generer()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void stop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
|
||||||
|
public class ChargeurTemperatureCPU {
|
||||||
|
public String load(){
|
||||||
|
try {
|
||||||
|
BufferedReader fichier = new BufferedReader(new FileReader("/sys/class/thermal/thermal_zone2/temp"));
|
||||||
|
return fichier.readLine();
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public abstract class StratGeneration {
|
||||||
|
abstract int generer();
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package model;
|
||||||
|
|
||||||
|
public class StratGenerationCPU extends StratGeneration{
|
||||||
|
private ChargeurTemperatureCPU chargeur = new ChargeurTemperatureCPU();
|
||||||
|
int generer(){
|
||||||
|
String lecture=chargeur.load();
|
||||||
|
if(lecture!=null){
|
||||||
|
return Integer.parseInt(lecture)/1000;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package view;
|
||||||
|
|
||||||
|
public class FXMLwindow {
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package view;
|
||||||
|
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import model.Capteur;
|
||||||
|
|
||||||
|
public abstract class VueCapteur implements Initializable {
|
||||||
|
protected Capteur capteur;
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package view;
|
||||||
|
|
||||||
|
public class VueCapteurCompose {
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package view;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Spinner;
|
||||||
|
import javafx.scene.control.SpinnerValueFactory;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
import model.CapteurSimple;
|
||||||
|
|
||||||
|
public class VueCapteurSimple {
|
||||||
|
@FXML
|
||||||
|
private TextArea nomCapteur;
|
||||||
|
@FXML
|
||||||
|
private Text idCapteur;
|
||||||
|
/*
|
||||||
|
@FXML
|
||||||
|
private Text valeurCapteur;
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> spinTps;*/
|
||||||
|
private CapteurSimple capteur=new CapteurSimple("Capt2","Mon Capteur Cpu");
|
||||||
|
|
||||||
|
public void initialize(){
|
||||||
|
nomCapteur.textProperty().bind(capteur.nomProperty());
|
||||||
|
/*
|
||||||
|
spinTps.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0,10,1,1));
|
||||||
|
spinTps.valueFactoryProperty().bindBidirectional(capteur.tpsGenProperty());*/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue