private void EventStart()
        {
            log.Debug("Event Race Started was triggered, horn pattern is" + HornPatternEventStart + ", using Relay 1,3,5 all off");

            try
            {
                if (_boardDriver == null)
                {
                    throw new Exception("Relay board not connected or in used by a different race.");
                }


                _boardDriver.PlaySoundPattern(HornPatternEventStart, InternalPlayer);
                _boardDriver.Relay1_PowerOff();
                _boardDriver.Relay3_PowerOff();
                _boardDriver.Relay6_PowerOff();
            }
            catch (Exception ex)
            {
                log.Fatal("Event Race Started has thrown an exception: ", ex);
            }

            lock (this)
            {
                LastEventCode = RaceEventCode.T0;
                RaceStartTime = DateTime.Now;
                _raceInCourse = true;
                _timer.Tick  -= _timer_Tick;
                _timer.CancelTimer();
                _timer.Dispose();
            }
        }
        private void EventT5()
        {
            log.Debug("ËventT5 triggered, horn pattern is" + HornPatternEventT5 + ", using Relay 1");
            string[] _hornPattern = null;

            try
            {
                if (_boardDriver == null)
                {
                    throw new Exception("Relay board not connected or in used by a different race.");
                }

                _boardDriver.Relay1_PowerOn();
                _boardDriver.PlaySoundPattern(HornPatternEventT5, InternalPlayer);
            }
            catch (Exception ex)
            {
                log.Fatal("Event T1 has thrown an exception: ", ex);
            }


            lock (this)
            {
                LastEventCode = RaceEventCode.T5;
            }
            NewRaceEvent?.Invoke(this, new RaceEvent(LastEventCode.ToString()));
        }
        private void _timer_Tick(object sender, HighPrecisionTimer.TickEventArgs e)
        {
            _raceCountDown = span.Subtract(new TimeSpan(0, 0, Convert.ToInt32(e.Duration.TotalSeconds)));

            //this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate()
            //{
            //            lbCounter.Text = span.ToString();


            //});

            if (e.Duration.TotalSeconds >= 60 && LastEventCode == RaceEventCode.T5)
            {
                lock (this)
                {
                    LastEventCode = RaceEventCode.T4;
                }
                Task.Factory.StartNew(() =>
                {
                    EventT4();
                });
            }
            if (e.Duration.TotalSeconds >= 240 && LastEventCode == RaceEventCode.T4)
            {
                lock (this)
                {
                    LastEventCode = RaceEventCode.T1;
                }
                Task.Factory.StartNew(() =>
                {
                    EventT1();
                });

                //  pict1minleft.Image=Marconi.Properties.Resources.race_red_light;
            }

            if (e.Duration.TotalSeconds >= 300 && LastEventCode == RaceEventCode.T1)
            {
                lock (this)
                {
                    LastEventCode = RaceEventCode.T0;
                }
                Task.Factory.StartNew(() =>
                {
                    EventStart();
                });
            }

            NewRaceClockEvent?.Invoke(this, e);
            NewRaceEvent?.Invoke(this, new RaceEvent(LastEventCode.ToString()));
        }
        private void EventT4()
        {
            log.Debug("ËventT4 triggered, horn pattern is" + HornPatternEventT4 + ", using Relay3 ");


            try{
                if (_boardDriver == null)
                {
                    throw new Exception("Relay board not connected or in used by a different race.");
                }

                _boardDriver.Relay3_PowerOn();
                _boardDriver.PlaySoundPattern(HornPatternEventT4, InternalPlayer);
            }
            catch (Exception ex)
            {
                log.Fatal("Event T1 has thrown an exception: ", ex);
            }
            lock (this)
            {
                LastEventCode = RaceEventCode.T4;
            }
        }
        public MarconiRaceControllerLogic()
        {
            this.LastEventCode = RaceEventCode.W;


            if (ConfigurationManager.AppSettings["HornPatternEventT5"] != null)
            {
                HornPatternEventT5 = ConfigurationManager.AppSettings["HornPatternEventT5"];
            }
            else
            {
                HornPatternEventT5 = "1,1";
            }

            if (ConfigurationManager.AppSettings["HornPatternEventT4"] != null)
            {
                HornPatternEventT4 = ConfigurationManager.AppSettings["HornPatternEventT4"];
            }
            else
            {
                HornPatternEventT4 = "1,1";
            }


            if (ConfigurationManager.AppSettings["HornPatternEventT1"] != null)
            {
                HornPatternEventT1 = ConfigurationManager.AppSettings["HornPatternEventT1"];
            }
            else
            {
                HornPatternEventT1 = "1,1";
            }


            if (ConfigurationManager.AppSettings["HornPatternEventStart"] != null)
            {
                HornPatternEventStart = ConfigurationManager.AppSettings["HornPatternEventStart"];
            }
            else
            {
                HornPatternEventStart = "1,1";
            }


            if (ConfigurationManager.AppSettings["HornPatternEventGeneralRecall"] != null)
            {
                HornPatternEventGeneralRecall = ConfigurationManager.AppSettings["HornPatternEventGeneralRecall"];
            }
            else
            {
                HornPatternEventGeneralRecall = "1,1";
            }

            if (ConfigurationManager.AppSettings["HornPatternIndividualRecall"] != null)
            {
                HornPatternIndividualRecall = ConfigurationManager.AppSettings["HornPatternIndividualRecall"];
            }
            else
            {
                HornPatternIndividualRecall = "1,1";
            }
        }