Example #1
0
        /// <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;
                RGV    rgv = new RGV(dev);
                if (rgv.DeviceStatus() == RGV.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                byte[] order = RGV._StopTask(rgv.RGVNum());
                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);
            }
        }
Example #2
0
        /// <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;
                RGV rgv = new RGV(dev);
                if (rgv.DeviceStatus() == RGV.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                order = RGV._StopTask(rgv.RGVNum());
                if (!DataControl._mSocket.SendToClient(dev, order, out string result))
                {
                    Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error);
                    // LOG
                    DataControl._mTaskTools.RecordTaskErrLog("TerminateBtn_Click()", "运输车-终止任务[RGV,指令]", 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()", "运输车-终止任务[RGV,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message);
            }
        }