/// <summary> /// 终止任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TerminateBtn_Click(object sender, RoutedEventArgs e) { try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } string dev = CBdev.Text; ARF arf = new ARF(dev); if (arf.DeviceStatus() == ARF.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } byte[] order = ARF._StopTask(arf.ARFNum()); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); return; } Notice.Show("终止任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, true); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error); } }
/// <summary> /// 终止任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TerminateBtn_Click(object sender, RoutedEventArgs e) { string dev = ""; byte[] order = null; try { if (CBdev.SelectedIndex == -1) { Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info); return; } dev = CBdev.Text; ARF arf = new ARF(dev); if (arf.DeviceStatus() == ARF.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } order = ARF._StopTask(arf.ARFNum()); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "摆渡车-终止任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString()); return; } Notice.Show("终止任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success); DataControl._mSocket.SwithRefresh(dev, true); } catch (Exception ex) { Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "摆渡车-终止任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }