Example #1
0
        public string applicationCodageHamming(string message)
        {
            string resultatFinal = "";

            string[] blocks             = this.Blocks;
            Matrice  matriceGeneratrice = this.MatriceGeneratrice;
            Matrice  matriceControle    = this.MatriceControle;

            BitDeParite[]   bitDeParite = this.BitsDeParite;
            List <double[]> codes       = this.blockCode(message);

            for (int i = 0; i < blocks.Length; i++)
            {
                string   resultat       = "";
                string   block          = blocks[i];
                double[] matriceColonne = this.blockEnMatriceColonne(block);
                double[] code           = codes[i];
                double[] syndrome       = matriceControle.code(code);
                if (!syndrome.Contains(1))
                {
                    resultat = this.decodage(code);
                }
                else
                {
                    BitDeParite[] equationAvecErreur = this.equationAvecErreur(code);
                    this.correctionErreur(code);
                    resultat = this.decodage(code);
                }
                resultatFinal += resultat;
            }

            return(resultatFinal);
        }
Example #2
0
        public string blockAvecErreur()
        {
            string resultatFinal = "";

            string[] blocks             = this.Blocks;
            string[] blocksCode         = new string[blocks.Length];
            Matrice  matriceGeneratrice = this.MatriceGeneratrice;
            Matrice  matriceControle    = this.MatriceControle;

            BitDeParite[] bitDeParite = this.BitsDeParite;
            for (int i = 0; i < blocks.Length; i++)
            {
                string   data           = "";
                string   block          = blocks[i];
                double[] matriceColonne = this.blockEnMatriceColonne(block);
                double[] code           = matriceGeneratrice.code(matriceColonne);
                for (int j = 0; j < code.Length; j++)
                {
                    string donnee = code[j].ToString();
                    data += donnee;
                }
                Console.WriteLine(data);
                resultatFinal += data;
            }
            this.BlockErreur = resultatFinal;
            return(resultatFinal);
        }