예제 #1
0
        public float[,] TuneVeTable(ProjectedAfrCorrection[,] corrections, float[,] veTable, out float[,] finalCorrection)
        {
            finalCorrection = new float[16, 16];
            var correctedTable = new float[16, 16];
            Array.Copy(veTable, correctedTable, veTable.Length);

            var maxKpaForCorrection = _mapCoordinates.KpaIndex(92);

            for (int rpmIndex = 0; rpmIndex < 16; rpmIndex++)
            {
                for (int kpaIndex = 0; kpaIndex < 16; kpaIndex++)
                {
                    var corr = corrections[rpmIndex, kpaIndex];
                    if (corr == null) continue;
                    float coeficient = 1;

                    if (kpaIndex <= maxKpaForCorrection)
                    {
                        coeficient = (corr.NboCorrection + (corr.AfrDiffPercent * 0.5f)) * GetImportance(corr.Count) * BulharskaKonstanta;
                    }
                    else
                    {
                        coeficient = corr.AfrDiffPercent * BulharskaKonstanta * GetImportance(corr.Count);
                    }

                    //AFR only
                    //coeficient = corr.AfrDiffPercent * BulharskaKonstanta;}}

                    var delta = correctedTable[rpmIndex, kpaIndex] * coeficient / 100;
                    finalCorrection[rpmIndex, kpaIndex] = delta;
                    correctedTable[rpmIndex, kpaIndex] += delta;
                }
            }
            return correctedTable;
        }
예제 #2
0
        public void ShowVeMap(float[,] data, ProjectedAfrCorrection.AfrCorrectionMethod? type = null)
        {
            for (int i = 15; i >= 0; i--)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Write("{0, 5}", _coords.RpmMap[i]);

                for (int j = 0; j < 16; j++)
                {
                    Console.ForegroundColor = ConsoleColor.Gray;

                    ChangeColor(data[i, j], type);
                    var formatted = string.Format("{0:0.#}", data[i, j]);
                    Console.Write(_format, formatted);
                    
                }
                Console.WriteLine();
            }

            Console.Write(_format, "");
            Console.ForegroundColor = ConsoleColor.Gray;
            for (int j = 0; j < 16; j++)
            {
                Console.Write(_format, _coords.KpaMap[j]);
            }
            Console.WriteLine();
            Console.WriteLine();
        }
예제 #3
0
        public void ShowAfrMap(ProjectedAfrCorrection[,] data, ProjectedAfrCorrection.AfrCorrectionMethod type)
        {
            for (int i = 15; i >= 0; i--)
            {
                Console.Write("{0, 5}", _coords.RpmMap[i]);

                for (int j = 0; j < 16; j++)
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                    if (data[i, j] == null)
                    {
                        Console.Write(_format, "-");
                    }
                    else
                    {
                        ChangeColor(data[i, j].GetVal(type), type);
                        var formatted = string.Format("{0:0.#}", data[i, j].GetVal(type));
                        Console.Write(_format, formatted);
                    }
                }
                Console.WriteLine();
            }

            Console.Write(_format, "");
            for (int j = 0; j < 16; j++)
            {
                Console.Write(_format, _coords.KpaMap[j]);
            }
            Console.WriteLine();
            Console.WriteLine();
        }
예제 #4
0
        public ProjectedAfrCorrection[,] GetCorrection(IEnumerable<LogLine>[,] allValues)
        {
            var ANALysed = new ProjectedAfrCorrection[16, 16];
            for (var rpmIndex = 0; rpmIndex < 16; rpmIndex++)
            {
                for (var kpaIndex = 0; kpaIndex < 16; kpaIndex++)
                {
                    var values = allValues[rpmIndex, kpaIndex];
                    if (values == null) continue;
                    var targetAfr = _targerAfr.GetTargetAfr(rpmIndex, kpaIndex);

                    var correction = AverangeCorrection(values, targetAfr);
                    ANALysed[rpmIndex, kpaIndex] = correction;
                }
            }
            return ANALysed;
        }
예제 #5
0
        private void ChangeColor(float number, ProjectedAfrCorrection.AfrCorrectionMethod? type = null)
        {
            var redOver = 2f;
            var yellowOver = 0.7f;
            var greenUnder = -0.7f;
            var blueUnder = -2f;

            switch (type)
            {
                case ProjectedAfrCorrection.AfrCorrectionMethod.AvgAfr:
                    redOver = 17f;
                    yellowOver = 15.0f;
                    greenUnder = 14.2f;
                    blueUnder = 13f;
                    break;
                case ProjectedAfrCorrection.AfrCorrectionMethod.Count:
                    return;
                case ProjectedAfrCorrection.AfrCorrectionMethod.NboCorrection:
                case ProjectedAfrCorrection.AfrCorrectionMethod.FinalCorrection:
                case ProjectedAfrCorrection.AfrCorrectionMethod.AfrDiffPercent:
                case ProjectedAfrCorrection.AfrCorrectionMethod.SumValue:
                    break;
                default:
                    redOver = 80;
                    yellowOver = 65;
                    greenUnder = 50;
                    blueUnder = 45;
                    break;
            }
            if (number < yellowOver && number > greenUnder)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
            } 
            else if (number > redOver)
            {
                Console.ForegroundColor = ConsoleColor.Red;
            }
            else if(number > yellowOver )
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
            }
            else if (number < blueUnder)
            {
                Console.ForegroundColor = ConsoleColor.Blue;
            }
            else if (number < greenUnder)
            {
                Console.ForegroundColor = ConsoleColor.Green;
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }