public override void LoadSymbol(string symbolname, IECUFile trionic_file) { // autonomous m_trionic_file = trionic_file; m_trionic_file.LibraryPath = Application.StartupPath + "\\Binaries"; this.IsUpsideDown = true; // always? foreach (SymbolHelper sh in m_trionic_file.GetFileInfo().SymbolCollection) { if (sh.Varname == symbolname) { // get data from it IECUFile file = new Trionic5File(); file.LibraryPath = Application.StartupPath + "\\Binaries"; file.SetAutoUpdateChecksum(m_autoUpdateChecksum); file.SelectFile(m_trionic_file.GetFileInfo().Filename); byte[] symboldata = file.ReadData((uint)sh.Flash_start_address, (uint)sh.Length); //byte[] symboldata = file.readdatafromfile(m_trionic_file.GetFileInfo().Filename, sh.Flash_start_address, sh.Length); this.Map_content = symboldata; this.Map_length = symboldata.Length; this.Filename = m_trionic_file.GetFileInfo().Filename; if (m_trionic_file.IsTableSixteenBits(symbolname)) { //this.Map_length /= 2; } this.Map_name = symbolname; this.Correction_factor = m_trionic_file.GetCorrectionFactorForMap(symbolname); this.correction_offset = m_trionic_file.GetOffsetForMap(symbolname); this.SetViewSize(ViewSize.NormalView); //this.Viewtype = Trionic5Tools.ViewType.Easy; // set axis information SymbolAxesTranslator sat = new SymbolAxesTranslator(); sat.GetXaxisSymbol(symbolname); sat.GetYaxisSymbol(symbolname); this.X_axisvalues = m_trionic_file.GetMapXaxisValues(symbolname); this.Y_axisvalues = m_trionic_file.GetMapYaxisValues(symbolname); string x = string.Empty; string y = string.Empty; string z = string.Empty; m_trionic_file.GetMapAxisDescriptions(symbolname, out x, out y, out z); this.X_axis_name = x; this.Y_axis_name = y; this.Z_axis_name = z; int columns = 1; int rows = 1; m_trionic_file.GetMapMatrixWitdhByName(symbolname, out columns, out rows); this.ShowTable(columns, m_trionic_file.IsTableSixteenBits(symbolname)); break; } } }
public TuningResult FreeTuneBinary(IECUFile m_File, double peakTorque, double peakBoost, bool tuneBasedOnTorque, MapSensorType mapType, TurboType turboType, InjectorType injectorType, BPCType valve, int rpmlimiter, int knockTime) { Trionic5Resume _localResume = new Trionic5Resume(); m_fileInformation = m_File.GetFileInfo(); string filename = m_fileInformation.Filename; // first set things right by running the tunetostagex wizard // generate a nice x_scale for ignition map (18 long) PressureToTorque ptt = new PressureToTorque(); double peak_boost = ptt.CalculatePressureFromTorque(peakTorque, turboType); if (!tuneBasedOnTorque) peak_boost = peakBoost; double peak_boost_request = peak_boost; double correction = 1.0; if (mapType == MapSensorType.MapSensor30) correction = 1.2; if (mapType == MapSensorType.MapSensor35) correction = 1.4; if (mapType == MapSensorType.MapSensor40) correction = 1.6; if (mapType == MapSensorType.MapSensor50) correction = 2.0; peak_boost_request *= 100; peak_boost_request += 100; peak_boost_request /= correction; peak_boost_request -= 100; peak_boost_request /= 100; double min_pressure = -1; double max_pressure = peak_boost; #region preparation /********* start of prepare phase *********/ string enginetp = readenginetype(filename); string partnumber = readpartnumber(filename); PartNumberConverter pnc = new PartNumberConverter(); ECUInformation ecuinfo = pnc.GetECUInfo(partnumber, enginetp); bool isLpt = true; if (ReadTunedToStageMarker(filename) > 0) { return TuningResult.TuningFailedAlreadyTuned; } else if (ReadThreeBarConversionMarker(filename) > 0) { return TuningResult.TuningFailedThreebarSensor; } Trionic5Properties t5p = m_File.GetTrionicProperties(); if (ecuinfo.Valid) { if (ecuinfo.Isaero || ecuinfo.Isfpt) { isLpt = false; } } if (t5p.MapSensorType != mapType) { ConvertFileToThreeBarMapSensor(m_fileInformation, t5p.MapSensorType, mapType); } // check injector type if (t5p.InjectorType != injectorType) { int inj_konst_diff = DetermineDifferenceInInjectorConstant(t5p.InjectorType, injectorType); AddToInjectorConstant(filename, inj_konst_diff); SetInjectorBatteryCorrectionMap(m_File, injectorType); //TODO: check this function for correctness! } /*if (injectorType == InjectorType.Stock) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 19); else if (injectorType == InjectorType.GreenGiants) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 18); else if (injectorType == InjectorType.Siemens630Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 15); else if (injectorType == InjectorType.Siemens875Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 13); else if (injectorType == InjectorType.Siemens875Dekas) writebyteinfile(filename, GetSymbolAddress("Inj_konst!"), 13);*/ t5p.TurboType = turboType; t5p.InjectorType = injectorType; t5p.MapSensorType = mapType; // determine stage?? int stage = 0; if (peak_boost < 1.2) stage = 1; else if (peak_boost < 1.3) stage = 2; else if (peak_boost < 1.4) stage = 3; else if (peak_boost < 1.5) stage = 4; else if (peak_boost < 1.6) stage = 5; else if (peak_boost < 1.7) stage = 6; else if (peak_boost < 1.8) stage = 7; else if (peak_boost < 1.9) stage = 8; else stage = 9; m_File.SetTrionicOptions(t5p); TuneToStage(filename, stage, peak_boost_request, 0.52, 1.0, 0.52, 1.54, 90, isLpt, turboType, injectorType, mapType); _localResume.ResumeTuning = m_resume.ResumeTuning.Copy(); /*********** end of prepare phase **************/ // set limiter, bpc valve type and knock time SetBPCValveType(filename, valve); _localResume.AddToResumeTable("Set BPC driving frequencies"); SetRPMLimiter(filename, rpmlimiter); _localResume.AddToResumeTable("Set RPM limiter"); SetKnockTime(filename, knockTime); _localResume.AddToResumeTable("Set knock time value"); #endregion // if mapsensor != stock and injectors are 630 cc or bigger if (mapType != MapSensorType.MapSensor25 && (injectorType == InjectorType.Siemens630Dekas || injectorType == InjectorType.Siemens875Dekas || injectorType == InjectorType.Siemens1000cc)) { // now scale it double step = (max_pressure - min_pressure) / 17; double[] axisforIgnitionMap = new double[18]; for (int i = 0; i < 18; i++) { axisforIgnitionMap.SetValue(min_pressure + (i * step), i); } byte[] actualAxis = new byte[36]; int j = 0; for (int i = 0; i < 18; i++) { double currValue = Convert.ToDouble(axisforIgnitionMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); byte v1 = (byte)(ival / 256); byte v2 = (byte)(ival - (int)v1 * 256); actualAxis.SetValue(v1, j++); actualAxis.SetValue(v2, j++); } m_File.WriteData(actualAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_x_axis!")); _localResume.AddToResumeTable("Generated and saved new ignition map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewIgnitionMap(m_File, false); _localResume.AddToResumeTable("Generated and saved new ignition map"); min_pressure = -0.8; step = (max_pressure - min_pressure) / 15; // now setup x axis for fuel map double[] axisforFuelMap = new double[16]; for (int i = 0; i < 16; i++) { axisforFuelMap.SetValue(min_pressure + (i * step), i); } byte[] actualFuelAxis = new byte[16]; for (int i = 0; i < 16; i++) { double currValue = Convert.ToDouble(axisforFuelMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); if (ival > 255) ival = 255; actualFuelAxis.SetValue((byte)ival, i); } m_File.WriteData(actualFuelAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_xaxis!")); _localResume.AddToResumeTable("Generated and saved new fuel map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewFuelMap(m_File); _localResume.AddToResumeTable("Generated and saved new fuel map"); min_pressure = -0.3; step = (max_pressure - min_pressure) / 11; // now setup x axis for fuel map double[] axisforFuelKnockMap = new double[12]; for (int i = 0; i < 12; i++) { axisforFuelKnockMap.SetValue(min_pressure + (i * step), i); } byte[] actualFuelKnockAxis = new byte[12]; for (int i = 0; i < 12; i++) { double currValue = Convert.ToDouble(axisforFuelKnockMap.GetValue(i)); currValue *= 100; currValue += 100; if (mapType == MapSensorType.MapSensor30) currValue /= 1.2; else if (mapType == MapSensorType.MapSensor35) currValue /= 1.4; else if (mapType == MapSensorType.MapSensor40) currValue /= 1.6; else if (mapType == MapSensorType.MapSensor50) currValue /= 2.0; int ival = Convert.ToInt32(currValue); if (ival > 255) ival = 255; actualFuelKnockAxis.SetValue((byte)ival, i); } m_File.WriteData(actualFuelKnockAxis, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_knock_xaxis!")); _localResume.AddToResumeTable("Generated and saved new fuel knock map x axis"); //Generate the ignition map based on the axis values GenerateAndSaveNewFuelKnockMap(m_File); _localResume.AddToResumeTable("Generated and saved new fuel knock map"); // mesh up a boost request map for this.. already possible // adjust peak boost to be scaled for the mapsensor type SetBoostRequestMaps(turboType, injectorType, mapType, m_File.GetFileInfo().Filename, peak_boost_request, 100, isLpt); _localResume.AddToResumeTable("Generated boost request maps"); } m_resume.ResumeTuning = _localResume.ResumeTuning.Copy(); return TuningResult.TuningSuccess; }
public bool DisassembleFile(IECUFile m_trionicFile, string inputfile, string outputfile/*, long startaddress*/, SymbolCollection symbols) { // recursive method when jsr was found mnemonics = new MNemonicCollection(); labels = new MNemonicCollection(); /*labels = */findLabels(m_trionicFile, inputfile); _passOne = false; uint i, t, seg, adr; long addr, endaddr, adrcntr, trgaddr, trgaddr1, trgaddr2, trgaddr3, offaddr; byte ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10; //byte n1, n2, n3, n4; //uint infile = 0, outfile = 0, uint addoff = 0; string inname, outname, offsetval; //byte inname[80], outname[80], offsetval[40]; //byte str[80],cmd[80]; string str, cmd; str = string.Empty; for (int temp = 0; temp < 8; temp++) { A_reg.SetValue(0, temp); D_reg.SetValue(0, temp); } m_symbols = symbols; swap = 0; addr = offaddr = 0; inname = inputfile; //infile = 1; // outname = outputfile; //outfile = 1; //addr = startaddress; /********************* DISASSEMBLY STARTS HERE *********************/ /* Read all the preceding words first */ adrcntr = 0L; //StreamWriter sw = new StreamWriter(outname, false); FileStream fsbr = new FileStream(inname, FileMode.Open, FileAccess.Read); if (fsbr == null) return false; BinaryReader br = new BinaryReader(fsbr); if (br == null) { fsbr.Close(); //sw.Close(); return false; } //fsbr.Position = addr; adrcntr = addr; // iterate through all functions // first get all the pointers to work from func_count = 0; FileInfo fi = new FileInfo(inputfile); CastProgressEvent("Starting disassembly", 0, ProgressType.DisassemblingVectors); for (int vec = 1; vec <= 127; vec++) { int percentage = (vec * 100) / 127; CastProgressEvent("Disassembling vectors", percentage, ProgressType.DisassemblingVectors); long vector = m_trionicFile.GetStartVectorAddress(inputfile, vec); long len = fi.Length; if (len == 0x20000) len = 0x60000; if (vector != 0 && vector < len * 2) { //Console.WriteLine("Vector: " + vec.ToString() + " addr: " + vector.ToString("X8")); try { DisassembleFunction(vector, symbols, fsbr, br, len); } catch (Exception E) { Console.WriteLine("Failed to handle vector: " + E.Message); } } } CastProgressEvent("Translating vector labels", 0, ProgressType.TranslatingVectors); //Console.WriteLine("Translating vector labels"); long[] vectors = m_trionicFile.GetVectorAddresses(m_trionicFile.GetFileInfo().Filename); int lblcount = 0; foreach (MNemonicHelper label in labels) { int percentage = (lblcount++ * 100) / labels.Count; CastProgressEvent("Translating vector labels", percentage, ProgressType.TranslatingVectors); for (i = 0; i < 128; i++) { if (label.Address == /*m_trionicFile.GetStartVectorAddress(m_trionicFileInformation.Filename, i)*/ Convert.ToInt64(vectors.GetValue(i))) { switch (i) { case 1: label.Mnemonic = "INIT_PROGRAM:"; break; case 2: label.Mnemonic = "BUS_ERROR:"; break; case 3: label.Mnemonic = "ADDRESS_ERROR:"; break; case 4: label.Mnemonic = "ILLEGAL_INSTRUCTION:"; break; case 5: label.Mnemonic = "DIVIDE_BY_ZERO:"; break; case 6: label.Mnemonic = "CHK12_INSTR:"; break; case 7: label.Mnemonic = "TRAPx_INSTR:"; break; case 8: label.Mnemonic = "PRIV_VIOLATION:"; break; case 9: label.Mnemonic = "TRACE:"; break; case 10: label.Mnemonic = "L1010_EMUL:"; break; case 11: label.Mnemonic = "L1111_EMUL:"; break; case 12: label.Mnemonic = "HW_BREAKPOINT:"; break; case 13: label.Mnemonic = "RESERVED:"; break; case 14: label.Mnemonic = "FMT_ERR1:"; break; case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: label.Mnemonic = "UNASSIGNED:"; break; case 23: label.Mnemonic = "FFFFFFFF:"; break; case 24: label.Mnemonic = "SPURIOUS_INTERRUPT:"; break; case 25: label.Mnemonic = "LEVEL1_INTERUPT_AUTOVECTOR:"; break; case 26: label.Mnemonic = "LEVEL2_INTERUPT_AUTOVECTOR:"; break; case 27: label.Mnemonic = "LEVEL3_INTERUPT_AUTOVECTOR:"; break; case 28: label.Mnemonic = "LEVEL4_INTERUPT_AUTOVECTOR:"; break; case 29: label.Mnemonic = "LEVEL5_INTERUPT_AUTOVECTOR:"; break; case 30: label.Mnemonic = "LEVEL6_INTERUPT_AUTOVECTOR:"; break; case 31: label.Mnemonic = "LEVEL7_INTERUPT_AUTOVECTOR:"; break; case 32: label.Mnemonic = "TAP0_INSTRUCTION_VECTOR:"; break; case 33: label.Mnemonic = "TAP1_INSTRUCTION_VECTOR:"; break; case 34: label.Mnemonic = "TAP2_INSTRUCTION_VECTOR:"; break; case 35: label.Mnemonic = "TAP3_INSTRUCTION_VECTOR:"; break; case 36: label.Mnemonic = "TAP4_INSTRUCTION_VECTOR:"; break; case 37: label.Mnemonic = "TAP5_INSTRUCTION_VECTOR:"; break; case 38: label.Mnemonic = "TAP6_INSTRUCTION_VECTOR:"; break; case 39: label.Mnemonic = "TAP7_INSTRUCTION_VECTOR:"; break; case 40: label.Mnemonic = "TAP8_INSTRUCTION_VECTOR:"; break; case 41: label.Mnemonic = "TAP9_INSTRUCTION_VECTOR:"; break; case 42: label.Mnemonic = "TAP10_INSTRUCTION_VECTOR:"; break; case 43: label.Mnemonic = "TAP11_INSTRUCTION_VECTOR:"; break; case 44: label.Mnemonic = "TAP12_INSTRUCTION_VECTOR:"; break; case 45: label.Mnemonic = "TAP13_INSTRUCTION_VECTOR:"; break; case 46: label.Mnemonic = "TAP14_INSTRUCTION_VECTOR:"; break; case 47: label.Mnemonic = "TAP15_INSTRUCTION_VECTOR:"; break; default: label.Mnemonic = "VECTOR_" + i.ToString() + ":"; break; } break; } } } /* Console.WriteLine("Translating known functions"); CastProgressEvent("Translating known functions", 0, ProgressType.TranslatingLabels); lblcount = 0; foreach (MNemonicHelper label in labels) { int percentage = (lblcount++ * 100) / labels.Count; CastProgressEvent("Translating known functions", percentage, ProgressType.TranslatingLabels); foreach (MNemonicHelper mnemonic in mnemonics) { if (mnemonic.Mnemonic.Contains("JSR") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); // break; } else if (mnemonic.Mnemonic.Contains("BEQ") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BRA") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BLS") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BNE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BHI") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BCS") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BCC") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BGE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BLT") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BGT") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } else if (mnemonic.Mnemonic.Contains("BLE") && mnemonic.Mnemonic.Contains(label.Address.ToString("X8"))) { mnemonic.Mnemonic = mnemonic.Mnemonic.Replace(label.Address.ToString("X8"), label.Mnemonic.Replace(":", "")); } } }*/ CastProgressEvent("Adding labels", 0, ProgressType.AddingLabels); //Console.WriteLine("Adding labels"); lblcount = 0; foreach (MNemonicHelper label in labels) { int percentage = (lblcount++ * 100) / labels.Count; CastProgressEvent("Adding labels", percentage, ProgressType.AddingLabels); label.Address--; // for sequencing mnemonics.Add(label); } //Console.WriteLine("Sorting data"); CastProgressEvent("Sorting mnemonics", 0, ProgressType.SortingData); mnemonics.SortColumn = "Address"; mnemonics.SortingOrder = Trionic5Controls.GenericComparer.SortOrder.Ascending; mnemonics.Sort(); CastProgressEvent("Sorting mnemonics", 100, ProgressType.SortingData); return true; }
private void IncreaseByteVariableWith140Percent(IECUFile m_File, string symbol) { // read value byte[] data = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash(symbol), (uint)m_File.GetFileInfo().GetSymbolLength(symbol)); for (int t = 0; t < data.Length; t++) { double dval = Convert.ToDouble(data[t]); dval *= 1.4; data[t] = Convert.ToByte(dval); } m_File.WriteData(data, (uint)m_File.GetFileInfo().GetSymbolAddressFlash(symbol)); }
/* public byte[] GetBatteryCorrectionMap(float[] correctionFactors) { byte[] retval = new byte[22]; int bcount = 0; for (int i = 0; i < 11; i++) { float val = GetBatteryCorrection(i) / 0.004F; int ival = Convert.ToInt32(val); byte b1 = (byte)(ival / 256); byte b2 = (byte)(ival - (int)b1 * 256); retval[bcount++] = b1; retval[bcount++] = b2; } return retval; }*/ private void SetInjectorBatteryCorrectionMap(IECUFile m_file, InjectorType injectorType) { byte[] batt_korr_tab = new byte[22]; // 11 values, first one is for 15 volt float tempvalue = 0; switch (injectorType) { case InjectorType.Stock: case InjectorType.Siemens875Dekas: case InjectorType.Siemens1000cc: batt_korr_tab.SetValue((byte)0x00, 0); // 15 volt = 0.59 batt_korr_tab.SetValue((byte)0x93, 1); batt_korr_tab.SetValue((byte)0x00, 2); // 14 volt = 0.77 batt_korr_tab.SetValue((byte)0xC0, 3); batt_korr_tab.SetValue((byte)0x00, 4); // 13 volt = 0.78 batt_korr_tab.SetValue((byte)0xC3, 5); batt_korr_tab.SetValue((byte)0x00, 6); // 12 volt = 0.94 batt_korr_tab.SetValue((byte)0xEB, 7); batt_korr_tab.SetValue((byte)0x01, 8); // 11 volt = 1.28 batt_korr_tab.SetValue((byte)0x40, 9); batt_korr_tab.SetValue((byte)0x01, 10); // 10 volt = 1.50 batt_korr_tab.SetValue((byte)0x77, 11); batt_korr_tab.SetValue((byte)0x01, 12); // 9 volt = 1.85 batt_korr_tab.SetValue((byte)0xCE, 13); batt_korr_tab.SetValue((byte)0x02, 14); // 8 volt = 2.32 batt_korr_tab.SetValue((byte)0x44, 15); batt_korr_tab.SetValue((byte)0x03, 16); // 7 volt = 3.73 batt_korr_tab.SetValue((byte)0xA4, 17); batt_korr_tab.SetValue((byte)0x03, 18); // 6 volt = 3.73 batt_korr_tab.SetValue((byte)0xA4, 19); batt_korr_tab.SetValue((byte)0x03, 20); // 5 volt = 3.73 batt_korr_tab.SetValue((byte)0xA4, 21); break; case InjectorType.GreenGiants: batt_korr_tab.SetValue((byte)0x00, 0); // 15 volt = 0.894 batt_korr_tab.SetValue((byte)0xDF, 1); batt_korr_tab.SetValue((byte)0x00, 2); // 14 volt = 1.003 batt_korr_tab.SetValue((byte)0xFA, 3); batt_korr_tab.SetValue((byte)0x01, 4); // 13 volt = 1.15 batt_korr_tab.SetValue((byte)0x1F, 5); batt_korr_tab.SetValue((byte)0x01, 6); // 12 volt = 1.308 batt_korr_tab.SetValue((byte)0x47, 7); batt_korr_tab.SetValue((byte)0x01, 8); // 11 volt = 1.521 batt_korr_tab.SetValue((byte)0x7C, 9); batt_korr_tab.SetValue((byte)0x01, 10); // 10 volt = 1.768 batt_korr_tab.SetValue((byte)0xBA, 11); batt_korr_tab.SetValue((byte)0x02, 12); // 9 volt = 2.102 batt_korr_tab.SetValue((byte)0x0D, 13); batt_korr_tab.SetValue((byte)0x02, 14); // 8 volt = 2.545 batt_korr_tab.SetValue((byte)0x7C, 15); batt_korr_tab.SetValue((byte)0x03, 16); // 7 volt = 3.216 batt_korr_tab.SetValue((byte)0x24, 17); batt_korr_tab.SetValue((byte)0x04, 18); // 6 volt = 4.142 batt_korr_tab.SetValue((byte)0x0B, 19); batt_korr_tab.SetValue((byte)0x05, 20); // 5 volt = 5.45 batt_korr_tab.SetValue((byte)0x52, 21); break; case InjectorType.Siemens630Dekas: batt_korr_tab.SetValue((byte)0x00, 0); // 15 volt = 0.33 batt_korr_tab.SetValue((byte)0x52, 1); batt_korr_tab.SetValue((byte)0x00, 2); // 14 volt = 0.433 batt_korr_tab.SetValue((byte)0x6C, 3); batt_korr_tab.SetValue((byte)0x00, 4); // 13 volt = 0.548 batt_korr_tab.SetValue((byte)0x89, 5); batt_korr_tab.SetValue((byte)0x00, 6); // 12 volt = 0.673 batt_korr_tab.SetValue((byte)0xA8, 7); batt_korr_tab.SetValue((byte)0x00, 8); // 11 volt = 0.802 batt_korr_tab.SetValue((byte)0xC8, 9); batt_korr_tab.SetValue((byte)0x00, 10); // 10 volt = 0.974 batt_korr_tab.SetValue((byte)0xF3, 11); batt_korr_tab.SetValue((byte)0x01, 12); // 9 volt = 1.208 batt_korr_tab.SetValue((byte)0x2E, 13); batt_korr_tab.SetValue((byte)0x01, 14); // 8 volt = 1.524 batt_korr_tab.SetValue((byte)0x7D, 15); batt_korr_tab.SetValue((byte)0x01, 16); // 7 volt = 2.023 batt_korr_tab.SetValue((byte)0xF9, 17); batt_korr_tab.SetValue((byte)0x02, 18); // 6 volt = 2.74 batt_korr_tab.SetValue((byte)0xAD, 19); batt_korr_tab.SetValue((byte)0x03, 20); // 5 volt = 3.6 batt_korr_tab.SetValue((byte)0x84, 21); break; } // write to batt_korr_tab m_file.WriteData(batt_korr_tab, (uint)m_file.GetFileInfo().GetSymbolAddressFlash("Batt_korr_tab!")); }
private void GenerateStartVevFak(IECUFile m_File) { byte[] vev_fak = new byte[15] { 8, 12, 16, 20, 23, 32, 36, 45, 60, 104, 128, 168, 208, 254, 255 }; m_File.WriteData(vev_fak, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Startvev_fak!")); }
private void GenerateAndSaveNewIgnitionMap(IECUFile m_File, bool runsE85) { //TODO: Implement // get the axis TuningReferenceMaps _referenceMaps = new TuningReferenceMaps(); byte[] pressure_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_x_axis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Ign_map_0_x_axis!")); byte[] rpm_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0_y_axis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Ign_map_0_y_axis!")); byte[] new_ignition_map = new byte[16 * 18 * 2]; int ign_map_index = 0; for (int rpm_index = rpm_axis.Length-2; rpm_index >=0; rpm_index -= 2) { for (int pressure_index = 0; pressure_index < pressure_axis.Length; pressure_index += 2) { int irpm = Convert.ToInt32(rpm_axis[rpm_index]) * 256; irpm += Convert.ToInt32(rpm_axis[rpm_index+1]); int ipressure = Convert.ToInt32(pressure_axis[pressure_index]) * 256; ipressure += Convert.ToInt32(pressure_axis[pressure_index + 1]); double correctionFactor = 1; double pressure = ipressure; MapSensorType mapsensor = m_File.GetMapSensorType(false); if (mapsensor == MapSensorType.MapSensor30) correctionFactor = 1.2; else if (mapsensor == MapSensorType.MapSensor35) correctionFactor = 1.4; else if (mapsensor == MapSensorType.MapSensor40) correctionFactor = 1.6; else if (mapsensor == MapSensorType.MapSensor50) correctionFactor = 2.0; pressure *= correctionFactor; pressure -= 100; pressure /= 100; double ignition_advance = _referenceMaps.GetIgnitionAdvanceForPressureRpm(pressure, (double)irpm); if (runsE85) ignition_advance = _referenceMaps.GetIgnitionAdvanceE85ForPressureRpm(pressure, (double)irpm); // write ignition advance into the map ignition_advance *= 10; // correction factor Int32 iAdvance = Convert.ToInt32(ignition_advance); byte v1 = (byte)(iAdvance / 256); byte v2 = (byte)(iAdvance - (int)v1 * 256); //Console.WriteLine("Writing data rpmidx : " + rpm_index.ToString() + " mapidx: " + pressure_index.ToString() + " ignidx: " + ign_map_index.ToString()); new_ignition_map[ign_map_index++] = v1; new_ignition_map[ign_map_index++] = v2; } } // now save the map m_File.WriteData(new_ignition_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_0!")); m_File.WriteData(new_ignition_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Ign_map_4!")); // save as warmup map as well }
private void GenerateAndSaveNewFuelMap(IECUFile m_File) { TuningReferenceMaps _referenceMaps = new TuningReferenceMaps(); byte[] pressure_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_xaxis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Fuel_map_xaxis!")); byte[] rpm_axis = m_File.ReadData((uint)m_File.GetFileInfo().GetSymbolAddressFlash("Fuel_map_yaxis!"), (uint)m_File.GetFileInfo().GetSymbolLength("Fuel_map_yaxis!")); byte[] new_fuel_map = new byte[16 * 16]; int fuel_map_index = 0; for (int rpm_index = rpm_axis.Length - 2; rpm_index >= 0; rpm_index -= 2) { for (int pressure_index = 0; pressure_index < pressure_axis.Length; pressure_index ++) { int irpm = Convert.ToInt32(rpm_axis[rpm_index]) * 256; irpm += Convert.ToInt32(rpm_axis[rpm_index + 1]); irpm *= 10; int ipressure = Convert.ToInt32(pressure_axis[pressure_index]); double correctionFactor = 1; double pressure = ipressure; MapSensorType mapsensor = m_File.GetMapSensorType(false); if (mapsensor == MapSensorType.MapSensor30) correctionFactor = 1.2; else if (mapsensor == MapSensorType.MapSensor35) correctionFactor = 1.4; else if (mapsensor == MapSensorType.MapSensor40) correctionFactor = 1.6; else if (mapsensor == MapSensorType.MapSensor50) correctionFactor = 2.0; pressure *= correctionFactor; pressure -= 100; pressure /= 100; double fuel_correction = _referenceMaps.FuelCorrectionForPressureRpm(pressure, (double)irpm); // write ignition advance into the map fuel_correction -= 0.5; fuel_correction /= 0.00390625; Int32 icorrection = Convert.ToInt32(fuel_correction); if (icorrection > 255) icorrection = 255; new_fuel_map[fuel_map_index++] = (byte)icorrection; } } // now save the map m_File.WriteData(new_fuel_map, (uint)m_File.GetFileInfo().GetSymbolAddressFlash("Insp_mat!")); }
private void InitIgnitionFeedbackMaps() { int columns = 18; int rows = 16; m_TrionicFile.GetMapMatrixWitdhByName(m_TrionicFile.GetFileInfo().GetIgnitionMap(), out columns, out rows); if (columns != 0) { IgnitionMapInMemory = new float[rows * columns]; IgnitionMapCounterInMemory = new int[rows * columns]; SaveIgnitionAndCounterMaps(); } }
private void RollForwardOnFile(IECUFile file2Rollback, TransactionEntry entry) { int addressToWrite = entry.SymbolAddress; while (addressToWrite > file2Rollback.GetFileInfo().Filelength) addressToWrite -= file2Rollback.GetFileInfo().Filelength; file2Rollback.WriteDataNoLog(entry.DataAfter, (uint)addressToWrite); }