Blame view

TestCircuits.java~ 1.91 KB
0498df6f   rsimonin   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  import java.util.Scanner;
  /**
   *
   * @author Bernard.Carre@polytech-lille.fr
   */
  
  public class TestCircuits {
      
  	public static void main(String[] args) {
  		//Construction
  	    Composant tabcomp[]= new Composant[7] ;
  	    Or c1=new Or();
  	    And c2= new And();
  	    Not c3= new Not();
  	    Interrupteur i1 = new Interrupteur();
  	    Interrupteur i2 = new Interrupteur();
  	    Interrupteur i3 = new Interrupteur();
  	    Vanne v1= new Vanne();
  	    tabcomp[0]=c1;
  	    tabcomp[1]=c2;
  	    tabcomp[2]=c3;
  	    tabcomp[3]=i1;
  	    tabcomp[4]=i2;
  	    tabcomp[5]=i3;
  	    tabcomp[6]=v1;
  	    
  
  	    
  		//Connexions
  	    
  	    ((Or)tabcomp[0]).setIN1(tabcomp[3]);
  	    
  	    ((Or)tabcomp[0]).setIN2(tabcomp[4]);
  	    ((Not)tabcomp[2]).setIn(tabcomp[5]);
  	    ((And)tabcomp[1]).setIN1(tabcomp[0]);
  	    ((And)tabcomp[1]).setIN2(tabcomp[2]);
  	    ((Vanne)tabcomp[6]).setIn(tabcomp[1]);
  	    
  	    c1.setIN1(new LazySonde(c1,"in1"));
  	    
  	    Circuit cir = new Circuit("circ",tabcomp);
  	    test(cir);
  	    
  		//Affichage
  		//c1.setIN1(new LazySonde(c1,"in1"));
  	    
  
  	    System.out.println("Au revoir!");
  	}
  
      static void test(Circuit circ){
  	System.out.println("Nomenclature:");
  	System.out.println(circ.nomenclature());
  	System.out.println();
  	System.out.println("description:");
  	circ.description();
  	System.out.println();
  	System.out.println("Interupteurs:");
  	System.out.println(circ.getIns());
  	System.out.println();
  	System.out.println("sorties:");
  	System.out.println(circ.getOuts());
  	System.out.println();
  	System.out.println("trace:");
  	circ.traceEtats();
      }
  
      
      static void printIds(Composant[] tabc){
  	for(Composant r : tabc){
  	    System.out.println(r.getId());
  	}
      }
      static void description(Composant[] tabc){
  	for(Composant r : tabc){
  	    System.out.println(r.description());
  	}	
      }
   
      static void traceEtats(Composant[] tabc){
  	for(Composant r : tabc){
  	    System.out.println(  r.traceEtat() );
  	   
  	}
      }
  
  }