Ejemplo n.º 1
0
        public void genererBitDeParite(int n)
        {
            List <BitDeParite> bitsDeParite = new List <BitDeParite>();
            int puissance = 0;
            int position  = 0;

            while (position < n)
            {
                BitDeParite bitDeParite = new BitDeParite();
                bitDeParite.Designation = "p" + puissance;
                bitDeParite.setPosition(puissance);

                bitsDeParite.Add(bitDeParite);
                position = bitDeParite.genererPosition(puissance + 1);
                Console.WriteLine(position);
                puissance++;
            }
            this.BitsDeParite = bitsDeParite.ToArray();
        }
Ejemplo n.º 2
0
        public List <int> positionErreur()
        {
            BitDeParite[] erreurs         = this.EquationErreur;
            List <int>    positionTrouvee = new List <int>();

            if (erreurs.Length > 0)
            {
                positionTrouvee = erreurs[0].PositionControle;
                for (int i = 1; i < erreurs.Length; i++)
                {
                    BitDeParite equation  = erreurs[i];
                    List <int>  positions = equation.PositionControle;
                    for (int j = 0; j < positionTrouvee.Count; j++)
                    {
                        int position = positionTrouvee[j];
                        if (!positions.Contains(position))
                        {
                            positionTrouvee.RemoveAt(j);
                        }
                    }
                }
            }
            return(positionTrouvee);
        }
Ejemplo n.º 3
0
        public BitDeParite[] equationAvecErreur(double[] code)
        {
            List <BitDeParite> equationsErreur = new List <BitDeParite>();

            BitDeParite[] bitsDeParite = this.BitsDeParite;
            for (int i = 0; i < bitsDeParite.Length; i++)
            {
                BitDeParite bitDeParite = bitsDeParite[i];
                List <int>  equation    = bitDeParite.PositionControle;
                int         valeur      = 0;
                for (int j = 0; j < equation.Count(); j++)
                {
                    Console.WriteLine(equation[j]);
                    int element = (int)code[equation[j] - 1];
                    valeur = BinaireClass.calculBinaire(valeur, element);
                }
                if (valeur == 1)
                {
                    equationsErreur.Add(bitDeParite);
                }
            }
            this.EquationErreur = equationsErreur.ToArray();
            return(this.EquationErreur);
        }