Ejemplo n.º 1
0
 public void Parser()
 {
     // Not really tested, because the ALGETdC8001LineParser is tested in ALGETdC8001Tests
     ALGETdC8001LineParser parser = new ALGETdC8001LineParser();
     {
         parser.Parse(" 0035 C0  21:46:36.3910 00");
         Assert.AreEqual(' ', parser.TimingData.Flag);
         Assert.AreEqual(35U, parser.TimingData.StartNumber);
         Assert.AreEqual("C0", parser.TimingData.Channel);
         Assert.AreEqual(' ', parser.TimingData.ChannelModifier);
         Assert.AreEqual(new TimeSpan(0, 21, 46, 36, 391), parser.TimingData.Time);
     }
 }
        protected void processLine(string dataLine)
        {
            try
            {
                _parser.Parse(dataLine);
            }
            catch (Exception)
            {}

            if (_parser.TimingData == null)
            {
                return;
            }

            try
            {
                if (_parser.Mode == ALGETdC8001LineParser.EMode.LiveTiming)
                {
                    UpdateLiveDayTime(_parser.TimingData);

                    TimeMeasurementEventArgs timeMeasurmentData = TransferToTimemeasurementData(_parser.TimingData);
                    if (timeMeasurmentData != null)
                    {
                        // Trigger event
                        var handle = TimeMeasurementReceived;
                        handle?.Invoke(this, timeMeasurmentData);
                    }
                }
                else if (_parser.Mode == ALGETdC8001LineParser.EMode.Classement)
                {
                    ImportTimeEntry entry  = new ImportTimeEntry(_parser.TimingData.StartNumber, _parser.TimingData.Time);
                    var             handle = ImportTimeEntryReceived;
                    handle?.Invoke(this, entry);
                }
            }
            catch (FormatException)
            {}
        }
Ejemplo n.º 3
0
        public IEnumerable <TimingData> TimingData()
        {
            do
            {
                try
                {
                    string dataLine = _serialPort.ReadLine();
                    if (dataLine.StartsWith("  ALGE-TIMING"))
                    {
                        // End of data => read two more lines
                        _serialPort.ReadLine(); // "  TIMY V 1982"
                        _serialPort.ReadLine(); // "20-10-04  16:54"
                        break;
                    }
                    _parser.Parse(dataLine);
                }
                catch (TimeoutException)
                {
                    break; // no new data
                }
                catch (Exception)
                { }

                if (_parser.TimingData != null)
                {
                    TimingData td = new TimingData
                    {
                        Time = _parser.TimingData.Time
                    };

                    reportProgress(td.Time.ToString());

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

            reportFinal();
        }
Ejemplo n.º 4
0
        public void ParserModeTest()
        {
            List <Tuple <string, ALGETdC8001LineParser.EMode> > testData = new List <Tuple <string, ALGETdC8001LineParser.EMode> >
            {
                Tuple.Create(" 0035 C0M 21:46:36.3900 00", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create("CLASSEMENT:", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("ALL", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("RUN TIME", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create(" 0001 RTM 00:00:13.39   00 0001", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create(" 0002 RTM 00:00:13.68   00 0002", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create(" 0004 RTM 00:00:13.89   00 0003", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create(" 0003 RTM 00:00:14.05   00 0004", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("                                ", ALGETdC8001LineParser.EMode.Classement),
                Tuple.Create("  ALGE TIMING", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create("   TdC  8001", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create("  DEU V 18.92", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create("21 - 11 - 28  17:04", ALGETdC8001LineParser.EMode.LiveTiming),
                Tuple.Create(" 0035 C0  21:46:36.3910 00", ALGETdC8001LineParser.EMode.LiveTiming)
            };

            ALGETdC8001LineParser parser = new ALGETdC8001LineParser();

            int line = 0;

            foreach (var item in testData)
            {
                parser.Parse(item.Item1);
                Assert.AreEqual(item.Item2, parser.Mode);
                line++;
            }
        }
Ejemplo n.º 5
0
        public void ParserAndTransferToTimemeasurementDataTest()
        {
            TimeMeasurementEventArgs ParseAndTransfer(string line)
            {
                ALGETdC8001LineParser parser = new ALGETdC8001LineParser();

                parser.Parse(line);
                return(ALGETdC8001TimeMeasurement.TransferToTimemeasurementData(parser.TimingData));
            }

            {
                var pd = ParseAndTransfer(" 0035 C0M 21:46:36.3900 00");
                Assert.AreEqual(35U, pd.StartNumber);
                Assert.AreEqual(true, pd.BStartTime);
                Assert.AreEqual(new TimeSpan(0, 21, 46, 36, 390), pd.StartTime);
                Assert.AreEqual(false, pd.BFinishTime);
                Assert.AreEqual(false, pd.BRunTime);
            }

            {
                var pd = ParseAndTransfer(" 0035 C0  21:46:36.3910 00");
                Assert.AreEqual(35U, pd.StartNumber);
                Assert.AreEqual(true, pd.BStartTime);
                Assert.AreEqual(new TimeSpan(0, 21, 46, 36, 391), pd.StartTime);
                Assert.AreEqual(false, pd.BFinishTime);
                Assert.AreEqual(false, pd.BRunTime);
            }

            {
                var pd = ParseAndTransfer(" 0001 RTM 00:00:20.1    00");
                Assert.AreEqual(1U, pd.StartNumber);
                Assert.AreEqual(true, pd.BRunTime);
                Assert.AreEqual(new TimeSpan(0, 0, 0, 20, 100), pd.RunTime);
                Assert.AreEqual(false, pd.BFinishTime);
                Assert.AreEqual(false, pd.BStartTime);
            }

            { // Disqualified
                var pd = ParseAndTransfer("d0035 C0  21:46:36.3910 00");
                Assert.AreEqual(35U, pd.StartNumber);
                Assert.AreEqual(true, pd.BStartTime);
                Assert.AreEqual(null, pd.StartTime);
                Assert.AreEqual(false, pd.BFinishTime);
                Assert.AreEqual(false, pd.BRunTime);
            }
            { // Cleared data
                var pd = ParseAndTransfer("c0035 C0  21:46:36.3910 00");
                Assert.AreEqual(35U, pd.StartNumber);
                Assert.AreEqual(true, pd.BStartTime);
                Assert.AreEqual(null, pd.StartTime);
                Assert.AreEqual(false, pd.BFinishTime);
                Assert.AreEqual(false, pd.BRunTime);
            }

            // Ignored data (first character)
            { // Invalid startnumber
                var pd = ParseAndTransfer("?0034 C1M 21:46:48.3300 00");
                Assert.IsNull(pd);
            }
            { // penalty time (parallelslalom)
                var pd = ParseAndTransfer("p0034 C1M 21:46:48.3300 00");
                Assert.IsNull(pd);
            }
            { // time was blocked with block key)
                var pd = ParseAndTransfer("b0034 C1M 21:46:48.3300 00");
                Assert.IsNull(pd);
            }
            { // memory time TODO: Check
                var pd = ParseAndTransfer("m0034 C1M 21:46:48.3300 00");
                Assert.IsNull(pd);
            }
            {
                var pd = ParseAndTransfer("n0034");
                Assert.IsNull(pd);
            }
            {
                var pd = ParseAndTransfer("s0003");
                Assert.IsNull(pd);
            }
        }
Ejemplo n.º 6
0
        public void ParserClassementTest()
        {
            ALGETdC8001LineParser parser = new ALGETdC8001LineParser();

            {
                parser.Parse("                                ");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("CLASSEMENT:");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse("ALL");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse("RUN TIME");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse(" 0001 RTM 00:00:13.39   00 0001");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(1U, parser.TimingData.StartNumber);
                Assert.AreEqual(new TimeSpan(0, 0, 0, 13, 390), parser.TimingData.Time);
                Assert.AreEqual("RT", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse(" 0002 RTM 00:00:13.68   00 0002");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(2U, parser.TimingData.StartNumber);
                Assert.AreEqual(new TimeSpan(0, 0, 0, 13, 680), parser.TimingData.Time);
                Assert.AreEqual("RT", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse(" 0004 RTM 00:00:13.89   00 0003");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(4U, parser.TimingData.StartNumber);
                Assert.AreEqual(new TimeSpan(0, 0, 0, 13, 890), parser.TimingData.Time);
                Assert.AreEqual("RT", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse(" 0003 RTM 00:00:14.05   00 0004");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(3U, parser.TimingData.StartNumber);
                Assert.AreEqual(new TimeSpan(0, 0, 0, 14, 50), parser.TimingData.Time);
                Assert.AreEqual("RT", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.Classement, parser.Mode);
            }
            {
                parser.Parse("  ALGE TIMING");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("   TdC  8001");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("  DEU V 18.92");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("21-11-28  17:04");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
        }
Ejemplo n.º 7
0
        public void ParserTest()
        {
            ALGETdC8001LineParser parser = new ALGETdC8001LineParser();

            {
                parser.Parse(" 0035 C0M 21:46:36.3900 00");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(35U, parser.TimingData.StartNumber);
                Assert.AreEqual("C0", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(new TimeSpan(0, 21, 46, 36, 390), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }

            {
                parser.Parse(" 0035 C0  21:46:36.3910 00");
                Assert.AreEqual(' ', parser.TimingData.Flag);
                Assert.AreEqual(35U, parser.TimingData.StartNumber);
                Assert.AreEqual("C0", parser.TimingData.Channel);
                Assert.AreEqual(' ', parser.TimingData.ChannelModifier);
                Assert.AreEqual(new TimeSpan(0, 21, 46, 36, 391), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }

            {
                parser.Parse("?0034 C1M 21:46:48.3300 00");
                Assert.AreEqual('?', parser.TimingData.Flag);
                Assert.AreEqual(34U, parser.TimingData.StartNumber);
                Assert.AreEqual("C1", parser.TimingData.Channel);
                Assert.AreEqual('M', parser.TimingData.ChannelModifier);
                Assert.AreEqual(new TimeSpan(0, 21, 46, 48, 330), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }

            {
                parser.Parse("n0034");
                Assert.AreEqual('n', parser.TimingData.Flag);
                Assert.AreEqual(34U, parser.TimingData.StartNumber);
                Assert.AreEqual("", parser.TimingData.Channel);
                Assert.AreEqual(' ', parser.TimingData.ChannelModifier);
                Assert.AreEqual(new TimeSpan(), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }

            {
                // Uncommon input for parser
                parser.Parse("                                ");
                Assert.IsNull(parser.TimingData);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            #region Different Time Accuracy
            {
                parser.Parse("?0034 C1M 21:46:48.1230 00");
                Assert.AreEqual(new TimeSpan(0, 21, 46, 48, 123), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("?0034 C1M 21:46:48.123  00");
                Assert.AreEqual(new TimeSpan(0, 21, 46, 48, 123), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("?0034 C1M 21:46:48.12   00");
                Assert.AreEqual(new TimeSpan(0, 21, 46, 48, 120), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("?0034 C1M 21:46:48.1    00");
                Assert.AreEqual(new TimeSpan(0, 21, 46, 48, 100), parser.TimingData.Time);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            #endregion

            #region ALGE WTN
            {
                parser.Parse("t0003 C1  16:01:56.6585 00");
                Assert.AreEqual('t', parser.TimingData.Flag);
                Assert.AreEqual(3U, parser.TimingData.StartNumber);
                Assert.AreEqual("C1", parser.TimingData.Channel);
                Assert.AreEqual(' ', parser.TimingData.ChannelModifier);
                Assert.AreEqual((new TimeSpan(0, 16, 01, 56, 658)).AddMicroseconds(500), parser.TimingData.Time);
            }
            #endregion

            #region Short Lines
            {
                parser.Parse("n0003");
                Assert.AreEqual('n', parser.TimingData.Flag);
                Assert.AreEqual(3U, parser.TimingData.StartNumber);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            {
                parser.Parse("s0003");
                Assert.AreEqual('s', parser.TimingData.Flag);
                Assert.AreEqual(3U, parser.TimingData.StartNumber);
                Assert.AreEqual(ALGETdC8001LineParser.EMode.LiveTiming, parser.Mode);
            }
            #endregion
        }