value est le temps d'exécution en milliseconde
This commit is contained in:
@@ -4,6 +4,7 @@ import interfaces.AlgoDiffusion;
|
||||
import interfaces.Capteur;
|
||||
import interfaces.ObserverDeCapteurAsync;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,6 +13,7 @@ public class CapteurImpl implements Capteur {
|
||||
private AlgoDiffusion diffusion;
|
||||
protected List<ObserverDeCapteurAsync> observers=new ArrayList<ObserverDeCapteurAsync>();
|
||||
private Boolean locker = false;
|
||||
public int initTime = 0;
|
||||
|
||||
@Override
|
||||
public void attach(ObserverDeCapteurAsync o) {
|
||||
@@ -25,6 +27,8 @@ public class CapteurImpl implements Capteur {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
Clock clockTime = Clock.systemDefaultZone();
|
||||
this.value = ((int)clockTime.millis())-initTime;
|
||||
if(!locker){
|
||||
diffusion.execute();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import impl.CapteurImpl;
|
||||
import impl.DiffusionAtomique;
|
||||
import impl.Scheduler;
|
||||
import interfaces.AlgoDiffusion;
|
||||
import java.time.*;
|
||||
|
||||
|
||||
public class main {
|
||||
|
||||
@@ -17,6 +19,9 @@ public class main {
|
||||
public static void main(String[] argv){
|
||||
Scheduler scheduler = new Scheduler(NB_CANAUX);
|
||||
CapteurImpl c = new CapteurImpl();
|
||||
|
||||
Clock clockTime = Clock.systemDefaultZone();
|
||||
c.initTime = ((int)clockTime.millis());
|
||||
DiffusionAtomique algo = new DiffusionAtomique();
|
||||
algo.capteur = c;
|
||||
c.setAlgoDiffusion(algo);
|
||||
|
||||
Reference in New Issue
Block a user