/// <summary> /// 开始单工站运行 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItemStart_Click(object sender, EventArgs e) { if (null == _station) { MessageBox.Show("无效操作,工站未设置"); return; } JFWorkStatus ws = _station.CurrWorkStatus; if (ws == JFWorkStatus.Running || ws == JFWorkStatus.Pausing || ws == JFWorkStatus.Interactiving) { JFTipsDelayClose.Show("无效操作,工站当前正在运行:" + ws, 1); return; } //EnableStationMsgReceive = true; JFWorkCmdResult ret = _station.Start(); if (ret != JFWorkCmdResult.Success) { MessageBox.Show("启动工站失败,错误代码:" + ret); //EnableStationMsgReceive = false; } else { JFTipsDelayClose.Show("操作信息:工站已启动", 1); } }
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; } }
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); }
/// <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 + "发送完成"); } }
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); }