Example #1
0
        public GearBox(GearBox copy, DieselEngine de)
        {
            mstsParams   = new MSTSGearBoxParams(copy.mstsParams);
            DieselEngine = de;

            if (mstsParams != null)
            {
                if ((!mstsParams.IsInitialized) && (mstsParams.AtLeastOneParamFound))
                {
                    Trace.TraceWarning("Some of the gearbox parameters are missing! Default physics will be used.");
                }
                for (int i = 0; i < mstsParams.GearBoxNumberOfGears; i++)
                {
                    Gears.Add(new Gear(this));
                    Gears[i].BackLoadForceN      = mstsParams.GearBoxBackLoadForceN;
                    Gears[i].CoastingForceN      = mstsParams.GearBoxCoastingForceN;
                    Gears[i].DownGearProportion  = mstsParams.GearBoxDownGearProportion;
                    Gears[i].IsDirectDriveGear   = (mstsParams.GearBoxDirectDriveGear == mstsParams.GearBoxNumberOfGears);
                    Gears[i].MaxSpeedMpS         = mstsParams.GearBoxMaxSpeedForGearsMpS[i];
                    Gears[i].MaxTractiveForceN   = mstsParams.GearBoxMaxTractiveForceForGearsN[i];
                    Gears[i].OverspeedPercentage = mstsParams.GearBoxOverspeedPercentageForFailure;
                    Gears[i].UpGearProportion    = mstsParams.GearBoxUpGearProportion;
                    Gears[i].Ratio = mstsParams.GearBoxMaxSpeedForGearsMpS[i] / DieselEngine.MaxRPM;
                }
                GearBoxOperation         = mstsParams.GearBoxOperation;
                OriginalGearBoxOperation = mstsParams.GearBoxOperation;
            }
        }
Example #2
0
 public MSTSGearBoxParams(MSTSGearBoxParams copy)
 {
     GearBoxNumberOfGears                 = copy.GearBoxNumberOfGears;
     GearBoxDirectDriveGear               = copy.GearBoxDirectDriveGear;
     GearBoxOperation                     = copy.GearBoxOperation;
     GearBoxEngineBraking                 = copy.GearBoxEngineBraking;
     GearBoxMaxSpeedForGearsMpS           = new List <float>(copy.GearBoxMaxSpeedForGearsMpS);
     GearBoxMaxTractiveForceForGearsN     = new List <float>(copy.GearBoxMaxTractiveForceForGearsN);
     GearBoxOverspeedPercentageForFailure = copy.GearBoxOverspeedPercentageForFailure;
     GearBoxBackLoadForceN                = copy.GearBoxBackLoadForceN;
     GearBoxCoastingForceN                = copy.GearBoxCoastingForceN;
     GearBoxUpGearProportion              = copy.GearBoxUpGearProportion;
     GearBoxDownGearProportion            = copy.GearBoxDownGearProportion;
     initLevel = copy.initLevel;
 }
Example #3
0
 public void Copy(MSTSGearBoxParams copy)
 {
     GearBoxNumberOfGears                 = copy.GearBoxNumberOfGears;
     GearBoxDirectDriveGear               = copy.GearBoxDirectDriveGear;
     GearBoxType                          = copy.GearBoxType;
     ClutchType                           = copy.ClutchType;
     GearBoxOperation                     = copy.GearBoxOperation;
     GearBoxEngineBraking                 = copy.GearBoxEngineBraking;
     GearBoxMaxSpeedForGearsMpS           = new List <float>(copy.GearBoxMaxSpeedForGearsMpS);
     GearBoxChangeUpSpeedRpM              = new List <float>(copy.GearBoxChangeUpSpeedRpM);
     GearBoxChangeDownSpeedRpM            = new List <float>(copy.GearBoxChangeDownSpeedRpM);
     GearBoxMaxTractiveForceForGearsN     = new List <float>(copy.GearBoxMaxTractiveForceForGearsN);
     GearBoxTractiveForceAtSpeedN         = new List <float>(copy.GearBoxTractiveForceAtSpeedN);
     GearBoxOverspeedPercentageForFailure = copy.GearBoxOverspeedPercentageForFailure;
     GearBoxBackLoadForceN                = copy.GearBoxBackLoadForceN;
     GearBoxCoastingForceN                = copy.GearBoxCoastingForceN;
     GearBoxUpGearProportion              = copy.GearBoxUpGearProportion;
     GearBoxDownGearProportion            = copy.GearBoxDownGearProportion;
     FreeWheelFitted                      = copy.FreeWheelFitted;
     initLevel = copy.initLevel;
 }
Example #4
0
        public void Initialize()
        {
            if (GearBoxParams != null)
            {
                if ((!GearBoxParams.IsInitialized) && (GearBoxParams.AtLeastOneParamFound))
                {
                    Trace.TraceWarning("Some of the gearbox parameters are missing! Default physics will be used.");
                }

                GearBoxType            = GearBoxParams.GearBoxType;
                ClutchType             = GearBoxParams.ClutchType;
                GearBoxFreeWheelFitted = GearBoxParams.FreeWheelFitted;

                for (int i = 0; i < GearBoxParams.GearBoxNumberOfGears; i++)
                {
                    Gears.Add(new Gear(this));
                    Gears[i].BackLoadForceN     = GearBoxParams.GearBoxBackLoadForceN;
                    Gears[i].CoastingForceN     = GearBoxParams.GearBoxCoastingForceN;
                    Gears[i].DownGearProportion = GearBoxParams.GearBoxDownGearProportion;
                    Gears[i].IsDirectDriveGear  = (GearBoxParams.GearBoxDirectDriveGear == GearBoxParams.GearBoxNumberOfGears);
                    Gears[i].MaxSpeedMpS        = GearBoxParams.GearBoxMaxSpeedForGearsMpS[i];
                    // Maximum torque (tractive effort) actually occurs at less then the maximum engine rpm, so this section uses either
                    // the TE at gear maximum speed, or if the user has entered the maximum TE
                    if (!GearBoxParams.MaxTEFound)
                    {
                        // If user has entered this value then assume that they have already put the maximum torque value in
                        Gears[i].MaxTractiveForceN = GearBoxParams.GearBoxMaxTractiveForceForGearsN[i];
                    }
                    else
                    {
                        // if they entered the TE at maximum gear speed, then increase the value accordingly
                        Gears[i].MaxTractiveForceN = GearBoxParams.GearBoxTractiveForceAtSpeedN[i] * 1.234f;
                    }
                    Gears[i].OverspeedPercentage = GearBoxParams.GearBoxOverspeedPercentageForFailure;
                    Gears[i].UpGearProportion    = GearBoxParams.GearBoxUpGearProportion;
                    if (Locomotive != null && Locomotive.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
                    {
                        // Calculate gear ratio, based on premise that drive wheel rpm @ max speed will be when engine is operating at max rpm
                        var   driveWheelCircumferenceM = 2 * Math.PI * Locomotive.DriverWheelRadiusM;
                        var   driveWheelRpm            = pS.TopM(Gears[i].MaxSpeedMpS) / driveWheelCircumferenceM;
                        float apparentGear             = (float)(DieselEngine.MaxRPM / driveWheelRpm);

                        Gears[i].Ratio = apparentGear;

                        Gears[i].BackLoadForceN = Gears[i].Ratio * GearBoxParams.GearBoxBackLoadForceN;
                        Gears[i].CoastingForceN = Gears[i].Ratio * GearBoxParams.GearBoxCoastingForceN;

                        Gears[i].ChangeUpSpeedRpM = DieselEngine.MaxRPM;

                        Gears[0].ChangeDownSpeedRpM = DieselEngine.IdleRPM;

                        if (i > 0)
                        {
                            driveWheelRpm = pS.TopM(Gears[i - 1].MaxSpeedMpS) / driveWheelCircumferenceM;
                            Gears[i].ChangeDownSpeedRpM = (float)driveWheelRpm * Gears[i].Ratio;
                        }
                    }
                    else
                    {
                        Gears[i].Ratio = GearBoxParams.GearBoxMaxSpeedForGearsMpS[i] / DieselEngine.MaxRPM;
                    }
                }
                GearBoxOperation         = GearBoxParams.GearBoxOperation;
                OriginalGearBoxOperation = GearBoxParams.GearBoxOperation;
            }
        }
Example #5
0
        public void Parse(string lowercasetoken, STFReader stf)
        {
            string temp = "";

            switch (lowercasetoken)
            {
            case "engine(gearboxnumberofgears": GearBoxNumberOfGears = stf.ReadIntBlock(1); initLevel++; break;

            case "engine(gearboxdirectdrivegear": GearBoxDirectDriveGear = stf.ReadIntBlock(1); break;

            case "engine(ortsgearboxfreewheel":
                var freeWheel = stf.ReadIntBlock(null);
                if (freeWheel == 1)
                {
                    FreeWheelFitted = true;
                }
                break;

            case "engine(ortsgearboxtype":
                stf.MustMatch("(");
                var gearType = stf.ReadString();
                try
                {
                    GearBoxType = (TypesGearBox)Enum.Parse(typeof(TypesGearBox), gearType.First().ToString().ToUpper() + gearType.Substring(1));
                }
                catch
                {
                    STFException.TraceWarning(stf, "Assumed unknown gear box type " + gearType);
                }
                break;

            case "engine(ortsmainclutchtype":
                stf.MustMatch("(");
                var clutchType = stf.ReadString();
                try
                {
                    ClutchType = (TypesClutch)Enum.Parse(typeof(TypesClutch), clutchType.First().ToString().ToUpper() + clutchType.Substring(1));
                }
                catch
                {
                    STFException.TraceWarning(stf, "Assumed unknown main clutch type " + clutchType);
                }
                break;

            case "engine(gearboxoperation":
                stf.MustMatch("(");
                var gearOperation = stf.ReadString();
                try
                {
                    GearBoxOperation = (GearBoxOperation)Enum.Parse(typeof(GearBoxOperation), gearOperation.First().ToString().ToUpper() + gearOperation.Substring(1));
                }
                catch
                {
                    STFException.TraceWarning(stf, "Assumed unknown gear box operation type " + gearOperation);
                }
                initLevel++;
                break;

            case "engine(gearboxenginebraking":
                stf.MustMatch("(");
                var engineBraking = stf.ReadString();
                try
                {
                    GearBoxEngineBraking = (GearBoxEngineBraking)Enum.Parse(typeof(GearBoxEngineBraking), engineBraking.First().ToString().ToUpper() + engineBraking.Substring(1));
                }
                catch
                {
                    STFException.TraceWarning(stf, "Assumed unknown gear box engine braking type " + engineBraking);
                }
                break;

            case "engine(gearboxmaxspeedforgears":
                temp = stf.ReadItem();
                if (temp == ")")
                {
                    stf.StepBackOneItem();
                }
                if (temp == "(")
                {
                    GearBoxMaxSpeedForGearsMpS.Clear();
                    for (int i = 0; i < GearBoxNumberOfGears; i++)
                    {
                        GearBoxMaxSpeedForGearsMpS.Add(stf.ReadFloat(STFReader.UNITS.SpeedDefaultMPH, 10.0f));
                    }
                    stf.SkipRestOfBlock();
                    initLevel++;
                }
                break;

            // gearboxmaxtractiveforceforgears purely retained for legacy reasons
            case "engine(gearboxmaxtractiveforceforgears":
                temp = stf.ReadItem();
                if (temp == ")")
                {
                    stf.StepBackOneItem();
                }
                if (temp == "(")
                {
                    GearBoxMaxTractiveForceForGearsN.Clear();
                    for (int i = 0; i < GearBoxNumberOfGears; i++)
                    {
                        GearBoxMaxTractiveForceForGearsN.Add(stf.ReadFloat(STFReader.UNITS.Force, 10000.0f));
                    }
                    stf.SkipRestOfBlock();
                    initLevel++;
                }
                break;

            case "engine(ortsgearboxtractiveforceatspeed":
                MaxTEFound = true;
                temp       = stf.ReadItem();
                if (temp == ")")
                {
                    stf.StepBackOneItem();
                }
                if (temp == "(")
                {
                    GearBoxTractiveForceAtSpeedN.Clear();
                    for (int i = 0; i < GearBoxNumberOfGears; i++)
                    {
                        GearBoxTractiveForceAtSpeedN.Add(stf.ReadFloat(STFReader.UNITS.Force, 0f));
                    }
                    stf.SkipRestOfBlock();
                    initLevel++;
                }
                break;

            case "engine(gearboxoverspeedpercentageforfailure": GearBoxOverspeedPercentageForFailure = stf.ReadFloatBlock(STFReader.UNITS.None, 150f); break;     // initLevel++; break;

            case "engine(gearboxbackloadforce": GearBoxBackLoadForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, 0f); break;

            case "engine(gearboxcoastingforce": GearBoxCoastingForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, 0f); break;

            case "engine(gearboxupgearproportion": GearBoxUpGearProportion = stf.ReadFloatBlock(STFReader.UNITS.None, 0.85f); break;     // initLevel++; break;

            case "engine(gearboxdowngearproportion": GearBoxDownGearProportion = stf.ReadFloatBlock(STFReader.UNITS.None, 0.25f); break; // initLevel++; break;

            default: break;
            }
        }
Example #6
0
        public void Parse(string lowercasetoken, STFReader stf)
        {
            string temp = "";

            switch (lowercasetoken)
            {
            case "engine(gearboxnumberofgears": GearBoxNumberOfGears = stf.ReadIntBlock(1); initLevel++; break;

            case "engine(gearboxdirectdrivegear": GearBoxDirectDriveGear = stf.ReadIntBlock(1); break;     // initLevel++; break;

            case "engine(gearboxoperation":
                temp = stf.ReadStringBlock("manual");
                switch (temp)
                {
                case "manual": GearBoxOperation = GearBoxOperation.Manual; break;

                case "automatic": GearBoxOperation = GearBoxOperation.Automatic; break;

                case "semiautomatic": GearBoxOperation = GearBoxOperation.Semiautomatic; break;
                }
                initLevel++;
                break;

            case "engine(gearboxenginebraking":
                temp = stf.ReadStringBlock("none");
                switch (temp)
                {
                case "none": GearBoxEngineBraking = GearBoxEngineBraking.None; break;

                case "all_gears": GearBoxEngineBraking = GearBoxEngineBraking.AllGears; break;

                case "direct_drive": GearBoxEngineBraking = GearBoxEngineBraking.DirectDrive; break;
                }
                initLevel++;
                break;

            case "engine(gearboxmaxspeedforgears":
                temp = stf.ReadItem();
                if (temp == ")")
                {
                    stf.StepBackOneItem();
                }
                if (temp == "(")
                {
                    GearBoxMaxSpeedForGearsMpS.Clear();
                    for (int i = 0; i < GearBoxNumberOfGears; i++)
                    {
                        GearBoxMaxSpeedForGearsMpS.Add(stf.ReadFloat(STFReader.UNITS.SpeedDefaultMPH, 10.0f));
                    }
                    stf.SkipRestOfBlock();
                    initLevel++;
                }
                break;

            case "engine(gearboxmaxtractiveforceforgears":
                temp = stf.ReadItem();
                if (temp == ")")
                {
                    stf.StepBackOneItem();
                }
                if (temp == "(")
                {
                    GearBoxMaxTractiveForceForGearsN.Clear();
                    for (int i = 0; i < GearBoxNumberOfGears; i++)
                    {
                        GearBoxMaxTractiveForceForGearsN.Add(stf.ReadFloat(STFReader.UNITS.Force, 10000.0f));
                    }
                    stf.SkipRestOfBlock();
                    initLevel++;
                }
                break;

            case "engine(gearboxoverspeedpercentageforfailure": GearBoxOverspeedPercentageForFailure = stf.ReadFloatBlock(STFReader.UNITS.None, 150f); break;     // initLevel++; break;

            case "engine(gearboxbackloadforce": GearBoxBackLoadForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, 0f); break;

            case "engine(gearboxcoastingforce": GearBoxCoastingForceN = stf.ReadFloatBlock(STFReader.UNITS.Force, 0f); break;

            case "engine(gearboxupgearproportion": GearBoxUpGearProportion = stf.ReadFloatBlock(STFReader.UNITS.None, 0.85f); break;     // initLevel++; break;

            case "engine(gearboxdowngearproportion": GearBoxDownGearProportion = stf.ReadFloatBlock(STFReader.UNITS.None, 0.25f); break; // initLevel++; break;

            default: break;
            }
        }