Exemplo n.º 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);
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
        string[] _currStations = null; //当前正在显示的工站


        /// <summary>
        /// 根据当前已激活的工站,布局界面
        /// </summary>
        public void AdjustView()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustView));
                return;
            }
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

            string[] allEnabledStationName = stationMgr.AllEnabledStationNames();
            if (allEnabledStationName == null || allEnabledStationName.Length == 0)
            {
                _currStations = null;
                pnStations.Controls.Clear();
                return;
            }

            if (_currStations != null)
            {
                if (_currStations.Length == allEnabledStationName.Length)
                {
                    bool isSame = true;
                    for (int i = 0; i < _currStations.Length; i++)
                    {
                        if (_currStations[i] != allEnabledStationName[i])
                        {
                            isSame = false;
                            break;
                        }
                    }
                    if (isSame) //不需要更新界面
                    {
                        return;
                    }
                }
            }
            _currStations = allEnabledStationName;
            //将当前工站界面和消息回调解除绑定
            foreach (Control ui in pnStations.Controls)
            {
                stationMgr.RemoveStationMsgReciever(ui as IJFStationMsgReceiver);
            }
            pnStations.Controls.Clear();
            foreach (string enabledStationName in allEnabledStationName)
            {
                IJFStation station = stationMgr.GetStation(enabledStationName);
                //JFRealtimeUI ui = station.GetRealtimeUI(); //如果station不提供界面,则提供一个默认的
                //if(null == ui)
                UcStationRealtimeUI ui = new UcStationRealtimeUI();
                ui.JfDisplayMode = UcStationRealtimeUI.JFDisplayMode.simple;
                ui.SetStation(station);
                stationMgr.AppendStationMsgReceiver(station, ui);
                pnStations.Controls.Add(ui);
            }
        }
Exemplo n.º 4
0
        string[] _currStationNames = null; //当前正在显示的工站列表


        /// <summary>
        /// 检查启动工站列表项
        /// </summary>
        void _CheckStationNamesInMenu() //
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[] allEnabledStaions = mgr.AllEnabledStationNames();
            if (allEnabledStaions == null || allEnabledStaions.Length == 0)
            {
                toolStripMenuItemStations.DropDownItems.Clear();
                return;
            }
            List <string> currStations = new List <string>(); //当前列表中的工站
            List <string> chkdStations = new List <string>();

            foreach (ToolStripMenuItem mi in toolStripMenuItemStations.DropDownItems)
            {
                currStations.Add(mi.Text);
                if (mi.Checked)
                {
                    chkdStations.Add(mi.Text);
                }
            }
            List <string> checkedStatios = new List <string>(); //当前已选中参与测试的工站

            if (allEnabledStaions.Length == currStations.Count)
            {
                bool isSame = true;
                for (int i = 0; i < allEnabledStaions.Length; i++)
                {
                    if (allEnabledStaions[i] != currStations[i])
                    {
                        isSame = false;
                        break;
                    }
                }
                if (isSame)
                {
                    return;
                }
            }
            toolStripMenuItemStations.DropDownItems.Clear();
            foreach (string s in allEnabledStaions)
            {
                ToolStripMenuItem mi = new ToolStripMenuItem(s, null, onToolStipItemStationClicked);
                toolStripMenuItemStations.DropDownItems.Add(mi);
                if (chkdStations.Contains(s))
                {
                    mi.Checked = true;
                }
            }
        }
Exemplo n.º 5
0
        private void btAuto_Click(object sender, EventArgs e)
        {
            if (IsAutoRunning) //当前处于自动化运行模式
            {
                JustShowSubForm(_autoForm);
            }
            else //非自动运行状态,可能有工站正在运行测试
            {
                JFStationManager stationMgr            = JFHubCenter.Instance.StationMgr;
                string[]         allEnableStationNames = stationMgr.AllEnabledStationNames();
                if (null == allEnableStationNames || allEnableStationNames.Length == 0)
                {
                    JustShowSubForm(_autoForm);
                    statusLabelRunMode.Text = "自动运行";
                    return;
                }


                List <IJFStation> runningStations = new List <IJFStation>();
                foreach (string sn in allEnableStationNames)
                {
                    IJFStation station = stationMgr.GetStation(sn);
                    if (_isStationWorking(station.CurrWorkStatus))
                    {
                        runningStations.Add(station);
                    }
                }

                if (runningStations.Count > 0)
                {
                    StringBuilder sbInfo = new StringBuilder("切换到自动运行模式失败,以下工站未停止:\n");
                    foreach (IJFStation station in runningStations)
                    {
                        sbInfo.AppendLine("工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString());
                    }
                    JFTipsDelayClose.Show(sbInfo.ToString(), 5);
                    return;
                }
                IsAutoRunning = true;
                JustShowSubForm(_autoForm);
                statusLabelRunMode.Text = "自动运行";
            }
        }
Exemplo n.º 6
0
        /// <summary>从暂停中恢复运行</summary>
        public virtual bool Resume(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            if (WorkStatus == JFWorkStatus.Running)
            {
                errorInfo = "当前正在运行!恢复运行指令将被忽略";
                return(true);
            }
            if (WorkStatus != JFWorkStatus.Pausing)
            {
                errorInfo = "当前状态 = " + WorkStatus + ",不能响应恢复运行指令";
                return(false);
            }

            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

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

            foreach (string sn in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(sn);
                JFWorkCmdResult ret     = station.Resume(1000);
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + "恢复运行失败:" + ret.ToString();
                    return(false);
                }
            }

            errorInfo  = "Success";
            WorkStatus = JFWorkStatus.Running;
            return(true);
        }
Exemplo n.º 7
0
        /// <summary>暂停</summary>
        public virtual bool Pause(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            if (WorkStatus != JFWorkStatus.Running)
            {
                errorInfo = "设备当前状态:" + WorkStatus.ToString();
                return(false);
            }
            if (WorkStatus == JFWorkStatus.Pausing)
            {
                errorInfo = "Success";
                return(true);
            }
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

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

            foreach (string sn in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(sn);
                JFWorkCmdResult ret     = station.Pause(-1);
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 暂停失败:" + ret.ToString();
                    return(false);
                }
            }

            WorkStatus = JFWorkStatus.Pausing;
            errorInfo  = "Success";
            return(true);
        }
Exemplo n.º 8
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);
        }