private void ParseDataLine(string line, ScanDirection direction) { if (string.IsNullOrWhiteSpace(line)) { return; } char[] charSeparators = { ';' }; // fields are separated by semicolons string[] tokens = line.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); if (tokens.Length != 5) { return; } DataMask = long.Parse(tokens[2]); // the data mask is hopefully always the same int scanLineLength = int.Parse(tokens[1]); DateTime timeStamp = ParseTimeToken(tokens[0]); if (direction == ScanDirection.Forward) { ForwardProfileLengths.Add(scanLineLength); forwardTimeStamps.Add(timeStamp); } if (direction == ScanDirection.Backward) { BackwardProfileLengths.Add(scanLineLength); backwardTimeStamps.Add(timeStamp); } }
private void FindShortProfiles(int nominalProfileLength) { if (ForwardProfileLengths.Count() > 0) { ProfilsDefectsForward = new int[ForwardProfileLengths.Count()]; for (int i = 0; i < ForwardProfileLengths.Count(); i++) { ProfilsDefectsForward[i] = nominalProfileLength - ForwardProfileLengths[i]; } } if (BackwardProfileLengths.Count() > 0) { ProfilsDefectsBackward = new int[BackwardProfileLengths.Count()]; for (int i = 0; i < BackwardProfileLengths.Count(); i++) { ProfilsDefectsBackward[i] = nominalProfileLength - BackwardProfileLengths[i]; } } }
private void AnalyzeDirectionStatus() { ScanStatus = ScanDirectionStatus.Unknown; SpuriousDataLines = 0; // no data at all if (ForwardProfileLengths.Count == 0) { ScanStatus = ScanDirectionStatus.NoData; return; } SpuriousProfiles = BackwardProfileLengths.Count - ForwardProfileLengths.Count; // backward scan data file invalid or not existing if (SpuriousProfiles < 0) { ScanStatus = ScanDirectionStatus.ForwardOnly; if (BackwardProfileLengths.Count != 0) { BackwardProfileLengths.Clear(); } SpuriousProfiles = 0; return; } // peculiar NMM file error if (SpuriousProfiles > 0) { ScanStatus = ScanDirectionStatus.ForwardAndBackwardJustified; for (int i = 0; i < SpuriousProfiles; i++) { SpuriousDataLines += BackwardProfileLengths[i]; } BackwardProfileLengths.RemoveRange(0, SpuriousProfiles); backwardTimeStamps.RemoveRange(0, SpuriousProfiles); return; } if (SpuriousProfiles == 0) { ScanStatus = ScanDirectionStatus.ForwardAndBackward; return; } }
} // the number of sporious data lines in the backward scan file private void DetermineNominalDataPointNumber() { NominalDataPoints = 0; DataPointsGlitch = 0; if (ScanStatus == ScanDirectionStatus.NoData) { return; } if (ScanStatus == ScanDirectionStatus.Unknown) { return; } if (NumberOfProfiles < 1) { return; } NominalDataPoints = ForwardProfileLengths.Max(); DataPointsGlitch = NominalDataPoints - ForwardProfileLengths.Min(); if (ScanStatus == ScanDirectionStatus.ForwardAndBackward || ScanStatus == ScanDirectionStatus.ForwardAndBackwardJustified) { NominalDataPoints = Math.Max(NominalDataPoints, BackwardProfileLengths.Max()); DataPointsGlitch = Math.Max(DataPointsGlitch, NominalDataPoints - BackwardProfileLengths.Min()); } }