예제 #1
0
        public override void Initialize()
        {
            base.Initialize();

            if (!Activated)
            {
                if (ScriptName != null && ScriptName != "Default")
                {
                    var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") };
                    AbstractScript = Simulator.ScriptManager.Load(pathArray, ScriptName) as DualModePowerSupply;
                }
                if (Script == null)
                {
                    AbstractScript = new DefaultDualModePowerSupply();
                }

                AssignScriptFunctions();

                Script.Initialize();
                Activated = true;
            }

            CircuitBreaker.Initialize();
            TractionCutOffRelay.Initialize();
        }
예제 #2
0
        public override void Initialize()
        {
            base.Initialize();

            if (!Activated)
            {
                if (ScriptName != null && ScriptName != "Default")
                {
                    AbstractScript = Simulator.ScriptManager.Load(Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script"), ScriptName) as DieselPowerSupply;
                }
                if (Script == null)
                {
                    AbstractScript = new DefaultDieselPowerSupply();
                }

                AssignScriptFunctions();

                Script.Initialize();
                Activated = true;
            }

            TractionCutOffRelay.Initialize();
        }
예제 #3
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;
            }
        }