Exemplo n.º 1
0
        void AdjustStationList() //
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[] allStationNames = mgr.AllStationNames();
            if (null == allStationNames || 0 == allStationNames.Length)
            {
                _currStationNames = null;
                tabControlCF1.TabPages.Clear();
                toolStripMenuItemStations.DropDownItems.Clear();
                return;
            }

            if (null != _currStationNames && _currStationNames.Length == allStationNames.Length)
            {
                bool isSame = true;
                for (int i = 0; i < _currStationNames.Length; i++)
                {
                    if (_currStationNames[i] != allStationNames[i])
                    {
                        isSame = false;
                        break;
                    }
                }
                if (isSame)
                {
                    _CheckStationNamesInMenu();
                    return;
                }
            }
            _currStationNames = allStationNames;

            tabControlCF1.TabPages.Clear();
            _dctStationForms.Clear();
            foreach (string stationName in allStationNames)
            {
                TabPage tp = new TabPage(stationName);
                FormSingleStationTest fmStationTest = new FormSingleStationTest();
                fmStationTest.SetStation(mgr.GetStation(stationName));
                fmStationTest.FormBorderStyle = FormBorderStyle.None;
                fmStationTest.TopLevel        = false;
                fmStationTest.ShowInTaskbar   = false;
                fmStationTest.Dock            = DockStyle.Fill;
                fmStationTest.Parent          = tp;
                fmStationTest.Show();
                tp.Controls.Add(fmStationTest);
                tabControlCF1.TabPages.Add(tp);
                ToolStripMenuItem tsi = new ToolStripMenuItem(stationName, null, onToolStipItemStationClicked);
                toolStripMenuItemStations.DropDownItems.Add(tsi);
                _dctStationForms.Add(mgr.GetStation(stationName), fmStationTest);
            }
            _CheckStationNamesInMenu();
        }
Exemplo n.º 2
0
        Dictionary <IJFStation, FormSingleStationTest> _dctTestingForms = new Dictionary <IJFStation, FormSingleStationTest>(); //参与当前测试的

        /// <summary>
        /// 启动所有选中的工站
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStart_Click(object sender, EventArgs e)
        {
            if (_isTesting)
            {
                MessageBox.Show("无效操作,当前测试正在运行");
                return;
            }

            string[] willTestStationNames = TestStationNames();
            if (null == willTestStationNames || 0 == willTestStationNames.Length)
            {
                MessageBox.Show("请先选择参与测试运行的工站!\n菜单->启动测试");
                return;
            }

            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[]      allStationNames     = mgr.AllStationNames();
            List <string> runningStationNames = new List <string>(); //当前正在运行的工站

            foreach (string s in allStationNames)
            {
                if (JFStationBase.IsWorkingStatus(mgr.GetStation(s).CurrWorkStatus))
                {
                    runningStationNames.Add(s);
                }
            }
            if (runningStationNames.Count > 0)
            {
                string info = "以下工站正在运行:\n";
                foreach (string s in runningStationNames)
                {
                    info += s + "\n";
                }
                info += "是否继续?";
                if (DialogResult.Cancel == MessageBox.Show(info, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                {
                    return;
                }
            }
            _isTesting = true;
            //mgr.EventStationWorkStatusChanged += OnStationWorkStatusChanged;
            _dctTestingForms.Clear();

            string Tipsinfo = "已启动工站:\n";

            foreach (string s in willTestStationNames)
            {
                IJFStation station = mgr.GetStation(s);
                _dctTestingForms.Add(station, _dctStationForms[station]);
                //_dctStationForms[station].EnableStationMsgReceive = true;
                JFWorkCmdResult ret = station.Start();
                if (ret != JFWorkCmdResult.Success) //启动工站失败
                {
                    //_dctStationForms[station].EnableStationMsgReceive = false;
                    foreach (KeyValuePair <IJFStation, FormSingleStationTest> kv in _dctTestingForms)
                    {
                        if (kv.Key.Stop(500) != JFWorkCmdResult.Success)
                        {
                            kv.Key.Abort();
                        }
                    }
                    _isTesting = false;
                    MessageBox.Show("启动工站:" + station.Name + "失败,ErrorCode = " + ret);
                    return;
                }

                Tipsinfo += s + "\n";

                JFTipsDelayClose.Show(Tipsinfo, 2);
                btReset.Enabled  = false;
                btResume.Enabled = true;
                btPause.Enabled  = true;
            }
        }