public override void Initialize() { if ((GearBox != null) && (GearBoxController == null)) { if (!GearBox.IsInitialized) { GearBox = null; } else { foreach (DieselEngine de in DieselEngines) { if (de.GearBox == null) { de.GearBox = new GearBox(GearBox, de); } //if (this.Train.TrainType == Train.TRAINTYPE.AI) // de.GearBox.GearBoxOperation = GearBoxOperation.Automatic; } GearBoxController = new MSTSNotchController(DieselEngines[0].GearBox.NumOfGears + 1); } } DieselEngines.Initialize(false); base.Initialize(); }
/// <summary> /// Returns the controller which refills from the matching pickup point. /// </summary> /// <param name="type">Pickup type</param> /// <returns>Matching controller or null</returns> public override MSTSNotchController GetRefillController(uint type) { MSTSNotchController controller = null; if (type == (uint)PickupType.FuelDiesel) { return(FuelController); } return(controller); }
/// <summary> /// This initializer is called when we are making a new copy of a locomotive already /// loaded in memory. We use this one to speed up loading by eliminating the /// need to parse the wag file multiple times. /// NOTE: you must initialize all the same variables as you parsed above /// </summary> public override void Copy(MSTSWagon copy) { base.Copy(copy); // each derived level initializes its own variables MSTSDieselLocomotive locoCopy = (MSTSDieselLocomotive)copy; EngineRPM = locoCopy.EngineRPM; IdleRPM = locoCopy.IdleRPM; MaxRPM = locoCopy.MaxRPM; MaxRPMChangeRate = locoCopy.MaxRPMChangeRate; MaximumDieselEnginePowerW = locoCopy.MaximumDieselEnginePowerW; PercentChangePerSec = locoCopy.PercentChangePerSec; LocomotiveMaxRailOutputPowerW = locoCopy.LocomotiveMaxRailOutputPowerW; EngineRPMderivation = locoCopy.EngineRPMderivation; EngineRPMold = locoCopy.EngineRPMold; MaxDieselLevelL = locoCopy.MaxDieselLevelL; DieselUsedPerHourAtMaxPowerL = locoCopy.DieselUsedPerHourAtMaxPowerL; DieselUsedPerHourAtIdleL = locoCopy.DieselUsedPerHourAtIdleL; DieselFlowLps = 0.0f; InitialMassKg = MassKG; if (this.CarID.StartsWith("0")) { DieselLevelL = locoCopy.DieselLevelL; } else { DieselLevelL = locoCopy.MaxDieselLevelL; } if (locoCopy.GearBoxController != null) { GearBoxController = new MSTSNotchController(locoCopy.GearBoxController); } DieselEngines = new DieselEngines(locoCopy.DieselEngines, this); if (DieselEngines[0].GearBox != null) { GearBox = DieselEngines[0].GearBox; } for (int i = 1; i < DieselEngines.Count; i++) { if (DieselEngines[i].GearBox == null && locoCopy.DieselEngines[i].GearBox != null) { DieselEngines[i].GearBox = new GearBox(GearBox, DieselEngines[i]); } } foreach (DieselEngine de in DieselEngines) { de.Initialize(true); } }
/// <summary> /// Ends a continuous increase in controlled value. /// </summary> public void StopRefillingFromTrough(CommandLog log) { MSTSWagon.RefillProcess.OkToRefill = false; MSTSWagon.RefillProcess.ActivePickupObjectUID = 0; SteamLocomotive.RefillingFromTrough = false; var controller = new MSTSNotchController(); controller = SteamLocomotive.GetRefillController((uint)MSTSWagon.PickupType.FuelWater); new RefillCommand(log, controller.CurrentValue, controller.CommandStartTime); // for Replay to use controller.StopIncrease(); SteamLocomotive.SignalEvent(Event.WaterScoopUp); }
public override void LoadFromWagFile(string wagFilePath) { base.LoadFromWagFile(wagFilePath); NormalizeParams(); if (DieselEngines == null) { DieselEngines = new DieselEngines(this); } if (DieselEngines.Count == 0) { DieselEngines.Add(new DieselEngine()); DieselEngines[0].InitFromMSTS(this); DieselEngines[0].Initialize(true); } if (GearBox != null && GearBox.IsInitialized) { GearBox.CopyFromMSTSParams(DieselEngines[0]); if (DieselEngines[0].GearBox == null) { DieselEngines[0].GearBox = GearBox; DieselEngines[0].GearBox.UseLocoGearBox(DieselEngines[0]); } for (int i = 1; i < DieselEngines.Count; i++) { if (DieselEngines[i].GearBox == null) { DieselEngines[i].GearBox = new GearBox(GearBox, DieselEngines[i]); } } if (GearBoxController == null) { GearBoxController = new MSTSNotchController(GearBox.NumOfGears + 1); } } InitialMassKg = MassKG; }
public override void LoadFromWagFile(string wagFilePath) { base.LoadFromWagFile(wagFilePath); if (Simulator.Settings.VerboseConfigurationMessages) // Display locomotivve name for verbose error messaging { Trace.TraceInformation("\n\n ================================================= {0} =================================================", LocomotiveName); } NormalizeParams(); // Check to see if Speed of Max Tractive Force has been set - use ORTS value as first priority, if not use MSTS, last resort use an arbitary value. if (SpeedOfMaxContinuousForceMpS == 0) { if (MSTSSpeedOfMaxContinuousForceMpS != 0) { SpeedOfMaxContinuousForceMpS = MSTSSpeedOfMaxContinuousForceMpS; // Use MSTS value if present if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("Speed Of Max Continuous Force: set to default value {0}", FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } } else if (MaxPowerW != 0 && MaxContinuousForceN != 0) { SpeedOfMaxContinuousForceMpS = MaxPowerW / MaxContinuousForceN; if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("Speed Of Max Continuous Force: set to 'calculated' value {0}", FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } } else { SpeedOfMaxContinuousForceMpS = 10.0f; // If not defined then set at an "arbitary" value of 22mph if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("Speed Of Max Continuous Force: set to 'arbitary' value {0}", FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } } } if (DieselEngines == null) { DieselEngines = new DieselEngines(this); } // Create a diesel engine block if none exits, typically for a MSTS or BASIC configuration if (DieselEngines.Count == 0) { DieselEngines.Add(new DieselEngine()); DieselEngines[0].InitFromMSTS(this); DieselEngines[0].Initialize(true); } // Check initialization of power values for diesel engines for (int i = 0; i < DieselEngines.Count; i++) { DieselEngines[i].InitDieselRailPowers(this); } if (GearBox != null && GearBox.IsInitialized) { GearBox.CopyFromMSTSParams(DieselEngines[0]); if (DieselEngines[0].GearBox == null) { DieselEngines[0].GearBox = GearBox; DieselEngines[0].GearBox.UseLocoGearBox(DieselEngines[0]); } for (int i = 1; i < DieselEngines.Count; i++) { if (DieselEngines[i].GearBox == null) { DieselEngines[i].GearBox = new GearBox(GearBox, DieselEngines[i]); } } if (GearBoxController == null) { GearBoxController = new MSTSNotchController(GearBox.NumOfGears + 1); } } InitialMassKg = MassKG; // If traction force curves not set (BASIC configuration) then check that power values are set, otherwise locomotive will not move. if (TractiveForceCurves == null && LocomotiveMaxRailOutputPowerW == 0) { if (MaxPowerW != 0) { LocomotiveMaxRailOutputPowerW = MaxPowerW; // Set to default power value if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("MaxRailOutputPower (BASIC Config): set to default value = {0}", FormatStrings.FormatPower(LocomotiveMaxRailOutputPowerW, IsMetric, false, false)); } } else { LocomotiveMaxRailOutputPowerW = 2500000.0f; // If no default value then set to arbitary value if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("MaxRailOutputPower (BASIC Config): set at arbitary value = {0}", FormatStrings.FormatPower(LocomotiveMaxRailOutputPowerW, IsMetric, false, false)); } } if (MaximumDieselEnginePowerW == 0) { MaximumDieselEnginePowerW = LocomotiveMaxRailOutputPowerW; // If no value set in ENG file, then set the Prime Mover power to same as RailOutputPower (typically the MaxPower value) if (Simulator.Settings.VerboseConfigurationMessages) { Trace.TraceInformation("Maximum Diesel Engine Prime Mover Power set the same as MaxRailOutputPower {0} value", FormatStrings.FormatPower(MaximumDieselEnginePowerW, IsMetric, false, false)); } } } // Check force assumptions set for diesel if (Simulator.Settings.VerboseConfigurationMessages) { float ThrottleSetting = 1.0f; // Must be at full throttle for these calculations if (TractiveForceCurves == null) // Basic configuration - ie no force and Power tables, etc { float CalculatedMaxContinuousForceN = ThrottleSetting * LocomotiveMaxRailOutputPowerW / SpeedOfMaxContinuousForceMpS; Trace.TraceInformation("Diesel Force Settings (BASIC Config): Max Starting Force {0}, Calculated Max Continuous Force {1} @ speed of {2}", FormatStrings.FormatForce(MaxForceN, IsMetric), FormatStrings.FormatForce(CalculatedMaxContinuousForceN, IsMetric), FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); Trace.TraceInformation("Diesel Power Settings (BASIC Config): Prime Mover {0}, Max Rail Output Power {1}", FormatStrings.FormatPower(MaximumDieselEnginePowerW, IsMetric, false, false), FormatStrings.FormatPower(LocomotiveMaxRailOutputPowerW, IsMetric, false, false)); if (MaxForceN < MaxContinuousForceN) { Trace.TraceInformation("!!!! Warning: Starting Tractive force {0} is less then Calculated Continuous force {1}, please check !!!!", FormatStrings.FormatForce(MaxForceN, IsMetric), FormatStrings.FormatForce(CalculatedMaxContinuousForceN, IsMetric), FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } } else // Advanced configuration - { float StartingSpeedMpS = 0.1f; // Assumed starting speed for diesel - can't be zero otherwise error will occurr float StartingForceN = (float)TractiveForceCurves.Get(ThrottleSetting, StartingSpeedMpS); float CalculatedMaxContinuousForceN = (float)TractiveForceCurves.Get(ThrottleSetting, SpeedOfMaxContinuousForceMpS); Trace.TraceInformation("Diesel Force Settings (ADVANCED Config): Max Starting Force {0} Calculated Max Continuous Force {1}, @ speed of {2}", FormatStrings.FormatForce(StartingForceN, IsMetric), FormatStrings.FormatForce(CalculatedMaxContinuousForceN, IsMetric), FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); Trace.TraceInformation("Diesel Power Settings (ADVANCED Config): Prime Mover {0}, Max Rail Output Power {1} @ {2} rpm", FormatStrings.FormatPower(DieselEngines.MaxPowerW, IsMetric, false, false), FormatStrings.FormatPower(DieselEngines.MaximumRailOutputPowerW, IsMetric, false, false), MaxRPM); if (StartingForceN < MaxContinuousForceN) { Trace.TraceInformation("!!!! Warning: Calculated Starting Tractive force {0} is less then Calculated Continuous force {1}, please check !!!!", FormatStrings.FormatForce(StartingForceN, IsMetric), FormatStrings.FormatForce(CalculatedMaxContinuousForceN, IsMetric), FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } } // Check that MaxPower value is realistic - Calculate power - metric - P = F x V float CalculatedContinuousPowerW = MaxContinuousForceN * SpeedOfMaxContinuousForceMpS; if (MaxPowerW < CalculatedContinuousPowerW) { Trace.TraceInformation("!!!! Warning: MaxPower {0} is less then continuous force calculated power {1} @ speed of {2}, please check !!!!", FormatStrings.FormatPower(MaxPowerW, IsMetric, false, false), FormatStrings.FormatPower(CalculatedContinuousPowerW, IsMetric, false, false), FormatStrings.FormatSpeedDisplay(SpeedOfMaxContinuousForceMpS, IsMetric)); } Trace.TraceInformation("===================================================================================================================\n\n"); } }