public void SetBPCType(BPCType valve) { comboBoxEdit4.SelectedIndex = (int)valve; }
private void SetBPCValveType(string filename, BPCType valve) { if (GetSymbolAddress("Frek_230!") > 0) { byte[] frek230 = new byte[2]; byte[] frek250 = new byte[2]; FileInfo fi = new FileInfo(filename); if (fi.Length == 0x20000) { // T5.2 if (valve == BPCType.Trionic5Valve) { frek230.SetValue((byte)0x02,0); frek230.SetValue((byte)0xD8, 1); //frek230 = 728; frek250.SetValue((byte)0x03, 0); frek250.SetValue((byte)0xA7, 1); //frek250 = 935; } else { frek230.SetValue((byte)0x02, 0); frek230.SetValue((byte)0x76, 1); //frek230 = 630; //TODO: fill right frek //frek250 = 1900; //TODO: fill right frek frek250.SetValue((byte)0x07, 0); frek250.SetValue((byte)0x6C, 1); } } else { // T5.5 if (valve == BPCType.Trionic5Valve) { frek230.SetValue((byte)0x00, 0); frek230.SetValue((byte)0x5A, 1); //frek230 = 90; //frek250 = 70; frek250.SetValue((byte)0x00, 0); frek250.SetValue((byte)0x46, 1); } else { frek230.SetValue((byte)0x00, 0); frek230.SetValue((byte)0x32, 1); //frek230 = 50; //frek250 = 32; frek250.SetValue((byte)0x00, 0); frek250.SetValue((byte)0x20, 1); } } // write the values savedatatobinary(GetSymbolAddress("Frek_230!"), 2, frek230, filename); savedatatobinary(GetSymbolAddress("Frek_250!"), 2, frek250, filename); } }
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 void SetBPCType(BPCType valve) { comboBoxEdit4.SelectedIndex = (int)valve; }