//recuperer les relations public Wire LoadWire(XElement wire, CircuitPersonnalise circuit) { //id int idStart = int.Parse(wire.Element("gatestart").Attribute("ID").Value); int idEnd = int.Parse(wire.Element("gateend").Attribute("ID").Value); //index int io1 = int.Parse(wire.Element("gatestart").Attribute("IO").Value); int io2 = int.Parse(wire.Element("gateend").Attribute("IO").Value); //points Point startp = new Point(double.Parse(wire.Element("startp").Attribute("X").Value), double.Parse(wire.Element("startp").Attribute("Y").Value)); Point endp = new Point(double.Parse(wire.Element("endp").Attribute("X").Value), double.Parse(wire.Element("endp").Attribute("Y").Value)); InputOutput IN1, IN2; //on recupere les gate qui ont ces identifiants Gate gatestart = Recuplist(idStart, circuit.gates), gateend = Recuplist(idEnd, circuit.gates); if (wire.Element("gatestart").Attribute("Type").Value == "ClasseEntree") { IN1 = gatestart.outil.getListeentrees()[io1]; IN2 = gateend.outil.getListesorties()[io2]; } else { IN1 = gatestart.outil.getListesorties()[io1]; IN2 = gateend.outil.getListeentrees()[io2]; } Wire w = new Wire(startp, gatestart, IN1); w.Connect(endp, gateend, IN2, circuit); return(w); }
public bool Connect(Point end, Gate gate, InputOutput io, CircuitPersonnalise circuit) { gateEnd = gate; Maj(); EndPoint = end; this.io2 = io; io1.LayoutUpdated += Redraw; io2.LayoutUpdated += Redraw; if (end.Equals(_fil.StartPoint) == true || io1.GetIsInput() == io2.GetIsInput() || io1.getEtat() != io2.getEtat()) { return(false); } else { if (io1 is ClasseEntree) { if (!circuit.Relate(gateEnd.GetOutil(), gateStart.GetOutil(), (Sortie)io2, (ClasseEntree)io1)) { return(false); } (io2 as Sortie).PropertyChanged += new PropertyChangedEventHandler((sender, e) => { Value = io2.getEtat(); }); } else { if (!circuit.Relate(gateStart.GetOutil(), gateEnd.GetOutil(), (Sortie)io1, (ClasseEntree)io2)) { return(false); } (io1 as Sortie).PropertyChanged += new PropertyChangedEventHandler((sender, e) => { Value = io1.getEtat(); }); } return(true); } }
public CircuitPersonnalise Reutilisation(string filename) { CircuitPersonnalise nouveauCircuit = new CircuitPersonnalise(); List <Gate> list = new List <Gate>(); XElement root = XElement.Load(filename); //Gates foreach (XElement gate in root.Element("Gates").Elements()) { Gate abgate = LoadGate(gate); nouveauCircuit.gates.Add(abgate); // list.Add(abgate); nouveauCircuit.AddComponent(abgate.outil); abgate.added = true; } //Wires foreach (XElement wire in root.Element("Wires").Elements()) { Wire w = LoadWire(wire, nouveauCircuit); nouveauCircuit.wires.Add(w); } nouveauCircuit.ConstructEntrée(); //construction de la liste des entrées nouveauCircuit.ConstructSortie(); //construction de la liste des sorties // nouveauCircuit.setLabel(filename); //on parcourt la liste des sortie et on ajoute les sorties non liées et celle liées à un pinout à la liste des sorties du circuit //on parcourt les composants et ceux qui ont une sortie non liée on l'ajoute à ,otre liste des sorties //on parcourt la liste des pinin et des horloge et on les ajoute à notre liste d'entrées du circuit return(nouveauCircuit); }
public MainWindow() { InitializeComponent(); circuit = new CircuitPersonnalise(); Wires = new List <Wire>(); Grille.AddHandler(Gate.DeletingGateEvent, new RoutedEventHandler(Supprimer)); Grille.AddHandler(Wire.SuppwireEvent, new RoutedEventHandler(Supp_Wire)); Grille.AddHandler(InputOutput.SupprimerWireEvent, new RoutedEventHandler(SupprimerWire)); }
//*************************************Reutilisation****************************************** #region Réeutilisation private void TextBlock_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".xaml"; // Default file extension dlg.Filter = "Xaml File (.xaml)|*.xaml"; // Filter files by extension // Show open file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process open file dialog box results if (result == true) { string filename = dlg.FileName; String nom = dlg.SafeFileName.Replace(".xaml", " "); CircuitPersonnalise personnalise = Reutilisation(filename); personnalise.setLabel(nom); CircuitComplet gate = new CircuitComplet(personnalise); this.circuit.AddComponent(personnalise); gate.added = true; Grille.Children.Add(gate); } }
int ChronoNumber;//Le nombre de chronogrammes affichés public Chronogrammes(CircuitPersonnalise circ) { InitializeComponent(); this.circuit = circ; IsReading = false; isPause = false; watch = new Stopwatch(); timer = new DispatcherTimer(); l_ts = new List <TimeSpan>(); l_ts.Add(new TimeSpan(0, 0, 5)); STs = new TimeSpan(0, 0, 16); l_ts.Add(STs); l_ts.Add(new TimeSpan(0, 0, 32)); l_ts.Add(new TimeSpan(0, 0, 48)); l_ts.Add(new TimeSpan(0, 0, 64)); l_ts.Add(new TimeSpan(0, 0, 128)); l_ts.Add(new TimeSpan(0, 0, 256)); newl = new List <ViewModel>(); foreach (var v in circ.getCircuit().Vertices) { list = new List <InputOutput>(); list.AddRange(v.getListesorties()); list.AddRange(v.getListeentrees()); ViewModel vm = new ViewModel(v, list); newl.Add(vm); } timer.Tick += StopPlotting; this.AddHandler(Button.ClickEvent, new RoutedEventHandler(Supprimer)); this.Closing += Quit; DataContext = this; }
private void TT_start() { DataTable dt = new DataTable(); int nbrPinEntree = 0; int nbrDiodSortie = 0; string ch1 = "Noyau.PinOut"; string ch2 = "Noyau.PinIn"; List <Outils> PinEntreeLLC = new List <Outils>(); List <Outils> DiodSortieLLC = new List <Outils>(); foreach (Outils noeud in circuit.Vertices) { if (noeud.GetType().ToString().CompareTo(ch1) == 0) { nbrDiodSortie++; DiodSortieLLC.Add(noeud); } else { if (noeud.GetType().ToString().CompareTo(ch2) == 0) { nbrPinEntree++; PinEntreeLLC.Add(noeud); } } } int numberOfVariables = nbrPinEntree; int biggestvalue = Convert.ToInt32(Math.Pow(2, numberOfVariables)) - 1; int biggestDigitLength = Convert.ToString(biggestvalue, 2).Length; int cpt = 1; //Creating the columns des PinIns foreach (Outils elmnt in circuit.Vertices) { if (elmnt.GetType().ToString().CompareTo(ch2) == 0) { string nom = elmnt.getname(); dt.Columns.Add(new DataColumn(nom, typeof(string))); cpt++; } } cpt = 1; //Creating the columns des PinOut foreach (Outils elmnt in circuit.Vertices) { if (elmnt.GetType().ToString().CompareTo(ch1) == 0) { DataColumn output = new DataColumn(elmnt.getname()); dt.Columns.Add(output); cpt++; } } for (int i = 0; i < Math.Pow(2, numberOfVariables); i++) { string binary = Convert.ToString(i, 2); //Pour remplir les bits forts non atteints avec des 0 ,indiquants false binary = binary.PadLeft(biggestDigitLength, '0'); bool[] binaryExpression = binary.Select(c => c == '1').ToArray(); DataRow inputRow = dt.NewRow(); //Add for (int j = 0; j < binaryExpression.Length; j++) { if (binaryExpression[j] == true) { inputRow[j] = "True"; } else if (binaryExpression[j] == false) { inputRow[j] = "False"; } } int l = 0; foreach (Outils elmnt in circuit.Vertices) { if (elmnt.GetType().ToString().CompareTo(ch2) == 0) { elmnt.getEntreeSpecifique(0).setEtat(binaryExpression[l]); l++; } } CircuitPersonnalise essaie = new CircuitPersonnalise(circuit); essaie.EvaluateCircuit(); l = 0; //La recuperation des etats des diodes apres la simulation foreach (Outils elmnt in circuit.Vertices) { if (elmnt.GetType().ToString().CompareTo(ch1) == 0) { inputRow[binaryExpression.Length + l] = elmnt.getEntreeSpecifique(0).getEtat().ToString(); l++; } } dt.Rows.Add(inputRow); } tVerite.ItemsSource = dt.DefaultView; }