Ejemplo n.º 1
0
        /// <summary>
        /// 更新小车货架信息
        /// </summary>
        static void UpdateAgvShelfPoint(AgvMsg agvMsg, Agv agv)
        {
            string oldBarcode = agv.barcode;
            string newBarcode = agvMsg.Barcode;

            //刚开机,没扫到码,给的是0
            if (newBarcode == "0")
            {
                agvMsg.Barcode = newBarcode = oldBarcode;
            }

            UpdatePoint(oldBarcode, newBarcode, agv);

            ////如果AGV的位置状态不变,不更新Agv状态
            if (newBarcode == oldBarcode &&
                agv.height == agvMsg.Height &&
                agv.currentCharge == agvMsg.Voltage &&
                agv.state == (AgvState)agvMsg.State &&
                agv.errorMsg == agvMsg.ErrCode1 + agvMsg.ErrCode2 + agvMsg.ErrCode3)
            {
                return;
            }

            //配送与仓库不同,此判断条件需要考量。   低位/中位/高位的问题
            if (agvMsg.Height == HeightEnum.High)
            {
                Shelf shelf = App.ShelfList.FirstOrDefault(a => a.currentBarcode == oldBarcode);
                if (shelf != null)
                {
                    //货架的当前点要变更为现在的点
                    string shelfSql = string.Format(@"UPDATE T_Base_Shelf SET CurrentBarcode = '{0}' 
                                            WHERE CurrentBarcode = '{1}';", newBarcode, oldBarcode);
                    DbHelperSQL.ExecuteSql(shelfSql);

                    shelf.currentBarcode = newBarcode;
                }
                else
                {
                    throw new Exception("小车顶升是高位,但是无货架点!");
                }
            }

            //更新数据库中小车的状态
            int    error = agvMsg.ErrCode1 * 10000 + agvMsg.ErrCode2 * 100 + agvMsg.ErrCode3;
            string sql   = string.Format(@"UPDATE dbo.T_Base_AGV SET Barcode = '{0}',ErrorMsg = '{1}',
                Height = '{2}',CurrentCharge = '{3}',UpdateTime = GETDATE(),State = '{4}' WHERE AgvNo = '{5}'",
                                         newBarcode, error, (int)agvMsg.Height, agvMsg.Voltage, agvMsg.State, agvMsg.AgvNo);

            DbHelperSQL.ExecuteSql(sql);

            agv.barcode       = newBarcode;
            agv.height        = agvMsg.Height;
            agv.currentCharge = agvMsg.Voltage;
            agv.state         = (AgvState)agvMsg.State;
            agv.errorMsg      = agvMsg.ErrCode1 + agvMsg.ErrCode2 + agvMsg.ErrCode3;
        }
Ejemplo n.º 2
0
        static void DownShelf()
        {
            string  sql = string.Format("SELECT * FROM dbo.T_Base_Shelf ");
            DataSet ds  = DbHelperSQL.Query(sql);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Shelf shelf = GetObject.GetShelf(dr);
                App.ShelfList.Add(shelf);
            }
        }
Ejemplo n.º 3
0
        public static Shelf GetShelf(DataRow dr)
        {
            Shelf s = new Shelf();

            s.areaNo         = dr["areaNo"].ToString();
            s.barcode        = dr["barcode"].ToString();
            s.currentBarcode = dr["currentBarcode"].ToString();
            s.isEnable       = bool.Parse(dr["isEnable"].ToString());
            s.isLocked       = bool.Parse(dr["isLocked"].ToString());
            s.shelfDirection = dr["shelfDirection"].ToString();
            s.shelfNo        = dr["shelfNo"].ToString();

            return(s);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取行走后面的点
        /// </summary>
        static List <Motion> GetNextListMotion(STask sTask, PathPoint pathPoint, Agv agv)
        {
            List <Motion>    listMotion    = new List <Motion>();
            List <PathPoint> listPathPoint = sTask.pathList;

            //移除当前点之前的路径点
            sTask.pathList.RemoveAll(a => a.serialNo < pathPoint.serialNo);

            int i = 0;

            foreach (PathPoint pp in listPathPoint)
            {
                i++;
                if (i == 5)
                {
                    break;
                }

                Point nowPoint = pp.point;

                if (Commond.IsTest && nowPoint.barCode == "2280")
                {
                    listMotion.Add(GetObject.GetMotion(sTask, pp));
                    continue;
                }
                if (nowPoint.lockedAgv == agv)
                {
                    listMotion.Add(GetObject.GetMotion(sTask, pp));
                    continue;
                }

                if (nowPoint.lockedAgv != null)
                {
                    //找到占用此点的小车
                    //如果小车没任务且在低位,则让其回家

                    Agv nextAgv = nowPoint.lockedAgv;

                    if (nextAgv.sTaskList.Count == 0)
                    {
                        //创建一个回家任务
                    }
                    else
                    {
                        List <PathPoint> lpp = nextAgv.sTaskList[0].pathList;
                        if (lpp.Exists(a => a.point.barCode == agv.barcode))
                        {
                            //发送取消任务
                            //agv回复取消成果,则删除路径及更新任务状态
                            //Task.ResetPath(agv);
                        }
                    }

                    break;
                }

                if (IsLoop(nowPoint, new List <Agv>()
                {
                    agv
                }))
                {
                    break;
                }

                //如果当前点货架,且小车是顶升   不走
                Shelf shelf = App.ShelfList.FirstOrDefault(a => a.currentBarcode == nowPoint.barCode);
                if (agv.height != HeightEnum.Low && shelf != null)
                {
                    break;
                }

                nowPoint.lockedAgv = agv;
                listMotion.Add(GetObject.GetMotion(sTask, pp));

                if (pp.isCorner)
                {
                    break;
                }
            }

            return(listMotion);
        }