Exemplo n.º 1
0
        private void barButtonItem62_ItemClick(object sender, ItemClickEventArgs e)
        {
            // write the required file for flashing the ECU
            // this is the current file, exported to S19 format in the directory that contains
            // the selected batchfile
            if (m_appSettings.Write_ecubatchfile != string.Empty)
            {
                try
                {
                    if (File.Exists(m_appSettings.Write_ecubatchfile))
                    {

                        if (!verifychecksum(false))
                        {
                            frmChecksumIncorrect check = new frmChecksumIncorrect();
                            if (m_appSettings.AutoChecksum)
                            {
                                UpdateChecksum(m_currentfile);
                                if (m_fileiss19)
                                {
                                    // automatisch terugschrijven
                                    srec2bin cnvrt = new srec2bin();
                                    cnvrt.ConvertBinToSrec(m_currentfile);
                                }

                            }
                            //else if (MessageBox.Show("Checksum invalid, auto correct?", "Question", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            else if (check.ShowDialog() == DialogResult.Yes)
                            {
                                UpdateChecksum(m_currentfile);
                                if (m_fileiss19)
                                {
                                    // automatisch terugschrijven
                                    srec2bin cnvrt = new srec2bin();
                                    cnvrt.ConvertBinToSrec(m_currentfile);
                                }
                            }
                        }

                        srec2bin sr = new srec2bin();
                        sr.ConvertBinToSrec(m_currentfile);
                        // and copy it to the target directory
                        string fromfile = Path.GetDirectoryName(m_currentfile) + "\\" + Path.GetFileNameWithoutExtension(m_currentfile) + ".S19";
                        string destfile = Path.GetDirectoryName(m_appSettings.Write_ecubatchfile) + "\\TO_ECU.S19";
                        File.Copy(fromfile, destfile, true);
                        System.Diagnostics.Process.Start(m_appSettings.Write_ecubatchfile);
                    }
                    else
                    {
                        frmInfoBox info = new frmInfoBox("Batch file not found. Check parameters");
                    }
                }
                catch (Exception E)
                {
                    MessageBox.Show(E.Message);
                }
            }
        }
Exemplo n.º 2
0
 private void File_ExportToS19(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     SaveFileDialog sfd1 = new SaveFileDialog();
     sfd1.Filter = "S19 files|*.S19";
     sfd1.AddExtension = true;
     sfd1.DefaultExt = "S19";
     sfd1.OverwritePrompt = true;
     sfd1.Title = "Export file to motorola S19 format...";
     if (sfd1.ShowDialog() == DialogResult.OK)
     {
         srec2bin srec = new srec2bin();
         srec.ConvertBinToSrec(m_currentfile, sfd1.FileName);
     }
 }
Exemplo n.º 3
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();
        }