public frmTuningWizard(frmMain inParent, string in_m_currentfile)
        {
            InitializeComponent();
            parent = inParent;

            // Set-up some navigation rules
            this.wizConfirmPage.AllowNext   = false;
            this.wizCompletedPage.AllowBack = false;

            // Read software version from binary
            if (in_m_currentfile != string.Empty)
            {
                if (File.Exists(in_m_currentfile))
                {
                    T7FileHeader t7InfoHeader = new T7FileHeader();
                    t7InfoHeader.init(in_m_currentfile, false);
                    softwareVersion = t7InfoHeader.getSoftwareVersion().Trim();
                    this.lblSoftwareVersion.Text = softwareVersion.Substring(0, 8);
                }
            }
            // List all compatible tuning packages
            foreach (frmMain.TuningAction t in frmMain.installedTunings)
            {
                if (t.compatibelSoftware(softwareVersion))
                {
                    this.listTuningActions.Items.Add(t);
                }
            }
            if (this.listTuningActions.ItemCount <= 0)
            {
                this.wizSelectActionPage.AllowNext = false;
            }
        }
Esempio 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);
                    }
                }
            }
        }
Esempio n. 3
0
        private void DynamicTuningMenu()
        {
            //
            // Show Tuning menu shortcuts depening on which file that was loaded.
            //
            if (m_currentfile != string.Empty)
            {
                if (File.Exists(m_currentfile))
                {
                    T7FileHeader t7header = new T7FileHeader();
                    t7header.init(m_currentfile, false);
                    string swVersion = t7header.getSoftwareVersion();
                    // B308E
                    if (swVersion.Substring(8, 3) == ".CB")
                    {

                    }

                    if (IsSymbolInBinary("BoostCal.RegMap"))
                    {
                        ribbonPageGroup22.Visible = true;
                    }
                    else
                    {
                        ribbonPageGroup22.Visible = false;
                    }

                    if (IsBinaryBiopower())
                    {
                        barButtonItem37.Visibility = BarItemVisibility.Always;
                        barButtonItem65.Visibility = BarItemVisibility.Always;
                        if (IsSymbolInBinary("TorqueCal.M_EngMaxE85TabAut"))
                        {
                            barButtonItem95.Visibility = BarItemVisibility.Always;
                        }
                        else
                        {
                            barButtonItem95.Visibility = BarItemVisibility.Never;
                        }
                    }
                    else
                    {
                        barButtonItem95.Visibility = BarItemVisibility.Never;
                        barButtonItem37.Visibility = BarItemVisibility.Never;
                        barButtonItem65.Visibility = BarItemVisibility.Never;
                    }

                    if (IsSymbolInBinary("TorqueCal.M_CabGearLim"))
                    {
                        barButtonItem54.Visibility =  BarItemVisibility.Always;
                    }
                    else
                    {
                        barButtonItem54.Visibility =  BarItemVisibility.Never;
                    }
                }
            }
        }
Esempio n. 4
0
        private Trionic7File TryToOpenFileUsingClass(string filename, out SymbolCollection symbol_collection, int filename_size, bool isWorkingFile)
        {
            Trionic7File retval = new Trionic7File();

            retval.onProgress += retval_onProgress;
            SymbolTranslator translator = new SymbolTranslator();
            string help = string.Empty;
            _softwareIsOpen = false;
            _softwareIsOpenDetermined = false;
            m_currentsramfile = string.Empty; // geen sramfile erbij
            barStaticItem1.Caption = "";
            barFilenameText.Caption = "";

            FileInfo fi = new FileInfo(filename);
            try
            {
                fi.IsReadOnly = false;
                btnReadOnly.Caption = "File access OK";
            }
            catch (Exception E)
            {
                logger.Debug("Failed to remove read only flag: " + E.Message);
                btnReadOnly.Caption = "File is READ ONLY";
            }

            try
            {
                if (isWorkingFile)
                {
                    T7FileHeader t7InfoHeader = new T7FileHeader();
                    if (t7InfoHeader.init(filename, m_appSettings.AutoFixFooter))
                    {
                        m_current_softwareversion = t7InfoHeader.getSoftwareVersion();
                        m_currentSramOffsett = ReverseInt(t7InfoHeader.Unknown_9cvalue);
                    }
                    else
                    {
                        m_current_softwareversion = "";
                    }
                }
            }
            catch (Exception E2)
            {
                logger.Debug(E2.Message);
            }
            AddFileToMRUList(filename);
            symbol_collection = retval.ExtractFile(filename, m_appSettings.ApplicationLanguage, m_current_softwareversion);

            SetProgressPercentage(60);
            SetProgress("Examining file");
            System.Windows.Forms.Application.DoEvents();
            if (isWorkingFile)
            {
                if (m_currentSramOffsett == 0)
                {
                    m_currentSramOffsett = retval.SramOffsetForOpenFile;
                    logger.Debug("Overrules m_currentSramOffsett with value from t7file: " + m_currentSramOffsett.ToString("X8"));
                }

                // <GS-27042010> now we need to check if there is a symbol information XML file present.
                try
                {
                    IsSoftwareOpen();
                    // fill in the rest of the parameters
                    barFilenameText.Caption = Path.GetFileNameWithoutExtension(filename);
                }
                catch (Exception E3)
                {
                    logger.Debug(E3.Message);
                }
            }

            if (IsBinaryBiopower())
            {
                foreach (SymbolHelper sh in symbol_collection)
                {
                    if (sh.Varname == "BFuelCal.StartMap")
                    {
                        sh.Varname = "BFuelCal.E85Map";
                        XDFCategories cat = XDFCategories.Undocumented;
                        XDFSubCategory sub = XDFSubCategory.Undocumented;
                        sh.Description = translator.TranslateSymbolToHelpText(sh.Varname, out help, out cat, out sub, m_appSettings.ApplicationLanguage);
                    }
                    if (sh.Userdescription == "BFuelCal.StartMap")
                    {
                        sh.Userdescription = "BFuelCal.E85Map";
                        XDFCategories cat = XDFCategories.Undocumented;
                        XDFSubCategory sub = XDFSubCategory.Undocumented;
                        sh.Description = translator.TranslateSymbolToHelpText(sh.Userdescription, out help, out cat, out sub, m_appSettings.ApplicationLanguage);
                    }
                }
            }
            return retval;
        }
Esempio n. 5
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);
     }
 }
Esempio n. 6
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); //?
                }
            }
        }
Esempio n. 7
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Binary files|*.bin";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                m_current_comparefilename = ofd.FileName;
                SymbolTranslator translator = new SymbolTranslator();
                string help = string.Empty;
                FileInfo fi = new FileInfo(m_current_comparefilename);
                fi.IsReadOnly = false;

                try
                {
                    T7FileHeader t7InfoHeader = new T7FileHeader();
                    if (t7InfoHeader.init(m_current_comparefilename, false))
                    {
                        m_current_softwareversion = t7InfoHeader.getSoftwareVersion();
                    }
                    else
                    {
                        m_current_softwareversion = "";
                    }
                }
                catch (Exception E2)
                {
                    logger.Debug(E2.Message);
                }
                Trionic7File t7file = new Trionic7File();

                Compare_symbol_collection = t7file.ExtractFile(m_current_comparefilename, 44, m_current_softwareversion);
                // so... now determine the max values for the compare file
                // show the dynograph
                xtraTabControl1.SelectedTabPage = xtraTabPage2;
                LoadGraphWithDetails(); // initial values from original bin
                //DataTable dt = CalculateDataTable(m_current_comparefilename, Compare_symbol_collection);
                //LoadExtraGraphFromCompareBin(dt, m_current_comparefilename);
            }
        }
Esempio n. 8
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();
 }