/// <summary>
 /// Use this function to add a new item into the 'AllItems' list.
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(GlobalItem item)
 {
     if (item == null)
     {
         return;
     }
     //if (!(sideItem is PathEventItem) && !(sideItem is SideStartItem))
     if (item.asMetadata)
     {
         if (routeItems.IndexOf(item) < 0)
         {
             routeItems.Add(item);
         }
     }
     if (AllItems.IndexOf(item) < 0)
     {
         AllItems.Add(item);
     }
     toSave = true;
     if (item.GetType() == typeof(StationItem))
     {
         foreach (StationAreaItem SAItem in ((StationItem)item).stationArea)
         {
             AllItems.Add(SAItem);
         }
     }
 }
 /// <summary>
 /// Used to remove a connector item from the 'AllItem' list.
 /// </summary>
 /// <param name="item"></param>
 public void RemoveConnectorItem(GlobalItem item)
 {
     if (item.GetType() == typeof(StationAreaItem))
     {
         AllItems.Remove(item);
         routeItems.Remove(item);
     }
 }
Esempio n. 3
0
 public override void alignEdition(TypeEditor interfaceType, GlobalItem ownParent)
 {
     if (interfaceType == TypeEditor.ROUTECONFIG)
     {
         setEditable();
         asMetadata = true;
     }
     parentStation = (StationItem)ownParent;
 }
Esempio n. 4
0
        public void setComplete(GlobalItem segment)
        {
            complete = true;

            if (segment.GetType() == typeof(TrackSegment) && ((TrackSegment)segment).HasConnector != null)
            {
                outLabel = ((TrackSegment)segment).HasConnector.label;
            }
            else if (segment.GetType() == typeof(AEBufferItem))
            {
                outLabel = ((AEBufferItem)segment).NameBuffer;
            }
        }
 /// <summary>
 /// Used to remove an item from all list of items: AllItems, RouteItems
 /// </summary>
 /// <param name="item">the item to remove</param>
 public void RemoveItem(GlobalItem item)
 {
     if (item.GetType() == typeof(StationItem))
     {
         foreach (var point in ((StationItem)item).stationArea)
         {
             RemoveConnectorItem(point);
         }
         ((StationItem)item).stationArea.Clear();
     }
     AllItems.Remove(item);
     routeItems.Remove(item);
     toSave = true;
 }
Esempio n. 6
0
 public StationPath(GlobalItem startNode, AETraveller travel)
 {
     ComponentItem = new List <GlobalItem>();
     SidesItem     = new List <SideItem>();
     ComponentItem.Add(startNode);
     complete          = false;
     jctnIdx           = -1;
     traveller         = new AETraveller(travel);
     Siding            = 0;
     Platform          = 0;
     PassingYard       = 0;
     NbrPlatform       = 0;
     NbrSiding         = 0;
     LastCommonTrack   = 0;
     directionJunction = 0;
     PathName          = "";
 }
        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 TrackCircuitElementPlatform(GlobalItem item, float position)
     : base(item, position)
 {
     info = TypeItem.SIDING_START;
 }
 public TrackCircuitElementConnector(GlobalItem item, float position)
     : base(item, position)
 {
     info = TypeItem.STATION_CONNECTOR;
 }
Esempio n. 10
0
 public TrackCircuitElement(GlobalItem item, float position)
 {
     refItem         = item;
     ElementLocation = position;
 }
Esempio n. 11
0
 public virtual void alignEdition(TypeEditor interfaceType, GlobalItem ownParent)
 {
 }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }