static void DownPath() { string sql = "SELECT * FROM dbo.T_Base_PathList order by sid,SerialNo"; DataSet ds = DbHelperSQL.Query(sql); List <PathPoint> listPathPoint = new List <PathPoint>(); foreach (DataRow dr in ds.Tables[0].Rows) { int sID = int.Parse(dr["SID"].ToString()); string barcode = dr["Barcode"].ToString(); int serialNo = int.Parse(dr["serialNo"].ToString()); int direction = int.Parse(dr["Direction"].ToString()); PathPoint pp = new PathPoint(); pp.SID = sID; pp.serialNo = serialNo; pp.point = App.pointList.FirstOrDefault(a => a.barCode == barcode); listPathPoint.Add(pp); } foreach (Agv agv in App.AgvList) { if (agv.sTaskList.Count == 0) { continue; } //将此点放到对应子任务的路径中 STask sTask = agv.sTaskList[0]; if (listPathPoint.Exists(a => a.SID == sTask.sID)) { sTask.pathList = listPathPoint.FindAll(a => a.SID == sTask.sID); sTask.pathList.Sort(); PathGet.OriLock(sTask.pathList, agv); } } }
/// <summary> /// 分配路径 /// </summary> static void AssignePath() { //try //{ //遍历所有AGV,找agv中的第一条任务 //如果状态是已下载,则分配路径 //如果分配成功,则更新数据库任务状态,插入路径 //如果更新成功,则更新内存已分配路径,更新任务状态 foreach (Agv agv in App.AgvList) { List <STask> listSTask = agv.sTaskList; if (listSTask.Count == 0) { continue; } STask sTask = listSTask[0]; if (sTask.state != TaskState.Down) { continue; } string sql = ""; List <PathPoint> listPathPoint = new List <PathPoint>(); //如果起点和终点一致,且是行走,则直接结束任务 if (sTask.beginPoint == sTask.endPoint && sTask.sTaskType == STaskType.D1) { FinishTask(agv, sTask); continue; } //因未实现路径重建,临时使用此方式来避免 将任务创建在别的小车路径上 //如果不是最后一个任务且是行走,如果终点被锁,则先不查找路径 if (listSTask.Count > 1 && sTask.sTaskType == STaskType.D1) { if (sTask.endPoint.listTmpDirection.Count != 0) { continue; } } if (sTask.sTaskType == STaskType.D25) { FinishTask(agv, sTask); continue; } listPathPoint = PathGet.GetPath(agv); if (listPathPoint == null) { continue; } int serialNo = 1; foreach (PathPoint pp in listPathPoint) { //待修改,需将点的方向也丢到路径中 sql += string.Format("INSERT INTO T_Base_PathList (SID,Barcode,serialNo,direction) VALUES('{0}','{1}','{2}','{3}');", agv.sTaskList[0].sID, pp.point.barCode, serialNo, 0); serialNo++; } sql += string.Format("UPDATE dbo.T_Task_Son SET State = 2 WHERE SID = '{0}'", sTask.sID); DbHelperSQL.ExecuteSql(sql); sTask.pathList = listPathPoint; sTask.state = TaskState.HavePath; } //} //catch (Exception ex) //{ // App.ExFile.MessageLog("AssignePath", ex.Message + "\r"); //} }