Beispiel #1
0
        //================================================================================================//
        /// <summary>
        /// Initialization when simulation starts with moving train
        /// <\summary>
        public override void InitializeMoving()
        {
            base.InitializeMoving();

            CircuitBreaker.InitializeMoving();
            TractionCutOffRelay.InitializeMoving();
        }
Beispiel #2
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();
        }
        protected override void AssignScriptFunctions()
        {
            base.AssignScriptFunctions();

            // DieselPowerSupply getters
            Script.CurrentDieselEnginesState = () => DieselLocomotive.DieselEngines.State;
            Script.CurrentDieselEngineState  = (id) =>
            {
                if (id >= 0 && id < DieselEngines.Count)
                {
                    return(DieselEngines[id].State);
                }
                else
                {
                    return(DieselEngineState.Unavailable);
                }
            };
            Script.CurrentTractionCutOffRelayState               = () => TractionCutOffRelay.State;
            Script.TractionCutOffRelayDriverClosingOrder         = () => TractionCutOffRelay.DriverClosingOrder;
            Script.TractionCutOffRelayDriverOpeningOrder         = () => TractionCutOffRelay.DriverOpeningOrder;
            Script.TractionCutOffRelayDriverClosingAuthorization = () => TractionCutOffRelay.DriverClosingAuthorization;

            // DieselPowerSupply setters
            Script.SignalEventToDieselEngines       = (evt) => DieselEngines.HandleEvent(evt);
            Script.SignalEventToDieselEngine        = (evt, id) => DieselEngines.HandleEvent(evt, id);
            Script.SignalEventToTractionCutOffRelay = (evt) => TractionCutOffRelay.HandleEvent(evt);
        }
        public override void Restore(BinaryReader inf)
        {
            ScriptName = inf.ReadString();

            base.Restore(inf);
            TractionCutOffRelay.Restore(inf);
        }
        public override void Save(BinaryWriter outf)
        {
            outf.Write(ScriptName);

            base.Save(outf);
            TractionCutOffRelay.Save(outf);
        }
        public override void Update(double elapsedClockSeconds)
        {
            base.Update(elapsedClockSeconds);

            TractionCutOffRelay.Update(elapsedClockSeconds);

            Script?.Update(elapsedClockSeconds);
        }
Beispiel #7
0
        public override void Update(float elapsedClockSeconds)
        {
            base.Update(elapsedClockSeconds);

            CircuitBreaker.Update(elapsedClockSeconds);
            TractionCutOffRelay.Update(elapsedClockSeconds);

            Script?.Update(elapsedClockSeconds);
        }
        public override void Copy(IPowerSupply other)
        {
            base.Copy(other);

            if (other is ScriptedDieselPowerSupply scriptedOther)
            {
                TractionCutOffRelay.Copy(scriptedOther.TractionCutOffRelay);
            }
        }
Beispiel #9
0
        public override void Copy(IPowerSupply other)
        {
            base.Copy(other);

            if (other is ScriptedDualModePowerSupply scriptedOther)
            {
                CircuitBreaker.Copy(scriptedOther.CircuitBreaker);
                TractionCutOffRelay.Copy(scriptedOther.TractionCutOffRelay);
            }
        }
Beispiel #10
0
        public override void Parse(string lowercasetoken, STFReader stf)
        {
            switch (lowercasetoken)
            {
            case "engine(ortstractioncutoffrelay":
            case "engine(ortstractioncutoffrelayclosingdelay":
                TractionCutOffRelay.Parse(lowercasetoken, stf);
                break;

            default:
                base.Parse(lowercasetoken, stf);
                break;
            }
        }
Beispiel #11
0
        protected override void AssignScriptFunctions()
        {
            base.AssignScriptFunctions();

            // DualModePowerSupply getters
            Script.CurrentDieselEngineState                      = () => (Locomotive as MSTSDieselLocomotive).DieselEngines.State;
            Script.CurrentTractionCutOffRelayState               = () => TractionCutOffRelay.State;
            Script.TractionCutOffRelayDriverClosingOrder         = () => TractionCutOffRelay.DriverClosingOrder;
            Script.TractionCutOffRelayDriverOpeningOrder         = () => TractionCutOffRelay.DriverOpeningOrder;
            Script.TractionCutOffRelayDriverClosingAuthorization = () => TractionCutOffRelay.DriverClosingAuthorization;

            // DualModePowerSupply setters
            Script.SignalEventToTractionCutOffRelay = (evt) => TractionCutOffRelay.HandleEvent(evt);
        }
        public override void Parse(string lowercasetoken, STFReader stf)
        {
            switch (lowercasetoken)
            {
            case "engine(ortstractioncutoffrelay":
            case "engine(ortstractioncutoffrelayclosingdelay":
                TractionCutOffRelay.Parse(lowercasetoken, stf);
                break;

            case "engine(ortselectrictrainsupply(dieselengineminrpm":
                DieselEngineMinRpmForElectricTrainSupply = stf.ReadFloatBlock(STFReader.Units.None, 0f);
                break;

            default:
                base.Parse(lowercasetoken, stf);
                break;
            }
        }
        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();
        }
        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;
            }
        }
Beispiel #15
0
 public void Copy(ScriptedDualModePowerSupply other)
 {
     base.Copy(other);
     CircuitBreaker.Copy(other.CircuitBreaker);
     TractionCutOffRelay.Copy(other.TractionCutOffRelay);
 }