Ejemplo n.º 1
0
        /* Data Looks like this
         * DS 01 245 TIME
         * ...
         * RR 0000 0232   05:27:51.01040
         * ...
         * RR 0002 9999   06:06:01.35403
         * DE 01
         */
        public TagHeuerData ParseRR(string line)
        {
            line = TrimNewEndLine(line);

            TagHeuerData parsedData = null;

            string prefix = line.Substring(0, 2);

            if (prefix == "RR")
            {
                string rank    = line.Substring(3, 4);
                string number  = line.Substring(8, 4);
                string timeStr = line.Substring(15);
                try
                {
                    int      nRank   = int.Parse(rank);
                    int      nNumber = int.Parse(number);
                    string[] formats = { @"hh\:mm\:ss\.fffff", @"hh\:mm\:ss\.ffff", @"hh\:mm\:ss\.fff", @"hh\:mm\:ss\.ff", @"hh\:mm\:ss\.f" };
                    timeStr = timeStr.TrimEnd(' ');
                    TimeSpan time = TimeSpan.ParseExact(timeStr, formats, System.Globalization.CultureInfo.InvariantCulture);

                    parsedData = new TagHeuerData {
                        Number = nNumber, Rank = nRank, Time = time
                    };
                }
                catch (FormatException)
                {
                    throw;
                }
            }
            return(parsedData);
        }
Ejemplo n.º 2
0
        public IEnumerable <TimingData> TimingData()
        {
            do
            {
                TagHeuerData parsedData = null;
                try
                {
                    string dataLine = _parser.TrimNewEndLine(_serialPort.ReadLine());

                    if (dataLine.StartsWith("DE ")) // until "DE NN"
                    {
                        break;
                    }

                    parsedData = _parser.ParseRR(dataLine);
                }
                catch (TimeoutException)
                {
                    break; // no new data
                }
                catch (Exception)
                { }

                TimingData td = new TimingData
                {
                    Time = (_synchroTime + parsedData.Time).TimeOfDay
                };

                reportProgress(td.Time.ToString());

                yield return(td);
            } while (true);

            reportFinal();
        }