Ejemplo n.º 1
0
        private int CheckAgainstTurboSpeedLimiter(SymbolCollection symbols, string filename, int rpm, int requestedairmass, ref limitType AirmassLimiter)
        {
            int[] turbospeed = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.TurboSpeedTab"), GetSymbolLength(symbols, "LimEngCal.TurboSpeedTab"));
            int[] nullvalue = new int[1];
            nullvalue.SetValue(0, 0);
            int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.p_AirSP"), GetSymbolLength(symbols, "LimEngCal.p_AirSP"));
            int ambientpressure = Convert.ToInt32(spinEdit1.EditValue) * 10; // 100.0 kPa = 1000 as table value unit is 0.1 kPa
            int airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(turbospeed, nullvalue, yaxis, ambientpressure, 0));

            // Second limitation is based on engine rpm to prevent the turbo from overspeeding at high rpm.
            // Interpolated correction factor applied to the calculated airmass value from main turbospeed table LimEngCal.TurboSpeedTab.
            int[] turbospeed2 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.TurboSpeedTab2"), GetSymbolLength(symbols, "LimEngCal.TurboSpeedTab2"));
            int[] yaxis2 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.n_EngSP"), GetSymbolLength(symbols, "LimEngCal.n_EngSP"));
            int correctionfactor = Convert.ToInt32(GetInterpolatedTableValue(turbospeed2, nullvalue, yaxis2, rpm, 0));
            airmasslimit = airmasslimit * correctionfactor / 1000; // correction factor value unit is 0.001
            if (airmasslimit < requestedairmass)
            {
                requestedairmass = airmasslimit;
                AirmassLimiter = limitType.TurboSpeedLimiter;
            }
            return requestedairmass;
        }
Ejemplo n.º 2
0
 private int CheckAgainstFuelcutLimiter(SymbolCollection symbols, string filename, int requestedairmass, ref limitType AirmassLimiter)
 {
     int retval = requestedairmass;
     if ((int)GetSymbolAddress(symbols, "FCutCal.m_AirInletLimit") > 0)
     {
         int[] fuelcutlimit = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FCutCal.m_AirInletLimit"), GetSymbolLength(symbols, "FCutCal.m_AirInletLimit"));
         if (fuelcutlimit.Length > 0)
         {
             if (Convert.ToInt32(fuelcutlimit.GetValue(0)) < requestedairmass)
             {
                 retval = Convert.ToInt32(fuelcutlimit.GetValue(0));
                 AirmassLimiter = limitType.FuelCutLimiter;
             }
         }
     }
     return retval;
 }
Ejemplo n.º 3
0
        private int CheckAgainstTorqueLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool E85, bool Convertable, bool Automatic, bool OverboostEnabled, bool E85Automatic, out limitType TrqLimiter)
        {
            int torque = 0;
            TrqLimiter = limitType.None;
            int LimitedAirMass = requestedairmass;

            //only if torquelimiters are enabled
            if (HasBinaryTorqueLimiterEnabled(symbols, filename))
            {
                torque = AirmassToTorque(requestedairmass, rpm, useTrionicCalculationForTorque.Checked);

                // check against TorqueCal.M_EngMaxTab, TorqueCal.M_ManGearLim and TorqueCal.M_5GearLimTab
                int[] enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxTab"));
                if (E85Automatic && E85 && Automatic)
                {
                    enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxE85TabAut"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxE85TabAut"));
                }
                else
                {
                    // Old style binary where there are no dedicated TorqueCal.M_EngMaxE85TabAut
                    if (Automatic)
                    {
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxAutTab"));
                    }
                    if (E85)
                    {
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxE85Tab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxE85Tab"));
                    }
                }
                if (OverboostEnabled)
                {
                    enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_OverBoostTab"), GetSymbolLength(symbols, "TorqueCal.M_OverBoostTab"));
                }

                int[] xdummy = new int[1];
                xdummy.SetValue(0, 0);
                int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP"));
                int torquelimit1 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                //requestedairmass
                if (torque > torquelimit1)
                {
                    //logger.Debug("Torque is limited from " + torque.ToString() + " to " + torquelimit1.ToString() + " at " + rpm.ToString() + " rpm");
                    torque = torquelimit1;
                    if (E85Automatic && E85 && Automatic)
                    {
                        TrqLimiter = limitType.TorqueLimiterEngineE85Auto;
                    }
                    else if (E85)
                    {
                        TrqLimiter = limitType.TorqueLimiterEngineE85;
                    }
                    else if (OverboostEnabled)
                    {
                        TrqLimiter = limitType.OverBoostLimiter;
                    }
                    else
                    {
                        TrqLimiter = limitType.TorqueLimiterEngine;
                    }
                }
                if (!Automatic)
                {
                    int[] gears = new int[6];
                    gears.SetValue(0, 0);
                    gears.SetValue(1, 1);
                    gears.SetValue(2, 2);
                    gears.SetValue(3, 3);
                    gears.SetValue(4, 4);
                    gears.SetValue(5, 5);

                    if (Convertable)
                    {
                        // extra check
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_CabGearLim"), GetSymbolLength(symbols, "TorqueCal.M_CabGearLim"));
                        //
                        int torquelimitConvertable = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, gears, comboBoxEdit1.SelectedIndex, 0));
                        if (torque > torquelimitConvertable)
                        {
                            torque = torquelimitConvertable;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Convertable gear torque limit hit");
                        }
                    }
                    else
                    {
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ManGearLim"), GetSymbolLength(symbols, "TorqueCal.M_ManGearLim"));
                        //
                        int torquelimitManual = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, gears, comboBoxEdit1.SelectedIndex, 0));
                        if (torque > torquelimitManual)
                        {
                            torque = torquelimitManual;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Manual gear torque limit hit");
                        }
                    }

                    // and check 5th gear limiter as well!!! (if checkbox is 5)
                    //TorqueCal.M_5GearTab		TorqueCal.n_Eng5GearSP
                    if (comboBoxEdit1.SelectedIndex == 5)
                    {
                        //logger.Debug("Checking fifth gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_5GearLimTab"), GetSymbolLength(symbols, "TorqueCal.M_5GearLimTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng5GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng5GearSP"));
                        int torquelimit5th = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimit5th)
                        {
                            torque = torquelimit5th;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Fifth gear torque limit hit");
                        }
                    }
                }
                else
                {
                    // automatic!
                    if (comboBoxEdit1.SelectedIndex == 0)
                    {
                        //logger.Debug("Checking reverse gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ReverseTab"), GetSymbolLength(symbols, "TorqueCal.M_ReverseTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngSP"), GetSymbolLength(symbols, "TorqueCal.n_EngSP"));
                        int torquelimitreverse = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimitreverse)
                        {
                            torque = torquelimitreverse;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Reverse gear torque limit hit");
                        }
                    }

                    // first gear
                    //TorqueCal.M_1GearTab		TorqueCal.n_Eng1GearSP
                    else if (comboBoxEdit1.SelectedIndex == 1)
                    {
                        //logger.Debug("Checking first gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_1GearTab"), GetSymbolLength(symbols, "TorqueCal.M_1GearTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng1GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng1GearSP"));
                        int torquelimit1st = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimit1st)
                        {
                            torque = torquelimit1st;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("First gear torque limit hit");
                        }
                    }
                }

                int[] airtorquemap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirTorqMap"), GetSymbolLength(symbols, "TorqueCal.m_AirTorqMap"));
                int[] xairtorque = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngXSP"), GetSymbolLength(symbols, "TorqueCal.M_EngXSP"));
                int TestLimitedAirmass = Convert.ToInt32(GetInterpolatedTableValue(airtorquemap, xairtorque, yaxis, rpm, torque));
                if (TestLimitedAirmass < LimitedAirMass)
                {
                    LimitedAirMass = TestLimitedAirmass;
                    if(TrqLimiter == limitType.None) TrqLimiter = limitType.AirTorqueCalibration;
                }
            }
            //            logger.Debug("1. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString());
            if (TrqLimiter == limitType.None) LimitedAirMass = requestedairmass; // bugfix for if no limiter is active
            //            logger.Debug("2. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString());

            return LimitedAirMass;
        }
Ejemplo n.º 4
0
        private int CalculateMaxAirmassforcell(SymbolCollection symbols, string filename, int pedalposition, int rpm, int requestairmass, bool autogearbox, bool E85, bool Convertable, bool OverboostEnabled, bool E85Automatic, out limitType limiterType)
        {
            int retval = requestairmass;
            //logger.Debug("Pedalpos: " + pedalposition.ToString() + " Rpm: " + rpm.ToString() + " requests: " + requestairmass.ToString() + " mg/c");
            //calculate the restricted airmass for the current point

            limiterType = limitType.None;

            limitType TrqLimiterType = limitType.None;
            retval = CheckAgainstTorqueLimiters(symbols, filename, rpm, requestairmass, E85, Convertable, autogearbox, OverboostEnabled, E85Automatic, out TrqLimiterType);
            if (retval < requestairmass)
            {
                limiterType = TrqLimiterType;
            }

            limitType AirmassLimiterType = limitType.None;
            int TorqueLimitedAirmass = retval;

            retval = CheckAgainstAirmassLimiters(symbols, filename, rpm, retval, autogearbox, ref AirmassLimiterType);

            retval = CheckAgainstTurboSpeedLimiter(symbols, filename, rpm, retval, ref AirmassLimiterType);

            // finally check agains fuelcut limiter???
            retval = CheckAgainstFuelcutLimiter(symbols, filename, retval, ref AirmassLimiterType);
            if (retval < TorqueLimitedAirmass)
            {
                limiterType = AirmassLimiterType;
            }
            return retval;
        }
Ejemplo n.º 5
0
 private int CheckAgainstAirmassLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool autogearbox, ref limitType AirmassLimiter)
 {
     //AirmassLimiter = limitType.None;
     //Y axis = BstKnkCal.n_EngYSP needed for interpolation (16)
     //X axis = BstKnkCal.OffsetXSP needed for length (16)
     // check against BstKnkCal.MaxAirmass
     int cols = GetSymbolLength(symbols, "BstKnkCal.OffsetXSP") / 2;
     int rows = GetSymbolLength(symbols, "BstKnkCal.n_EngYSP") / 2;
     // only the right-most column (no knock)
     int[] bstknk = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmass"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmass"));
     if (autogearbox)
     {
         bstknk = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmassAu"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmassAu"));
     }
     int[] xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.OffsetXSP"), GetSymbolLength(symbols, "BstKnkCal.OffsetXSP"));
     for (int a = 0; a < xaxis.Length; a++)
     {
         int val = (int)xaxis.GetValue(a);
         if (val > 32000) val = -(65536 - val);
         xaxis.SetValue(val, a);
     }
     int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.n_EngYSP"), GetSymbolLength(symbols, "BstKnkCal.n_EngYSP"));
     int airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(bstknk, xaxis, yaxis, rpm, 0));
     if (airmasslimit < requestedairmass)
     {
         requestedairmass = airmasslimit;
         AirmassLimiter = limitType.AirmassLimiter;
         //logger.Debug("Reduced airmass because of BstKnkCal.MaxAirmass: " + requestedairmass.ToString() + " rpm: " + rpm.ToString());
     }
     return requestedairmass;
 }
Ejemplo n.º 6
0
        private int CheckAgainstTorqueLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool E85, bool Convertable, bool Automatic, bool OverboostEnabled, out limitType TrqLimiter)
        {
            //only if torquelimiters are enabled
            // first convert airmass torque to torque using TorqueCal.M_NominalMap
            // axis are
            // x = TorqueCal.m_AirXSP (airmass)
            // y = TorqueCal.n_EngYSP (rpm)
            TrqLimiter = limitType.None;
            int LimitedAirMass = requestedairmass;
            /*if (requestedairmass == 1100 && rpm == 2400)
            {
                logger.Debug("1100");
            }*/
            if (HasBinaryTorqueLimiterEnabled(symbols, filename))
            {
                int[] nominaltorque = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_NominalMap"), GetSymbolLength(symbols, "TorqueCal.M_NominalMap"));
                for (int a = 0; a < nominaltorque.Length; a++)
                {
                    int val = (int)nominaltorque.GetValue(a);
                    if (val > 32000) val = -(65536 - val);
                    nominaltorque.SetValue(val, a);
                }
                int[] xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirXSP"), GetSymbolLength(symbols, "TorqueCal.m_AirXSP"));
                int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP"));
                int torque = Convert.ToInt32(GetInterpolatedTableValue(nominaltorque, xaxis, yaxis, rpm, requestedairmass));
                // check against TorqueCal.M_EngMaxTab, TorqueCal.M_ManGearLim and TorqueCal.M_5GearLimTab
                int[] enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxTab"));
                if (Automatic)
                {
                    enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxAutTab"));
                }
                if (E85)
                {
                    enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxE85Tab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxE85Tab"));
                }
                if (OverboostEnabled)
                {
                    enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_OverBoostTab"), GetSymbolLength(symbols, "TorqueCal.M_OverBoostTab"));
                }

                int[] xdummy = new int[1];
                xdummy.SetValue(0, 0);
                int torquelimit1 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                if (torque > torquelimit1)
                {
                    //logger.Debug("Torque is limited from " + torque.ToString() + " to " + torquelimit1.ToString() + " at " + rpm.ToString() + " rpm");
                    torque = torquelimit1;
                    if (E85)
                    {
                        TrqLimiter = limitType.TorqueLimiterEngineE85;
                    }
                    else if (OverboostEnabled)
                    {
                        TrqLimiter = limitType.OverBoostLimiter;
                    }
                    else
                    {
                        TrqLimiter = limitType.TorqueLimiterEngine;
                    }
                }
                if (!Automatic)
                {
                    int[] gears = new int[6];
                    gears.SetValue(0, 0);
                    gears.SetValue(1, 1);
                    gears.SetValue(2, 2);
                    gears.SetValue(3, 3);
                    gears.SetValue(4, 4);
                    gears.SetValue(5, 5);

                    if (Convertable)
                    {
                        // extra check
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_CabGearLim"), GetSymbolLength(symbols, "TorqueCal.M_CabGearLim"));
                        //
                        int torquelimitConvertable = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, gears, comboBoxEdit1.SelectedIndex, 0));
                        if (torque > torquelimitConvertable)
                        {
                            torque = torquelimitConvertable;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Convertable gear torque limit hit");
                        }
                    }
                    else
                    {
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ManGearLim"), GetSymbolLength(symbols, "TorqueCal.M_ManGearLim"));
                        //
                        int torquelimitManual = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, gears, comboBoxEdit1.SelectedIndex, 0));
                        if (torque > torquelimitManual)
                        {
                            torque = torquelimitManual;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Manual gear torque limit hit");
                        }
                    }

                    // and check 5th gear limiter as well!!! (if checkbox is 5)
                    //TorqueCal.M_5GearTab		TorqueCal.n_Eng5GearSP
                    if (comboBoxEdit1.SelectedIndex == 5)
                    {
                        //logger.Debug("Checking fifth gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_5GearLimTab"), GetSymbolLength(symbols, "TorqueCal.M_5GearLimTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng5GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng5GearSP"));
                        int torquelimit5th = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimit5th)
                        {
                            torque = torquelimit5th;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Fifth gear torque limit hit");
                        }
                    }
                }
                else
                {
                    // automatic!
                    if (comboBoxEdit1.SelectedIndex == 0)
                    {
                        //logger.Debug("Checking reverse gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ReverseTab"), GetSymbolLength(symbols, "TorqueCal.M_ReverseTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngSP"), GetSymbolLength(symbols, "TorqueCal.n_EngSP"));
                        int torquelimitreverse = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimitreverse)
                        {
                            torque = torquelimitreverse;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("Reverse gear torque limit hit");
                        }
                    }

                    // first gear
                    //TorqueCal.M_1GearTab		TorqueCal.n_Eng1GearSP
                    else if (comboBoxEdit1.SelectedIndex == 1)
                    {
                        //logger.Debug("Checking first gear!");
                        enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_1GearTab"), GetSymbolLength(symbols, "TorqueCal.M_1GearTab"));
                        yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng1GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng1GearSP"));
                        int torquelimit1st = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                        if (torque > torquelimit1st)
                        {
                            torque = torquelimit1st;
                            TrqLimiter = limitType.TorqueLimiterGear;
                            //logger.Debug("First gear torque limit hit");
                        }
                    }
                }

                int[] airtorquemap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirTorqMap"), GetSymbolLength(symbols, "TorqueCal.m_AirTorqMap"));
                int[] xairtorque = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngXSP"), GetSymbolLength(symbols, "TorqueCal.M_EngXSP"));
                int TestLimitedAirmass = Convert.ToInt32(GetInterpolatedTableValue(airtorquemap, xairtorque, yaxis, rpm, torque));
                if (TestLimitedAirmass < LimitedAirMass) LimitedAirMass = TestLimitedAirmass;
            }
            if (TrqLimiter == limitType.None) LimitedAirMass = requestedairmass; // bugfix for if no limiter is active
            return LimitedAirMass;
        }
 => !(GetLimitLevel(limitType, featureType, cycleType, levelType) is null);
Ejemplo n.º 8
0
        private int CheckAgainstTorqueLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool Automatic, out limitType TrqLimiter)
        {
            int torque = 0;
            TrqLimiter = limitType.None;
            int LimitedAirMass = requestedairmass;
            int[] xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirXSP"), GetSymbolLength(symbols, "TorqueCal.m_AirXSP"));
            int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP"));
            torque = Tools.Instance.IQToTorque(requestedairmass, rpm, m_numberCylinders);

            int[] enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxTab"));
            if (Automatic)
            {
                enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxAutTab"));
            }

            int[] xdummy = new int[1];
            xdummy.SetValue(0, 0);
            int torquelimit1 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
            //requestedairmass
            if (torque > torquelimit1)
            {
                //Console.WriteLine("Torque is limited from " + torque.ToString() + " to " + torquelimit1.ToString() + " at " + rpm.ToString() + " rpm");
                torque = torquelimit1;
                TrqLimiter = limitType.TorqueLimiterEngine;
            }

            int[] airtorquemap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirTorqMap"), GetSymbolLength(symbols, "TorqueCal.m_AirTorqMap"));
            int[] xairtorque = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngXSP"), GetSymbolLength(symbols, "TorqueCal.M_EngXSP"));
            int TestLimitedAirmass = Convert.ToInt32(GetInterpolatedTableValue(airtorquemap, xairtorque, yaxis, rpm, torque));
            if (TestLimitedAirmass < LimitedAirMass)
            {
                LimitedAirMass = TestLimitedAirmass;
                if (TrqLimiter == limitType.None) TrqLimiter = limitType.AirTorqueCalibration;
            }
            if (TrqLimiter == limitType.None) LimitedAirMass = requestedairmass; // bugfix for if no limiter is active
            return LimitedAirMass;
        }
Ejemplo n.º 9
0
 private int CheckAgainstTurboSpeedLimiter(SymbolCollection symbols, string filename, int rpm, int requestedairmass, ref limitType AirmassLimiter)
 {
     int cols = GetSymbolLength(symbols, "LimEngCal.p_AirSP") / 2;
     int[] turbospeed = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.TurboSpeedTab"), GetSymbolLength(symbols, "LimEngCal.TurboSpeedTab"));
     int[] xaxis = new int[1];
     xaxis.SetValue(0, 0);
     int[] yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.p_AirSP"), GetSymbolLength(symbols, "LimEngCal.p_AirSP"));
     int ambientpressure = /*1000*/ Convert.ToInt32(spinEdit1.EditValue) * 10;
     int airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(turbospeed, xaxis, yaxis, /*rpm*/ ambientpressure, 0));
     if (airmasslimit < requestedairmass)
     {
         requestedairmass = airmasslimit;
         AirmassLimiter = limitType.TurboSpeedLimiter;
     }
     return requestedairmass;
 }
Ejemplo n.º 10
0
        private int CalculateMaxAirmassforcell(SymbolCollection symbols, string filename, int pedalposition, int rpm, int requestedQuantity, bool autogearbox, out limitType limiterType, bool torqueBased)
        {
            limiterType = limitType.None;
            // check against torque limiter
            SymbolHelper trqLimiter = GetSymbolLike(symbols, "Torque limiter", selectedBank);
            int[] trqLimitMap = readIntdatafromfile(filename, (int)trqLimiter.Flash_start_address, trqLimiter.Length);
            int[] trqXAxis = readIntdatafromfile(filename, trqLimiter.Y_axis_address, trqLimiter.Y_axis_length * 2);
            int[] trqYAxis = readIntdatafromfile(filename, trqLimiter.X_axis_address, trqLimiter.X_axis_length * 2);

            if (torqueBased)
            {
                int Nmlimit = Convert.ToInt32(GetInterpolatedTableValue(trqLimitMap, trqXAxis, trqYAxis, Convert.ToInt32(spinEdit1.EditValue) * 10, rpm));
                //requestedairmass
                if (requestedQuantity > Nmlimit)
                {
                    Console.WriteLine("Torque is limited from " + requestedQuantity.ToString() + " to " + Nmlimit.ToString() + " at " + rpm.ToString() + " rpm");
                    requestedQuantity = Nmlimit;
                    limiterType = limitType.TorqueLimiterEngine;
                }
            }
            else
            {
                int IQlimit = requestedQuantity;
                if (trqXAxis.Length == 1)
                {
                    // 2d map
                    IQlimit = Convert.ToInt32(GetInterpolatedTableValue(trqLimitMap, trqXAxis, trqYAxis, rpm, Convert.ToInt32(spinEdit1.EditValue) * 10));
                }
                else
                {
                    IQlimit = Convert.ToInt32(GetInterpolatedTableValue(trqLimitMap, trqXAxis, trqYAxis, Convert.ToInt32(spinEdit1.EditValue) * 10, rpm));
                }
                //requestedairmass
                if (requestedQuantity > IQlimit)
                {
            //                    Console.WriteLine("IQ is limited from " + requestedQuantity.ToString() + " to " + IQlimit.ToString() + " at " + rpm.ToString() + " rpm");
                    requestedQuantity = IQlimit;

                    limiterType = limitType.TorqueLimiterEngine;
                }
            }

            // check against smoke limiter

            return requestedQuantity; // no limits ...
        }
Ejemplo n.º 11
0
        private int CheckAgainstTorqueLimiters(int rpm, int requestedairmass, bool E85, bool Automatic, bool OverboostEnabled, out limitType TrqLimiter)
        {
            // first convert airmass torque to torque using TorqueCal.M_NominalMap
            // axis are
            // x = TorqueCal.m_AirXSP (airmass)
            // y = TorqueCal.n_EngYSP (rpm)
            TrqLimiter = limitType.None;
            int LimitedAirMass = requestedairmass;
            int torque = Convert.ToInt32(GetInterpolatedTableValue(nominaltorque, nominaltorquexaxis, nominaltorqueyaxis, rpm, requestedairmass));

            int[] enginetorquelim;
            if (E85)
            {
                enginetorquelim = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "FFTrqCal.FFTrq_MaxEngineTab1"), GetSymbolLength(m_symbols, "FFTrqCal.FFTrq_MaxEngineTab1"));
                // TODO: Add support for FFTrqCal.FFTrq_MaxEngineTab2 // 150 hp
            }
            else
            {
                // Select old style TrqLimCal.Trq_MaxEngineManTab1 or TrqLimCal.Trq_MaxEngineAutTab1
                string engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineManTab1";
                if (Automatic)
                {
                    engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineAutTab1";
                }
                if (!SymbolExists(engineTorqueLimiter))
                {
                    // If it does not exist, default to the newer style TrqLimCal.Trq_MaxEngineTab1
                    engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineTab1";
                    // TODO: Add support for TrqLimCal.Trq_MaxEngineTab2"; // 150 hp
                }
                enginetorquelim = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, engineTorqueLimiter), GetSymbolLength(m_symbols, engineTorqueLimiter));
            }
            if (OverboostEnabled)
            {
                enginetorquelim = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TrqLimCal.Trq_OverBoostTab"), GetSymbolLength(m_symbols, "TrqLimCal.Trq_OverBoostTab"));
            }

            int[] xdummy = new int[1];
            xdummy.SetValue(0, 0);
            int torquelimit1 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
            if (torque > torquelimit1)
            {
                //logger.Debug("Torque is limited from " + torque.ToString() + " to " + torquelimit1.ToString() + " at " + rpm.ToString() + " rpm");
                torque = torquelimit1;
                if (E85)
                {
                    TrqLimiter = limitType.TorqueLimiterEngineE85;
                }
                else if (OverboostEnabled)
                {
                    TrqLimiter = limitType.OverBoostLimiter;
                }
                else
                {
                    TrqLimiter = limitType.TorqueLimiterEngine;
                }
            }

            // Trq_ManGear = only manual gearbox
            if (!cbHasAutomaticGearbox.Checked)
            {
                // Gear values have the same meaning as in ECMStat.ManualGear
                // Actual gear (manual gearbox).
                int[] gears = new int[8];
                gears.SetValue(0, 0); // Undefined gear  0
                gears.SetValue(1, 1); // First gear      1
                gears.SetValue(2, 2); // Second gear     2
                gears.SetValue(3, 3); // Third gear      3
                gears.SetValue(4, 4); // Fourth gear     4
                gears.SetValue(5, 5); // Fifth gear      5
                gears.SetValue(6, 6); // Sixth gear      6
                gears.SetValue(7, 7); // Reverse gear    7

                enginetorquelim = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TrqLimCal.Trq_ManGear"), GetSymbolLength(m_symbols, "TrqLimCal.Trq_ManGear"));
                //
                int torquelimitManual = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, gears, comboBoxEdit1.SelectedIndex, 0));
                if (torque > torquelimitManual)
                {
                    torque = torquelimitManual;
                    TrqLimiter = limitType.TorqueLimiterGear;
                    logger.Debug("Manual gear torque limit hit");
                }
            }
            else
            {
                // Newer style automatic torque limits:
                // TMCCal.Trq_MaxEngineTab 170 hp because we use petrol: TrqLimCal.Trq_MaxEngineTab1 and E85: FFTrqCal.FFTrq_MaxEngineTab1
                // TODO: Add support for TMCCal.Trq_MaxEngineLowTab 150 hp

                enginetorquelim = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "TMCCal.Trq_MaxEngineTab"), GetSymbolLength(m_symbols, "TMCCal.Trq_MaxEngineTab"));
                int torquelimitAutomatic = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, yaxis, rpm, 0));
                if (torque > torquelimitAutomatic)
                {
                    torque = torquelimitAutomatic;
                    TrqLimiter = limitType.TorqueLimiterGear;
                    logger.Debug("Automatic gear torque limit hit");
                }
            }

            // else ???
            if (TrqLimiter != limitType.None)
            {
                LimitedAirMass = Convert.ToInt32(GetInterpolatedTableValue(airtorquemap, xairtorque, yaxis, rpm, torque));
            }

            return LimitedAirMass;
        }
Ejemplo n.º 12
0
 private int CheckAgainstFuelcutLimiter(int requestedairmass, ref limitType AirmassLimiter)
 {
     int retval = requestedairmass;
     if ((int)GetSymbolAddress(m_symbols, "FCutCal.m_AirInletLimit") > 0)
     {
         if (fuelcutlimit.Length > 0)
         {
             if (Convert.ToInt32(fuelcutlimit.GetValue(0)) < requestedairmass)
             {
                 retval = Convert.ToInt32(fuelcutlimit.GetValue(0));
                 AirmassLimiter = limitType.FuelCutLimiter;
             }
         }
     }
     return retval;
 }
Ejemplo n.º 13
0
        private int CheckAgainstAirmassLimiters(int rpm, int requestedairmass, bool autogearbox, bool E85, ref limitType AirmassLimiter)
        {
            //AirmassLimiter = limitType.None;
            // check against BstKnkCal.MaxAirmass
            string xaxisstr = "BstKnkCal.OffsetXSP";
            if (!SymbolExists(xaxisstr)) xaxisstr = "BstKnkCal.fi_offsetXSP";
            // only the right-most column (no knock)

            // BstKnkCal.fi_offsetXSP in case of flexfuel!
            int[] xaxis = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, xaxisstr), GetSymbolLength(m_symbols, xaxisstr));
            for (int a = 0; a < xaxis.Length; a++)
            {
                int val = (int)xaxis.GetValue(a);
                if (val > 32000) val = -(65536 - val);
                xaxis.SetValue(val, a);
            }
            int[] yaxis = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "BstKnkCal.n_EngYSP"), GetSymbolLength(m_symbols, "BstKnkCal.n_EngYSP"));
            int airmasslimit = requestedairmass;

            // E85 flexfuel air limit
            int[] xaxisFFAir = new int[1]; // TODO: Move all axis out in Calculate
            if (E85)
            {
                xaxisFFAir = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "FFAirCal.fi_offsetXSP"), GetSymbolLength(m_symbols, "FFAirCal.fi_offsetXSP"));
                for (int a = 0; a < xaxisFFAir.Length; a++)
                {
                    int val = (int)xaxisFFAir.GetValue(a);
                    if (val > 32000) val = -(65536 - val);
                    xaxisFFAir.SetValue(val, a);
                }
            }

            if (autogearbox) airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(bstknkau, xaxis, yaxis, rpm, 0));
            else if (E85) airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(ffmaxairmass, xaxisFFAir, yaxis, rpm, 0)); // zero degree ignition offset
            else airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(bstknk, xaxis, yaxis, rpm, 0));
            if (airmasslimit < requestedairmass)
            {
                requestedairmass = airmasslimit;
                AirmassLimiter = limitType.AirmassLimiter;
                logger.Debug("Reduced airmass because of BstKnkCal.MaxAirmass/FFAirCal.m_maxAirmass: " + requestedairmass.ToString() + " rpm: " + rpm.ToString() + " E85: " + E85.ToString());
            }

            return requestedairmass;
        }
Ejemplo n.º 14
0
        private int CalculateMaxAirmassforcell(int pedalposition, int rpm, int requestairmass, bool autogearbox, bool E85, bool OverboostEnabled, out limitType limiterType)
        {
            // calculate the restricted airmass for the current point
            int retval = requestairmass;
            limiterType = limitType.None;

            logger.Debug("Pedalpos: " + pedalposition.ToString() + " Rpm: " + rpm.ToString() + " requests: " + requestairmass.ToString() + " mg/c");

            // first check against torquelimiters
            limitType TrqLimiterType = limitType.None;
            retval = CheckAgainstTorqueLimiters(rpm, requestairmass, E85, autogearbox, OverboostEnabled, out TrqLimiterType);
            if (retval < requestairmass)
            {
                limiterType = TrqLimiterType;
            }

            // secondly check against airmasslimiters
            limitType AirmassLimiterType = limitType.None;
            int TorqueLimitedAirmass = retval;
            retval = CheckAgainstAirmassLimiters(rpm, retval, autogearbox, E85, ref AirmassLimiterType);
            retval = CheckAgainstFuelcutLimiter(retval, ref AirmassLimiterType);
            if (retval < TorqueLimitedAirmass)
            {
                limiterType = AirmassLimiterType;
            }

            return retval;
        }