Пример #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);
        }
Пример #2
0
        /// <summary>
        /// 关闭工站/设备,释放各种资源
        /// </summary>
        public void Close()
        {
            string errInfo = "";
            ///关闭工站
            IJFMainStation mainStation = StationMgr.MainStation;

            if (null != mainStation)
            {
                mainStation.Stop(out errInfo);
            }
            string[] stationNames = StationMgr.AllStationNames();
            if (null != stationNames && stationNames.Length > 0)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = StationMgr.GetStation(stationName);
                    station.Stop();
                }
            }
            ///关闭所有设备
            string[] deviceIDs = InitorManager.GetIDs(typeof(IJFDevice));
            if (null != deviceIDs && deviceIDs.Length > 0)
            {
                foreach (string devID in deviceIDs)
                {
                    IJFDevice dev = InitorManager.GetInitor(devID) as IJFDevice;
                    dev.CloseDevice();
                }
            }

            ///释放其他对象
            ///添加代码 ...
        }
Пример #3
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);
        }
Пример #4
0
        /// <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);
            }
        }
Пример #5
0
        /// <summary>
        /// 向工站发送一条指令(包含 开始/停止/暂停/恢复/结批 和用户自定义指令)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btSendCmd_Click(object sender, EventArgs e)
        {
            int selIndex = cbCmds.SelectedIndex;

            if (selIndex < 0)
            {
                JFTipsDelayClose.Show("请选择需要发送的指令", 2);//MessageBox.Show("请选择需要发送的指令");
                return;
            }
            JFWorkCmdResult cmdRet = JFWorkCmdResult.UnknownError;

            if (AllowedStartStopCmd)
            {
                if (selIndex < 5) //开始/暂停/恢复/结批/停止
                {
                    switch (selIndex)
                    {
                    case 0: cmdRet = _station.Start(); break;

                    case 1: cmdRet = _station.Pause(1000); break;

                    case 2: cmdRet = _station.Resume(1000); break;

                    case 3: cmdRet = _station.EndBatch(1000); break;

                    case 4: cmdRet = _station.Stop(1000); break;
                    }
                }
                else
                {
                    int cmdIndex = selIndex - 5;
                    cmdRet = _station.SendCmd(_station.AllCmds[cmdIndex], 1000);
                }
            }
            else
            {
                if (selIndex < 2) //暂停/恢复
                {
                    switch (selIndex)
                    {
                    case 0: cmdRet = _station.Pause(1000); break;

                    case 1: cmdRet = _station.Resume(1000); break;
                    }
                }
                else
                {
                    int cmdIndex = selIndex - 2;
                    cmdRet = _station.SendCmd(_station.AllCmds[cmdIndex], 1000);
                }
            }
            string errInfo = "";

            switch (cmdRet)
            {
            case JFWorkCmdResult.UnknownError:    // = -1, //发生未定义的错误
                errInfo = "未知错误";
                break;

            case JFWorkCmdResult.Success:    // = 0, //指令执行成功
                errInfo = "指令执行成功";
                break;

            case JFWorkCmdResult.IllegalCmd:    //,//不支持的非法指令
                errInfo = "不支持的非法指令";
                break;

            case JFWorkCmdResult.StatusError:    //, //工作状态(包括用户自定义状态)不支持当前指令 ,(向未运行的线程发送Resume指令)
                errInfo = "当前状态不支持该指令";
                break;

            case JFWorkCmdResult.ActionError:    //, //指令执行失败
                errInfo = "执行失败";
                break;

            case JFWorkCmdResult.Timeout:    //,//线程超时未响应
                errInfo = "指令执行超时";
                break;
            }

            if (cmdRet != JFWorkCmdResult.Success)
            {
                JFTipsDelayClose.Show("指令:" + cbCmds.Text + " 发送失败:" + errInfo, 3);
            }
            else
            {
                ShowTips("指令:" + cbCmds.Text + "发送完成");
            }
        }
Пример #6
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);
        }
Пример #7
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);
        }