예제 #1
0
        /// <summary>
        /// 获取当前目标对应的合适摆渡车
        /// </summary>
        /// <param name="loc"></param>
        /// <param name="device"></param>
        /// <returns></returns>
        public String GetSuitableARF(String loc, List <WCS_CONFIG_DEVICE> dList)
        {
            try
            {
                // 摆渡车
                ARF ARF;
                // 终选摆渡车
                String arf = String.Empty;
                // 距离比较值
                int X = 0;
                // 摆渡车于运输车对接点值
                int AR = Convert.ToInt32(ConfigurationManager.AppSettings["StandbyAR"]);

                // 遍历比对
                foreach (WCS_CONFIG_DEVICE d in dList)
                {
                    // 获取摆渡车设备资讯
                    ARF = new ARF(d.DEVICE);
                    // 命令状态为完成
                    // 当前坐标值
                    // 货物状态为无货
                }
                return("");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 public ARFDeviceModel(string devid, string area)
 {
     arf      = new ARF(devid);
     DeviceID = devid;
     Area     = area;
     Update();
 }
예제 #3
0
파일: TaskControl.cs 프로젝트: xdpcxq/WCS
 public ARFTack(WCS_TASK_ITEM item, string deviceType, byte[] order) : base(item, deviceType, order)
 {
     _device = new ARF(ITEM.DEVICE);
     log     = new Log("Task_ARF-" + ITEM.ID + "-");
     // 记录生成指令LOG
     log.LOG(DataControl._mTaskTools.GetLogMessC(item, order));
 }
예제 #4
0
파일: W_ARF.xaml.cs 프로젝트: xdpcxq/WCS
        /// <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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
파일: TaskTools.cs 프로젝트: xdpcxq/WCS
        /// <summary>
        /// 连接网络设备
        /// </summary>
        public void LinkDevicesClient()
        {
            try
            {
                // 清空设备
                DataControl._mSocket.Close();
                // 获取设备设定档资讯
                String    sql = "select * from wcs_config_device where FLAG <> 'N' order by CREATION_TIME";
                DataTable dt  = DataControl._mMySql.SelectAll(sql);
                if (DataControl._mStools.IsNoData(dt))
                {
                    return;
                }
                List <WCS_CONFIG_DEVICE> devList = dt.ToDataList <WCS_CONFIG_DEVICE>();
                // 遍历加入网络设备
                foreach (WCS_CONFIG_DEVICE dev in devList)
                {
                    byte[] refreshB = null;
                    switch (dev.TYPE)
                    {
                    case DeviceType.固定辊台:
                        refreshB = FRT._GetData();
                        break;

                    case DeviceType.摆渡车:
                        refreshB = ARF._GetData();
                        break;

                    case DeviceType.行车:
                        refreshB = ABC._GetData();
                        break;

                    case DeviceType.运输车:
                        refreshB = RGV._GetData();
                        break;

                    default:
                        continue;
                    }
                    if (!DataControl._mSocket.AddClient(dev.DEVICE, dev.IP, dev.PORT, refreshB, out string result))
                    {
                        throw new Exception(result);
                    }
                }
            }
            catch (Exception ex)
            {
                // 记录LOG
                RecordTaskErrLog("LinkDevicesClient()", "连接网络设备", null, null, ex.ToString());
                MessageBox.Show("连接网络设备发生异常:" + ex.ToString(), "Error");
                System.Environment.Exit(0);
            }
        }
예제 #7
0
파일: W_ARF.xaml.cs 프로젝트: xdpcxq/WCS
        /// <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);
            }
        }
예제 #8
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;
                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);
            }
        }
예제 #9
0
파일: W_ARF.xaml.cs 프로젝트: xdpcxq/WCS
        /// <summary>
        /// 启动辊台
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNrun_Click(object sender, EventArgs e)
        {
            try
            {
                if (CBdev.SelectedIndex == -1)
                {
                    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;
                }

                // 方式
                byte site1 = ARF.RollerRun1;
                if (CBsite1.SelectedValue.ToString() == "启动2#辊台")
                {
                    site1 = ARF.RollerRun2;
                }
                if (CBsite1.SelectedValue.ToString() == "启动全部辊台")
                {
                    site1 = ARF.RollerRunAll;
                }
                // 方向
                byte site2 = ARF.RunFront;
                if (CBsite2.SelectedValue.ToString() == "反向启动")
                {
                    site2 = ARF.RunObverse;
                }
                // 类型
                byte site3 = ARF.GoodsReceive;
                if (CBsite3.SelectedValue.ToString() == "送货")
                {
                    site3 = ARF.GoodsDeliver;
                }
                // 数量
                byte site4 = ARF.GoodsQty1;
                if (CBsite4.SelectedValue.ToString() == "货物数量2")
                {
                    site4 = ARF.GoodsQty2;
                }

                byte[] order = ARF._RollerControl(arf.ARFNum(), site1, site2, site3, site4);
                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);
            }
        }
예제 #10
0
        /// <summary>
        /// 启动辊台
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BTNrun_Click(object sender, EventArgs 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.ActionStatus() == ARF.Run)
                {
                    Notice.Show("指令发送失败:设备运行中!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }
                if (arf.DeviceStatus() == ARF.DeviceError)
                {
                    Notice.Show("指令发送失败:设备故障!", "错误", 3, MessageBoxIcon.Error);
                    return;
                }

                // 方式
                byte site1 = ARF.RollerRun1;
                if (CBsite1.SelectedValue.ToString() == "启动2#辊台")
                {
                    site1 = ARF.RollerRun2;
                }
                if (CBsite1.SelectedValue.ToString() == "启动全部辊台")
                {
                    site1 = ARF.RollerRunAll;
                }
                // 方向
                byte site2 = ARF.RunFront;
                if (CBsite2.SelectedValue.ToString() == "反向启动")
                {
                    site2 = ARF.RunObverse;
                }
                // 类型
                byte site3 = ARF.GoodsReceive;
                if (CBsite3.SelectedValue.ToString() == "送货")
                {
                    site3 = ARF.GoodsDeliver;
                }
                // 数量
                byte site4 = ARF.GoodsQty1;
                if (CBsite4.SelectedValue.ToString() == "货物数量2")
                {
                    site4 = ARF.GoodsQty2;
                }

                if (!WindowCommon.ConfirmAction("是否发送滚筒启动指令!!"))
                {
                    return;
                }


                order = ARF._RollerControl(arf.ARFNum(), site1, site2, site3, site4);
                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("BTNrun_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("BTNrun_Click()", "摆渡车-启动辊台任务[ARF,指令]", dev, DataControl._mStools.BytetToString(order), ex.Message);
            }
        }
예제 #11
0
파일: TaskTools.cs 프로젝트: xdpcxq/WCS
        /// <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;
            }
        }
예제 #12
0
파일: TaskControl.cs 프로젝트: xdpcxq/WCS
        public override void DoWork()
        {
            try
            {
                // 异常
                if (_device.DeviceStatus() == RGV.DeviceError || _device.CommandStatus() == RGV.CommandError)
                {
                    ISetTaskErr();
                    // LOG
                    log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, "设备故障或命令错误."));
                    return;
                }
                // 对接任务
                if (ITEM.ITEM_ID.Substring(0, 2) == "11")
                {
                    #region 调试
                    if (PublicParam.IsIgnoreRGV) //add调试判断
                    {
                        if (_device.ActionStatus() == RGV.Stop)
                        {
                            // 发送指令
                            if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result))
                            {
                                throw new Exception(result);
                            }
                            DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false);
                            // LOG
                            log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order));
                        }
                        else
                        {
                            Thread.Sleep(5000);
                            // 完成任务
                            ISetTaskSuc();
                            // 解锁设备数据状态
                            DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE);
                            // LOG
                            log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                        }
                        return;
                    }
                    #endregion

                    if (!string.IsNullOrEmpty(ITEM.LOC_TO.Trim())) // 目标不为空即最终无货
                    {
                        // 获取目标设备类型
                        String typeTo = DataControl._mTaskTools.GetDeviceType(ITEM.LOC_TO);
                        // 运输车对接 摆渡车/运输车
                        switch (typeTo)
                        {
                        case DeviceType.摆渡车:
                            ARF _arf = new ARF(ITEM.LOC_TO);
                            // 摆渡车辊台停止状态
                            if (_arf.CurrentStatus() == ARF.RollerStop)
                            {
                                // 摆渡车辊台上无货物
                                if (_arf.GoodsStatus() == ARF.GoodsNoAll)
                                {
                                    return;
                                }
                            }
                            else if (_device.GoodsStatus() == RGV.GoodsYesAll && _device.ActionStatus() == RGV.Stop &&
                                     _arf.GoodsStatus() == ARF.GoodsYesAll && _arf.ActionStatus() == ARF.Stop)
                            {
                                return;     // 摆渡车与运输车都有货,不启动辊台
                            }
                            break;

                        case DeviceType.运输车:
                            RGV _rgv = new RGV(ITEM.LOC_TO);
                            // 目的运输车辊台停止状态
                            if (_rgv.CurrentStatus() == RGV.RollerStop)
                            {
                                // 目的运输车辊台上无货物
                                if (_rgv.GoodsStatus() == RGV.GoodsNoAll)
                                {
                                    return;
                                }
                            }
                            else if (_device.GoodsStatus() == RGV.GoodsYesAll && _device.ActionStatus() == RGV.Stop &&
                                     _rgv.GoodsStatus() == RGV.GoodsYesAll && _rgv.ActionStatus() == RGV.Stop)
                            {
                                return;     // 运输车与运输车都有货,不启动辊台
                            }
                            break;

                        default:
                            break;
                        }
                        // 运输车无货物
                        if (_device.GoodsStatus() == RGV.GoodsNoAll)
                        {
                            // 完成任务
                            ISetTaskSuc();
                            // 解锁设备数据状态
                            DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE);
                            // LOG
                            log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                            return;
                        }
                    }
                    else
                    {
                        // 获取目标设备类型
                        String typeFrom = DataControl._mTaskTools.GetDeviceType(ITEM.LOC_FROM);
                        // 运输车对接 摆渡车/运输车
                        switch (typeFrom)
                        {
                        case DeviceType.摆渡车:
                            ARF _arf = new ARF(ITEM.LOC_FROM);
                            // 摆渡车辊台上无货物,运输车辊台上有货物
                            if (_arf.GoodsStatus() == ARF.GoodsNoAll && _device.GoodsStatus() != RGV.GoodsNoAll && _device.ActionStatus() == RGV.Stop)
                            {
                                // 完成任务
                                ISetTaskSuc();
                                // LOG
                                log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                                return;
                            }
                            else if (_device.GoodsStatus() == RGV.GoodsYesAll && _device.ActionStatus() == RGV.Stop &&
                                     _arf.GoodsStatus() == ARF.GoodsYesAll && _arf.ActionStatus() == ARF.Stop)
                            {
                                return;     // 摆渡车与运输车都有货,不启动辊台
                            }
                            break;

                        case DeviceType.运输车:
                            RGV _rgv = new RGV(ITEM.LOC_FROM);
                            // 来源运输车辊台上无货物,运输车辊台上有货物
                            if (_rgv.GoodsStatus() == FRT.GoodsNoAll && _device.GoodsStatus() != ARF.GoodsNoAll && _device.ActionStatus() == RGV.Stop)
                            {
                                // 完成任务
                                ISetTaskSuc();
                                // LOG
                                log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                                return;
                            }
                            else if (_device.GoodsStatus() == RGV.GoodsYesAll && _device.ActionStatus() == RGV.Stop &&
                                     _rgv.GoodsStatus() == RGV.GoodsYesAll && _rgv.ActionStatus() == RGV.Stop)
                            {
                                return;     // 运输车与运输车都有货,不启动辊台
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    // 发送指令
                    if (_device.ActionStatus() == RGV.Stop)
                    {
                        if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result))
                        {
                            throw new Exception(result);
                        }
                        DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order));
                    }
                }
                // 定位任务
                else
                {
                    // 发送指令
                    if (_device.ActionStatus() == RGV.Stop)
                    {
                        if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result))
                        {
                            throw new Exception(result);
                        }
                        DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order));
                    }
                    // 当前位置与目的位置一致 视为任务完成
                    if (_device.GetCurrentSite() == Convert.ToInt32(ITEM.LOC_TO) && _device.ActionStatus() == RGV.Stop)
                    {
                        // 等待对接
                        ISetTaskWait();
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMessW(ITEM, Order));
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                // LOG
                log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, ex.ToString()));
            }
        }
예제 #13
0
파일: TaskControl.cs 프로젝트: xdpcxq/WCS
        public override void DoWork()
        {
            try
            {
                // 异常
                if (_device.DeviceStatus() == FRT.DeviceError || _device.CommandStatus() == FRT.CommandError)
                {
                    ISetTaskErr();
                    // LOG
                    log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, "设备故障或命令错误."));
                    return;
                }

                #region 调试
                if (PublicParam.IsIgnoreFRT) //add调试判断
                {
                    if (_device.ActionStatus() == FRT.Stop)
                    {
                        // 发送指令
                        if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result))
                        {
                            throw new Exception(result);
                        }
                        DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order));
                    }
                    else
                    {
                        Thread.Sleep(5000);
                        // 完成任务
                        ISetTaskSuc();
                        // 解锁设备数据状态
                        DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                    }
                    return;
                }
                #endregion

                ARF _arf = new ARF(ITEM.LOC_TO);
                // 对接设备状态
                if (!string.IsNullOrEmpty(ITEM.LOC_TO.Trim())) // 目标不为空即最终无货
                {
                    // 摆渡车辊台停止状态
                    if (_arf.CurrentStatus() == ARF.RollerStop)
                    {
                        // 摆渡车辊台上无货物
                        if (_arf.GoodsStatus() == ARF.GoodsNoAll)
                        {
                            return;
                        }
                    }
                    // 固定辊台无货物
                    if (_device.GoodsStatus() == FRT.GoodsNoAll && _device.ActionStatus() == FRT.Stop)
                    {
                        // 完成任务
                        ISetTaskSuc();
                        // 解锁设备数据状态
                        DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                        return;
                    }
                    else if (_device.GoodsStatus() == FRT.GoodsYesAll && _device.ActionStatus() == FRT.Stop &&
                             _arf.GoodsStatus() == ARF.GoodsYesAll && _arf.ActionStatus() == ARF.Stop)
                    {
                        return; // 固定辊台与摆渡车都有货,不启动辊台
                    }
                }
                else
                {
                    // 摆渡车辊台上无货物,固定辊台上有货物
                    if (_arf.GoodsStatus() == ARF.GoodsNoAll && _device.GoodsStatus() != FRT.GoodsNoAll && _device.ActionStatus() == FRT.Stop)
                    {
                        // 完成任务
                        ISetTaskSuc();
                        // 解锁设备数据状态
                        DataControl._mTaskTools.DeviceUnLock(ITEM.DEVICE);
                        // LOG
                        log.LOG(DataControl._mTaskTools.GetLogMessS(ITEM, Order));
                        return;
                    }
                    else if (_device.GoodsStatus() == FRT.GoodsYesAll && _device.ActionStatus() == FRT.Stop &&
                             _arf.GoodsStatus() == ARF.GoodsYesAll && _arf.ActionStatus() == ARF.Stop)
                    {
                        return; // 固定辊台与摆渡车都有货,不启动辊台
                    }
                }
                // 发送指令
                if (_device.ActionStatus() == FRT.Stop)
                {
                    if (!DataControl._mSocket.SendToClient(ITEM.DEVICE, Order, out string result))
                    {
                        throw new Exception(result);
                    }
                    DataControl._mSocket.SwithRefresh(ITEM.DEVICE, false);
                    // LOG
                    log.LOG(DataControl._mTaskTools.GetLogMess(ITEM, Order));
                }
            }
            catch (Exception ex)
            {
                // LOG
                log.LOG(DataControl._mTaskTools.GetLogMessE(ITEM, Order, ex.ToString()));
            }
        }