Represents a speed.
コード例 #1
0
ファイル: KVB.cs プロジェクト: tiennotg/FrTrainSys
        public KVB(TrainSoundManager soundManager,
		            TrainHandleManager handleManager,
		            TrainControlManager controlManager)
            : base(soundManager, handleManager, controlManager)
        {
            beepBeep = -1;
            enabled = false;
            newSpeedLimit = new Speed(-1);
            signalAspect = true;
        }
コード例 #2
0
 public void setTargetSpeed(Speed newSpeedLimit, int targetDistance)
 {
     if (targetDistance == 0)
         currentSpeedLimit = newSpeedLimit;
     else
     {
         speedTransition = true;
         this.newSpeedLimit = newSpeedLimit;
         newSpeedLimitTargetDistance = targetDistance;
     }
 }
コード例 #3
0
        public SpeedLimitComputer(Speed maxSpeed, int trainLength, double decelCoeff, TrainTypes trainType)
        {
            this.maxSpeed = maxSpeed;
            this.trainLength = trainLength;
            this.decelCoeff = decelCoeff;
            this.trainType = trainType;

            decelerationControlEnabled = false;

            currentSpeedLimit = maxSpeed;
        }
コード例 #4
0
ファイル: KVB.cs プロジェクト: tiennotg/FrTrainSys
        public override void elapse(OpenBveApi.Runtime.ElapseData data)
        {
            if (enabled)
            {
                currentSpeed = data.Vehicle.Speed;
                location = (int) Math.Round(data.Vehicle.Location);
                Speed limit = speedLimiter.getCurrentSpeedLimit(data);

                if (data.Vehicle.Speed.KilometersPerHour > limit.KilometersPerHour + firstMargin)
                {
                    soundManager.startSound(ref beepBeep, SoundIndex.KvbOverSpeed);

                    if (data.Vehicle.Speed.KilometersPerHour > limit.KilometersPerHour + secondMargin)
                        stopTrain();
                }
                else
                    soundManager.stopSound(ref beepBeep);
            }
        }
コード例 #5
0
ファイル: KVB.cs プロジェクト: tiennotg/FrTrainSys
        public override void reset()
        {
            targetDistance = -1;
            newSpeedLimit = new Speed(-1);
            signalAspect = false;

            soundManager.stopSound(ref beepBeep);

            controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.none);
            controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.triple0);
        }
コード例 #6
0
ファイル: KVB.cs プロジェクト: tiennotg/FrTrainSys
        public override void trainEvent(TrainEvent _event)
        {
            if (_event.getEventType() == EventTypes.EventTypeGetBeacon)
            {
                BeaconData beacon = (BeaconData) _event.getEventData();

                if (beacon.Type == Beacons.KvbControl)
                {
                    if (beacon.Optional == KvbEnable && !enabled)
                    {
                        controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.running);
                        controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.running);
                        reset();
                        enabled = true;
                    }
                    else if (beacon.Optional == KvbDisable)
                    {
                        controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.none);
                        controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.none);
                        enabled = false;
                    }
                }

                if (enabled)
                {
                    if (beacon.Type == Beacons.Signal)
                    {
                        if (beacon.Signal.Aspect == 0)
                            stopTrain();
                        else if (beacon.Signal.Aspect <= ClosedSignal.signalAspectForConsideringClosed)
                            signalAspect = false;
                        else
                            signalAspect = true;
                    }

                    if (beacon.Type == Beacons.NextSignal)
                    {
                        if (!signalAspect)
                        {
                            controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.none);
                            if (beacon.Optional >= 0)
                            {
                                speedLimiter.startDecelerationControl(currentSpeed, location, location + (int) Math.Round(beacon.Signal.Distance), DecelerationControlType.low);
                                controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.double0);
                            }
                            else
                            {
                                speedLimiter.startDecelerationControl(currentSpeed, location, (int) Math.Round(beacon.Signal.Distance), DecelerationControlType.strong);
                                controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.triple0);
                            }
                        }
                        else
                        {
                            speedLimiter.stopDecelerationControl();
                            controlManager.setState(cabControls.GreenKVB, (int) GreenKvbAspects.running);
                            controlManager.setState(cabControls.YellowKVB, (int) YellowKvbAspects.running);
                        }
                    }

                    if (beacon.Type == Beacons.SpeedLimit)
                        newSpeedLimit = new Speed(kmhToMs((double) beacon.Optional));

                    if (beacon.Type == Beacons.TargetDistance)
                        targetDistance = beacon.Optional;

                    if (targetDistance != -1 && newSpeedLimit.KilometersPerHour != -1)
                        speedLimiter.setTargetSpeed(newSpeedLimit,targetDistance);
                }
            }
        }
コード例 #7
0
ファイル: KVB.cs プロジェクト: tiennotg/FrTrainSys
 public void setParameters(Speed maxSpeed, int trainLength, double decelCoeff, TrainTypes trainType)
 {
     speedLimiter = new SpeedLimitComputer(maxSpeed, trainLength, decelCoeff, trainType);
 }
コード例 #8
0
 public void startDecelerationControl(Speed currentSpeed, int location, int targetDistance, DecelerationControlType type)
 {
     decelerationInitSpeed = currentSpeed;
     decelerationInitLocation = location;
     decelerationTargetDistance = targetDistance;
     decelerationType = type;
     decelerationControlEnabled = true;
 }
コード例 #9
0
ファイル: Runtime.cs プロジェクト: sladen/openbve
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="location">Gets the location of the back of the preceding train, in meters.</param>
 /// <param name="distance">The distance from the front of the current train to the back of the preceding train, in meters.</param>
 /// <param name="speed">Gets the speed of the preceding train.</param>
 public PrecedingVehicleState(double location, double distance, Speed speed)
 {
     this.MyLocation = location;
     this.MyDistance = distance;
     this.MySpeed = speed;
 }
コード例 #10
0
ファイル: Runtime.cs プロジェクト: sladen/openbve
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="location">The location of the front of the train, in meters.</param>
 /// <param name="speed">The speed of the train.</param>
 /// <param name="bcPressure">The pressure in the brake cylinder, in pascal.</param>
 /// <param name="mrPressure">The pressure in the main reservoir, in pascal.</param>
 /// <param name="erPressure">The pressure in the emergency reservoir, in pascal.</param>
 /// <param name="bpPressure">The pressure in the brake pipe, in pascal.</param>
 /// <param name="sapPressure">The pressure in the straight air pipe, in pascal.</param>
 public VehicleState(double location, Speed speed, double bcPressure, double mrPressure, double erPressure, double bpPressure, double sapPressure)
 {
     this.MyLocation = location;
     this.MySpeed = speed;
     this.MyBcPressure = bcPressure;
     this.MyMrPressure = mrPressure;
     this.MyErPressure = erPressure;
     this.MyBpPressure = bpPressure;
     this.MySapPressure = sapPressure;
 }
コード例 #11
0
ファイル: Runtime.cs プロジェクト: leezer3/OpenBVE
		// --- constructors ---
		/// <summary>Creates a new instance of this class.</summary>
		/// <param name="location">The location of the front of the train, in meters.</param>
		/// <param name="speed">The speed of the train.</param>
		/// <param name="bcPressure">The pressure in the brake cylinder, in pascal.</param>
		/// <param name="mrPressure">The pressure in the main reservoir, in pascal.</param>
		/// <param name="erPressure">The pressure in the emergency reservoir, in pascal.</param>
		/// <param name="bpPressure">The pressure in the brake pipe, in pascal.</param>
		/// <param name="sapPressure">The pressure in the straight air pipe, in pascal.</param>
		/// <param name="Radius">The curve radius at the front of the train, in meters.</param>
		/// <param name="Cant">The cant value for this curve radius.</param>
		/// <param name="Pitch">The pitch value at the front of the train.</param>
		/// Three paramaters added at the far end
		public VehicleState(double location, Speed speed, double bcPressure, double mrPressure, double erPressure, double bpPressure, double sapPressure, double Radius, double Cant, double Pitch)
		{
			this.MyRadius = Radius;
			this.MyCant = Cant;
			this.MyPitch = Pitch;
			this.MyLocation = location;
			this.MySpeed = speed;
			this.MyBcPressure = bcPressure;
			this.MyMrPressure = mrPressure;
			this.MyErPressure = erPressure;
			this.MyBpPressure = bpPressure;
			this.MySapPressure = sapPressure;
		}
コード例 #12
0
 // --- constructors ---
 /// <summary>Creates a new instance of this class.</summary>
 /// <param name="location">Gets the location of the back of the preceding train, in meters.</param>
 /// <param name="distance">The distance from the front of the current train to the back of the preceding train, in meters.</param>
 /// <param name="speed">Gets the speed of the preceding train.</param>
 public PrecedingVehicleState(double location, double distance, Speed speed)
 {
     this.MyLocation = location;
     this.MyDistance = distance;
     this.MySpeed    = speed;
 }