// Porte de tempo (equivalent d'une porte OU qui decale les valeurs de sorties de 1 seconde), herite de Composant
public class Tempo extends Composant {

	static int n = 1;
	
	public Tempo(int n_in, int n_out){
		super(n_in, n_out);
		charName 	  = "C2";
		composantName = "Tempo";
		Name		  = "Tempo_"+(n++);
	}
	
	Thread thr = null;
	//@SuppressWarnings("deprecation") // thr.stop(), pas critique
	protected void doWork() {
		boolean state = false;
		for(Pin pin : pin_in)
			if(pin.isOn()){ state = true; break; }
		//if(thr!=null){ thr.stop(); thr = null; } // Retour a off annule
		final boolean fstate = state;
		thr = new Thread(){public void run(){
			try {
				Thread.sleep(1000);
				for(Pin pin : pin_out)
					pin.setState(fstate);
				thr = null;
			} catch (InterruptedException e) {
				thr = null;
			}
		}};
		thr.start();
	}

}
