Пример #1
0
        //================================================================================================//
        /// <summary>
        /// Constructor for speedposts
        /// </summary>

        public SignalHead(Signal signal, int trackItem, int tbdRef, SpeedPostItem speedItem)
        {
            if (speedItem == null)
            {
                throw new ArgumentNullException(nameof(speedItem));
            }

            MainSignal            = signal ?? throw new ArgumentNullException(nameof(signal));
            TrackItemIndex        = trackItem;
            TDBIndex              = tbdRef;
            DrawState             = 1;
            SignalIndicationState = SignalAspectState.Clear_2;
            SignalType            = new SignalType(SignalFunction.Speed, SignalAspectState.Clear_2);

            double speedMpS = Speed.MeterPerSecond.ToMpS(speedItem.Distance, !speedItem.IsMPH);

            if (speedItem.IsResume)
            {
                speedMpS = 999.0;
            }

            float passSpeed    = speedItem.IsPassenger ? (float)speedMpS : -1;
            float freightSpeed = speedItem.IsFreight ? (float)speedMpS : -1;

            SpeedInfoSet[SignalIndicationState] = new SpeedInfo(passSpeed, freightSpeed, false, false, speedItem is TempSpeedPostItem ? (speedMpS == 999f ? 2 : 1) : 0, speedItem.IsWarning);
        }
Пример #2
0
        }                                                                  // for AI trains, set active by TRAIN

        //================================================================================================//
        /// <summary>
        /// Constructor
        /// </summary>

        public SignalItemInfo(Signal signal, float distance)
        {
            State = SignalItemFindState.Item;

            DistanceFound = distance;

            SignalDetails = signal ?? throw new ArgumentNullException(nameof(signal));

            if (signal.IsSignal)
            {
                ItemType    = SignalItemType.Signal;
                SignalState = SignalAspectState.Unknown; // set active by TRAIN
                SpeedInfo   = new SpeedInfo(null);       // set active by TRAIN
            }
            else
            {
                ItemType    = SignalItemType.SpeedLimit;
                SignalState = SignalAspectState.Unknown;
                SpeedInfo   = signal.SpeedLimit(SignalFunction.Speed);
            }
        }