Example #1
0
        /// <summary>
        /// 运输车复位
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="mes"></param>
        public void ResetLoc_RGV(List <WCS_CONFIG_DEVICE> dev, out string mes)
        {
            try
            {
                // 运输车待命点1
                int loc1 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyR1"));
                // 运输车待命点2
                int loc2 = Convert.ToInt32(DataControl._mStools.GetValueByKey("StandbyR2"));

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

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

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

                if (a1.GetCurrentSite() < a2.GetCurrentSite())
                {
                    // 定位任务指令
                    order1 = RGV._Position(a1.RGVNum(), DataControl._mStools.IntToBytes(loc1));
                    order2 = RGV._Position(a2.RGVNum(), DataControl._mStools.IntToBytes(loc2));
                    // 任务明细
                    item1 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.运输车复位1,
                        ID      = 3,
                        DEVICE  = dev[0].DEVICE,
                        LOC_TO  = loc1.ToString()
                    };
                    item2 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.运输车复位2,
                        ID      = 4,
                        DEVICE  = dev[1].DEVICE,
                        LOC_TO  = loc2.ToString()
                    };
                }
                else
                {
                    // 定位任务指令
                    order1 = RGV._Position(a1.RGVNum(), DataControl._mStools.IntToBytes(loc2));
                    order2 = RGV._Position(a2.RGVNum(), DataControl._mStools.IntToBytes(loc1));
                    // 任务明细
                    item1 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.运输车复位2,
                        ID      = 3,
                        DEVICE  = dev[0].DEVICE,
                        LOC_TO  = loc2.ToString()
                    };
                    item2 = new WCS_TASK_ITEM()
                    {
                        ITEM_ID = ItemId.运输车复位1,
                        ID      = 4,
                        DEVICE  = dev[1].DEVICE,
                        LOC_TO  = loc1.ToString()
                    };
                }
                // 加入任务作业链表
                mes = null;
                if (dev[0].FLAG == DeviceFlag.空闲)
                {
                    DataControl._mTaskControler.StartTask(new RGVTack(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[1].DEVICE + " 运输车目前无法操作复位任务; \r";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public void Update()
        {
            if (isconnect != rgv.IsAlive())
            {
                ISConnect = rgv.IsAlive();
            }

            if (!rgv.IsAlive())
            {
                return;
            }

            if (actionsta != rgv.ActionStatus())
            {
                actionsta    = rgv.ActionStatus();
                ActionStatus = "";
            }

            if (devicesta != rgv.DeviceStatus())
            {
                devicesta    = rgv.DeviceStatus();
                DeviceStatus = "";
            }

            if (commandsta != rgv.CommandStatus())
            {
                commandsta    = rgv.CommandStatus();
                CommandStatus = "";
            }

            if (des_x_y_z != rgv.GetGoodsSite())
            {
                Des_X_Y_Z = rgv.GetGoodsSite();
            }

            if (now_task != rgv.CurrentTask())
            {
                now_task = rgv.CurrentTask();
                Now_Task = "";
            }

            if (now_x_y_z != rgv.GetCurrentSite())
            {
                Now_X_Y_Z = rgv.GetCurrentSite();
            }

            if (finish_task != rgv.FinishTask())
            {
                finish_task = rgv.FinishTask();
                Finish_Task = "";
            }

            if (loadstatus != rgv.GoodsStatus())
            {
                loadstatus = rgv.GoodsStatus();
                LoadStatus = "";
            }

            if (rollerstatus != rgv.CurrentStatus())
            {
                rollerstatus = rgv.CurrentStatus();
                RollerStatus = "";
            }

            if (rollerdirection != rgv.RunDirection())
            {
                rollerdirection = rgv.RunDirection();
                RollerDirection = "";
            }

            if (errormsg != rgv.ErrorMessage())
            {
                errormsg = rgv.ErrorMessage();
                ErrorMsg = "";
            }

            if (rgv.GetUpdateTime(out string time))
            {
                if (datatime != time)
                {
                    DataTime = time;
                }
            }
        }
Example #3
0
        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()));
            }
        }