Exemplo n.º 1
0
 /// <summary>
 /// 安排进行行车作业
 /// </summary>
 /// <returns></returns>
 public void LockAWC(string area, DevFlag df, TaskTypeEnum tt, string lockid)
 {
     try
     {
         if (devices.Exists(c => c.area == area && c.flag == DevFlag.参考))
         {
             DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == DevFlag.参考);
             if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) &&
                 a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 &&
                 a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止)
             {
                 a.IsLockUnlockNew(tt, false, lockid);
             }
         }
         else
         {
             if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df))
             {
                 DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df);
                 if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) &&
                     a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 &&
                     a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止)
                 {
                     a.IsLockUnlockNew(tt, false, lockid);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 是否能进行行车作业
 /// </summary>
 /// <returns></returns>
 public bool IsOk(string area, DevFlag df)
 {
     try
     {
         bool res = false;
         if (devices.Exists(c => c.area == area && c.flag == DevFlag.参考))
         {
             DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == DevFlag.参考);
             if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) &&
                 a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 &&
                 a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止)
             {
                 res = true;
             }
         }
         else
         {
             if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df))
             {
                 DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df);
                 if (ADS.mSocket.IsConnected(a.devName) && string.IsNullOrEmpty(a.lockID) &&
                     a._.CommandStatus == CommandEnum.命令正常 && a._.GoodsStatus == AwcGoodsEnum.无货 &&
                     a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止)
                 {
                     res = true;
                 }
             }
         }
         return(res);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获取 X轴值距离
        /// </summary>
        private int GetDisXByFlag(int x, DevFlag flag)
        {
            DevInfoAWC awc = devices.Find(c => c.flag == flag);

            if (awc == null)
            {
                return(999999);
            }
            return(Math.Abs(awc._.CurrentSiteX - x));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取距离最近行车设备参考值
        /// </summary>
        private DevFlag GetNearFlag(int x, out int mindis)
        {
            DevFlag flag        = DevFlag.参考;
            int     mindistance = 1000000000;

            foreach (DevInfoAWC awc in devices)
            {
                if (mindistance > awc._.CurrentSiteX - x)
                {
                    mindistance = Math.Abs(awc._.CurrentSiteX - x);
                    flag        = awc.flag;
                }
            }
            mindis = mindistance;
            return(flag);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 添加或更新行车 X轴值
 /// </summary>
 public void AddUpdateDev(string devname, DevFlag flag, int x)
 {
     if (devices.Exists(c => c.devName.Equals(devname)))
     {
         devices.Find(c => c.devName.Equals(devname))._.CurrentSiteX = x;
     }
     else
     {
         devices.Add(new DevInfoAWC()
         {
             devName = devname, flag = flag, _ = new DeviceAWC()
             {
                 CurrentSiteX = x
             }
         });
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// 是否抵达取货点
        /// </summary>
        /// <returns></returns>
        public bool IsInTakeSite(string area, DevFlag df, string loc)
        {
            try
            {
                bool res = false;
                if (string.IsNullOrEmpty(loc))
                {
                    return(res);
                }

                if (devices.Exists(c => c.area == area && !c.isLock && c.isUseful && c.flag == df))
                {
                    DevInfoAWC a = devices.Find(c => c.area == area && !c.isLock && c.isUseful && c.flag == df);
                    if (ADS.mSocket.IsConnected(a.devName) && a._.CommandStatus == CommandEnum.命令正常 &&
                        a._.DeviceStatus == DeviceEnum.设备正常 && a._.ActionStatus == ActionEnum.停止)
                    {
                        int x = Convert.ToInt32(loc.Split('-')[0]) + a.gapX;
                        int y = Convert.ToInt32(loc.Split('-')[1]) + a.gapY;
                        // |接货点 - 当前坐标| <= 允许范围
                        if (Math.Abs(x - a._.CurrentSiteX) <= a.limitX &&
                            Math.Abs(y - a._.CurrentSiteY) <= a.limitY)
                        {
                            res = true;
                        }
                        else
                        {
                            if (IsSafeDis(a.area, df, a._.CurrentSiteX - a.gapX, x - a.gapX))
                            {
                                a.ToSite(x, y);
                            }
                        }
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 当前行车任务
 /// </summary>
 /// <param name="area"></param>
 /// <param name="df"></param>
 /// <returns></returns>
 public string GetLockid(string area, DevFlag df)
 {
     try
     {
         string mes = "";
         if (devices.Exists(c => c.area == area && c.flag == DevFlag.参考))
         {
             mes = devices.Find(c => c.area == area && c.flag == DevFlag.参考).lockID ?? "";
         }
         else
         {
             if (devices.Exists(c => c.area == area && c.flag == df))
             {
                 mes = devices.Find(c => c.area == area && c.flag == df).lockID ?? "";
             }
         }
         return(mes);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 获取最优行车
        /// </summary>
        /// <param name="area"></param>
        /// <param name="x"></param>
        /// <returns></returns>
        public DevFlag GetRightAWC(string area, int x)
        {
            try
            {
                DevFlag df = DevFlag.参考;
                int     y  = 0;
                // 2端就不比较了
                if (x <= 15000)
                {
                    return(DevFlag.靠近入库口);
                }
                if (x >= 29000)
                {
                    return(DevFlag.远离入库口);
                }

                if (devices.Exists(c => c.area == area && c.flag == DevFlag.靠近入库口))
                {
                    df = DevFlag.靠近入库口;
                    y  = Math.Abs(devices.Find(c => c.area == area && c.flag == DevFlag.靠近入库口)._.CurrentSiteX - x);
                }

                if (devices.Exists(c => c.area == area && c.flag == DevFlag.远离入库口))
                {
                    if (y == 0 || y > Math.Abs(devices.Find(c => c.area == area && c.flag == DevFlag.远离入库口)._.CurrentSiteX - x))
                    {
                        df = DevFlag.远离入库口;
                    }
                }

                return(df);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 行车间是否安全距离
        /// </summary>
        /// <param name="area"></param>
        /// <param name="df"></param>
        /// <param name="tx"></param>
        /// <returns></returns>
        public bool IsSafeDis(string area, DevFlag df, int cx, int tx)
        {
            try
            {
                bool res = false;
                switch (df)
                {
                case DevFlag.参考:
                    res = true;
                    break;

                case DevFlag.靠近入库口:
                case DevFlag.远离入库口:
                    df = df == DevFlag.远离入库口 ? DevFlag.靠近入库口 : DevFlag.远离入库口;
                    if (devices.Exists(c => c.area == area && c.flag == df))
                    {
                        DevInfoAWC a = devices.Find(c => c.area == area && c.flag == df);
                        if (a.isUseful)
                        {
                            if (ADS.mSocket.IsConnected(a.devName) && a._.CommandStatus == CommandEnum.命令正常 && a._.DeviceStatus == DeviceEnum.设备正常)
                            {
                                int disOK = 6000;

                                int dis = ADS.mDis.GetAwcSafeDis(a.area);
                                if (dis == 0)
                                {
                                    throw new Exception("无对应行车安全距离!");
                                }

                                tx = tx + a.gapX;
                                if (Math.Abs(tx - a._.CurrentSiteX) >= disOK)
                                {
                                    res = true;
                                }
                                else
                                {
                                    if (a._.ActionStatus == ActionEnum.停止)
                                    {
                                        if (string.IsNullOrEmpty(a.lockID))
                                        {
                                            a.ToSite(df == DevFlag.靠近入库口 ? (tx - dis) : (tx + dis), a._.CurrentSiteY);
                                        }
                                    }
                                    else
                                    {
                                        if (a._.CurrentTask == AwcTaskEnum.定位任务 && string.IsNullOrEmpty(a.lockID))
                                        {
                                            cx = cx + a.gapX;
                                            if (Math.Abs(cx - a._.CurrentSiteX) >= disOK)
                                            {
                                                res = true;
                                            }
                                            else
                                            {
                                                a.ToSite(df == DevFlag.靠近入库口 ? (tx - dis) : (tx + dis), a._.CurrentSiteY);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            res = true;
                        }
                    }
                    break;

                default:
                    break;
                }
                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取行车设备参考值
        /// </summary>
        public DevFlag[] GetAwcFlag(string area, params int[] x)
        {
            if (x.Length == 0 || x.Length > 4)
            {
                return(null);
            }

            DevFlag[] flags;
            // 安全距离
            int safe = ADS.mDis.GetAwcSafeDis(area);
            // 2货位间距;
            int dis1, dis2, dis3;
            // 行车1/2最近作业距离
            int mindis1, mindis2;
            // 行车1/2单独作业距离
            int alonedis1, alonedis2;
            // 行车1/2同时作业距离;
            int sumdis;

            switch (x.Length)
            {
            case 1:
                flags    = new DevFlag[1];
                flags[0] = GetNearFlag(x[0], out mindis1);
                break;

            case 2:
                flags     = new DevFlag[2];
                mindis1   = GetDisXByFlag(x[0], DevFlag.靠近入库口);
                mindis2   = GetDisXByFlag(x[1], DevFlag.远离入库口);
                dis1      = Math.Abs(x[0] - x[1]);
                alonedis1 = mindis1 + dis1;
                alonedis2 = mindis2 + dis1;
                sumdis    = mindis1 + mindis2;
                // 2货位间距 < 安全距离 || 行车1/2同时作业距离 > 行车1/2单独作业距离
                if (dis1 < safe || sumdis > alonedis1 || sumdis > alonedis2)
                {
                    if (alonedis1 > alonedis2)
                    {
                        flags[0] = DevFlag.远离入库口;
                        flags[1] = DevFlag.远离入库口;
                    }
                    else
                    {
                        flags[0] = DevFlag.靠近入库口;
                        flags[1] = DevFlag.靠近入库口;
                    }
                }
                break;

            case 3:
                // 第一货与第三货距离 对比 安全距离
                dis1 = Math.Abs(x[0] - x[2]);
                if (dis1 < safe)
                {
                    flags    = new DevFlag[2];
                    flags[0] = GetNearFlag(x[0], out mindis1);
                    flags[1] = flags[0];
                }
                else
                {
                    flags     = new DevFlag[3];
                    mindis1   = GetDisXByFlag(x[0], DevFlag.靠近入库口);
                    mindis2   = GetDisXByFlag(x[1], DevFlag.远离入库口);
                    dis2      = Math.Abs(x[0] - x[1]);
                    dis3      = Math.Abs(x[1] - x[2]);
                    alonedis1 = mindis1 + dis2;
                    alonedis2 = mindis2 + dis3;
                    if (alonedis1 > alonedis2)
                    {
                        flags[0] = DevFlag.靠近入库口;
                        flags[1] = DevFlag.远离入库口;
                        flags[2] = DevFlag.远离入库口;
                    }
                    else
                    {
                        flags[0] = DevFlag.靠近入库口;
                        flags[1] = DevFlag.靠近入库口;
                        flags[2] = DevFlag.远离入库口;
                    }
                }
                break;

            case 4:
                flags    = new DevFlag[2];
                flags[0] = DevFlag.靠近入库口;
                flags[1] = DevFlag.远离入库口;
                break;

            default:
                flags = null;
                break;
            }

            return(flags);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 寻找有效设备
 /// </summary>
 /// <param name="tasktype"></param>
 /// <returns></returns>
 private DevInfoAWC FindFreeDevice(string area, DevFlag flag)
 {
     return(devices.Find(c => !c.isLock && !c.isUseful && c.area.Equals(area) && c.flag == flag));
 }
Exemplo n.º 12
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task"></param>
        public void AddTask(string jobid, string taskid, string area, TaskTypeEnum tasktype, DevFlag flag, string takesite, string givesite)
        {
            int id = ADS.ID;

            ADS.PlusID();
            string[] take = takesite.Split('-');
            string[] give = givesite.Split('-');
            TaskAWC  t    = new TaskAWC()
            {
                id         = id,
                jobid      = jobid,
                taskid     = taskid,
                area       = area,
                tasktype   = tasktype,
                flag       = flag,
                takesiteX  = int.Parse(take[0]),
                takesiteY  = int.Parse(take[1]),
                takesiteZ  = int.Parse(take[2]),
                givesiteX  = int.Parse(give[0]),
                givesiteY  = int.Parse(give[1]),
                givesiteZ  = int.Parse(give[2]),
                taskstatus = TaskStatus.init,
                device     = new DevInfoAWC()
            };

            task.Add(t);
            t.InsertDB();
        }