コード例 #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (sequence.Count != 0)
            {
                SystemExploitation tmpOs = new SystemExploitation();
                tmpOs = systemExploitation.Clone();
                List <object> tmp = sequence.Pop();
                systemExploitation = (SystemExploitation)tmp[0];
                ram        = (RamVirtuelle)tmp[1];
                diskDur    = (DiskDur)tmp[2];
                tablePages = (List <EntreeTablePage>)tmp[3];
                requete    = (List <String>)tmp[4];
                sauvSuite  = (String)tmp[5];
                afficherRam(ram);
                champAdressePhysique.Text = "";
                champAux.Text             = "";
                champRam.Text             = "";
                champTPages.Text          = "";
                demande.Text     = "Demande de l'adresse virtuelle: ";
                deroulement.Text = "Nombre de defauts de page: " + systemExploitation.getDefautDePage().ToString();
                switch (choixAlgorithme.SelectedIndex)
                {
                case 0:
                    suppFileLru();
                    if (tmpOs.fileLru.Count == systemExploitation.fileLru.Count && tmpOs.fileLru.Peek() != systemExploitation.fileLru.Peek())
                    {
                        double  y       = 0;
                        Ellipse ellipse = new Ellipse()
                        {
                            Height = 30, Width = 30, Fill = Brushes.Cyan
                        };

                        TextBlock num = new TextBlock
                        {
                            Text = tablePages.FindIndex(h => h.getPageCorrespandante() == systemExploitation.fileLru.Peek() && h.getDisponible() == true).ToString(), FontSize = 14
                        };
                        double x = (aux.Children.Count / 2) * (ellipse.Width + 10);
                        aux.Children.Insert(0, ellipse);
                        Canvas.SetLeft(ellipse, x);
                        Canvas.SetTop(ellipse, y);
                        aux.Children.Insert(1, num);
                        Canvas.SetLeft(num, x + ellipse.Height / 2 - num.FontSize / 2 + 1);
                        Canvas.SetTop(num, y + ellipse.Width / 2 - num.FontSize / 2);
                    }
                    break;

                case 1:
                    foreach (EntreeTablePage page in tablePages)
                    {
                    }
                    //suppFileFifo();
                    //if (tmpOs.fifo.Count == systemExploitation.fifo.Count && tmpOs.fifo.Peek() != systemExploitation.fifo.Peek())
                    //{
                    //    double y = 0;
                    //    Ellipse ellipse = new Ellipse()
                    //    { Height = 30, Width = 30, Fill = Brushes.Cyan };

                    //    TextBlock num = new TextBlock
                    //    { Text = tablePages.FindIndex(h => h.getPageCorrespandante() == systemExploitation.fifo.Peek() && h.getDisponible() == true).ToString(), FontSize = 14 };
                    //    double x =  (aux.Children.Count / 2) * (ellipse.Width + 10);
                    //    aux.Children.Insert(0, ellipse);
                    //    Canvas.SetLeft(ellipse, x);
                    //    Canvas.SetTop(ellipse, y);
                    //    aux.Children.Insert(1, num);
                    //    Canvas.SetLeft(num, x + ellipse.Height / 2 - num.FontSize / 2 + 1);
                    //    Canvas.SetTop(num, y + ellipse.Width / 2 - num.FontSize / 2);
                    //}
                    break;

                case 2:
                    affichLfu();
                    break;

                case 3:
                    affichMatriceAging();
                    break;
                }
                iteration--;
                lancer.IsEnabled  = true;
                suivant.IsEnabled = true;
                majTablePage();
                if (iteration == 0)
                {
                    precedent.IsEnabled = false;
                }
            }
        }
コード例 #2
0
        private void begin(object sender, RoutedEventArgs e)
        {
            champAdressePhysique.Text = "";
            champAux.Text             = "";
            champRam.Text             = "";
            champTPages.Text          = "";
            deroulement.Text          = "";

            stop.IsEnabled             = true;
            suivant.IsEnabled          = true;
            suiteReferences.IsReadOnly = true;
            if (iteration == 0)
            {
                sauvSuite = suiteReferences.Text;
                requete   = sauvSuite.Split(' ').ToList <String>();
            }
            if (iteration < suiteReferences.Text.Split(' ').Length)
            {
                sequence.Push(new List <object> {
                    systemExploitation.Clone(), ram.Clone(), diskDur.Clone(), new List <EntreeTablePage>(tablePages.Select(x => x.Clone())), requete, sauvSuite
                });
                if (requete.Count != 0)
                {
                    String r = requete[iteration];
                    demande.Text = "Demande de l'adresse virtuelle: " + r;
                    try
                    {
                        int tmp = Convert.ToInt32(r);
                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 3:
                            affichMatriceAging();
                            break;
                        }

                        int             sDefaut = systemExploitation.getDefautDePage();
                        int             sNbpage = ram.getNombrepagesLibres();
                        SolidColorBrush myBrush = new SolidColorBrush();
                        myBrush.Color = Colors.White;
                        ColorAnimation ba = new ColorAnimation()
                        {
                            Duration = TimeSpan.FromMilliseconds(1000)
                        };
                        if (tablePages[tmp].getDisponible() == true)
                        {
                            ba.To = Colors.Green;
                        }
                        else
                        {
                            ba.To = Colors.Red;
                        }
                        myBrush.BeginAnimation(SolidColorBrush.ColorProperty, ba);
                        oTable.RowGroups[0].Rows[tmp].Background = myBrush;
                        systemExploitation.gestionRequete(choixAlgorithme.SelectedIndex, tablePages, tmp, ram, diskDur);
                        Line line = new Line()
                        {
                            X1 = 150, Y1 = (tmp + 1) * 51 + 25, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2
                        };
                        DoubleAnimation animation = new DoubleAnimation(260, TimeSpan.FromSeconds(0.5))
                        {
                            From = 150, AutoReverse = true
                        };

                        memVirtuelle.Children.Add(line);
                        line.BeginAnimation(Line.X2Property, animation);
                        animation.From = line.Y1;
                        animation.To   = 200 + (51) * tablePages[tmp].getPageCorrespandante();
                        line.BeginAnimation(Line.Y2Property, animation);



                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 0:
                            if (sDefaut < systemExploitation.getDefautDePage() && sNbpage == 0)
                            {
                                aux.Children.RemoveAt(0);
                                aux.Children.RemoveAt(0);
                            }
                            else
                            {
                                if (sDefaut == systemExploitation.getDefautDePage())
                                {
                                    for (int i = 1; i < aux.Children.Count; i = i + 2)
                                    {
                                        if (((TextBlock)aux.Children[i]).Text == r)
                                        {
                                            aux.Children.RemoveRange(i - 1, 2);
                                            for (int k = i - 1; k < aux.Children.Count; k++)
                                            {
                                                DoubleAnimation db = new DoubleAnimation
                                                {
                                                    To       = Canvas.GetLeft(aux.Children[k]) + 10,
                                                    Duration = new Duration(new TimeSpan(1000000))
                                                };
                                                aux.Children[k].BeginAnimation(Canvas.LeftProperty, db);
                                            }

                                            break;
                                        }
                                    }
                                }
                            }
                            ajoutFileLru();
                            break;

                        case 1:
                            if (sDefaut < systemExploitation.getDefautDePage())
                            {
                                if (sNbpage == 0)
                                {
                                    aux.Children.RemoveAt(0);
                                    aux.Children.RemoveAt(0);
                                }

                                ajoutFileFifo();
                            }

                            break;

                        case 2:
                            affichLfu();
                            break;

                        case 3:
                            affichMatriceAging();
                            break;
                        }
                        champTPages.Text = "Mise a jour de la table de pages ";
                        afficherRam(ram);
                        champAdressePhysique.Text = "L'adresse physique de la page " + r + " est: " + tablePages[Convert.ToInt32(r)].getPageCorrespandante().ToString();
                        deroulement.Text          = "Nombre de defauts de page: " + systemExploitation.getDefautDePage().ToString();
                        majTablePage();
                        iteration++;
                    }
                    catch (FormatException)
                    {
                        msgErreur.Text = "erreur dans la suite entrée.";
                    }

                    precedent.IsEnabled = true;
                    if (iteration == suiteReferences.Text.Split(' ').Length)
                    {
                        lancer.IsEnabled  = false;
                        suivant.IsEnabled = false;
                    }
                }
            }
        }