private void cancelRace_Click(object sender, EventArgs e)
        {
            AllLightsOff();
            this.pictindividualrecall.Image = Marconi.Properties.Resources.race_off_light;
            this.pictgeneralrecall.Image    = Marconi.Properties.Resources.race_off_light;

            logic.EventReset();

            span = new TimeSpan(0, 5, 0);

            lbCounter.Text = span.ToString();

            btStartRace.Enabled = true;

            btnIndividualRecall.Enabled = false;
            btGeneralRecall.Enabled     = false;
        }
示例#2
0
        private void buttonReset_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Please confirm you want to reset all races and shut down all lights.", "WARNING: Reset All Races", MessageBoxButtons.OKCancel);

            if (dialogResult == DialogResult.OK)
            {
                AllLightsOff();


                relayBoard.BoardReset();

                countDownSpan = new TimeSpan(0, 5, 0).ToString(@"mm\:ss");

                lbCounter.Text = countDownSpan;


                panel1.Visible       = false;
                panelButtons.Visible = false;
                panelStart.Visible   = true;
                panelRaces.Visible   = false;
                if (_activeRace != null)
                {
                    _activeRace.EventReset();
                }

                foreach (var item in _raceQueue)
                {
                    item.NewRaceClockEvent -= R_NewRaceClockEvent;

                    item.NewRaceEvent -= R_NewRaceEvent;
                    item.EventReset();

                    try
                    {
                        var sc = Scheduler.GetSchedule(item.RaceName);
                        sc.OnTrigger -= Sc_OnTrigger;

                        Scheduler.RemoveSchedule(item.RaceName);
                    }
                    catch (Exception ex)
                    {
                        log.Warn(ex);
                    }
                }
                _raceQueue.Clear();

                btnIndividualRecall.Enabled = false;
                btGeneralRecall.Enabled     = false;
                dateTimePicker1.Value       = DateTime.Now.AddMinutes(1);
            }
            else if (dialogResult == DialogResult.Cancel)
            {
                //do something else
            }
        }
        public MarconiRaceController()
        {
            InitializeComponent();
            relayBoard = RelayBoardDriver.Instance;

            logic     = new MarconiRaceControllerLogic();
            _raceList = new List <MarconiRaceControllerLogic>();
            _raceList.Add(logic);

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

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


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


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


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

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

            System.Media.SoundPlayer _soundPlayer = new SoundPlayer();
            Stream str = Marconi.Properties.Resources.marconi_race_sound1;

            _soundPlayer        = new System.Media.SoundPlayer();
            _soundPlayer.Stream = str;
            _soundPlayer.LoadAsync();

            logic.InternalPlayer = _soundPlayer;

            logic.BoardDriver = relayBoard;
            logic.EventReset();


            this.btGeneralRecall.Enabled     = false;
            this.btnIndividualRecall.Enabled = false;



            this.lblRelayBoardStatusValue.Text = relayBoard.RelayBoardMessage;
        }