Ejemplo n.º 1
0
 private void File_CompareToOriginal_ItemClick(object sender, ItemClickEventArgs e)
 {
     T7FileHeader t7header = new T7FileHeader();
     t7header.init(m_currentfile, false);
     if (Directory.Exists(System.Windows.Forms.Application.StartupPath + "\\Binaries"))
     {
         string[] files = Directory.GetFiles(System.Windows.Forms.Application.StartupPath + "\\Binaries", t7header.getPartNumber() + ".bin");
         if (files.Length == 1)
         {
             CompareToFile((string)files.GetValue(0));
         }
     }
 }
Ejemplo n.º 2
0
        private void Information_firmwareInformation_ItemClick(object sender, ItemClickEventArgs e)
        {
            // show firmware information screen!
            bool _correctFooter = m_appSettings.AutoFixFooter;
            frmFirmwareInformation frminfo = new frmFirmwareInformation();

            if (m_currentfile != null)
            {
                if (File.Exists(m_currentfile))
                {
                    T7FileHeader t7InfoHeader = new T7FileHeader();
                    t7InfoHeader.init(m_currentfile, m_appSettings.AutoFixFooter);
                    string swVersion = t7InfoHeader.getSoftwareVersion();
                    PartNumberConverter pnc = new PartNumberConverter();
                    ECUInformation ecuinfo = pnc.GetECUInfo(t7InfoHeader.getPartNumber().Trim(), "");
                    frminfo.SIDDate = t7InfoHeader.getSIDDate();
                    if (ecuinfo.Valid)
                    {
                        frminfo.OriginalCarType = ecuinfo.Carmodel.ToString();
                        frminfo.OriginalEngineType = ecuinfo.Enginetype.ToString();
                    }

                    if (swVersion.Trim() == "EU0AF01C.55P" || swVersion.Trim() == "EU0AF01C.46T" || swVersion.Trim().StartsWith("ET02U01C") || swVersion.Trim() == "ET03F01C.46S")
                    {
                        // additional requirements for the bytes in that location
                        // http://www.trionictuning.com/forum/viewtopic.php?f=17&t=109&p=8569#p8537

                        // set these options correct
                        if (swVersion.Trim().StartsWith("EU0AF01C") || swVersion.Trim() == "ET03F01C.46S")
                        {
                            if ((CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) || (CheckBytesInFile(m_currentfile, 0x4968E, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x4968F, 0x80, 1))) &&
                                (CheckBytesInFile(m_currentfile, 0x496B4, 0, 2) || (CheckBytesInFile(m_currentfile, 0x496B4, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x496B5, 0x80, 1))) &&
                                (CheckBytesInFile(m_currentfile, 0x49760, 0, 2) || (CheckBytesInFile(m_currentfile, 0x49760, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x49761, 0x80, 1))))
                            {
                                frminfo.EnableSIDAdvancedOptions(true);
                                if (/*CheckBytesInFile(m_currentfile, 0x495FA, 0, 2) &&*/ CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) && CheckBytesInFile(m_currentfile, 0x496B4, 0, 2))
                                {
                                    frminfo.SIDDisableStartScreen = true;
                                }
                                else
                                {
                                    frminfo.SIDDisableStartScreen = false;
                                }
                                if (CheckBytesInFile(m_currentfile, 0x49760, 0, 2)) // should be 0x49760 in stead of 0x4975E
                                {
                                    frminfo.SIDDisableAdaptionMessages = true;
                                }
                                else
                                {
                                    frminfo.SIDDisableAdaptionMessages = false;
                                }
                                /*
                                 *  Remove startup screen:
                                    change to 00 00 instead of 00 80
                                    000495FA // not needed!!! <GS-11042011>
                                    0004968E
                                    000496B4
                                    Remove adaptation messages:
                                    Change 0x49760 to 00 00 instead of 00 80
                                 */
                            }
                            else
                            {
                                frminfo.EnableSIDAdvancedOptions(false);
                            }
                        }
                        else
                        {
                            if ((CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1) || CheckBytesInFile(m_currentfile, 0x46F4D, 0x80, 1)) &&
                                (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1) || CheckBytesInFile(m_currentfile, 0x4701F, 0x80, 1)))
                            {
                                frminfo.EnableSIDAdvancedOptions(true);

                                //Disable startscreen, change 0x00046F4D to 00 in stead of 80
                                if (CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1))
                                {
                                    frminfo.SIDDisableStartScreen = true;
                                }
                                else
                                {
                                    frminfo.SIDDisableStartScreen = false;
                                }
                                //Remove the adaption messages, change 0x0004701F to 00 in stead of 80
                                if (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1))
                                {
                                    frminfo.SIDDisableAdaptionMessages = true;
                                }
                                else
                                {
                                    frminfo.SIDDisableAdaptionMessages = false;
                                }
                            }
                            else
                            {
                                frminfo.EnableSIDAdvancedOptions(false);
                            }

                        }
                    }
                    else
                    {
                        frminfo.EnableSIDAdvancedOptions(false);
                    }

                    // Pavel Angelov created this modification.
                    // Disable effect of the emission limitation function.
                    if (swVersion.Trim().StartsWith("EU0AF01C"))
                    {
                        if (CheckBytesInFile(m_currentfile, 0x13837, 0x03, 1))
                        {
                            frminfo.EmissionLimitation = true;
                            frminfo.EnableEmissionLimitation(true);
                        }
                        else if (CheckBytesInFile(m_currentfile, 0x13837, 0x02, 1))
                        {
                            frminfo.EmissionLimitation = false;
                            frminfo.EnableEmissionLimitation(true);
                        }
                        else
                        {
                            frminfo.EnableEmissionLimitation(false);
                        }
                    }
                    else
                    {
                        frminfo.EnableEmissionLimitation(false);
                    }

                    frminfo.SoftwareID = t7InfoHeader.getSoftwareVersion();
                    frminfo.ChassisID = t7InfoHeader.getChassisID();
                    frminfo.EngineType = t7InfoHeader.getCarDescription();
                    frminfo.Partnumber = t7InfoHeader.getPartNumber();
                    frminfo.ImmoID = t7InfoHeader.getImmobilizerID();
                    frminfo.SoftwareIsOpen = IsBinaryFileOpen();
                    frminfo.BioPowerSoftware = IsBinaryBiopower();
                    frminfo.BioPowerEnabled = IsBioPowerEnabled();
                    frminfo.CompressedSymboltable = IsBinaryPackedVersion(m_currentfile);
                    frminfo.MissingSymbolTable = IsBinaryMissingSymbolTable();
                    if (frminfo.MissingSymbolTable) frminfo.BioPowerSoftware = true; // only missing in biopower software
                    frminfo.ChecksumEnabled = HasBinaryChecksumEnabled();
                    frminfo.TorqueLimitersEnabled = HasBinaryTorqueLimiterEnabled();
                    if (!HasBinaryTorqueLimiters()) frminfo.TorqueLimitersPresent = false;
                    //if (!frminfo.MissingSymbolTable)
                    {
                        frminfo.OBDIIPresent = HasBinaryOBDIIMaps();
                        if (!frminfo.OBDIIPresent)
                        {
                            frminfo.OBDIIEnabled = false;
                        }
                        else
                        {
                            frminfo.OBDIIEnabled = HasBinaryOBDIIEnabled();
                        }
                    }
                    if (HasBinaryOBDIIMaps())
                    {
                        frminfo.OBDIIEnabled = HasBinaryOBDIIEnabled();
                    }
                    frminfo.SecondLambdaEnabled = HasBinarySecondLambdaEnabled();

                    if (!HasBinarySecondLambdaMap()) frminfo.SecondLambdaPresent = false;

                    if (!HasBinaryTipInOutParameters()) frminfo.FastThrottleResponsePresent = false;
                    else frminfo.FastThrottleResponsePresent = true;
                    frminfo.FastThrottleReponse = HasBinaryFastThrottleResponse();
                    frminfo.ExtraFastThrottleReponse = HasBinaryExtraFastThrottleResponse();
                    if (!HasBinaryTipInOutParameters())
                    {
                        frminfo.FastThrottleReponse = false;
                        frminfo.ExtraFastThrottleReponse = false;
                    }
                    if (!HasBinaryCatalystLightOffParameters()) frminfo.CatalystLightoffPresent = false;
                    else frminfo.CatalystLightoffPresent = true;
                    frminfo.CatalystLightOff = HasBinaryCatalystLightOffEnabled();
                    frminfo.ProgrammingDateTime = GetProgrammingDateTime();
                    if (!m_appSettings.WriteTimestampInBinary)
                    {
                        frminfo.DisableTimeStamping();
                    }
                    if (frminfo.ShowDialog() == DialogResult.OK)
                    {
                        if (t7InfoHeader.IsTISBinary(m_currentfile))
                        {
                            // user is trying to update a TIS file, ask for footer correction.
                            if ((frminfo.ImmoID != t7InfoHeader.getImmobilizerID()) || frminfo.ChassisID != t7InfoHeader.getChassisID())
                            {
                                if (!_correctFooter)
                                {
                                    if (MessageBox.Show("It seems you are trying to update data in a TIS file, would you like T7Suite to correct the footer information?", "TIS file question", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                    {
                                        //_correctFooter = true;
                                        // create a backup file at this point
                                        File.Copy(m_currentfile, Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + DateTime.Now.ToString("yyyyMMddHHmmss") + ".binarybackup", true);
                                        t7InfoHeader.init(m_currentfile, true);
                                    }
                                }
                            }
                        }
                        t7InfoHeader.setImmobilizerID(frminfo.ImmoID);
                        t7InfoHeader.setSoftwareVersion(frminfo.SoftwareID);
                        t7InfoHeader.setCarDescription(frminfo.EngineType);
                        t7InfoHeader.setChassisID(frminfo.ChassisID);
                        t7InfoHeader.setSIDDate(frminfo.SIDDate);
                        if (GetProgrammingDateTime() != frminfo.ProgrammingDateTime)
                        {
                            SetProgrammingDateTime(frminfo.ProgrammingDateTime);
                        }

                        if (frminfo.SoftwareIsOpen)
                        {
                            SetBinaryFileOpen();
                        }
                        else
                        {
                            SetBinaryFileClosed();
                        }
                        if (frminfo.TorqueLimitersEnabled && !HasBinaryTorqueLimiterEnabled() && HasBinaryTorqueLimiters())
                        {
                            SetTorqueLimiterEnabled(true);
                        }
                        else if (!frminfo.TorqueLimitersEnabled && HasBinaryTorqueLimiterEnabled() && HasBinaryTorqueLimiters())
                        {
                            SetTorqueLimiterEnabled(false);
                        }
                        if (frminfo.OBDIIEnabled && !HasBinaryOBDIIEnabled())
                        {
                            SetOBDIIEnabled(true);
                        }
                        else if (!frminfo.OBDIIEnabled && HasBinaryOBDIIEnabled())
                        {
                            SetOBDIIEnabled(false);
                        }
                        if (frminfo.SecondLambdaEnabled && HasBinarySecondLambdaMap()/*&& !HasBinarySecondLambdaEnabled()*/)
                        {
                            SetSecondLambdaEnabled(true);
                        }
                        else if (!frminfo.SecondLambdaEnabled && HasBinarySecondLambdaMap() && HasBinarySecondLambdaEnabled())
                        {
                            SetSecondLambdaEnabled(false);
                        }
                        if (HasBinaryTipInOutParameters())
                        {
                            if (frminfo.FastThrottleReponse && !HasBinaryFastThrottleResponse())
                            {
                                SetFastThrottleResponse(true);
                            }
                            else if (!frminfo.FastThrottleReponse && HasBinaryFastThrottleResponse())
                            {
                                SetFastThrottleResponse(false);
                            }
                            if (frminfo.ExtraFastThrottleReponse && !HasBinaryExtraFastThrottleResponse())
                            {
                                SetExtraFastThrottleResponse(true);
                            }
                            else if (!frminfo.ExtraFastThrottleReponse && !frminfo.FastThrottleReponse && HasBinaryExtraFastThrottleResponse())
                            {
                                SetExtraFastThrottleResponse(false);
                            }
                            else if (!frminfo.ExtraFastThrottleReponse && frminfo.FastThrottleReponse && HasBinaryExtraFastThrottleResponse())
                            {
                                SetActG2(false);
                            }

                        }
                        if (HasBinaryCatalystLightOffParameters())
                        {
                            if (frminfo.CatalystLightOff && !HasBinaryCatalystLightOffEnabled())
                            {
                                SetCatalystLightOff(true);
                            }
                            else if (!frminfo.CatalystLightOff && HasBinaryCatalystLightOffEnabled())
                            {
                                SetCatalystLightOff(false);
                            }

                        }
                        if (IsBinaryBiopower())
                        {
                            if (frminfo.BioPowerEnabled && !IsBioPowerEnabled())
                            {
                                SetBioPowerEnabled(true);
                            }
                            else if (!frminfo.BioPowerEnabled && IsBioPowerEnabled())
                            {
                                SetBioPowerEnabled(false);
                            }
                        }
                        t7InfoHeader.save(m_currentfile);

                        if (swVersion.Trim() == "EU0AF01C.55P" || swVersion.Trim() == "EU0AF01C.46T" || swVersion.Trim().StartsWith("ET02U01C") || swVersion.Trim() == "ET03F01C.46S")
                        {
                            if (swVersion.Trim().StartsWith("EU0AF01C") || swVersion.Trim() == "ET03F01C.46S")
                            {
                                if ((CheckBytesInFile(m_currentfile, 0x4968E, 0, 2) || (CheckBytesInFile(m_currentfile, 0x4968E, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x4968F, 0x80, 1))) &&
                                    (CheckBytesInFile(m_currentfile, 0x496B4, 0, 2) || (CheckBytesInFile(m_currentfile, 0x496B4, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x496B5, 0x80, 1))) &&
                                    (CheckBytesInFile(m_currentfile, 0x49760, 0, 2) || (CheckBytesInFile(m_currentfile, 0x49760, 0x00, 1) && CheckBytesInFile(m_currentfile, 0x49761, 0x80, 1))))
                                {

                                    if (frminfo.SIDDisableStartScreen)
                                    {
                                        byte[] data2write = new byte[2];
                                        data2write.SetValue((byte)0x00, 0);
                                        data2write.SetValue((byte)0x00, 1);
                                        //savedatatobinary(0x495FA, 2, data2write, m_currentfile, false);
                                        savedatatobinary(0x4968E, 2, data2write, m_currentfile, false);
                                        savedatatobinary(0x496B4, 2, data2write, m_currentfile, false);
                                    }
                                    else
                                    {
                                        byte[] data2write = new byte[2];
                                        data2write.SetValue((byte)0x00, 0);
                                        data2write.SetValue((byte)0x80, 1);
                                        //savedatatobinary(0x495FA, 2, data2write, m_currentfile, false);
                                        savedatatobinary(0x4968E, 2, data2write, m_currentfile, false);
                                        savedatatobinary(0x496B4, 2, data2write, m_currentfile, false);
                                    }
                                    if (frminfo.SIDDisableAdaptionMessages)
                                    {
                                        byte[] data2write = new byte[2];
                                        data2write.SetValue((byte)0x00, 0);
                                        data2write.SetValue((byte)0x00, 1);
                                        savedatatobinary(0x49760, 2, data2write, m_currentfile, false);
                                    }
                                    else
                                    {
                                        byte[] data2write = new byte[2];
                                        data2write.SetValue((byte)0x00, 0);
                                        data2write.SetValue((byte)0x80, 1);
                                        savedatatobinary(0x49760, 2, data2write, m_currentfile, false);
                                    }
                                }
                            }
                            else
                            {
                                if ((CheckBytesInFile(m_currentfile, 0x46F4D, 0, 1) || CheckBytesInFile(m_currentfile, 0x46F4D, 0x80, 1)) &&
                                    (CheckBytesInFile(m_currentfile, 0x4701F, 0, 1) || CheckBytesInFile(m_currentfile, 0x4701F, 0x80, 1)))
                                {

                                    //Disable startscreen, change 0x00046F4D to 00 in stead of 80
                                    //Remove the adaption messages, change 0x0004701F to 00 in stead of 80
                                    if (frminfo.SIDDisableStartScreen)
                                    {
                                        byte[] data2write = new byte[1];
                                        data2write.SetValue((byte)0x00, 0);
                                        savedatatobinary(0x46F4D, 1, data2write, m_currentfile, false);
                                    }
                                    else
                                    {
                                        byte[] data2write = new byte[1];
                                        data2write.SetValue((byte)0x80, 0);
                                        savedatatobinary(0x46F4D, 1, data2write, m_currentfile, false);
                                    }
                                    if (frminfo.SIDDisableAdaptionMessages)
                                    {
                                        byte[] data2write = new byte[1];
                                        data2write.SetValue((byte)0x00, 0);
                                        savedatatobinary(0x4701F, 1, data2write, m_currentfile, false);
                                    }
                                    else
                                    {
                                        byte[] data2write = new byte[1];
                                        data2write.SetValue((byte)0x80, 0);
                                        savedatatobinary(0x4701F, 1, data2write, m_currentfile, false);
                                    }
                                }
                            }
                        }

                        // Disable effect of the emission limitation function.
                        if (swVersion.Trim().StartsWith("EU0AF01C"))
                        {
                            if (frminfo.EmissionLimitation)
                            {
                                byte[] data2write = new byte[1];
                                data2write.SetValue((byte)0x03, 0);
                                savedatatobinary(0x13837, 1, data2write, m_currentfile, false);
                            }
                            else
                            {
                                byte[] data2write = new byte[1];
                                data2write.SetValue((byte)0x02, 0);
                                savedatatobinary(0x13837, 1, data2write, m_currentfile, false);
                            }
                        }

                        UpdateChecksum(m_currentfile);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void SaveAdditionalSymbols()
 {
     using (System.Data.DataTable dt = new System.Data.DataTable(Path.GetFileNameWithoutExtension(m_currentfile)))
     {
         dt.Columns.Add("SYMBOLNAME");
         dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
         dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
         dt.Columns.Add("DESCRIPTION");
         T7FileHeader fh = new T7FileHeader();
         fh.init(m_currentfile, false);
         string checkstring = fh.getPartNumber() + fh.getSoftwareVersion();
         string xmlfilename = String.Format("{0}\\repository\\{1}{2:yyyyMMddHHmmss}{3}.xml", System.Windows.Forms.Application.StartupPath, Path.GetFileNameWithoutExtension(m_currentfile), File.GetCreationTime(m_currentfile), checkstring);
         if (Directory.Exists(String.Format("{0}\\repository", System.Windows.Forms.Application.StartupPath)))
         {
             if (File.Exists(xmlfilename))
             {
                 File.Delete(xmlfilename);
             }
         }
         else
         {
             Directory.CreateDirectory(String.Format("{0}\\repository", System.Windows.Forms.Application.StartupPath));
         }
         foreach (SymbolHelper sh in m_symbols)
         {
             if (sh.Userdescription != "")
             {
                 if (sh.Userdescription == String.Format("Symbolnumber {0}", sh.Symbol_number))
                 {
                     dt.Rows.Add(sh.Userdescription, sh.Symbol_number, sh.Flash_start_address, sh.Varname);
                 }
                 else
                 {
                     dt.Rows.Add(sh.Varname, sh.Symbol_number, sh.Flash_start_address, sh.Userdescription);
                 }
             }
         }
         dt.WriteXml(xmlfilename);
     }
 }
Ejemplo n.º 4
0
        private void btnTuneBinary_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (ValidateFile())
            {
                // read tuned marker to see if binary has been tuned before
                T7FileHeader fh = new T7FileHeader();
                fh.init(m_currentfile, m_appSettings.AutoFixFooter);
                PartNumberConverter pnc = new PartNumberConverter();
                ECUInformation ecuinfo = pnc.GetECUInfo(fh.getPartNumber().Trim(), "");
                //<GS-05102010> Need to validate the type of binary file loaded (which engine type and turbo type, A/M transmission)
                // and base the initially targeted torque and power figures on that
                frmTuningWizard tunWiz = new frmTuningWizard();

                string msg = "Partnumber not recognized, tuning will continue anyway, please verify settings afterwards";
                //msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm";
                if (ecuinfo.Valid)
                {
                    msg = "Partnumber " + fh.getPartNumber() + ", carmodel " + ecuinfo.Carmodel.ToString() + ", engine " + ecuinfo.Enginetype.ToString();
                    //msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm";
                }
                tunWiz.ExtraInfo = msg;

                if (ecuinfo.Stage1torque != 0)
                {
                    tunWiz.PeakTorque = Convert.ToInt32(ecuinfo.Stage1torque);
                }
                if (tunWiz.ShowDialog() == DialogResult.OK)
                {
                    int desiredHP = tunWiz.DesiredHP;
                    bool carRunsE85 = tunWiz.CarRunsE85;

                    // convert HP to torque and airmass
                    //int torque = PowerToTorque(desiredHP, 6000);
                    //int peaktorque = (110 * torque) / 100;
                    int peaktorque = tunWiz.PeakTorque;
                    int maxairmass = TorqueToAirmass(peaktorque, carRunsE85);

                    // give user a warning if airmass/c > 1300 mg/c
                    if (maxairmass > 1300)
                    {
                        frmInfoBox info = new frmInfoBox("Your maximum requested airmass exceeds 1300 mg/c [" + maxairmass.ToString() + " mg/c]. Please make sure all your other maps will support this airflow!");
                    }

                    TuneToStageNew(1, maxairmass, peaktorque, desiredHP, ecuinfo.Enginetype, carRunsE85);
                    TuningReport tuningrep = new TuningReport();
                    tuningrep.DataSource = resumeTuning;
                    tuningrep.CreateReport();
                    tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel);
                }

                // start window to ask user for desired horses (depending on E85 usage?)
                /*frmTuneBinary frmTune = new frmTuneBinary();
                if (ecuinfo.Stage1torque != 0)
                {
                    frmTune.PeakTorque = Convert.ToInt32(ecuinfo.Stage1torque);
                }
                if (frmTune.ShowDialog() == DialogResult.OK)
                {
                    int desiredHP = frmTune.DesiredHP;
                    bool carRunsE85 = frmTune.CarRunsE85;

                    // convert HP to torque and airmass
                    //int torque = PowerToTorque(desiredHP, 6000);
                    //int peaktorque = (110 * torque) / 100;
                    int peaktorque = frmTune.PeakTorque;
                    int maxairmass = TorqueToAirmass(peaktorque, carRunsE85);

                    // give user a warning if airmass/c > 1300 mg/c
                    if (maxairmass > 1300)
                    {
                        MessageBox.Show("Your maximum requested airmass exceeds 1300 mg/c [" + maxairmass.ToString() + " mg/c]. Please make sure all your other maps will support this airflow!", "Warning!", MessageBoxButtons.OK);
                    }

                    string msg = "Partnumber not recognized, tuning will continue anyway, please verify settings afterwards";
                    msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm";
                    if (ecuinfo.Valid)
                    {
                        msg = "Partnumber " + fh.getPartNumber() + ", carmodel " + ecuinfo.Carmodel.ToString() + ", engine " + ecuinfo.Enginetype.ToString();
                        msg += Environment.NewLine + " desired airmass " + maxairmass.ToString() + " mg/c and peak torque " + peaktorque.ToString() + " Nm";
                    }
                    PSTaskDialog.cTaskDialog.ForceEmulationMode = false;
                    PSTaskDialog.cTaskDialog.EmulatedFormWidth = 600;
                    PSTaskDialog.cTaskDialog.UseToolWindowOnXP = false;
                    PSTaskDialog.cTaskDialog.VerificationChecked = true;
                    PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Tune me up™ wizard", "This wizard will tune your binary.", "Several maps will be altered" + Environment.NewLine + msg, "Happy driving!!!\nDilemma © 2009", "The author does not take responsibility for any damage done to your car or other objects in any form!", "Show me a summary after tuning", "", "Yes, tune me up!|No thanks!", eTaskDialogButtons.None, eSysIcons.Information, eSysIcons.Warning);
                    switch (PSTaskDialog.cTaskDialog.CommandButtonResult)
                    {
                        case 0:
                            // tune to stage x
                            // must use fixed maps, scaled to be good for the current airmass (e.g. pedalrequest map)
                            TuneToStageNew(1, maxairmass, peaktorque, desiredHP, ecuinfo.Enginetype, carRunsE85);
                            break;
                        case 1:
                            // cancel
                            break;
                    }
                    if (PSTaskDialog.cTaskDialog.VerificationChecked && PSTaskDialog.cTaskDialog.CommandButtonResult != 1)
                    {
                        TuningReport tuningrep = new TuningReport();
                        tuningrep.DataSource = resumeTuning;
                        tuningrep.CreateReport();
                        tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel);
                    }
                }*/
            }
        }
Ejemplo n.º 5
0
        private void Projects_btnCreateProject_ItemClick(object sender, ItemClickEventArgs e)
        {
            // show the project properties screen for the user to fill in
            // if a bin file is loaded, ask the user whether this should be the new projects binary file
            // the project XML should contain a reference to this binfile as well as a lot of other stuff
            frmProjectProperties projectprops = new frmProjectProperties();
            if (m_currentfile != string.Empty)
            {
                projectprops.BinaryFile = m_currentfile;
                T7FileHeader fileheader = new T7FileHeader();
                fileheader.init(m_currentfile, false);
                projectprops.CarModel = fileheader.getCarDescription().Trim();

                projectprops.ProjectName = fileheader.getPartNumber().Trim() + " " + fileheader.getSoftwareVersion().Trim();
            }
            if (projectprops.ShowDialog() == DialogResult.OK)
            {
                if (!Directory.Exists(m_appSettings.ProjectFolder)) Directory.CreateDirectory(m_appSettings.ProjectFolder);
                // create a new folder with these project properties.
                // also copy the binary file into the subfolder for this project
                if (Directory.Exists(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName)))
                {
                    frmInfoBox info = new frmInfoBox("The chosen projectname already exists, please choose another one");
                    //TODO: reshow the dialog
                }
                else
                {
                    // create the project
                    Directory.CreateDirectory(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName));
                    // copy the selected binary file to this folder
                    string binfilename = m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\" + Path.GetFileName(projectprops.BinaryFile);
                    File.Copy(projectprops.BinaryFile, binfilename);
                    // now create the projectproperties.xml in this new folder
                    System.Data.DataTable dtProps = new System.Data.DataTable("T5PROJECT");
                    dtProps.Columns.Add("CARMAKE");
                    dtProps.Columns.Add("CARMODEL");
                    dtProps.Columns.Add("CARMY");
                    dtProps.Columns.Add("CARVIN");
                    dtProps.Columns.Add("NAME");
                    dtProps.Columns.Add("BINFILE");
                    dtProps.Columns.Add("VERSION");
                    dtProps.Rows.Add(projectprops.CarMake, projectprops.CarModel, projectprops.CarMY, projectprops.CarVIN, MakeDirName(projectprops.ProjectName), binfilename, projectprops.Version);
                    dtProps.WriteXml(m_appSettings.ProjectFolder + "\\" + MakeDirName(projectprops.ProjectName) + "\\projectproperties.xml");
                    OpenProject(projectprops.ProjectName); //?
                }
            }
        }
Ejemplo n.º 6
0
        private void OpenFile(string filename, bool showmessage)
        {
            m_fileiss19 = false;
            m_currentsramfile = string.Empty; // geen sramfile erbij
            barStaticItem1.Caption = "";
            if (filename.ToUpper().EndsWith(".S19"))
            {
                m_fileiss19 = true;
                srec2bin convert = new srec2bin();
                string convertedfile = string.Empty;
                if (convert.ConvertSrecToBin(filename, out convertedfile))
                {
                    filename = convertedfile;
                }
                else
                {
                    frmInfoBox info = new frmInfoBox("Failed to convert S19 file to binary");
                }
            }

            FileInfo fi = new FileInfo(filename);
            try
            {
                fi.IsReadOnly = false;
            }
            catch (Exception E)
            {
                logger.Debug("Failed to clear readonly flag: " + E.Message);
                // failed
            }

            m_currentfile = filename;
            m_appSettings.Lastfilename = m_currentfile;
            if (ValidateFile())
            {
                m_symbols = new SymbolCollection();
                t7file = TryToOpenFileUsingClass(m_currentfile, out m_symbols, m_currentfile_size, true);
                SetProgressPercentage(70);
                SetProgress("Sorting data");
                System.Windows.Forms.Application.DoEvents();
                m_symbols.SortColumn = "Length";
                m_symbols.SortingOrder = GenericComparer.SortOrder.Descending;
                m_symbols.Sort();
                SetProgressPercentage(80);
                SetProgress("Loading data into view");
                gridControlSymbols.DataSource = m_symbols;
                //gridViewSymbols.BestFitColumns();
                SetDefaultFilters();
                Text = String.Format("T7SuitePro v{0} [ {1} ]", System.Windows.Forms.Application.ProductVersion, Path.GetFileName(m_currentfile));
                SetProgressPercentage(90);
                SetProgress("Loading realtime info");
                // also rearrange the symbolnumbers in the realtime view
                UpdateRealTimeDataTableWithNewSRAMValues();
                SetProgressPercentage(100);
                System.Windows.Forms.Application.DoEvents();
            }
            else
            {
                m_symbols = new SymbolCollection();
                gridControlSymbols.DataSource = m_symbols;
                Text = String.Format("T7SuitePro v{0} [ none ]", System.Windows.Forms.Application.ProductVersion);
                if (showmessage)
                {
                    frmInfoBox info = new frmInfoBox("File is not a Trionic 7 binary file!");
                }
                m_currentfile = string.Empty;
            }
            logger.Debug("Number of symbols loaded: " + m_symbols.Count);

            try
            {
                int _width = 18;
                int _height = 16;
                if (m_appSettings.AutoCreateAFRMaps)
                {
                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, "BFuelCal.Map", out _width, out _height);
                    m_AFRMap.RpmYSP = GetSymbolAsIntArray("BFuelCal.RpmYSP");
                    m_AFRMap.AirXSP = GetSymbolAsIntArray("BFuelCal.AirXSP");
                    m_AFRMap.InitializeMaps(_width * _height, m_currentfile);
                }
            }
            catch (Exception E)
            {
                logger.Debug("Failed to load AFR maps: " + E.Message);
            }

            try
            {
                T7FileHeader t7header = new T7FileHeader();
                t7header.init(m_currentfile, false);
                if(CheckFileInLibrary(t7header.getPartNumber()))
                {
                    btnCompareToOriginal.Enabled = true;
                }
                else btnCompareToOriginal.Enabled = false;
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }

            if (m_currentfile != string.Empty) LoadRealtimeTable();
            // <GS-07072011> If the opened file is a BioPower file, then BFuelCal.StartMap = the actual fuel E85 map
            if (IsBinaryBiopower())
            {
                barButtonItem67.Caption = "Petrol VE Map";
                barButtonItem69.Caption = "E85 VE Map";
            }
            else
            {
                barButtonItem67.Caption = "VE map";
                barButtonItem69.Caption = "Startup VE map";
            }

            DynamicTuningMenu();

            System.Windows.Forms.Application.DoEvents();
        }
Ejemplo n.º 7
0
        private void LoadCompressorMapWithDetails()
        {
            // we should get the top line like for the chart

            if (gridControl1.DataSource != null)
            {
                TurboType tt = TurboType.TD0415T;
                if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.T25_55 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.T25_60 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT17)
                {
                    tt = TurboType.Stock;
                }
                else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD04 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0416T)
                {
                    tt = TurboType.TD0415T;
                }
                else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0418T || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.TD0419T)
                {
                    tt = TurboType.TD0419T;
                }
                else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT2871R || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT28RS)
                {
                    tt = TurboType.GT28RS;
                }
                else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT3071R86 || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT30R)
                {
                    tt = TurboType.GT3071R;
                }
                else if (ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.GT40R || ctrlCompressorMap1.Compressor == ctrlCompressorMap.CompressorMap.HX40W)
                {
                    tt = TurboType.HX40w;
                }
                DataTable dt = (DataTable)gridControl1.DataSource;
                double[] boost_req = new double[dt.Columns.Count];
                /*PressureToTorque ptt = new PressureToTorque();

                 <GS-09032011> changed to airmass calculation
                for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++)
                {
                    double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i));
                    // we get the airmass from this.. now convert to boost pressure
                    double trq = AirmassToTorque(Convert.ToInt32(o), Convert.ToInt32(x_axisvalues.GetValue(i)), checkEdit7.Checked);
                    double val = ptt.CalculatePressureFromTorque(trq, tt );
                    boost_req.SetValue(val, i);
                }*/

                for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++)
                {
                    double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i));
                    boost_req.SetValue(o, i);
                }
                ctrlCompressorMap1.Boost_request = boost_req;
                // set rpm range
                ctrlCompressorMap1.Rpm_points = x_axisvalues;
                PartNumberConverter pnc = new PartNumberConverter();
                //
                T7FileHeader header = new T7FileHeader();
                header.init(m_currentfile, false);
                ECUInformation ecuinfo = pnc.GetECUInfo(header.getPartNumber().Trim(), "");
                if (!ctrlCompressorMap1.IsInitiallyLoaded)
                {
                    if (ecuinfo.Is2point3liter) ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter23;
                    else ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter2;
                    if (ecuinfo.Isaero) ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.TD04);
                    else ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.GT17);
                }
                ctrlCompressorMap1.IsInitiallyLoaded = true;
                ctrlCompressorMap1.Redraw();
            }
        }
Ejemplo n.º 8
0
        private void LoadCompressorMapWithDetails()
        {
            // we should get the top line like for the chart

            if (gridControl1.DataSource != null)
            {
                DataTable dt = (DataTable)gridControl1.DataSource;
                double[] boost_req = new double[dt.Columns.Count];
                /*PressureToTorque ptt = new PressureToTorque();
                for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++)
                {
                    double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i));
                    // we get the airmass from this.. now convert to boost pressure
                    double trq = AirmassToTorque(Convert.ToInt32(o), Convert.ToInt32(x_axisvalues.GetValue(i)), checkEdit7.Checked);
                    double val = ptt.CalculatePressureFromTorque(trq, TurboType.TD0415T);
                    boost_req.SetValue(val, i);
                }*/

                for (int i = 0; i < dt.Rows[0].ItemArray.Length; i++)
                {
                    double o = Convert.ToDouble(dt.Rows[0].ItemArray.GetValue(i));
                    boost_req.SetValue(o, i);
                }
                ctrlCompressorMap1.Boost_request = boost_req;

                // set rpm range
                ctrlCompressorMap1.Rpm_points = x_axisvalues;
                PartNumberConverter pnc = new PartNumberConverter();
                //
                T7FileHeader header = new T7FileHeader();
                header.init(m_currentfile, false);
                ECUInformation ecuinfo = pnc.GetECUInfo(header.getPartNumber().Trim(), "");
                if (ecuinfo.Is2point3liter) ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter23;
                else ctrlCompressorMap1.Current_engineType = ctrlCompressorMap.EngineType.Liter2;
                //ctrlCompressorMap1.SetCompressorType(ctrlCompressorMap.CompressorMap.TD04); //TODO: always for now, later rewrite and add the GT17 map
                ctrlCompressorMap1.Redraw();
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="m_symbols"></param>
 /// <param name="LanguageID"></param>
 private static void TryToLoadAdditionalSymbols(string filename, SymbolCollection m_symbols, int LanguageID)
 {
     DataTable dt = new DataTable(Path.GetFileNameWithoutExtension(filename));
     dt.Columns.Add("SYMBOLNAME");
     dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
     dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
     dt.Columns.Add("DESCRIPTION");
     T7FileHeader fh = new T7FileHeader();
     fh.init(filename, false);
     string checkstring = fh.getPartNumber() + fh.getSoftwareVersion();
     string xmlfilename = String.Format("{0}\\repository\\{1}{2:yyyyMMddHHmmss}{3}.xml", Application.StartupPath, Path.GetFileNameWithoutExtension(filename), File.GetCreationTime(filename), checkstring);
     if (File.Exists(xmlfilename))
     {
         dt.ReadXml(xmlfilename);
     }
     else
     {
         // check the file folder
         string[] xmlfiles = Directory.GetFiles(Path.GetDirectoryName(filename), "*.xml");
         foreach (string xmlfile in xmlfiles)
         {
             if (Path.GetFileName(xmlfile).StartsWith(Path.GetFileNameWithoutExtension(filename)))
             {
                 dt.ReadXml(xmlfile);
                 logger.Debug(String.Format("Read: {0} symbols from {1}", dt.Rows.Count, xmlfile));
                 break;
             }
         }
     }
     // auto add symbols for 55P / 46T files only if no other sources of additional symbols can be found
     bool createRepositoryFile = false;
     if (dt.Rows.Count == 0)
     {
         if (fh.getSoftwareVersion().Trim().StartsWith("EU0AF01C", StringComparison.OrdinalIgnoreCase) ||
             fh.getSoftwareVersion().Trim().StartsWith("EU0BF01C", StringComparison.OrdinalIgnoreCase) ||
             fh.getSoftwareVersion().Trim().StartsWith("EU0CF01C", StringComparison.OrdinalIgnoreCase))
         {
             if (MessageBox.Show("Do you want to load the known symbollist for EU0AF01C/EU0BF01C/EU0CF01C files now?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 string BioPowerXmlFile = String.Format("{0}\\EU0AF01C.xml", Application.StartupPath);
                 if (File.Exists(BioPowerXmlFile))
                 {
                     string binname = GetFileDescriptionFromFile(BioPowerXmlFile);
                     if (binname != string.Empty)
                     {
                         dt = new DataTable(binname);
                         dt.Columns.Add("SYMBOLNAME");
                         dt.Columns.Add("SYMBOLNUMBER", Type.GetType("System.Int32"));
                         dt.Columns.Add("FLASHADDRESS", Type.GetType("System.Int32"));
                         dt.Columns.Add("DESCRIPTION");
                         dt.ReadXml(BioPowerXmlFile);
                         createRepositoryFile = true;
                     }
                 }
             }
         }
     }
     foreach (DataRow dr in dt.Rows)
     {
         try
         {
             SymbolHelper sh = m_symbols[Convert.ToInt32(dr["SYMBOLNUMBER"])];
             if (dr["SYMBOLNAME"].ToString() == sh.Varname)
             {
                 if (sh.Flash_start_address == Convert.ToInt32(dr["FLASHADDRESS"]))
                 {
                     if (sh.Varname == String.Format("Symbolnumber {0}", sh.Symbol_number))
                     {
                         sh.Userdescription = sh.Varname;
                         sh.Varname = dr["DESCRIPTION"].ToString();
                     }
                     else
                     {
                         sh.Userdescription = dr["DESCRIPTION"].ToString();
                     }
                     string helptext = string.Empty;
                     XDFCategories cat = XDFCategories.Undocumented;
                     XDFSubCategory sub = XDFSubCategory.Undocumented;
                     SymbolTranslator st = new SymbolTranslator();
                     sh.Description = st.TranslateSymbolToHelpText(sh.Varname, out helptext, out cat, out sub, LanguageID);
                     if (sh.Category == "Undocumented" || sh.Category == "")
                     {
                         if (sh.Varname.Contains("."))
                         {
                             try
                             {
                                 sh.Category = sh.Varname.Substring(0, sh.Varname.IndexOf("."));
                                 //logger.Debug(String.Format("Set cat to {0} for {1}", sh.Category, sh.Userdescription));
                             }
                             catch (Exception cE)
                             {
                                 logger.Debug(String.Format("Failed to assign category to symbol: {0} err: {1}", sh.Userdescription, cE.Message));
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception E)
         {
             logger.Debug(E.Message);
         }
     }
     if (createRepositoryFile)
     {
         SaveAdditionalSymbols(filename, m_symbols);
     }
     foreach (SymbolHelper sh in m_symbols)
     {
         if (sh.Varname == "X_AccPedalManSP" || sh.Varname == "X_AccPedalAutTAB" || sh.Varname == "X_AccPedalAutSP" || sh.Varname == "X_AccPedalManTAB" || sh.Userdescription == "X_AccPedalManSP" || sh.Userdescription == "X_AccPedalAutTAB" || sh.Userdescription == "X_AccPedalAutSP" || sh.Userdescription == "X_AccPedalManTAB")
         {
             if (sh.Length == 4)
             {
                 sh.Flash_start_address -= 0x0C;
                 sh.Length = 0x0C;
             }
         }
     }
     dt.Dispose();
 }