示例#1
0
        /// <summary>
        /// 设备运行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStart_Click(object sender, EventArgs e)
        {
            IJFMainStation ms = JFHubCenter.Instance.StationMgr.MainStation;

            if (ms.WorkStatus == JFWorkStatus.Running)
            {
                JFTipsDelayClose.Show("无效操作:正在运行中", 2);
                return;
            }
            string errorInfo;

            if (!_isStationWorking(ms.WorkStatus))
            {
                ///先将所有使能工站切换为自动模式
                JFStationManager mgr = JFHubCenter.Instance.StationMgr;
                string[]         allEnableStationNames = mgr.AllEnabledStationNames();
                if (null != allEnableStationNames)
                {
                    foreach (string sn in allEnableStationNames)
                    {
                        IJFStation station = mgr.GetStation(sn);
                        if (!station.SetRunMode(JFStationRunMode.Auto))
                        {
                            MessageBox.Show("启动运行失败,未能将工站:" + sn + "切换为自动运行模式");
                            return;
                        }
                    }
                }


                //// 添加消息回调
                //string[] allEnableStationNames = JFHubCenter.Instance.StationMgr.AllEnabledStationNames();
                bool isOK = ms.Start(out errorInfo);
                if (!isOK)
                {
                    MessageBox.Show("启动失败:" + errorInfo);
                    return;
                }
                else
                {
                    JFTipsDelayClose.Show("设备开始运行", 1);
                }
            }

            if (ms.WorkStatus == JFWorkStatus.Pausing) //当前处于暂停状态
            {
                bool isOK = ms.Resume(out errorInfo);
                if (!isOK)
                {
                    MessageBox.Show("恢复运行失败:" + errorInfo);
                    return;
                }
                else
                {
                    JFTipsDelayClose.Show("设备开始运行", 1);
                }
            }
        }
        /// <summary>
        /// 工站自动运行模式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItemAuto_Click(object sender, EventArgs e)
        {
            JFWorkStatus ws = _station.CurrWorkStatus;

            if (ws == JFWorkStatus.Running || ws == JFWorkStatus.Pausing || ws == JFWorkStatus.Interactiving)
            {
                MessageBox.Show("工站正在运行,不能修改运行模式");
                return;
            }
            bool isOK = _station.SetRunMode(JFStationRunMode.Auto);

            if (isOK)
            {
                toolStripMenuItemAuto.Checked   = true;
                toolStripMenuItemManual.Checked = false;
            }
            else
            {
                MessageBox.Show("设置自动/连续模式 失败");
            }
        }