Ejemplo n.º 1
0
        public override void HandleEvent(TCSEvent evt,string message)
        {
            switch (evt)
            {
            case TCSEvent.AlerterPressed:
            case TCSEvent.AlerterReleased:
            case TCSEvent.AlerterReset:
                if (Activated)
                {
                    switch (VigilanceMonitorState)
                    {
                    // case VigilanceState.Disabled: do nothing

                    case MonitorState.StandBy:
                        VigilanceAlarmTimer.Stop();
                        break;

                    case MonitorState.Alarm:
                        VigilanceEmergencyTimer.Stop();
                        VigilanceMonitorState = MonitorState.StandBy;
                        break;

                        // case VigilanceState.Emergency: do nothing
                    }
                }
                break;
            }

            switch (evt)
            {
            case TCSEvent.AlerterPressed:
                ResetButtonPressed = true;
                break;

            case TCSEvent.AlerterReleased:
                ResetButtonPressed = false;
                break;
            }
        }
Ejemplo n.º 2
0
        public override void HandleEvent(TCSEvent evt, string message)
        {
            switch (evt)
            {
            case TCSEvent.AlerterPressed:
                VACMAPressed = true;
                break;

            case TCSEvent.AlerterReleased:
                VACMAPressed = false;
                break;

            case TCSEvent.ThrottleChanged:
            case TCSEvent.DynamicBrakeChanged:
            case TCSEvent.HornActivated:
                if (VACMAPressedAlertTimer.Started || VACMAPressedEmergencyTimer.Started)
                {
                    VACMAPressedAlertTimer.Start();
                    VACMAPressedEmergencyTimer.Start();
                }
                break;
            }
        }
Ejemplo n.º 3
0
        public override void HandleEvent(TCSEvent evt,string message)
        {
            switch (evt)
            {
            case TCSEvent.AlerterPressed:
            case TCSEvent.AlerterReleased:
            case TCSEvent.AlerterReset:
                if (!Activated || VigilanceEmergency)
                {
                    return;
                }

                if (VigilanceMonitor != null)
                {
                    VigilanceAlarmTimer.Start();
                    VigilanceAlarm = VigilanceAlarmTimer.Triggered;
                    if (AlerterSound())
                    {
                        SetVigilanceAlarm(false);
                    }
                }

                if (OverspeedMonitor != null)
                {
                    if (OverspeedWarning && OverspeedMonitor.ResetOnResetButton)
                    {
                        OverspeedAlarmTimer.Start();
                    }
                }

                if (ExternalEmergency && SpeedMpS() < 0.1f)
                {
                    ExternalEmergency = false;
                }
                break;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Called when a TCS event happens (like the alerter button pressed)
 /// </summary>
 /// <param name="evt">The event happened</param>
 /// <param name="message">The message the event wants to communicate. May be empty.</param>
 public abstract void HandleEvent(TCSEvent evt, string message);
Ejemplo n.º 5
0
        public void Initialize()
        {
            if (!Activated)
            {
                if (ScriptName != null)
                {
                    switch (ScriptName)
                    {
                    case "Automatic":
                        Script = new AutomaticCircuitBreaker() as CircuitBreaker;
                        break;

                    case "Manual":
                        Script = new ManualCircuitBreaker() as CircuitBreaker;
                        break;

                    default:
                        var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") };
                        Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as CircuitBreaker;
                        break;
                    }
                }
                // Fallback to automatic circuit breaker if the above failed.
                if (Script == null)
                {
                    Script = new AutomaticCircuitBreaker() as CircuitBreaker;
                }

                // AbstractScriptClass
                Script.ClockTime          = () => (float)Simulator.ClockTime;
                Script.GameTime           = () => (float)Simulator.GameTime;
                Script.DistanceM          = () => Locomotive.DistanceM;
                Script.Confirm            = Locomotive.Simulator.Confirmer.Confirm;
                Script.Message            = Locomotive.Simulator.Confirmer.Message;
                Script.SignalEvent        = Locomotive.SignalEvent;
                Script.SignalEventToTrain = (evt) =>
                {
                    if (Locomotive.Train != null)
                    {
                        Locomotive.Train.SignalEvent(evt);
                    }
                };

                // CircuitBreaker getters
                Script.CurrentState               = () => State;
                Script.CurrentPantographState     = () => Locomotive.Pantographs.State;
                Script.CurrentPowerSupplyState    = () => Locomotive.PowerSupply.State;
                Script.DriverClosingOrder         = () => DriverClosingOrder;
                Script.DriverOpeningOrder         = () => DriverOpeningOrder;
                Script.DriverClosingAuthorization = () => DriverClosingAuthorization;
                Script.TCSClosingOrder            = () => TCSClosingOrder;
                Script.TCSOpeningOrder            = () => TCSOpeningOrder;
                Script.TCSClosingAuthorization    = () => TCSClosingAuthorization;
                Script.ClosingAuthorization       = () => ClosingAuthorization;
                Script.ClosingDelayS              = () => DelayS;

                // CircuitBreaker setters
                Script.SetCurrentState = (value) =>
                {
                    State = value;
                    TCSEvent CircuitBreakerEvent = State == CircuitBreakerState.Closed ? TCSEvent.CircuitBreakerClosed : TCSEvent.CircuitBreakerOpen;
                    Locomotive.TrainControlSystem.HandleEvent(CircuitBreakerEvent);
                };
                Script.SetDriverClosingOrder         = (value) => DriverClosingOrder = value;
                Script.SetDriverOpeningOrder         = (value) => DriverOpeningOrder = value;
                Script.SetDriverClosingAuthorization = (value) => DriverClosingAuthorization = value;
                Script.SetClosingAuthorization       = (value) => ClosingAuthorization = value;

                Script.Initialize();
                Activated = true;
            }
        }
Ejemplo n.º 6
0
        public void Initialize()
        {
            if (!Activated)
            {
                if (ScriptName != null)
                {
                    switch (ScriptName)
                    {
                    case "Automatic":
                        Script = new AutomaticTractionCutOffRelay() as TractionCutOffRelay;
                        break;

                    case "Manual":
                        Script = new ManualTractionCutOffRelay() as TractionCutOffRelay;
                        break;

                    default:
                        Script = Simulator.ScriptManager.Load(Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script"), ScriptName) as TractionCutOffRelay;
                        break;
                    }
                }
                // Fallback to automatic circuit breaker if the above failed.
                if (Script == null)
                {
                    Script = new AutomaticTractionCutOffRelay() as TractionCutOffRelay;
                }

                // AbstractScriptClass
                Script.ClockTime          = () => (float)Simulator.ClockTime;
                Script.GameTime           = () => (float)Simulator.GameTime;
                Script.PreUpdate          = () => Simulator.PreUpdate;
                Script.DistanceM          = () => Locomotive.DistanceM;
                Script.Confirm            = Locomotive.Simulator.Confirmer.Confirm;
                Script.Message            = Locomotive.Simulator.Confirmer.Message;
                Script.SignalEvent        = Locomotive.SignalEvent;
                Script.SignalEventToTrain = (evt) =>
                {
                    if (Locomotive.Train != null)
                    {
                        Locomotive.Train.SignalEvent(evt);
                    }
                };

                // TractionCutOffSubsystem getters
                Script.SupplyType                 = () => PowerSupply.Type;
                Script.CurrentState               = () => State;
                Script.CurrentPantographState     = () => Locomotive?.Pantographs.State ?? PantographState.Unavailable;
                Script.CurrentDieselEngineState   = () => (Locomotive as MSTSDieselLocomotive)?.DieselEngines.State ?? DieselEngineState.Unavailable;
                Script.CurrentPowerSupplyState    = () => PowerSupply.MainPowerSupplyState;
                Script.DriverClosingOrder         = () => DriverClosingOrder;
                Script.DriverOpeningOrder         = () => DriverOpeningOrder;
                Script.DriverClosingAuthorization = () => DriverClosingAuthorization;
                Script.TCSClosingAuthorization    = () => TCSClosingAuthorization;
                Script.ClosingAuthorization       = () => ClosingAuthorization;
                Script.IsLowVoltagePowerSupplyOn  = () => PowerSupply.LowVoltagePowerSupplyOn;
                Script.IsCabPowerSupplyOn         = () => PowerSupply.CabPowerSupplyOn;
                Script.ClosingDelayS              = () => DelayS;

                // TractionCutOffSubsystem setters
                Script.SetDriverClosingOrder         = (value) => DriverClosingOrder = value;
                Script.SetDriverOpeningOrder         = (value) => DriverOpeningOrder = value;
                Script.SetDriverClosingAuthorization = (value) => DriverClosingAuthorization = value;
                Script.SetClosingAuthorization       = (value) => ClosingAuthorization = value;

                // TractionCutOffRelay getters
                Script.CurrentState = () => State;

                // TractionCutOffRelay setters
                Script.SetCurrentState = (value) =>
                {
                    State = value;
                    TCSEvent CircuitBreakerEvent = State == TractionCutOffRelayState.Closed ? TCSEvent.TractionCutOffRelayClosed : TCSEvent.TractionCutOffRelayOpen;
                    Locomotive.TrainControlSystem.HandleEvent(CircuitBreakerEvent);
                };

                // DualModeTractionCutOffRelay getters
                Script.CurrentCircuitBreakerState = () => PowerSupply.Type == PowerSupplyType.DualMode ? (PowerSupply as ScriptedDualModePowerSupply).CircuitBreaker.State : CircuitBreakerState.Unavailable;

                Script.Initialize();
                Activated = true;
            }
        }
Ejemplo n.º 7
0
 public void HandleEvent(TCSEvent evt)
 {
     HandleEvent(evt,String.Empty);
 }
Ejemplo n.º 8
0
        public override void HandleEvent(TCSEvent evt, string message)
        {
            switch (evt)
            {
            case TCSEvent.AlerterPressed:
                VACMAPressed = true;
                break;

            case TCSEvent.AlerterReleased:
                VACMAPressed = false;
                break;

            case TCSEvent.ThrottleChanged:
            case TCSEvent.DynamicBrakeChanged:
            case TCSEvent.HornActivated:
                if (VACMAPressedAlertTimer.Started || VACMAPressedEmergencyTimer.Started)
                {
                    VACMAPressedAlertTimer.Start();
                    VACMAPressedEmergencyTimer.Start();
                }
                break;

            case TCSEvent.GenericTCSButtonPressed:
            {
                int tcsButton = -1;
                if (Int32.TryParse(message, out tcsButton))
                {
                    SetCabDisplayControl(tcsButton, 1);

                    switch (tcsButton)
                    {
                    // BP (AC) SF
                    case BP_AC_SF:
                        RSPressed = true;
                        break;

                    // BP (A) LS (SF)
                    case BP_A_LS_SF:
                        RSCancelPressed = true;
                        break;
                    }
                }
            }
            break;

            case TCSEvent.GenericTCSButtonReleased:
            {
                int tcsButton = -1;
                if (Int32.TryParse(message, out tcsButton))
                {
                    SetCabDisplayControl(tcsButton, 0);

                    switch (tcsButton)
                    {
                    // BP (AC) SF
                    case BP_AC_SF:
                        RSPressed = false;
                        break;

                    // BP (A) LS (SF)
                    case BP_A_LS_SF:
                        RSCancelPressed = false;
                        break;

                    // BP AM V1 and BP AM V2
                    case BP_AM_V1:
                    case BP_AM_V2:
                        if (!TVMArmed)
                        {
                            TVMArmed = true;
                            UpdateTVMAspect(NextSignalAspect(0), false);
                        }
                        break;

                    // BP DM
                    case BP_DM:
                        TVMArmed = false;
                        break;
                    }
                }
            }
            break;

            case TCSEvent.GenericTCSSwitchOn:
            {
                int tcsButton = -1;
                if (Int32.TryParse(message, out tcsButton))
                {
                    SetCabDisplayControl(tcsButton, 1);

                    switch (tcsButton)
                    {
                    // Z (ES) VA
                    case Z_ES_VA:
                        VACMATest = true;
                        break;
                    }
                }
            }
            break;

            case TCSEvent.GenericTCSSwitchOff:
            {
                int tcsButton = -1;
                if (Int32.TryParse(message, out tcsButton))
                {
                    SetCabDisplayControl(tcsButton, 0);

                    switch (tcsButton)
                    {
                    // Z (ES) VA
                    case Z_ES_VA:
                        VACMATest = false;
                        break;
                    }
                }
            }
            break;
            }
        }
Ejemplo n.º 9
0
 public void SendEvent(TCSEvent evt)
 {
     SendEvent(evt,String.Empty);
 }