public void Initialize() { if (!Activated) { if (ScriptName != null && ScriptName != "MSTS") { var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") }; Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as BrakeController; } if (Script == null) { Script = new MSTSBrakeController() as BrakeController; (Script as MSTSBrakeController).ForceControllerReleaseGraduated = Simulator.Settings.GraduatedRelease; } // AbstractScriptClass Script.ClockTime = () => (float)Simulator.ClockTime; Script.GameTime = () => (float)Simulator.GameTime; Script.DistanceM = () => Locomotive.DistanceM; // BrakeController Script.EmergencyBrakingPushButton = () => EmergencyBrakingPushButton; Script.TCSEmergencyBraking = () => TCSEmergencyBraking; Script.TCSFullServiceBraking = () => TCSFullServiceBraking; Script.MainReservoirPressureBar = () => { if (Locomotive.Train != null) { return(Bar.FromPSI(Locomotive.Train.BrakeLine2PressurePSI)); } else { return(float.MaxValue); } }; Script.MaxPressureBar = () => Bar.FromPSI(MaxPressurePSI); Script.ReleaseRateBarpS = () => BarpS.FromPSIpS(ReleaseRatePSIpS); Script.QuickReleaseRateBarpS = () => BarpS.FromPSIpS(QuickReleaseRatePSIpS); Script.ApplyRateBarpS = () => BarpS.FromPSIpS(ApplyRatePSIpS); Script.EmergencyRateBarpS = () => BarpS.FromPSIpS(EmergencyRatePSIpS); Script.FullServReductionBar = () => Bar.FromPSI(FullServReductionPSI); Script.MinReductionBar = () => Bar.FromPSI(MinReductionPSI); Script.CurrentValue = () => CurrentValue; Script.MinimumValue = () => MinimumValue; Script.MaximumValue = () => MaximumValue; Script.StepSize = () => StepSize; Script.UpdateValue = () => UpdateValue; Script.Notches = () => Notches; Script.SetCurrentValue = (value) => CurrentValue = value; Script.SetUpdateValue = (value) => UpdateValue = value; Script.Initialize(); } }
public void Initialize() { if (!Activated) { if (ScriptName != null && ScriptName != "MSTS") { var pathArray = new string[] { Path.Combine(Path.GetDirectoryName(Locomotive.WagFilePath), "Script") }; Script = Simulator.ScriptManager.Load(pathArray, ScriptName) as BrakeController; } if (Script == null) { Script = new MSTSBrakeController() as BrakeController; (Script as MSTSBrakeController).ForceControllerReleaseGraduated = Simulator.Settings.GraduatedRelease; } // AbstractScriptClass Script.ClockTime = () => (float)Simulator.ClockTime; Script.GameTime = () => (float)Simulator.GameTime; Script.DistanceM = () => Locomotive.DistanceM; Script.SpeedMpS = () => Math.Abs(Locomotive.SpeedMpS); 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); } }; // BrakeController Script.EmergencyBrakingPushButton = () => EmergencyBrakingPushButton; Script.TCSEmergencyBraking = () => TCSEmergencyBraking; Script.TCSFullServiceBraking = () => TCSFullServiceBraking; Script.QuickReleaseButtonPressed = () => QuickReleaseButtonPressed; Script.OverchargeButtonPressed = () => OverchargeButtonPressed; Script.IsLowVoltagePowerSupplyOn = () => Locomotive.LocomotivePowerSupply.LowVoltagePowerSupplyOn; Script.IsCabPowerSupplyOn = () => Locomotive.LocomotivePowerSupply.CabPowerSupplyOn; Script.MainReservoirPressureBar = () => { if (Locomotive.Train != null) { return(Bar.FromPSI(Locomotive.Train.BrakeLine2PressurePSI)); } else { return(float.MaxValue); } }; Script.MaxPressureBar = () => Bar.FromPSI(MaxPressurePSI); Script.MaxOverchargePressureBar = () => Bar.FromPSI(MaxOverchargePressurePSI); Script.ReleaseRateBarpS = () => BarpS.FromPSIpS(ReleaseRatePSIpS); Script.QuickReleaseRateBarpS = () => BarpS.FromPSIpS(QuickReleaseRatePSIpS); Script.OverchargeEliminationRateBarpS = () => BarpS.FromPSIpS(OverchargeEliminationRatePSIpS); Script.SlowApplicationRateBarpS = () => BarpS.FromPSIpS(SlowApplicationRatePSIpS); Script.ApplyRateBarpS = () => BarpS.FromPSIpS(ApplyRatePSIpS); Script.EmergencyRateBarpS = () => BarpS.FromPSIpS(EmergencyRatePSIpS); Script.FullServReductionBar = () => Bar.FromPSI(FullServReductionPSI); Script.MinReductionBar = () => Bar.FromPSI(MinReductionPSI); Script.CurrentValue = () => CurrentValue; Script.MinimumValue = () => MinimumValue; Script.MaximumValue = () => MaximumValue; Script.StepSize = () => StepSize; Script.UpdateValue = () => UpdateValue; Script.Notches = () => Notches; Script.SetCurrentValue = (value) => CurrentValue = value; Script.SetUpdateValue = (value) => UpdateValue = value; Script.SetDynamicBrakeIntervention = (value) => { // TODO: Set dynamic brake intervention instead of controller position // There are some issues that need to be identified and fixed before setting the intervention directly if (Locomotive.DynamicBrakeController == null) { return; } Locomotive.DynamicBrakeChangeActiveState(value > 0); Locomotive.DynamicBrakeController.SetValue(value); }; Script.Initialize(); } }