Example #1
0
        /// <summary>
        /// Attempts to correct any error in the HammingObject.
        /// </summary>
        /// <param name="report">Report will indicate the status and syndrome of this HammingObject</param>
        /// <returns>Returns true if the HammingObject has no errors and that is successfully corrected any errors. Returns false
        /// if errors were detected, but unable to fix. </returns>
        protected virtual bool CorrectError(int syndrome, ErrorTypesEnum status)
        {
            if (HammingBytes == null)
            {
                throw new EmptyHammingObjectException("Hamming Object is empty");
            }

            bool success = false;

            switch (status)
            {
            case ErrorTypesEnum.NoError:
                success = true;
                break;

            case ErrorTypesEnum.MasterParityBitError:
            case ErrorTypesEnum.ParityBitError:
            case ErrorTypesEnum.DataBitError:
                FlipBitAt(syndrome);
                success = true;
                break;

            case ErrorTypesEnum.MultiBitError:
                success = false;
                break;
            }
            return(success);
        }
Example #2
0
 public HammingReport(int errorLocation, ErrorTypesEnum typeOfError, bool errorFixed)
 {
     Status    = typeOfError;
     Syndrome  = errorLocation;
     Corrected = errorFixed;
 }
Example #3
0
 public void LogError(string message, ErrorTypesEnum errorType, string imagePath)
 {
     using (var writer = new StreamWriter(Path.Combine(ERROR_LOG_LOCATION, ERROR_LOG_FILE_NAME), true, Encoding.UTF8, 0x1000)) {
         writer.WriteLine(string.Concat(new object[] { "\r\n", DateTime.Now, ",", errorType, ",", message, ",", imagePath }));
     }
 }
Example #4
0
 public void AddError(string error, ErrorTypesEnum errorType)
 {
     _errors.Add(error);
     Type = errorType;
 }
Example #5
0
 public Result(string error, ErrorTypesEnum errorType)
 {
     AddError(error, errorType);
 }
Example #6
0
 public void LogError(string message, ErrorTypesEnum errorType, string imagePath) {
   using (var writer = new StreamWriter(Path.Combine(ERROR_LOG_LOCATION,ERROR_LOG_FILE_NAME), true,Encoding.UTF8,0x1000)) {
     writer.WriteLine(string.Concat(new object[]{"\r\n",DateTime.Now,",",errorType,",",message,",",imagePath}));
   }
 }