示例#1
0
        //================================================================================================//
        //
        // Constructor
        //

        public TrackCircuitCrossReference(TrackCircuitSection thisSection)
        {
            CrossRefIndex = thisSection.Index;
            Length        = thisSection.Length;
            Position[0]   = thisSection.OffsetLength[0];
            Position[1]   = thisSection.OffsetLength[1];
        }
示例#2
0
        //================================================================================================//
        //
        // Copy basic info only
        //

        public TrackCircuitSection CopyBasic(int INode)
        {
            TrackCircuitSection newSection = new TrackCircuitSection(INode, this.signalRef);

            newSection.OriginalIndex = this.OriginalIndex;
            newSection.CircuitType   = this.CircuitType;

            newSection.EndSignals[0] = this.EndSignals[0];
            newSection.EndSignals[1] = this.EndSignals[1];

            newSection.Length = this.Length;

            Array.Copy(this.OffsetLength, newSection.OffsetLength, this.OffsetLength.Length);

            return(newSection);
        }
示例#3
0
        //================================================================================================//
        //
        // de-align active switch pins
        //

        public void deAlignSwitchPins()
        {
            for (int iDirection = 0; iDirection <= 1; iDirection++)
            {
                if (Pins[iDirection, 1].Link > 0)     // active switchable end
                {
                    for (int iLink = 0; iLink <= 1; iLink++)
                    {
                        int activeLink      = Pins[iDirection, iLink].Link;
                        int activeDirection = Pins[iDirection, iLink].Direction == 0 ? 1 : 0;
                        ActivePins[iDirection, iLink].Link = -1;

                        TrackCircuitSection linkSection = signalRef.TrackCircuitList[activeLink];
                        linkSection.ActivePins[activeDirection, 0].Link = -1;
                    }
                }
            }
        }
示例#4
0
        //================================================================================================//
        //
        // Get distance between objects
        //

        public float GetDistanceBetweenObjects(int startSectionIndex, float startOffset, int startDirection,
                                               int endSectionIndex, float endOffset)
        {
            int thisSectionIndex = startSectionIndex;
            int direction        = startDirection;

            TrackCircuitSection thisSection = signalRef.TrackCircuitList[thisSectionIndex];

            float distanceM = 0.0f;
            int   lastIndex = -2; // set to non-occuring value

            while (thisSectionIndex != endSectionIndex && thisSectionIndex > 0)
            {
                distanceM += thisSection.Length;
                TrPin nextLink = thisSection.GetNextActiveLink(direction, lastIndex);

                lastIndex        = thisSectionIndex;
                thisSectionIndex = nextLink.Link;
                direction        = nextLink.Direction;

                if (thisSectionIndex > 0)
                {
                    thisSection = signalRef.TrackCircuitList[thisSectionIndex];
                }
            }

            // use found distance, correct for begin and end offset

            if (thisSectionIndex == endSectionIndex)
            {
                distanceM += endOffset - startOffset;
                return(distanceM);
            }

            return(-1.0f);
        }
示例#5
0
        //================================================================================================//
        //
        // align pins switch or crossover
        //

        public void alignSwitchPins(int linkedSectionIndex)
        {
            int alignDirection = -1;  // pin direction for leading section
            int alignLink      = -1;  // link index for leading section

            for (int iDirection = 0; iDirection <= 1; iDirection++)
            {
                for (int iLink = 0; iLink <= 1; iLink++)
                {
                    if (Pins[iDirection, iLink].Link == linkedSectionIndex)
                    {
                        alignDirection = iDirection;
                        alignLink      = iLink;
                    }
                }
            }

            if (alignDirection >= 0)
            {
                ActivePins[alignDirection, 0].Link = -1;
                ActivePins[alignDirection, 1].Link = -1;

                ActivePins[alignDirection, alignLink].Link =
                    Pins[alignDirection, alignLink].Link;
                ActivePins[alignDirection, alignLink].Direction =
                    Pins[alignDirection, alignLink].Direction;

                TrackCircuitSection linkedSection = signalRef.TrackCircuitList[linkedSectionIndex];
                for (int iDirection = 0; iDirection <= 1; iDirection++)
                {
                    for (int iLink = 0; iLink <= 1; iLink++)
                    {
                        if (linkedSection.Pins[iDirection, iLink].Link == Index)
                        {
                            linkedSection.ActivePins[iDirection, iLink].Link      = Index;
                            linkedSection.ActivePins[iDirection, iLink].Direction =
                                linkedSection.Pins[iDirection, iLink].Direction;
                        }
                    }
                }
            }

            // if junction, align physical switch

            if (CircuitType == TrackCircuitType.Junction)
            {
                int switchPos = -1;
                if (ActivePins[1, 0].Link != -1)
                {
                    switchPos = 0;
                }
                if (ActivePins[1, 1].Link != -1)
                {
                    switchPos = 1;
                }

                if (switchPos >= 0)
                {
                    //signalRef.setSwitch(OriginalIndex, switchPos, this);
                }
            }
        }