public void highlightTrackFromArea(MSTSItems aeItems) { foreach (StationPath path in paths) { path.highlightTrackFromArea(aeItems); } }
public PseudoSim(UserSettings settings) { Settings = settings; State = new ProcessState("Updater"); Thread = new Thread(UpdaterThread); Thread.Start(); mstsItems = new MSTSItems(); areaRoute = new AreaRoute(); }
public void highlightTrackFromArea(MSTSItems aeItems) { foreach (GlobalItem item in ComponentItem) { if (item.GetType() == typeof(TrackSegment)) { ((TrackSegment)item).setAreaSnaps(aeItems); } } }
public void highlightTrackFromArea(MSTSItems aeItems) { if (!Configured) { return; } if (stationPaths != null) { stationPaths.highlightTrackFromArea(aeItems); } }
public GlobalItem FindMetadataItem(PointF point, double snapSize, MSTSItems aeItems) { double positiveInfinity = double.PositiveInfinity; double actualDist = double.PositiveInfinity; GlobalItem item = null; // First we check only for items except StationItem foreach (GlobalItem item2 in AllItems) { if (item2.GetType() == typeof(StationItem)) { continue; } if (!item2.IsEditable() && !item2.IsMovable() && !item2.IsRotable()) { continue; } item2.SynchroLocation(); positiveInfinity = item2.FindItem(point, snapSize, actualDist, aeItems); if ((((item != null) && (positiveInfinity <= actualDist)) && ((positiveInfinity == 0.0) || item2.isItSeen())) || (item == null)) { actualDist = positiveInfinity; item = item2; } } if ((item == null) || (actualDist == double.PositiveInfinity)) { foreach (GlobalItem item2 in AllItems) { item2.SynchroLocation(); positiveInfinity = item2.FindItem(point, snapSize, actualDist, aeItems); if ((((item != null) && (positiveInfinity <= actualDist)) && ((positiveInfinity == 0.0) || item2.isItSeen())) || (item == null)) { actualDist = positiveInfinity; item = item2; } } if ((item == null) || (actualDist == double.PositiveInfinity)) { return(null); } } item.isSeen = true; return(item); }
public virtual double FindItem(PointF point, double snap, double actualDist, MSTSItems aeItems) { double usedSnap = snap; isSeen = false; //snap = 1.0;// / snap; if ((((this.Location.X < (point.X - usedSnap)) || (Location.X > (point.X + usedSnap))) || (Location.Y < (point.Y - usedSnap))) || (this.Location.Y > (point.Y + usedSnap))) { return(double.PositiveInfinity); } double dist = Math.Sqrt(Math.Pow((double)(Location.X - point.X), 2.0) + Math.Pow((double)(Location.Y - point.Y), 2.0)); if (!(dist < usedSnap && actualDist == 0.0) && dist > actualDist) { return(double.PositiveInfinity); } isSeen = true; return(dist); }
public List <StationPath> searchPaths(AETraveller myTravel, List <TrackSegment> listConnectors, MSTSItems aeItems, StationItem parent) { List <StationPath> paths; if (!Configured) { return(null); } if (stationPaths == null) { stationPaths = new StationPaths(); } stationPaths.Clear(); paths = stationPaths.explore(myTravel, listConnectors, aeItems, parent); return(paths); }
public virtual void complete(ORRouteConfig orRouteConfig, MSTSItems aeItems, MSTSBase tileBase) { }
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); }