UnapplyEmergencyBrake() static private method

Releases the emergency brake
static private UnapplyEmergencyBrake ( Train Train ) : void
Train Train The train
return void
Exemplo n.º 1
0
        /// <summary>
        /// main timer interrupt
        /// </summary>
        static private void MainTimerProcess(object state)
        {
            if (Interlocked.Exchange(ref inTimer_Main, 1) == 0)
            {
                try
                {
                    nowControl = TrainManager.PlayerTrain;
                    //Master key
                    if (!MasterKey)
                    {
                        SetAutoPilot(0);
                        SetBrake(0);
                        SetPower(0);
                        ReverserNeutral();
                    }

                    //emergency
                    if (Emergency)
                    {
                        SetAutoPilot(0);
                        TrainManager.ApplyEmergencyBrake(nowControl);
                    }
                    else
                    {
                        TrainManager.UnapplyEmergencyBrake(nowControl);
                    }

                    //signal
                    if (GetSignal() == 0)
                    {
                        inRedLight = true;
                    }
                    else
                    {
                        if (inRedLight)
                        {
                            SetBrake(nowControl.Handles.Brake.MaximumNotch);
                            SetReverser(0);
                            SetAutoPilot(0);
                        }
                        inRedLight = false;
                    }
                }
                catch (Exception ex) { }
                Interlocked.Exchange(ref inTimer_Main, 0);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// set emergency
 /// </summary>
 static public void SetEmergency(int value)
 {
     try
     {
         Emergency = value == 0 ? false : true;
         TrainManager.Train nowControl = TrainManager.PlayerTrain;
         if (Emergency)
         {
             TrainManager.ApplyEmergencyBrake(nowControl);
         }
         else
         {
             TrainManager.UnapplyEmergencyBrake(nowControl);
         }
     }
     catch (Exception ex) { }
 }
Exemplo n.º 3
0
 /// <summary>
 /// power up
 /// </summary>
 static public void PowerUp()
 {
     try
     {
         int currretPower = nowControl.Handles.Power.Driver;
         int currentBrake = nowControl.Handles.Brake.Driver;
         if (nowControl.Handles.EmergencyBrake.Actual)
         {
             TrainManager.UnapplyEmergencyBrake(nowControl);
         }
         if (currentBrake > 0)
         {
             nowControl.ApplyNotch(0, true, -1, true);
         }
         else
         {
             nowControl.ApplyNotch(1, true, 0, true);
         }
         return;
     }
     catch (Exception ex) { }
 }
Exemplo n.º 4
0
            /// <summary>Sets the driver handles or the virtual handles.</summary>
            /// <param name="handles">The handles.</param>
            /// <param name="virtualHandles">Whether to set the virtual handles.</param>
            private void SetHandles(Handles handles, bool virtualHandles)
            {
                /*
                 * Process the handles.
                 */
                if (this.Train.Specs.SingleHandle & handles.BrakeNotch != 0)
                {
                    handles.PowerNotch = 0;
                }

                /*
                 * Process the reverser.
                 */
                if (handles.Reverser >= -1 & handles.Reverser <= 1)
                {
                    if (virtualHandles)
                    {
                        this.Train.Specs.CurrentReverser.Actual = handles.Reverser;
                    }
                    else
                    {
                        TrainManager.ApplyReverser(this.Train, handles.Reverser, false);
                    }
                }
                else
                {
                    if (virtualHandles)
                    {
                        this.Train.Specs.CurrentReverser.Actual = this.Train.Specs.CurrentReverser.Driver;
                    }
                    this.PluginValid = false;
                }

                /*
                 * Process the power.
                 * */
                if (handles.PowerNotch >= 0 & handles.PowerNotch <= this.Train.Specs.MaximumPowerNotch)
                {
                    if (virtualHandles)
                    {
                        this.Train.Specs.CurrentPowerNotch.Safety = handles.PowerNotch;
                    }
                    else
                    {
                        TrainManager.ApplyNotch(this.Train, handles.PowerNotch, false, 0, true);
                    }
                }
                else
                {
                    if (virtualHandles)
                    {
                        this.Train.Specs.CurrentPowerNotch.Safety = this.Train.Specs.CurrentPowerNotch.Driver;
                    }
                    this.PluginValid = false;
                }
//				if (handles.BrakeNotch != 0) {
//					if (virtualHandles) {
//						this.Train.Specs.CurrentPowerNotch.Safety = 0;
//					}
//				}

                /*
                 * Process the brakes.
                 * */
                if (virtualHandles)
                {
                    this.Train.Specs.CurrentEmergencyBrake.Safety = false;
                    this.Train.Specs.CurrentHoldBrake.Actual      = false;
                }
                if (this.Train.Cars[this.Train.DriverCar].Specs.BrakeType == TrainManager.CarBrakeType.AutomaticAirBrake)
                {
                    if (handles.BrakeNotch == 0)
                    {
                        if (virtualHandles)
                        {
                            this.Train.Specs.AirBrake.Handle.Safety = TrainManager.AirBrakeHandleState.Release;
                        }
                        else
                        {
                            TrainManager.UnapplyEmergencyBrake(this.Train);
                            TrainManager.ApplyAirBrakeHandle(this.Train, TrainManager.AirBrakeHandleState.Release);
                        }
                    }
                    else if (handles.BrakeNotch == 1)
                    {
                        if (virtualHandles)
                        {
                            this.Train.Specs.AirBrake.Handle.Safety = TrainManager.AirBrakeHandleState.Lap;
                        }
                        else
                        {
                            TrainManager.UnapplyEmergencyBrake(this.Train);
                            TrainManager.ApplyAirBrakeHandle(this.Train, TrainManager.AirBrakeHandleState.Lap);
                        }
                    }
                    else if (handles.BrakeNotch == 2)
                    {
                        if (virtualHandles)
                        {
                            this.Train.Specs.AirBrake.Handle.Safety = TrainManager.AirBrakeHandleState.Service;
                        }
                        else
                        {
                            TrainManager.UnapplyEmergencyBrake(this.Train);
                            TrainManager.ApplyAirBrakeHandle(this.Train, TrainManager.AirBrakeHandleState.Release);
                        }
                    }
                    else if (handles.BrakeNotch == 3)
                    {
                        if (virtualHandles)
                        {
                            this.Train.Specs.AirBrake.Handle.Safety       = TrainManager.AirBrakeHandleState.Service;
                            this.Train.Specs.CurrentEmergencyBrake.Safety = true;
                        }
                        else
                        {
                            TrainManager.ApplyAirBrakeHandle(this.Train, TrainManager.AirBrakeHandleState.Service);
                            TrainManager.ApplyEmergencyBrake(this.Train);
                        }
                    }
                    else
                    {
                        this.PluginValid = false;
                    }
                }
                else
                {
                    if (this.Train.Specs.HasHoldBrake)
                    {
                        if (handles.BrakeNotch == this.Train.Specs.MaximumBrakeNotch + 2)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentEmergencyBrake.Safety = true;
                                this.Train.Specs.CurrentBrakeNotch.Safety     = this.Train.Specs.MaximumBrakeNotch;
                            }
                            else
                            {
                                TrainManager.ApplyHoldBrake(this.Train, false);
                                TrainManager.ApplyNotch(this.Train, 0, true, this.Train.Specs.MaximumBrakeNotch, false);
                                TrainManager.ApplyEmergencyBrake(this.Train);
                            }
                        }
                        else if (handles.BrakeNotch >= 2 & handles.BrakeNotch <= this.Train.Specs.MaximumBrakeNotch + 1)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = handles.BrakeNotch - 1;
                            }
                            else
                            {
                                TrainManager.UnapplyEmergencyBrake(this.Train);
                                TrainManager.ApplyHoldBrake(this.Train, false);
                                TrainManager.ApplyNotch(this.Train, 0, true, handles.BrakeNotch - 1, false);
                            }
                        }
                        else if (handles.BrakeNotch == 1)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = 0;
                                this.Train.Specs.CurrentHoldBrake.Actual  = true;
                            }
                            else
                            {
                                TrainManager.UnapplyEmergencyBrake(this.Train);
                                TrainManager.ApplyNotch(this.Train, 0, true, 0, false);
                                TrainManager.ApplyHoldBrake(this.Train, true);
                            }
                        }
                        else if (handles.BrakeNotch == 0)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = 0;
                            }
                            else
                            {
                                TrainManager.UnapplyEmergencyBrake(this.Train);
                                TrainManager.ApplyNotch(this.Train, 0, true, 0, false);
                                TrainManager.ApplyHoldBrake(this.Train, false);
                            }
                        }
                        else
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = this.Train.Specs.CurrentBrakeNotch.Driver;
                            }
                            this.PluginValid = false;
                        }
                    }
                    else
                    {
                        if (handles.BrakeNotch == this.Train.Specs.MaximumBrakeNotch + 1)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentEmergencyBrake.Safety = true;
                                this.Train.Specs.CurrentBrakeNotch.Safety     = this.Train.Specs.MaximumBrakeNotch;
                            }
                            else
                            {
                                TrainManager.ApplyHoldBrake(this.Train, false);
                                TrainManager.ApplyEmergencyBrake(this.Train);
                            }
                        }
                        else if (handles.BrakeNotch >= 0 & handles.BrakeNotch <= this.Train.Specs.MaximumBrakeNotch | this.Train.Specs.CurrentBrakeNotch.DelayedChanges.Length == 0)
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = handles.BrakeNotch;
                            }
                            else
                            {
                                TrainManager.UnapplyEmergencyBrake(this.Train);
                                TrainManager.ApplyNotch(this.Train, 0, true, handles.BrakeNotch, false);
                            }
                        }
                        else
                        {
                            if (virtualHandles)
                            {
                                this.Train.Specs.CurrentBrakeNotch.Safety = this.Train.Specs.CurrentBrakeNotch.Driver;
                            }
                            this.PluginValid = false;
                        }
                    }
                }

                /*
                 * Process the const speed system.
                 * */
                this.Train.Specs.CurrentConstSpeed = handles.ConstSpeed & this.Train.Specs.HasConstSpeed;
            }