Esempio n. 1
0
        /// <summary>
        /// 定位任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocateBtn_Click(object sender, RoutedEventArgs e)
        {
            string dev = "";

            byte[] order = null;
            try
            {
                if (CBdev.SelectedIndex == -1)
                {
                    Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                if (string.IsNullOrEmpty(location.Text.Trim()))
                {
                    Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                dev = CBdev.Text;

                ARF arf = new ARF(dev);
                if (arf.ActionStatus() == ARF.Run)
                {
                    Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                if (arf.DeviceStatus() == ARF.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                if (!WindowCommon.ConfirmAction("是否发送定位指令!!"))
                {
                    return;
                }

                int loc = Convert.ToInt32(location.Text.Trim());
                order = ARF._Position(arf.ARFNum(), (byte)loc);
                DataControl._mSocket.SwithRefresh(dev, false);
                if (!DataControl._mSocket.SendToClient(dev, order, out string result))
                {
                    DataControl._mSocket.SwithRefresh(dev, true);
                    Notice.Show("指令发送失败:" + result.ToString(), "错误", 3, MessageBoxIcon.Error);
                    // LOG
                    DataControl._mTaskTools.RecordTaskErrLog("LocateBtn_Click()", "摆渡车-定位任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), result.ToString());
                    return;
                }
                Notice.Show("定位任务 指令发送成功!", "成功", 3, MessageBoxIcon.Success);
            }
            catch (Exception ex)
            {
                Notice.Show("指令发送失败:" + ex.Message, "错误", 3, MessageBoxIcon.Error);
                // LOG
                DataControl._mTaskTools.RecordTaskErrLog("LocateBtn_Click()", "摆渡车-定位任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 定位任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocateBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CBdev.SelectedIndex == -1)
                {
                    Notice.Show("请选择设备!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                if (string.IsNullOrEmpty(location.Text.Trim()))
                {
                    Notice.Show("请填写目的坐标!", "提示", 3, MessageBoxIcon.Info);
                    return;
                }
                string dev = CBdev.Text;

                ARF arf = new ARF(dev);
                if (arf.ActionStatus() == ARF.Run)
                {
                    Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                if (arf.DeviceStatus() == ARF.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                int    loc   = Convert.ToInt32(location.Text.Trim());
                byte[] order = ARF._Position(arf.ARFNum(), (byte)loc);
                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, false);
            }
            catch (Exception ex)
            {
                Notice.Show("指令发送失败:" + ex.ToString(), "错误", 3, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 摆渡车复位
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="mes"></param>
        public void ResetLoc_ARF(List <WCS_CONFIG_DEVICE> dev, out string mes)
        {
            try
            {
                // 摆渡车待命点1
                int loc1 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyF1"));
                // 摆渡车待命点2
                int loc2 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyF2"));

                // 获取当前摆渡车资讯
                ARF a1 = new ARF(dev[0].DEVICE);
                ARF a2 = new ARF(dev[1].DEVICE);

                // 定位任务指令
                byte[] order1;
                byte[] order2;

                // 任务明细
                WCS_TASK_ITEM item1;
                WCS_TASK_ITEM item2;

                if (a1.CurrentSite() < a2.CurrentSite())
                {
                    // 定位任务指令
                    order1 = ARF._Position(a1.ARFNum(), (byte)loc1);
                    order2 = ARF._Position(a2.ARFNum(), (byte)loc2);
                    // 任务明细
                    item1 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.摆渡车复位,
                        ID      = 1,
                        DEVICE  = dev[0].DEVICE,
                        LOC_TO  = loc1.ToString()
                    };
                    item2 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.摆渡车复位,
                        ID      = 2,
                        DEVICE  = dev[1].DEVICE,
                        LOC_TO  = loc2.ToString()
                    };
                }
                else
                {
                    // 定位任务指令
                    order1 = ARF._Position(a1.ARFNum(), (byte)loc2);
                    order2 = ARF._Position(a2.ARFNum(), (byte)loc1);
                    // 任务明细
                    item1 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.摆渡车复位,
                        ID      = 1,
                        DEVICE  = dev[0].DEVICE,
                        LOC_TO  = loc2.ToString()
                    };
                    item2 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.摆渡车复位,
                        ID      = 2,
                        DEVICE  = dev[1].DEVICE,
                        LOC_TO  = loc1.ToString()
                    };
                }
                // 加入任务作业链表
                mes = null;
                if (dev[0].FLAG == DeviceFlag.空闲)
                {
                    DataControl._mTaskControler.StartTask(new ARFTack(item1, DeviceType.摆渡车, order1));
                }
                else
                {
                    mes = dev[0].DEVICE + " 摆渡车目前无法操作复位任务; \r";
                }

                if (dev[1].FLAG == DeviceFlag.空闲)
                {
                    DataControl._mTaskControler.StartTask(new ARFTack(item2, DeviceType.摆渡车, order2));
                }
                else
                {
                    mes = mes + dev[0].DEVICE + " 摆渡车目前无法操作复位任务; \r";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }