public TrackNode explore(MSTSItems aeItems, List <TrackSegment> listConnector, int entryNode, StationItem parent) { #if false Stopwatch stopWatch = new Stopwatch(); TimeSpan ts; string elapsedTime; #endif TrackNode currentNode = traveller.GetCurrentNode(); if ((currentNode.TrJunctionNode == null) && !currentNode.TrEndNode) { do { int sectionIdx = traveller.TrackVectorSectionIndex; TrackSegment item = (TrackSegment)aeItems.GetTrackSegment(currentNode, sectionIdx); foreach (TrackSegment conSeg in listConnector) { if (conSeg.associateNodeIdx == entryNode) { continue; } // Il faut tester que l'on change bien d'index de node pour quitter mais pas pour le premier et aussi l'idx de la section if (currentNode.Index == conSeg.associateNodeIdx && sectionIdx == conSeg.associateSectionIdx) { setComplete(conSeg); break; } } item.inStationArea = true; ComponentItem.Add(item); ((TrackSegment)item).InStation(parent); foreach (var trItem in item.sidings) { SidesItem.Add(trItem); if (trItem.typeSiding == (int)TypeSiding.SIDING_START) { PathName = trItem.Name; NbrSiding++; if (trItem.sizeSiding > Siding) { Siding = trItem.sizeSiding; } } else if (trItem.typeSiding == (int)TypeSiding.PLATFORM_START) { PathName = trItem.Name; NbrPlatform++; if (trItem.sizeSiding > Platform) { Platform = trItem.sizeSiding; } } } //yard += sideItem.lengthSegment; #if false ts = stopWatch.Elapsed; // Format and display the TimeSpan value. elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); elapse.Add(elapsedTime); #endif } while (traveller.NextVectorSection() && !complete); if (currentNode.Index != entryNode && !complete && traveller.TrackNodeLength > PassingYard) { PassingYard = traveller.TrackNodeLength; } traveller.NextTrackNode(); } else { GlobalItem item = aeItems.GetTrackSegment(currentNode, -1); item.inStationArea = true; ComponentItem.Add(item); } if (currentNode.TrEndNode) { complete = true; } return(currentNode); }
public List <StationPath> explore(AETraveller myTravel, List <TrackSegment> listConnector, MSTSItems aeItems, StationItem parent) { List <AEJunctionItem> insideJunction = new List <AEJunctionItem>(); Stopwatch stopWatch = new Stopwatch(); TimeSpan ts; string elapsedTime; stopWatch.Start(); TrackNode currentNode = myTravel.GetCurrentNode(); int pathChecked = 0; int trackNodeIndex = myTravel.TrackNodeIndex; int lastCommonTrack = trackNodeIndex; int trackVectorSectionIndex = myTravel.TrackVectorSectionIndex; TrVectorSection currentSection = myTravel.GetCurrentSection(); GlobalItem startNode = aeItems.GetTrackSegment(currentNode, trackVectorSectionIndex); //paths.Add(new StationPath(startNode, myTravel)); paths.Add(new StationPath(myTravel)); paths[0].LastCommonTrack = trackNodeIndex; while ((pathChecked < paths.Count && !paths[pathChecked].complete) && paths.Count < 100) { TrackNode node2 = paths[pathChecked].explore(aeItems, listConnector, trackNodeIndex, parent); ts = stopWatch.Elapsed; // Format and display the TimeSpan value. elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime " + elapsedTime); if (node2.TrJunctionNode != null) { AEJunctionItem junction = (AEJunctionItem)paths[pathChecked].ComponentItem[paths[pathChecked].ComponentItem.Count - 1]; if (!insideJunction.Contains(junction)) { insideJunction.Add(junction); } if (node2.TrPins[0].Link == lastCommonTrack) { paths[pathChecked].jctnIdx = paths[pathChecked].ComponentItem.Count - 1; paths[pathChecked].LastCommonTrack = lastCommonTrack; paths.Add(new StationPath(paths[pathChecked])); paths[pathChecked].directionJunction = 0; paths[pathChecked].switchJnct(0); } else { paths[pathChecked].NextNode(); } } else if (node2.TrEndNode) { AEBufferItem buffer = (AEBufferItem)paths[pathChecked].ComponentItem[paths[pathChecked].ComponentItem.Count - 1]; if (!buffer.Configured || buffer.DirBuffer == AllowedDir.OUT) { //AEJunctionItem junction = (AEJunctionItem)paths[pathChecked].ComponentItem[paths[pathChecked].jctnIdx]; paths.RemoveAt(pathChecked); } else { paths[pathChecked].setComplete(buffer); pathChecked++; } if (pathChecked < paths.Count) { paths[pathChecked].switchJnct(paths[pathChecked].directionJunction); if (paths[pathChecked].ComponentItem.Count > 1) { lastCommonTrack = (int)paths[pathChecked].LastCommonTrack; } else { lastCommonTrack = trackNodeIndex; } } } else { int lastIndex = (int)node2.Index; //lastCommonTrack = (int)node2.Index; if (paths[pathChecked].complete) { TrackSegment segment = (TrackSegment)paths[pathChecked].ComponentItem[paths[pathChecked].ComponentItem.Count - 1]; if (segment.HasConnector == null || (segment.HasConnector != null && (segment.HasConnector.dirConnector == AllowedDir.IN || !segment.HasConnector.isConfigured()))) { paths.RemoveAt(pathChecked); } else { pathChecked++; } //pathChecked++; if (pathChecked < paths.Count) { lastIndex = (int)paths[pathChecked].ComponentItem[paths[pathChecked].ComponentItem.Count - 2].associateNode.Index; paths[pathChecked].switchJnct(paths[pathChecked].directionJunction); } } if (pathChecked < paths.Count) { if (paths[pathChecked].ComponentItem.Count > 1) { lastCommonTrack = lastIndex; //lastCommonTrack = (int)paths[pathChecked].ComponentItem[paths[pathChecked].ComponentItem.Count - 2].associateNode.Index; } else { lastCommonTrack = trackNodeIndex; } } } } stopWatch.Stop(); ts = stopWatch.Elapsed; // Format and display the TimeSpan value. elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime " + elapsedTime); pathChecked = 1; foreach (StationPath path in paths) { if (path.PassingYard > MaxPassingYard) { MaxPassingYard = path.PassingYard; } if (path.PassingYard < ShortPassingYard) { ShortPassingYard = path.PassingYard; } } return(paths); }