Example #1
0
        /// <summary>停止运行</summary>
        public virtual bool Stop(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            //if (!IsStationRunning(WorkStatus))
            //{
            //    errorInfo = "Success";
            //    return true;
            //}
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "Success";
                return(true);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    JFWorkCmdResult ret = station.Stop(1000);
                    if (ret != JFWorkCmdResult.Success)
                    {
                        station.Abort();
                    }
                }
            }

            WorkStatus = JFWorkStatus.CommandExit;
            errorInfo  = "Success";
            return(true);
        }
Example #2
0
        /// <summary>
        /// 停止工站日志记录/显示
        /// 在程序退出前调用
        /// </summary>
        public void Stop()
        {
            string errorInfo;

            MainStation.Stop(out errorInfo);
            string[] stationNames = AllStationNames();
            if (null != stationNames)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = GetStation(stationName);
                    if (IsStationRunning(station))
                    {
                        JFWorkCmdResult ret = station.Stop(1000);
                        if (ret != JFWorkCmdResult.Success)
                        {
                            //日后可能添加强制关闭的系统日志...
                            station.Abort();
                        }
                    }
                }
            }
            JFLoggerManager.Instance.Stop();
            StopShowStationLog();
            if (null != stationNames)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = GetStation(stationName);
                    station.WorkStatusChanged   -= StationWorkStatusChanged;
                    station.CustomStatusChanged -= StationCustomStatusChanged;
                    if (station is JFCmdWorkBase)
                    {
                        (station as JFCmdWorkBase).WorkMsg2Outter -= StationTxtMsg;
                    }

                    if (station is JFStationBase)
                    {
                        (station as JFStationBase).EventCustomizeMsg    -= StationCustomizeMsg;
                        (station as JFStationBase).EventProductFinished -= StationProductFinished;
                    }
                }
            }

            Thread.Sleep(2000);
        }
        /// <summary>
        /// 停止单工站运行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItemStop_Click(object sender, EventArgs e)
        {
            if (null == _station)
            {
                MessageBox.Show("无效操作,工站未设置");
                return;
            }

            JFWorkCmdResult ret = _station.Stop(2000);

            if (ret != JFWorkCmdResult.Success)
            {
                if (DialogResult.OK == MessageBox.Show(" 停止操作失败,错误代码:" + ret + "\n是否强制终止?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Error))
                {
                    _station.Abort();
                    JFTipsDelayClose.Show("工站已强制停止!", 2);
                }
            }
            else
            {
                JFTipsDelayClose.Show("工站已停止!", 2);
            }
        }
Example #4
0
        public virtual bool Start(out string errorInfo)//开始运行
        {
            errorInfo = "Unknown Error";
            if (IsAlarming)
            {
                errorInfo = "当前处于报警状态";
                return(false);
            }
            if (IsStationRunning(WorkStatus))
            {
                errorInfo = "Success";
                return(true);
            }
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "不存在使能的工站";
                return(false);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    errorInfo = "启动失败,工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString();
                    return(false);
                }
            }

            int failedIndex = -1; //启动失败的工站号

            foreach (string stationName in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(stationName);
                JFWorkCmdResult ret     = station.Start();
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 启动失败,Error:" + ret.ToString();
                    break;
                }
            }

            if (failedIndex > -1)
            {
                for (int i = 0; i < failedIndex + 1; i++)
                {
                    IJFStation station = stationMgr.GetStation(allEnableStationNames[i]);
                    if (JFWorkCmdResult.Success != station.Stop(100))
                    {
                        station.Abort();
                    }
                }
                return(false);
            }
            WorkStatus = JFWorkStatus.Running;
            errorInfo  = "Success";
            return(true);
        }
Example #5
0
        public virtual bool Start(out string errorInfo)//开始运行
        {
            errorInfo = "Unknown Error";
            if (IsAlarming)
            {
                errorInfo = "当前处于报警状态";
                return(false);
            }
            if (IsStationRunning(WorkStatus))
            {
                errorInfo = "Success";
                return(true);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm)
            {
                errorInfo = "配方管理器未创建!";
                return(false);
            }
            if (!rm.IsInitOK)
            {
                errorInfo = "配方管理器初始化未完成,ErrorInfo:" + rm.GetInitErrorInfo();
                return(false);
            }



            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "不存在使能的工站";
                return(false);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    errorInfo = "启动失败,工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString();
                    return(false);
                }
            }

            ///检查当前RecipeID 和 LotID
            if (string.IsNullOrEmpty(CurrRecipeID))
            {
                errorInfo = "启动失败:当前产品ID未设置";
                return(false);
            }

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(SCN_CategotyProd);
            if (null == allRecipeIDs || !allRecipeIDs.Contains(CurrRecipeID))
            {
                errorInfo = "启动失败,当前产品ID:" + CurrRecipeID + " 在配方管理器中不存在";
                return(false);
            }


            if (string.IsNullOrEmpty(CurrLotID))
            {
                errorInfo = "启动失败:当前批次号未设置!";
                return(false);
            }



            int failedIndex = -1; //启动失败的工站号

            foreach (string stationName in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(stationName);
                JFWorkCmdResult ret     = station.Start();
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 启动失败,Error:" + ret.ToString();
                    break;
                }
            }

            if (failedIndex > -1)
            {
                for (int i = 0; i < failedIndex + 1; i++)
                {
                    IJFStation station = stationMgr.GetStation(allEnableStationNames[i]);
                    if (JFWorkCmdResult.Success != station.Stop(100))
                    {
                        station.Abort();
                    }
                }
                return(false);
            }
            WorkStatus = JFWorkStatus.Running;
            errorInfo  = "Success";
            return(true);
        }