TrafficManager.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Configuration;
  6. using System.Data.SqlClient;
  7. namespace AGV_WPF.TrafficDefine
  8. {
  9. public class TrafficManager
  10. {
  11. public List<TrafficArea> TrafficAreaList;
  12. public bool OfflineControlFlag = false;//掉线是否仍能管制其他AGV标志,默认不能
  13. public static TrafficManager Traffic;
  14. public TrafficManager()
  15. {
  16. Traffic = this;
  17. TrafficAreaList = new List<TrafficArea>();
  18. }
  19. void CheckColumn()
  20. {
  21. string strCon = ConfigurationManager.AppSettings["ConnString"];
  22. using (SqlConnection con = new SqlConnection(strCon))
  23. {
  24. try
  25. {
  26. string sql = string.Format("select count(1) from syscolumns where ID=OBJECT_ID('T_Traffic') and name='IsNeedKeyMark'");
  27. con.Open();
  28. using (SqlCommand com = new SqlCommand(sql, con))
  29. {
  30. object o = com.ExecuteScalar();
  31. if (int.Parse(o.ToString()) == 0)
  32. {
  33. sql = string.Format("alter table T_Traffic add IsNeedkeyMark bit");
  34. com.CommandText = sql;
  35. com.ExecuteNonQuery();
  36. }
  37. sql = string.Format("select count(1) from syscolumns where ID=OBJECT_ID('T_Traffic') and name='KeyMarkID'");
  38. com.CommandText = sql;
  39. o = com.ExecuteScalar();
  40. if (int.Parse(o.ToString()) == 0)
  41. {
  42. sql = string.Format("alter table T_Traffic add KeyMarkID bigint");
  43. com.CommandText = sql;
  44. com.ExecuteNonQuery();
  45. }
  46. }
  47. }
  48. catch (System.Exception ex)
  49. {
  50. throw ex;
  51. }
  52. }
  53. }
  54. public void InitTrafficAreas()
  55. {
  56. CheckColumn();
  57. string strCon = ConfigurationManager.AppSettings["ConnString"];
  58. using (SqlConnection con = new SqlConnection(strCon))
  59. {
  60. try
  61. {
  62. string sql = string.Format("select distinct TrafficNum from T_Traffic");
  63. con.Open();
  64. using (SqlCommand com = new SqlCommand(sql, con))
  65. {
  66. //1、先得到所有管制区编号
  67. SqlDataReader reader = com.ExecuteReader();
  68. List<int> totalTrafficNum = new List<int>();
  69. while (reader.Read())
  70. {
  71. totalTrafficNum.Add(int.Parse(reader["TrafficNum"].ToString()));
  72. }
  73. reader.Close();
  74. TrafficAreaList.Clear();//清空之前数据
  75. //2、填充管制区站点数据
  76. for (int i = 0; i < totalTrafficNum.Count;i++ )
  77. {
  78. TrafficArea area = new TrafficArea();
  79. area.TrafficNum = totalTrafficNum[i];
  80. area.IsNeedKeyMark = false;
  81. sql = string.Format("select top(1) IsNeedKeyMark from T_Traffic where TrafficNum={0}", totalTrafficNum[i]);//确定是否要关键点
  82. com.CommandText = sql;
  83. object isNeedOjbect = com.ExecuteScalar();
  84. if (isNeedOjbect != null && !string.IsNullOrEmpty(isNeedOjbect.ToString()) && bool.Parse(isNeedOjbect.ToString()))
  85. {
  86. area.IsNeedKeyMark = true;
  87. }
  88. sql = string.Format("select A.ID,A.TrafficNum,A.IsNeedKeyMark,A.Mark,A.WorkLine,A.XPos,A.YPos,B.Mark as KeyMark,B.WorkLine as KeyMarkWorkLine,B.XPos as KeyMarkXPos,B.YPos as KeyMarkYPos from (select T_Traffic.ID,T_Traffic.TrafficNum,T_Traffic.MarkID,T_Mark.Mark,T_Mark.WorkLine,T_Mark.XPos,T_Mark.YPos,T_Traffic.IsNeedKeyMark from T_Traffic left join T_Mark on T_Mark.ID=T_Traffic.MarkID) as A left join (select T_Traffic.ID,T_Traffic.TrafficNum,T_Traffic.KeyMarkID,T_Mark.Mark,T_Mark.WorkLine,T_Mark.XPos,T_Mark.YPos,T_Traffic.IsNeedKeyMark from T_Traffic left join T_Mark on T_Mark.ID=T_Traffic.KeyMarkID) as B on A.ID=B.ID where A.TrafficNum=B.TrafficNum and A.TrafficNum={0}", totalTrafficNum[i]);
  89. com.CommandText = sql;
  90. reader = com.ExecuteReader();
  91. while (reader.Read())
  92. {
  93. TrafficStation station = new TrafficStation();
  94. object markObject = reader["Mark"];
  95. object workLineObject = reader["WorkLine"];
  96. object keyMarkObject = reader["KeyMark"];
  97. object keyMarkWorkLineObject = reader["KeyMarkWorkLine"];
  98. //检测是否为空,如果为空则用默认的
  99. if (markObject != null && !string.IsNullOrEmpty(markObject.ToString()))
  100. station.CurrentMark.MarkNum = int.Parse(markObject.ToString());
  101. if (workLineObject != null && !string.IsNullOrEmpty(workLineObject.ToString()))
  102. station.CurrentMark.WorkLine = int.Parse(workLineObject.ToString());
  103. if (keyMarkObject != null && !string.IsNullOrEmpty(keyMarkObject.ToString()))
  104. station.NextMark.MarkNum = int.Parse(keyMarkObject.ToString());
  105. if (keyMarkWorkLineObject != null && !string.IsNullOrEmpty(keyMarkWorkLineObject.ToString()))
  106. station.NextMark.WorkLine = int.Parse(keyMarkWorkLineObject.ToString());
  107. area.StationList.Add(station);
  108. }
  109. reader.Close();
  110. TrafficAreaList.Add(area);
  111. }
  112. }
  113. }
  114. catch (System.Exception ex)
  115. {
  116. throw ex;
  117. }
  118. }
  119. }
  120. public bool UpdateAreaStatus(AgvStatus agv)
  121. {
  122. bool trafficFlag = false;//管制状态,true需要管制,false不需要管制
  123. //1、先备份之前管制区号
  124. int[] tempTrafficList = agv.TrafficNumList.ToArray();
  125. //2、再得到当前管制区号
  126. List<int> trafficIndexList = GetAgvTrafficIndexListEx(agv);
  127. List<bool> trafficFlagList = new List<bool>();
  128. for (int i = 0; i < trafficIndexList.Count;i++ )
  129. {
  130. trafficFlagList.Add(false);
  131. }
  132. //3、依次判断管制区状态并更新
  133. if(trafficIndexList.Count>0)
  134. {
  135. #region 在管制区中
  136. for (int i = 0; i < trafficIndexList.Count; i++)
  137. {
  138. TrafficArea area = TrafficAreaList[trafficIndexList[i]];
  139. if (area.Status)//已经有AGV占领此管制区
  140. {
  141. if (area.OccupyAgv == agv.AgvNum)//占领此区域的为自己
  142. {
  143. if (!agv.WirelessStaus)//掉线了
  144. {
  145. if (OfflineControlFlag)//掉线仍能管制其他AGV,不需要更新排队数据
  146. {
  147. trafficFlagList[i] = false;
  148. }
  149. else//否则从排队中选出占领AGV,需要更新排队数据
  150. {
  151. if (area.WaitAgvList.Count > 0)
  152. {
  153. area.OccupyAgv = area.WaitAgvList[0];
  154. area.WaitAgvList.Remove(area.OccupyAgv);
  155. }
  156. else
  157. {
  158. area.OccupyAgv = 0;
  159. area.Status = false;
  160. }
  161. trafficFlagList[i] = false;
  162. }
  163. }
  164. else
  165. {
  166. trafficFlagList[i] = false;
  167. }
  168. }
  169. else
  170. {
  171. if (!agv.WirelessStaus)
  172. {
  173. if (OfflineControlFlag)
  174. {
  175. trafficFlagList[i] = true;
  176. }
  177. else
  178. {
  179. area.WaitAgvList.Remove(agv.AgvNum);
  180. trafficFlagList[i] = false;
  181. }
  182. }
  183. else//没掉线
  184. {
  185. AddWaitAgv(area, agv.AgvNum);//向队列中添加
  186. trafficFlagList[i] = true;
  187. //if (area.IsNeedKeyMark)//如果是关键点,则需要判断下是否同向,同向不需管制
  188. //{
  189. // AgvStatus occupyAgvStatus = MainWindow.mainWindow.GetAgvStatus(area.OccupyAgv);
  190. // /*int tempIndex = area.StationList.FindIndex(c => (c.CurrentMark.WorkLine == occupyAgvStatus.WorkLine && c.CurrentMark.MarkNum == occupyAgvStatus.MarkNum && c.NextMark.WorkLine == agv.WorkLine && c.NextMark.MarkNum == agv.MarkNum) || (c.NextMark.WorkLine == occupyAgvStatus.WorkLine && c.NextMark.MarkNum == occupyAgvStatus.MarkNum && c.CurrentMark.WorkLine == agv.WorkLine && c.CurrentMark.MarkNum == agv.MarkNum));*/
  191. // bool flag = CheckAgvTraffic(agv, occupyAgvStatus, area);
  192. // if ((occupyAgvStatus.WorkLine == agv.WorkLine && occupyAgvStatus.MarkNum == agv.MarkNum)||flag)//管制AGV和当前AGV地标一样(管制AGV读完后,后面AGV跟上来),不需要管制
  193. // {
  194. // trafficFlagList[i] = false;
  195. // }
  196. //}
  197. }
  198. }
  199. }
  200. else//无AGV占领此管制区
  201. {
  202. if (!agv.WirelessStaus)//掉线
  203. {
  204. if (OfflineControlFlag)
  205. {
  206. area.OccupyAgv = agv.AgvNum;//占领
  207. area.Status = true;//置占领状态
  208. trafficFlagList[i] = false;//此AGV不需管制
  209. }
  210. }
  211. else
  212. {
  213. area.OccupyAgv = agv.AgvNum;//占领
  214. area.Status = true;//置占领状态
  215. trafficFlagList[i] = false;//此AGV不需管制
  216. }
  217. }
  218. }
  219. #endregion
  220. }
  221. //出管制区
  222. {
  223. int[] outArea = GetDifferentArea(tempTrafficList.ToList(), agv.TrafficNumList);
  224. UpdateOutofArea(agv, outArea);
  225. }
  226. if (trafficFlagList.Contains(true))
  227. {
  228. trafficFlag = true;
  229. }
  230. else
  231. trafficFlag = false;
  232. return trafficFlag;
  233. }
  234. int[] GetDifferentArea(List<int> oldList, List<int> newList)
  235. {
  236. List<int> result = new List<int>();
  237. if (newList.Count == 0)
  238. return oldList.ToArray();
  239. for (int i = 0; i < oldList.Count;i++ )
  240. {
  241. if (!newList.Contains(oldList[i]))
  242. {
  243. result.Add(oldList[i]);
  244. }
  245. }
  246. return result.ToArray();
  247. }
  248. /// <summary>
  249. /// 对出管制区的AGV更新各个管制区数据
  250. /// </summary>
  251. /// <param name="agv"></param>
  252. void UpdateOutofArea(AgvStatus agv,int[] trafficList)
  253. {
  254. if (trafficList.Length > 0)
  255. {
  256. for (int i = 0; i < trafficList.Length; i++)
  257. {
  258. TrafficArea area = GetTrafficArea(trafficList[i]);
  259. if (area.OccupyAgv == agv.AgvNum)
  260. {
  261. if (area.WaitAgvList.Count > 0)
  262. {
  263. area.OccupyAgv = area.WaitAgvList[0];
  264. area.WaitAgvList.Remove(area.OccupyAgv);
  265. }
  266. else
  267. {
  268. area.OccupyAgv = 0;
  269. area.Status = false;
  270. }
  271. }
  272. else
  273. {
  274. area.WaitAgvList.Remove(agv.AgvNum);
  275. }
  276. }
  277. }
  278. }
  279. public List<int> GetTrafficAgvList(AgvStatus agv)
  280. {
  281. List<int> result = new List<int>();
  282. List<int> areaList = agv.TrafficNumList;
  283. for (int i = 0; i < areaList.Count;i++ )
  284. {
  285. TrafficArea area = GetTrafficArea(areaList[i]);
  286. if (area.OccupyAgv != agv.AgvNum)
  287. result.Add(area.OccupyAgv);
  288. }
  289. //var v = from c in result
  290. result = result.Distinct().ToList();
  291. return result;
  292. }
  293. List<int> GetAgvTrafficIndexList(AgvStatus agv)
  294. {
  295. List<int> result = new List<int>();
  296. agv.TrafficNumList.Clear();
  297. for (int i = 0; i < TrafficAreaList.Count;i++ )
  298. {
  299. int index = TrafficAreaList[i].StationList.FindIndex(c => c.CurrentMark.MarkNum == agv.MarkNum && c.CurrentMark.WorkLine == agv.WorkLine);
  300. if (index != -1)
  301. {
  302. agv.TrafficNumList.Add(TrafficAreaList[i].TrafficNum);//更新AGV管制区编号列表
  303. result.Add(i);
  304. }
  305. }
  306. return result;
  307. }
  308. void AddToList(List<int> list, int value)
  309. {
  310. if (!list.Contains(value))
  311. list.Add(value);
  312. }
  313. /// <summary>
  314. /// 得到当前管制区号
  315. /// </summary>
  316. /// <param name="agv"></param>
  317. /// <returns></returns>
  318. List<int> GetAgvTrafficIndexListEx(AgvStatus agv)
  319. {
  320. List<int> result = new List<int>();
  321. List<int> trafficList = new List<int>();
  322. for (int i = 0; i < TrafficAreaList.Count; i++)
  323. {
  324. int index = TrafficAreaList[i].StationList.FindIndex(c => c.CurrentMark.MarkNum == agv.MarkNum && c.CurrentMark.WorkLine == agv.WorkLine);
  325. if (index != -1)
  326. {
  327. if (!TrafficAreaList[i].IsNeedKeyMark)//如果不需要关键点
  328. {
  329. //agv.TrafficNumList.Add(TrafficAreaList[index].TrafficNum);//更新AGV管制区编号列表
  330. AddToList(trafficList, TrafficAreaList[i].TrafficNum);
  331. AddToList(result, i);
  332. }
  333. else//需要关键点
  334. {
  335. MarkStation keyMark = TrafficAreaList[i].StationList[index].NextMark;
  336. if (CheckNodeOrder(keyMark, new MarkStation() { WorkLine = agv.WorkLine, MarkNum = agv.MarkNum }, agv.Route))//在同一路线且关键点在当前路线后面
  337. {
  338. //agv.TrafficNumList.Add(TrafficAreaList[index].TrafficNum);//更新AGV管制区编号列表
  339. //result.Add(index);
  340. AddToList(trafficList, TrafficAreaList[i].TrafficNum);
  341. AddToList(result, i);
  342. }
  343. }
  344. }
  345. }
  346. agv.TrafficNumList = trafficList;
  347. return result;
  348. }
  349. /// <summary>
  350. /// 检测在某条路线中节点1是否在节点2后面
  351. /// </summary>
  352. /// <param name="node1">节点1</param>
  353. /// <param name="node2">节点2</param>
  354. /// <param name="route">待检测路线</param>
  355. /// <returns></returns>
  356. bool CheckNodeOrder(MarkStation node1, MarkStation node2, int route)
  357. {
  358. bool result = false;
  359. string strCon = ConfigurationManager.AppSettings["ConnString"];
  360. using (SqlConnection con = new SqlConnection(strCon))
  361. {
  362. try
  363. {
  364. string sql = string.Format("select MarkOrder from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}",node1.WorkLine,node1.MarkNum,route);
  365. con.Open();
  366. using (SqlCommand com = new SqlCommand(sql, con))
  367. {
  368. object o1 = com.ExecuteScalar();
  369. sql = string.Format("select MarkOrder from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", node2.WorkLine, node2.MarkNum,route);
  370. com.CommandText = sql;
  371. object o2 = com.ExecuteScalar();
  372. if (o1 == null || string.IsNullOrEmpty(o1.ToString()))
  373. {
  374. result = false;
  375. }
  376. else if (o2 == null || string.IsNullOrEmpty(o2.ToString()))
  377. {
  378. result = false;
  379. }
  380. else
  381. {
  382. if (int.Parse(o1.ToString()) >= int.Parse(o2.ToString()))//考虑同一个节点
  383. {
  384. result = true;
  385. }
  386. else
  387. result = false;
  388. }
  389. }
  390. }
  391. catch (System.Exception ex)
  392. {
  393. throw ex;
  394. }
  395. }
  396. return result;
  397. }
  398. public TrafficArea GetTrafficArea(int trafficNum)
  399. {
  400. TrafficArea area = null;
  401. int index = TrafficAreaList.FindIndex(c => c.TrafficNum == trafficNum);
  402. if (index != -1)
  403. {
  404. area = TrafficAreaList[index];
  405. }
  406. return area;
  407. }
  408. public void AddAgvTrafficNum(AgvStatus agv,int trafficNum)
  409. {
  410. int index = agv.TrafficNumList.FindIndex(c => c == trafficNum);
  411. if (index == -1)
  412. {
  413. agv.TrafficNumList.Add(trafficNum);
  414. }
  415. }
  416. public void AddWaitAgv(TrafficArea area, int agvNum)
  417. {
  418. int index = area.WaitAgvList.FindIndex(c => c == agvNum);
  419. if (index == -1)
  420. {
  421. area.WaitAgvList.Add(agvNum);
  422. }
  423. }
  424. /// <summary>
  425. /// 检测两车路径是否相同
  426. /// </summary>
  427. /// <param name="agv1">AGV1信息</param>
  428. /// <param name="agv2">AGV2信息</param>
  429. /// <returns>成功返回true,失败返回false</returns>
  430. bool CheckTheSamePath(AgvStatus agv1, AgvStatus agv2,MarkStation keyMark)
  431. {
  432. //bool result = false;
  433. string strCon = ConfigurationManager.AppSettings["ConnString"];
  434. using (SqlConnection con = new SqlConnection(strCon))
  435. {
  436. try
  437. {
  438. //判断三点是否在同一路径上
  439. string sql1 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}",agv1.WorkLine,agv1.MarkNum,agv1.Route);
  440. string sql2 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", agv2.WorkLine, agv2.MarkNum, agv1.Route);
  441. string sql3 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", keyMark.WorkLine, keyMark.MarkNum, agv1.Route);
  442. con.Open();
  443. using (SqlCommand com = new SqlCommand(sql1, con))
  444. {
  445. int temp1 = int.Parse(com.ExecuteScalar().ToString());
  446. com.CommandText = sql2;
  447. int temp2 = int.Parse(com.ExecuteScalar().ToString());
  448. com.CommandText = sql3;
  449. int temp3 = int.Parse(com.ExecuteScalar().ToString());
  450. sql1 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", agv1.WorkLine, agv1.MarkNum, agv2.Route);
  451. sql2 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", agv2.WorkLine, agv2.MarkNum, agv2.Route);
  452. sql3 = string.Format("select count(1) from T_Line left join T_Mark on T_Line.MarkID=T_Mark.ID where T_Mark.WorkLine={0} and T_Mark.Mark={1} and LineNum={2}", keyMark.WorkLine, keyMark.MarkNum, agv2.Route);
  453. com.CommandText = sql1;
  454. int temp4 = int.Parse(com.ExecuteScalar().ToString());
  455. com.CommandText = sql2;
  456. int temp5 = int.Parse(com.ExecuteScalar().ToString());
  457. com.CommandText = sql3;
  458. int temp6 = int.Parse(com.ExecuteScalar().ToString());
  459. if (temp1 > 0 && temp2 > 0 && temp3 > 0 && temp4 > 0 && temp5 > 0 && temp6 > 0)
  460. {
  461. return true;
  462. }
  463. else
  464. return false;
  465. }
  466. }
  467. catch (System.Exception ex)
  468. {
  469. throw ex;
  470. }
  471. }
  472. //return result;
  473. }
  474. /// <summary>
  475. /// 判断指定两点在管制区中是否有相同关键点
  476. /// </summary>
  477. /// <param name="node1">待判断节点1</param>
  478. /// <param name="node2">待判断节点2</param>
  479. /// <param name="area">管制区</param>
  480. /// <param name="keyNode">返回的关键点列表(可能两个节点对应多个关键点)</param>
  481. /// <returns>成功返回true</returns>
  482. bool GetSameKeyNode(AgvStatus node1, AgvStatus node2, TrafficArea area, ref List<MarkStation> keyNodeList)
  483. {
  484. bool result = false;
  485. List<TrafficStation> nodeList1 = area.StationList.FindAll(c => c.CurrentMark.WorkLine == node1.WorkLine && c.CurrentMark.MarkNum == node1.MarkNum);//节点1在管制区中所有满足条件的点
  486. List<TrafficStation> nodeList2 = area.StationList.FindAll(c => c.CurrentMark.WorkLine == node2.WorkLine && c.CurrentMark.MarkNum == node2.MarkNum);//节点2在管制区中所有满足条件的点
  487. int count = nodeList1.Count < nodeList2.Count ? nodeList1.Count : nodeList2.Count;
  488. if(nodeList1.Count>nodeList2.Count)
  489. {
  490. for (int i = 0; i < count; i++)
  491. {
  492. int index = nodeList1.FindIndex(c => c.NextMark.WorkLine == nodeList2[i].NextMark.WorkLine && c.NextMark.MarkNum == nodeList2[i].NextMark.MarkNum);
  493. if (index != -1)
  494. {
  495. keyNodeList.Add(new MarkStation() { WorkLine = nodeList2[i].NextMark.WorkLine, MarkNum = nodeList2[i].NextMark.MarkNum });
  496. }
  497. }
  498. }
  499. else
  500. {
  501. for (int i = 0; i < count; i++)
  502. {
  503. int index = nodeList2.FindIndex(c => c.NextMark.WorkLine == nodeList1[i].NextMark.WorkLine && c.NextMark.MarkNum == nodeList1[i].NextMark.MarkNum);
  504. if (index != -1)
  505. {
  506. keyNodeList.Add(new MarkStation() { WorkLine = nodeList1[i].NextMark.WorkLine, MarkNum = nodeList1[i].NextMark.MarkNum });
  507. }
  508. }
  509. }
  510. if (keyNodeList.Count > 0)
  511. return true;
  512. return result;
  513. }
  514. /// <summary>
  515. /// 判断两车是否需要管制,只适用于关键点管制区
  516. /// </summary>
  517. /// <param name="agv1"></param>
  518. /// <param name="agv2"></param>
  519. /// <returns>不需要管制返回true,否则返回false</returns>
  520. bool CheckAgvTraffic(AgvStatus agv1, AgvStatus agv2,TrafficArea area)
  521. {
  522. bool result = false;
  523. List<MarkStation> list = new List<MarkStation>();
  524. if (GetSameKeyNode(agv1, agv2, area,ref list))
  525. {
  526. for (int i = 0; i < list.Count;i++ )
  527. {
  528. bool b = CheckTheSamePath(agv1, agv2, list[i]);
  529. if (b)
  530. return b;
  531. }
  532. }
  533. return result;
  534. }
  535. }
  536. }