/// <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; ABC abc = new ABC(dev); if (abc.DeviceStatus() == ABC.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } byte[] order = ABC._StopTask(abc.ABCNum()); 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; ABC abc = new ABC(dev); if (abc.DeviceStatus() == ABC.DeviceError) { Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error); return; } order = ABC._StopTask(abc.ABCNum()); if (!DataControl._mSocket.SendToClient(dev, order, out string result)) { Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error); // LOG DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "行车-终止任务[ABC,指令]", 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()", "行车-终止任务[ABC,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message); } }