/// <summary> /// 生成路径 /// </summary> /// <returns>路径集合</returns> public static List <PathPoint> GetPath(Agv agv) { STask sTask = agv.sTaskList[0]; Point beginPoint = sTask.beginPoint; Point endPoint = sTask.endPoint; STaskType sTaskType = sTask.sTaskType; switch (sTask.sTaskType) { case STaskType.D1: if (beginPoint == endPoint) { return new List <PathPoint>() { GetObject.GetPathPoint(beginPoint), GetObject.GetPathPoint(endPoint) } } ; AStar aStart = new AStar(); List <Point> listApoint = GetCanUseApoint(agv); ClearParentPoint(); Point Parent = aStart.PathGet(listApoint, beginPoint, endPoint, agv); if (Parent == null) { return(null); } List <PathPoint> listPathPoint = GetPathList(Parent); AddCorner(listPathPoint); OriLock(listPathPoint, agv); return(listPathPoint); case STaskType.D2: case STaskType.D3: case STaskType.D6: case STaskType.D15: return(new List <PathPoint>() { GetObject.GetPathPoint(beginPoint), GetObject.GetPathPoint(endPoint) }); case STaskType.D13: case STaskType.D14: //左弧右弧进 break; case STaskType.D17: case STaskType.D19: //左弧右弧出 break; default: throw new Exception("无此任务类型:" + sTask.sTaskType); } return(null); }
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); } }
static void DownSTask() { string sql = string.Format(@"SELECT ts.*,c.ItemName FROM dbo.T_Task_Son ts LEFT JOIN dbo.T_Type_Config c ON ts.STaskType = c.ItemNo WHERE State IN(1, 2, 3) ORDER BY AgvNo, SerialNo"); DataSet ds = DbHelperSQL.Query(sql); foreach (DataRow dr in ds.Tables[0].Rows) { GetObject.GetSTask(dr); } }
static void DownAgv() { string sql = string.Format("SELECT * FROM dbo.T_Base_AGV "); DataSet ds = DbHelperSQL.Query(sql); foreach (DataRow dr in ds.Tables[0].Rows) { Agv agv = GetObject.GetAgv(dr); App.AgvList.Add(agv); Point point = App.pointList.FirstOrDefault(a => a.barCode == agv.barcode); point.lockedAgv = agv; } }
static List <PathPoint> GetPathList(Point Parent) { List <PathPoint> listPathPoint = new List <PathPoint>(); while (Parent != null) { listPathPoint.Add(GetObject.GetPathPoint(Parent)); Parent = Parent.ParentPoint; } listPathPoint.Reverse(); for (int i = 0; i < listPathPoint.Count; i++) { listPathPoint[i].serialNo = i + 1; } return(listPathPoint); }
static void DownPoint() { string sql = string.Format("SELECT * FROM dbo.T_Base_Point "); DataSet ds = DbHelperSQL.Query(sql); foreach (DataRow dr in ds.Tables[0].Rows) { Point point = GetObject.GetPoint(dr); App.pointList.Add(point); } foreach (Point p in App.pointList) { p.xPosPoint = App.pointList.FirstOrDefault(a => a.x == p.x + 1 && a.y == p.y); p.xNegPoint = App.pointList.FirstOrDefault(a => a.x == p.x - 1 && a.y == p.y); p.yPosPoint = App.pointList.FirstOrDefault(a => a.x == p.x && a.y == p.y + 1); p.yNegPoint = App.pointList.FirstOrDefault(a => a.x == p.x && a.y == p.y - 1); } }
/// <summary> /// 下载任务 /// </summary> static void DownTask() { try { string sql = @"SELECT ts.*,c.ItemName FROM dbo.T_Task_Son ts LEFT JOIN dbo.T_Type_Config c ON ts.STaskType = c.ItemNo WHERE State = 0 ORDER BY AgvNo, SerialNo"; DataSet ds = DbHelperSQL.Query(sql); DataRowCollection drc = ds.Tables[0].Rows; foreach (DataRow dr in drc) { STask s = GetObject.GetSTask(dr); string sql2 = string.Format("UPDATE dbo.T_Task_Son SET State = 1 WHERE SID = '{0}'", s.sID); DbHelperSQL.ExecuteSql(sql2); s.state = TaskState.Down; } } catch (Exception ex) { App.ExFile.MessageLog("DownTask", ex.Message + "\r"); } }
/// <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); }