/// <summary> /// 结批操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItemEndBatch_Click(object sender, EventArgs e) { if (null == _station) { MessageBox.Show("无效操作,工站未设置"); return; } JFWorkStatus ws = _station.CurrWorkStatus; if (!JFStationBase.IsWorkingStatus(ws)) { JFTipsDelayClose.Show("无效操作,工站当前未运行:" + ws, 1); return; } JFWorkCmdResult ret = _station.EndBatch(2000); if (ret != JFWorkCmdResult.Success) { MessageBox.Show("发送结批指令失败,错误代码:" + ret); } else { ShowTips("操作信息:结批指令已发送"); JFTipsDelayClose.Show("结批指令已发送", 1); } }
/// <summary> /// 工站恢复 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItemResume_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("无效操作,工站当前非暂停状态:" + ws, 1); return; } JFWorkCmdResult ret = _station.Resume(2000); if (ret != JFWorkCmdResult.Success) { MessageBox.Show("恢复运行失败,错误代码:" + ret); } else { ShowTips("操作信息:工站已恢复运行"); JFTipsDelayClose.Show("工站已恢复运行", 1); } }
/// <summary> /// 工站归零 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItemReset_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; } JFWorkCmdResult ret = _station.Reset(); if (ret != JFWorkCmdResult.Success) { MessageBox.Show("启动复位失败,错误代码:" + ret); } else { ShowTips("操作信息:复位已启动"); JFTipsDelayClose.Show("复位已启动", 1); } }
/// <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); } }
/// <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); } }
/// <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 + "发送完成"); } }