/// <summary> /// 工站暂停 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItemPause_Click(object sender, EventArgs e) { if (null == _station) { MessageBox.Show("无效操作,工站未设置"); return; } JFWorkStatus ws = _station.CurrWorkStatus; if (!JFStationBase.IsWorkingStatus(ws)) { JFTipsDelayClose.Show("无效操作,工站当前未运行:" + ws, 1); return; } if (ws == JFWorkStatus.Pausing) { JFTipsDelayClose.Show("无效操作,工站当前已暂停", 1); return; } JFWorkCmdResult ret = _station.Pause(2000); if (ret != JFWorkCmdResult.Success) { MessageBox.Show("工站暂停失败,错误代码:" + ret); } else { ShowTips("操作信息:工站已暂停"); JFTipsDelayClose.Show("工站已暂停", 1); } }
/// <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); }
/// <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 + "发送完成"); } }