public void ActOnActiveTimelineEntries()
        {
            IEvaluator ev;

            while ((ev = _timeline.PopNextActiveEvent(UIMap.GetTime())) != null)
            {
                try
                {
                    ev.Execute();
                }
                catch (Exception e)
                {
                    ErrorEvaluator.Error(e.Message, e.StackTrace, Messages).Execute();
                }
            }
        }
Exemple #2
0
        // Decode the received codewords
        internal static int TestCodewords
        (
            int[] Codewords,
            int ErrorCorrectionLength
        )
        {
            // create codewords polynomial
            Polynomial PolyCodewords = new Polynomial(Codewords);

            // create syndrom coefficients array
            int[] Syndrome = new int[ErrorCorrectionLength];

            // assume no errors
            bool Error = false;

            // test for errors
            // if the syndrom array is all zeros, there is no error
            for (int Index = ErrorCorrectionLength; Index > 0; Index--)
            {
                if ((Syndrome[ErrorCorrectionLength - Index] = PolyCodewords.EvaluateAt(Modulus.ExpTable[Index])) != 0)
                {
                    Error = true;
                }
            }

            // no errors
            if (!Error)
            {
                return(0);
            }

            // convert syndrom array to polynomial
            Polynomial PolySyndrome = new Polynomial(Syndrome);

            // Greatest Common Divisor (return -1 if error cannot be corrected)
            if (!EuclideanAlgorithm(ErrorCorrectionLength, PolySyndrome,
                                    out Polynomial ErrorLocator, out Polynomial ErrorEvaluator))
            {
                return(-1);
            }

            // error locator (return -1 if error cannot be corrected)
            int[] ErrorLocations = FindErrorLocations(ErrorLocator);
            if (ErrorLocations == null)
            {
                return(-1);
            }

            // formal derivatives
            Polynomial FormalDerivative = FindFormalDerivatives(ErrorLocator);

            // This is directly applying Forney's Formula
            int Errors = ErrorLocations.Length;

            for (int Index = 0; Index < Errors; Index++)
            {
                // error location
                int ErrLoc = ErrorLocations[Index];

                // error position  (return -1 if error cannot be corrected)
                int ErrPos = Codewords.Length - 1 - Modulus.LogTable[Modulus.Inverse(ErrLoc)];
                if (ErrPos < 0)
                {
                    return(-1);
                }

                // error magnitude
                int ErrorMagnitude = Modulus.Divide(Modulus.Negate(ErrorEvaluator.EvaluateAt(ErrLoc)), FormalDerivative.EvaluateAt(ErrLoc));

                // correct codeword
                Codewords[ErrPos] = Modulus.Subtract(Codewords[ErrPos], ErrorMagnitude);

                // save error position in error locations array
                ErrorLocations[Index] = ErrPos;
            }

                #if DEBUG && ERRCORRECT
            Array.Sort(ErrorLocations);
            StringBuilder Str1 = new StringBuilder();
            for (int Row = 0; Row < DataRows; Row++)
            {
                Str1.Clear();
                Str1.AppendFormat("{0}: ", Row);
                for (int Col = 1; Col <= DataColumns; Col++)
                {
                    int Pos   = DataColumns * Row + Col - 1;
                    int Index = Array.BinarySearch(ErrorLocations, Pos);
                    if (Index < 0)
                    {
                        Str1.AppendFormat("{0}, ", Codewords[Pos]);
                    }
                    else
                    {
                        Str1.AppendFormat("{0}*, ", Codewords[Pos]);
                    }
                }
                Pdf417Trace.Write(Str1.ToString());
            }
                #endif

            // message was successfuly repaired
            return(Errors);
        }