Beispiel #1
0
 private void btnCreateProject_ItemClick(object sender, DevExpress.XtraBars.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_trionicFile != null)
     {
         projectprops.BinaryFile = m_trionicFileInformation.Filename;
         projectprops.CarModel = m_trionicFile.GetTrionicProperties().Carmodel.Trim();
         projectprops.ProjectName = m_trionicFile.GetTrionicProperties().Enginetype.Trim() + " " + m_trionicFile.GetTrionicProperties().Partnumber.Trim() + " " + m_trionicFile.GetTrionicProperties().SoftwareID.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 if the project name already exists
         }
         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
             DataTable dtProps = new 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); //?
         }
     }
 }
Beispiel #2
0
        private void RunTuningWizard()
        {
            props = m_trionicFile.GetTrionicProperties();
            if ((int)props.TuningStage > 3)
            {
                frmInfoBox infofail = new frmInfoBox("This file has already been tuned to a higher stage, the tuning wizard will not be started");
                return;
            }

            frmTuningWizard tunWiz = new frmTuningWizard();
            int _currStage = (int)props.TuningStage;
            if (_currStage == 0) _currStage++;
            tunWiz.TuningStage = _currStage;
            tunWiz.SetMapSensorType(props.MapSensorType);
            tunWiz.SetInjectorType(props.InjectorType);
            tunWiz.SetTurboType(props.TurboType);
            ECUFileType fileType = m_trionicFile.DetermineFileType();
            int frek230 = m_trionicFile.GetSymbolAsInt("Frek_230!");
            int frek250 = m_trionicFile.GetSymbolAsInt("Frek_250!");

            int knockTime = m_trionicFile.GetSymbolAsInt("Knock_matrix_time!");
            tunWiz.SetKnockTime(knockTime);
            int rpmLimit = m_trionicFile.GetSymbolAsInt("Rpm_max!");
            tunWiz.SetRPMLimiter(rpmLimit);

            if (fileType == ECUFileType.Trionic52File)
            {
                if (frek230 == 728 || frek250 == 935)
                {
                    //dtReport.Rows.Add("APC valve type: Trionic 5");
                    tunWiz.SetBPCType(BPCType.Trionic5Valve);
                }
                else
                {
                    tunWiz.SetBPCType(BPCType.Trionic7Valve);
                }
            }
            else if (fileType == ECUFileType.Trionic55File)
            {
                if (frek230 == 90 || frek250 == 70)
                {
                    tunWiz.SetBPCType(BPCType.Trionic5Valve);
                }
                else
                {
                    tunWiz.SetBPCType(BPCType.Trionic7Valve);
                }
            }
            if (tunWiz.ShowDialog() == DialogResult.OK)
            {
                Application.DoEvents();
                Trionic5Tuner _tuner = new Trionic5Tuner();
                _tuner.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                frmInfoBox info;
                TuningResult result = TuningResult.TuningFailed;
                if (tunWiz.TuningStage == 4)
                {
                    result = _tuner.FreeTuneBinary(m_trionicFile, tunWiz.GetPeakTorque(), tunWiz.GetPeakBoost(), tunWiz.IsTorqueBased, tunWiz.GetMapSensorType(), tunWiz.GetTurboType(), tunWiz.GetInjectorType(), tunWiz.GetBCVType(), tunWiz.GetRPMLimiter(), tunWiz.GetKnockTime());
                }
                else
                {
                    result = _tuner.TuneFileToStage(tunWiz.TuningStage, m_trionicFile.GetFileInfo().Filename, m_trionicFile, m_trionicFileInformation, true);

                }
                switch (result)
                {
                    case TuningResult.TuningFailed:
                        info = new frmInfoBox("Tuning of the binary file failed!");
                        break;
                    case TuningResult.TuningFailedAlreadyTuned:
                        info = new frmInfoBox("Your binary file was already tuned!");
                        break;
                    case TuningResult.TuningFailedThreebarSensor:
                        info = new frmInfoBox("Your binary file was already tuned (3 bar sensor)!");
                        break;
                    case TuningResult.TuningSuccess:
                        // show report
                        props = m_trionicFile.GetTrionicProperties();
                        TuningReport tuningrep = new TuningReport();
                        tuningrep.ReportTitle = "Tuning report (stage " + tunWiz.TuningStage.ToString() + ")";
                        tuningrep.SetDataSource(_tuner.Resume.ResumeTuning);
                        tuningrep.CreateReport();
                        tuningrep.ShowReportPreview(defaultLookAndFeel1.LookAndFeel);
                        //info = new frmInfoBox("Your binary file was succesfully tuned to stage 1");
                        break;
                    case TuningResult.TuningCancelled:
                        // show report
                        info = new frmInfoBox("Tuning process cancelled by user");
                        break;
                }
            }
        }
Beispiel #3
0
 private void btnBinaryCompare_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = "Binary files|*.bin";
     ofd.Multiselect = false;
     if (m_trionicFile.GetFileInfo().Filename != "")
     {
         ofd.Multiselect = false;
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             frmBinCompare bincomp = new frmBinCompare();
             bincomp.SetCurrentFilename(m_trionicFile.GetFileInfo().Filename);
             bincomp.SetCompareFilename(ofd.FileName);
             bincomp.CompareFiles();
             bincomp.ShowDialog();
         }
     }
     else
     {
         frmInfoBox info = new frmInfoBox("No file is currently opened, you need to open a binary file first to compare it to another one!");
     }
 }
Beispiel #4
0
        private void ctrlRealtime1_onSwitchIgnitionTuningOnOff(object sender, ctrlRealtime.ClosedLoopOnOffEventArgs e)
        {
            // toggle closed loop on /off based on e.SwitchOn
            //Fastest way to detect cell stability and such is in ECUConnection but we don't want that logic in there.
            //Design decision is to feed the AFRMaps object with the data and have that figure out what to do.
            // DO NOT support T5.2 anymore, because of lack of proper knock detection
            if (!props.IsTrionic55)
            {
                frmInfoBox info = new frmInfoBox("T5.2 is currently not supported for Autotuning Ignition");
                return;
            }

            _ecuConnection.StopECUMonitoring();
            Thread.Sleep(10);
            if (m_IgnitionMaps == null)
            {
                m_IgnitionMaps = new IgnitionMaps();
                m_IgnitionMaps.onIgnitionmapCellChanged += new IgnitionMaps.IgnitionmapCellChanged(m_IgnitionMaps_onIgnitionmapCellChanged);
                m_IgnitionMaps.onCellLocked += new IgnitionMaps.CellLocked(m_IgnitionMaps_onCellLocked);
                m_IgnitionMaps.TrionicFile = m_trionicFile;
                m_IgnitionMaps.InitializeMaps();
            }

            byte[] pgm_mod = _ecuConnection.ReadSymbolData(m_trionicFileInformation.GetProgramModeSymbol(), (uint)m_trionicFileInformation.GetSymbolAddressSRAM(m_trionicFileInformation.GetProgramModeSymbol()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetProgramModeSymbol()));
            Thread.Sleep(50);
            // we have to check whether knock detection is turned on, otherwise we DO NOT start ignition autotune

            if (pgm_mod.Length > 3)
            {
                if (!e.SwitchOn)
                {
                    Thread.Sleep(100);
                    // user ended an ignition tuning session.. what todo ?
                    //TODO: ask the user whether he wants to merge the altered fuelmap into ECU memory!
                    // if he replies NO: revert to the previous ignition map (we still need to preserve a copy!)
                    if (MessageBox.Show("Keep adjusted ignition map?", "Question", MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        _ecuConnection.WriteSymbolDataForced((int)m_trionicFileInformation.GetSymbolAddressSRAM(m_trionicFileInformation.GetIgnitionMap()), (int)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap()), IntArrayToByteArray(m_IgnitionMaps.GetOriginalIgnitionmap()));
                    }
                    else
                    {
                        // user selected to keep this map, sync ignition map to the opened binary file! <GS-11042011>
                        byte[] bIgnMap = IntArrayToByteArray(m_IgnitionMaps.GetCurrentlyMutatedIgnitionMap());
                        m_trionicFile.WriteDataNoCounterIncrease(bIgnMap, (uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetIgnitionMap()));
                    }
                    // init the ignitionmaps values
                    m_IgnitionMaps.InitAutoTuneVars(e.SwitchOn);
                    ctrlRealtime1.SetAutoTuneIgnitionButtonText("Autotune ignition");
                    SetStatusText("Idle");
                }
                else
                {

                    // init the afrmaps values
                    SetStatusText("Starting ignition autotune...");
                    System.Windows.Forms.Application.DoEvents();
                    m_IgnitionMaps.InitAutoTuneVars(e.SwitchOn);
                    byte[] ignitionmap;
                    ignitionmap = _ecuConnection.ReadSymbolData(m_trionicFileInformation.GetIgnitionMap(), (uint)m_trionicFileInformation.GetSymbolAddressSRAM(m_trionicFileInformation.GetIgnitionMap()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap()));
                    Thread.Sleep(50);

                    // TODO: Check whether there are cells that have more advance than the setting allows
                    if (m_appSettings.CapIgnitionMap) // <GS-05042011> added new option to cap off ignition map before commencing autotune
                    {
                        bool _writeMapToECU = false;
                        for (int i = 0; i < ignitionmap.Length; i += 2)
                        {
                            // get the value from the map
                            int advance = Convert.ToInt32(ignitionmap[i]) * 256 + Convert.ToInt32(ignitionmap[i + 1]);
                            if (advance > 32000) advance = -(65535 - advance);
                            //check against m_appSettings.GlobalMaximumIgnitionAdvance
                            if (advance > m_appSettings.GlobalMaximumIgnitionAdvance * 10)
                            {
                                advance = Convert.ToInt32(m_appSettings.GlobalMaximumIgnitionAdvance * 10);
                                // write into the map and indicate we have to update the map in the ECU
                                byte b1 = (byte)(advance / 256);
                                byte b2 = (byte)(advance - (int)(advance * 256));
                                ignitionmap[i] = b1;
                                ignitionmap[i + 1] = b2;
                                _writeMapToECU = true;
                            }
                        }
                        if (_writeMapToECU)
                        {
                            _ecuConnection.WriteSymbolDataForced(m_trionicFileInformation.GetSymbolAddressSRAM(m_trionicFileInformation.GetIgnitionMap()), m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap()), ignitionmap);
                            Thread.Sleep(50);
                        }
                    }

                    byte[] knockpressuremap;
                    if (props.IsTrionic55)
                    {
                        knockpressuremap = _ecuConnection.ReadSymbolData("Knock_press_tab!", (uint)m_trionicFileInformation.GetSymbolAddressSRAM("Knock_press_tab!"), (uint)m_trionicFileInformation.GetSymbolLength("Knock_press_tab!"));
                    }
                    else
                    {
                        byte[] knock_press_value = _ecuConnection.ReadSymbolData("Knock_press!", (uint)m_trionicFileInformation.GetSymbolAddressSRAM("Knock_press!"), (uint)m_trionicFileInformation.GetSymbolLength("Knock_press!"));
                        knockpressuremap = new byte[32];
                        for (int i = 0; i < knockpressuremap.Length; i += 2)
                        {
                            knockpressuremap[i] = 0;
                            knockpressuremap[i + 1] = knock_press_value[0];
                        }
                    }
                    Thread.Sleep(50);
                    m_IgnitionMaps.SetKnockPressTab(ByteArrayToIntArray(knockpressuremap));
                    m_IgnitionMaps.SetOriginalIgnitionMap(ByteArrayToIntArray(ignitionmap)); // for reverting back if the user chooses so after the session
                    m_IgnitionMaps.SetCurrentIgnitionMap(ByteArrayToIntArray(ignitionmap)); // for editing & display by autotune functions
                    ctrlRealtime1.SetAutoTuneIgnitionButtonText("Tuning...");
                    SetStatusText("Autotune ignition running...");
                }
                m_IgnitionMaps.CellStableTime_ms = m_appSettings.IgnitionCellStableTime_ms;
                m_IgnitionMaps.MinimumEngineSpeedForIgnitionTuning = m_appSettings.MinimumEngineSpeedForIgnitionTuning;
                m_IgnitionMaps.MaxumimIgnitionAdvancePerSession = m_appSettings.MaximumIgnitionAdvancePerSession;
                m_IgnitionMaps.IgnitionAdvancePerCycle = m_appSettings.IgnitionAdvancePerCycle;
                m_IgnitionMaps.IgnitionRetardFirstKnock = m_appSettings.IgnitionRetardFirstKnock;
                m_IgnitionMaps.IgnitionRetardFurtherKnocks = m_appSettings.IgnitionRetardFurtherKnocks;
                m_IgnitionMaps.GlobalMaximumIgnitionAdvance = m_appSettings.GlobalMaximumIgnitionAdvance;
                m_IgnitionMaps.IsAutoMappingActive = e.SwitchOn;
            }
            else
            {
                // could not read pgm_mod...wtf?
            }
            _ecuConnection.StartECUMonitoring();
        }
Beispiel #5
0
        private void gridViewSymbols_DoubleClick(object sender, EventArgs e)
        {
            // test if we hit a datarow
            Point p = gridSymbols.PointToClient(Cursor.Position);
            GridHitInfo hitinfo = gridViewSymbols.CalcHitInfo(p);
            int[] selectedrows = gridViewSymbols.GetSelectedRows();
            if (hitinfo.InRow)
            {
                int grouplevel = gridViewSymbols.GetRowLevel((int)selectedrows.GetValue(0));
                if (grouplevel >= gridViewSymbols.GroupCount)
                {
                    //Console.WriteLine("In row");
                    if (gridViewSymbols.GetFocusedRow() is Trionic5Tools.SymbolHelper)
                    {
                        Trionic5Tools.SymbolHelper sh = (Trionic5Tools.SymbolHelper)gridViewSymbols.GetFocusedRow();
                        //Console.WriteLine("Symbol:" + sh.Varname);
                        if (!_ecuConnection.Opened && sh.Flash_start_address == 0/*!sh.Varname.Contains("!")*/ && m_trionicFileInformation.SRAMfilename == "")
                        {
                                frmInfoBox info = new frmInfoBox("Symbol resides in SRAM and you are in offline mode. T5Suite is unable to fetch this symboldata in offline mode");

                        }
                        else
                        {
                            StartTableViewer(sh.Varname);
                        }
                    }
                }
            }
        }
Beispiel #6
0
 private void btnVerifyChecksum_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // verify the files checksum (if opened)
     if (m_trionicFile != null)
     {
         if (m_trionicFile.Exists())
         {
             if (m_trionicFile.ValidateChecksum())
             {
                 frmInfoBox info = new frmInfoBox("Checksum is valid");
             }
             else
             {
                 frmChecksumWarning warning = new frmChecksumWarning();
                 if (warning.ShowDialog() == DialogResult.Yes)
                 {
                     m_trionicFile.UpdateChecksum();
                 }
             }
         }
     }
 }
Beispiel #7
0
        private void CompareSymbolTableToFile(string filename, Trionic5Tools.SymbolCollection curSymbolCollection, AddressLookupCollection curAddressLookupCollection, out int numberofsymboldifferent)
        {
            numberofsymboldifferent = 0;
            if (filename != string.Empty)
            {
                //bool m_fileparsed = false;
                SetTaskProgress(0, true);
                SetStatusText("Start symbol parsing");
                // available in repository?
                //ParseFile(progress, filename, curTrionic5Tools.SymbolCollection, curAddressLookupCollection);
                Trionic5File m_CompareToFile = new Trionic5File();
                m_CompareToFile.LibraryPath = Application.StartupPath + "\\Binaries";
                m_CompareToFile.SetAutoUpdateChecksum(m_appSettings.AutoChecksum);

                m_CompareToFile.onDecodeProgress += new IECUFile.DecodeProgress(m_CompareToFile_onDecodeProgress);
                Trionic5FileInformation m_CompareInfo = m_CompareToFile.ParseTrionicFile(filename);
                // available in repository?
                curSymbolCollection = m_CompareInfo.SymbolCollection;
                curAddressLookupCollection = m_CompareInfo.AddressCollection;
                //m_fileparsed = true;
                // AddLogItem("Start symbol export...");
                curSymbolCollection.SortColumn = "Start_address";
                curSymbolCollection.SortingOrder = Trionic5Tools.GenericComparer.SortOrder.Ascending;
                curSymbolCollection.Sort();
                //listView1.SuspendLayout();

                foreach (Trionic5Tools.SymbolHelper sh in curSymbolCollection)
                {
                    float diffperc = 0;
                    int diffabs = 0;
                    float diffavg = 0;
                    if (!CompareSymbolToCurrentFile(sh.Varname, sh.Flash_start_address, sh.Length, filename, out diffperc, out diffabs, out diffavg))
                    {
                        numberofsymboldifferent++;
                    }
                }
                /*if (m_fileparsed)
                {
                    CreateRepositoryItem(filename, curTrionic5Tools.SymbolCollection);
                }*/
                //listView1.ResumeLayout();
                SetTaskProgress(0, false);
                SetStatusText("Idle");
                //barButtonItem14.Enabled = true;
                //progress.Close();

            }
            else
            {
                frmInfoBox info = new frmInfoBox("No file selected, please select one first");
            }
        }
Beispiel #8
0
 private void btnPeMicroBruteforceErase_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // brute force erase batch file
     if (m_appSettings.Erasebruteforcebatchfile != string.Empty)
     {
         try
         {
             if (File.Exists(m_appSettings.Write_ecuIntelbatchfile))
             {
                 System.Diagnostics.Process.Start(m_appSettings.Erasebruteforcebatchfile);
             }
             else
             {
                 frmInfoBox info = new frmInfoBox("Batch file not found. Check parameters");
             }
         }
         catch (Exception E)
         {
             MessageBox.Show(E.Message);
         }
     }
 }
Beispiel #9
0
        private void btnPeMicroProgramIntel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // write the required file for flashing the ECU (INTEL)
            // this is the current file, exported to S19 format in the directory that contains
            // the selected batchfile
            if (m_appSettings.Write_ecuIntelbatchfile != string.Empty)
            {
                try
                {
                    if (File.Exists(m_appSettings.Write_ecuIntelbatchfile))
                    {
                        m_trionicFile.UpdateChecksum();

                        srec2bin sr = new srec2bin();
                        sr.ConvertBinToSrec(m_trionicFileInformation.Filename);
                        // and copy it to the target directory
                        string fromfile = Path.GetDirectoryName(m_trionicFileInformation.Filename) + "\\" + Path.GetFileNameWithoutExtension(m_trionicFileInformation.Filename) + ".S19";
                        string destfile = Path.GetDirectoryName(m_appSettings.Write_ecuIntelbatchfile) + "\\TO_ECU.S19";
                        File.Copy(fromfile, destfile, true);
                        System.Diagnostics.Process.Start(m_appSettings.Write_ecuIntelbatchfile);
                    }
                    else
                    {
                        frmInfoBox info = new frmInfoBox("Batch file not found. Check parameters");
                    }
                }
                catch (Exception E)
                {
                    MessageBox.Show(E.Message);
                }
            }
        }
Beispiel #10
0
        private void btnMoveSymbolsToAnotherBinary_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //TODO: have the  user select which symbols to move and which not to move (only the different symbols should be listed)
            // ask for another bin file
            Trionic5Resume resume = new Trionic5Resume();

            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Binary files|*.bin";
            ofd.Multiselect = false;
            if (m_trionicFileInformation.Filename != string.Empty)
            {
                frmTransferDataWizard dataWiz = new frmTransferDataWizard();

                if (dataWiz.ShowDialog() == DialogResult.OK)
                {
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        TransferMapsToNewBinary(ofd.FileName, resume);
                        TuningReport tuningrep = new TuningReport();
                        tuningrep.ReportTitle = "Data transfer report";
                        tuningrep.DataSource = resume.ResumeTuning;
                        tuningrep.CreateReport();
                        tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel);
                        frmInfoBox info = new frmInfoBox("Data was transferred to the target binary");
                    }
                    else
                    {
                        return;
                    }
                }

            }
        }
Beispiel #11
0
        private void btnOpenProject_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //let the user select a project from the Project folder. If none are present, let the user know
            if (!Directory.Exists(m_appSettings.ProjectFolder)) Directory.CreateDirectory(m_appSettings.ProjectFolder);
            DataTable ValidProjects = new DataTable();
            ValidProjects.Columns.Add("Projectname");
            ValidProjects.Columns.Add("NumberBackups");
            ValidProjects.Columns.Add("NumberTransactions");
            ValidProjects.Columns.Add("DateTimeModified");
            ValidProjects.Columns.Add("Version");
            string[] projects = Directory.GetDirectories(m_appSettings.ProjectFolder);
            // filter for folders with a projectproperties.xml file
            foreach (string project in projects)
            {
                string[] projectfiles = Directory.GetFiles(project, "projectproperties.xml");

                if (projectfiles.Length > 0)
                {
                    DataTable projectprops = new DataTable("T5PROJECT");
                    projectprops.Columns.Add("CARMAKE");
                    projectprops.Columns.Add("CARMODEL");
                    projectprops.Columns.Add("CARMY");
                    projectprops.Columns.Add("CARVIN");
                    projectprops.Columns.Add("NAME");
                    projectprops.Columns.Add("BINFILE");
                    projectprops.Columns.Add("VERSION");
                    projectprops.ReadXml((string)projectfiles.GetValue(0));
                    // valid project, add it to the list
                    if (projectprops.Rows.Count > 0)
                    {
                        string projectName = projectprops.Rows[0]["NAME"].ToString();
                        ValidProjects.Rows.Add(projectName, GetNumberOfBackups(projectName), GetNumberOfTransactions(projectName), GetLastAccessTime(projectprops.Rows[0]["BINFILE"].ToString()), projectprops.Rows[0]["VERSION"].ToString());
                    }
                }
            }
            if (ValidProjects.Rows.Count > 0)
            {
                frmProjectSelection projselection = new frmProjectSelection();
                projselection.SetDataSource(ValidProjects);
                if (projselection.ShowDialog() == DialogResult.OK)
                {
                    string selectedproject = projselection.GetProjectName();
                    if (selectedproject != "")
                    {
                        OpenProject(selectedproject);
                    }

                }
            }
            else
            {
                frmInfoBox info = new frmInfoBox("No projects were found, please create one first!");
            }
        }
Beispiel #12
0
        private void btnImportSRAMSnapshot_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //Import an SRAM snapshots data into the binfile.
            //First find out what maps / vars are different and prompt the user to make a selection from these.
            // also remember the last set of selected symbols here
            // frmInfoBox info = new frmInfoBox("Still needs to be implemented");
            // let the user select a SRAM file first
            OpenFileDialog ofd1 = new OpenFileDialog();
            ofd1.Title = "Select SRAM file...";
            ofd1.Filter = "SRAM dumps|*.ram";
            ofd1.Multiselect = false;
            if (ofd1.ShowDialog() == DialogResult.OK)
            {
                //
                frmMergeAdaptionData frmMergeData = new frmMergeAdaptionData();
                if (frmMergeData.ShowDialog() == DialogResult.OK)
                {
                    //resumeTuning = new System.Data.DataTable();
                    //resumeTuning.Columns.Add("Description");
                    //AddToResumeTable("Importing and merging SRAM file into binary");
                    // well then, open the binary file and extract the relevant data from it
                    File.Copy(m_trionicFileInformation.Filename, Path.GetDirectoryName(m_trionicFileInformation.Filename) + "\\" + Path.GetFileNameWithoutExtension(m_trionicFileInformation.Filename) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforemergingadaptiondata.bin", true);
                    //AddToResumeTable("Backup file created: " + Path.GetFileNameWithoutExtension(m_currentfile) + DateTime.Now.ToString("yyyyMMddHHmmss") + "beforemergingadaptiondata.bin");
                    //AddToResumeTable("Reading adaption data from SRAM file... ");
                    byte[] adaptkorr = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Adapt_korr!"), (uint)m_trionicFileInformation.GetSymbolLength( "Adapt_korr!"));
                    byte[] adaptggr = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Adapt_ggr"), (uint)m_trionicFileInformation.GetSymbolLength( "Adapt_ggr"));
                    byte[] knockcountmap = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Knock_count_map"), (uint)m_trionicFileInformation.GetSymbolLength( "Knock_count_map"));
                    byte[] knockcountcyl1 = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Knock_count_cyl1"), 2);
                    byte[] knockcountcyl2 = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Knock_count_cyl2"), 2);
                    byte[] knockcountcyl3 = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Knock_count_cyl3"), 2);
                    byte[] knockcountcyl4 = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM( "Knock_count_cyl4"), 2);
                    if (frmMergeData.AllowCylinderCorrectionBasedOnKnockInformation)
                    {
                        //AddToResumeTable("Checking individual cylinder knock values... ");

                        int iknockcyl1 = 0;
                        int iknockcyl2 = 0;
                        int iknockcyl3 = 0;
                        int iknockcyl4 = 0;
                        try
                        {
                            iknockcyl1 = Convert.ToInt32(knockcountcyl1[0]) * 256 + Convert.ToInt32(knockcountcyl1[1]);
                            iknockcyl2 = Convert.ToInt32(knockcountcyl2[0]) * 256 + Convert.ToInt32(knockcountcyl2[1]);
                            iknockcyl3 = Convert.ToInt32(knockcountcyl3[0]) * 256 + Convert.ToInt32(knockcountcyl3[1]);
                            iknockcyl4 = Convert.ToInt32(knockcountcyl4[0]) * 256 + Convert.ToInt32(knockcountcyl4[1]);
                        }
                        catch (Exception E)
                        {
                            Console.WriteLine("Failed to determine knock counter for cylinders: " + E.Message);
                        }
                        // average knock count for cylinders
                        int iknockaverage = (iknockcyl1 + iknockcyl2 + iknockcyl3 + iknockcyl4) / 4;
                        //AddToResumeTable("Average knock count over all cyinders: " + iknockaverage.ToString());

                        byte[] cylindercompensation = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM("Cyl_komp!"), (uint)m_trionicFileInformation.GetSymbolLength("Cyl_komp!"));
                        if (iknockcyl1 > (iknockaverage * 3))
                        {
                            // add fuel to this cylinder
                            cylindercompensation[0] += 5;
                            //AddToResumeTable("Cylinder 1 had severely more knock than average, increasing fuel compensation slightly");

                        }
                        if (iknockcyl2 > (iknockaverage * 3))
                        {
                            // add fuel to this cylinder
                            cylindercompensation[1] += 5;
                            //AddToResumeTable("Cylinder 2 had severely more knock than average, increasing fuel compensation slightly");
                        }
                        if (iknockcyl3 > (iknockaverage * 3))
                        {
                            // add fuel to this cylinder
                            cylindercompensation[2] += 5;
                            //AddToResumeTable("Cylinder 3 had severely more knock than average, increasing fuel compensation slightly");
                        }
                        if (iknockcyl4 > (iknockaverage * 3))
                        {
                            // add fuel to this cylinder
                            cylindercompensation[3] += 5;
                            //AddToResumeTable("Cylinder 4 had severely more knock than average, increasing fuel compensation slightly");
                        }
                        m_trionicFile.WriteData(cylindercompensation, (uint)m_trionicFileInformation.GetSymbolAddressFlash("Cyl_komp!"));
                    }
                    //<GS-31032010> not allowed in T5.2, should overwite data in insp_mat instead
                    if (frmMergeData.AllowSpotAdaption)
                    {
                        //AddToResumeTable("Checking spot adaption table values...");
                        int cols = 0;
                        int rows = 0;
                        m_trionicFile.GetMapMatrixWitdhByName("Adapt_korr!", out cols, out rows);
                        // read the fuel map as well
                        byte[] insp_mat = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetInjectionMap()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetInjectionMap()));
                        // now handle adaptkorr
                        for (int rt = 0; rt < rows; rt++)
                        {
                            for (int ct = 0; ct < cols; ct++)
                            {
                                //if (adaptggr[rt * cols + ct] > 0)
                                {
                                    byte correctionbyte = adaptkorr[rt * cols + ct];
                                    // offset = 0.75
                                    // correction = 0.001953125; // 1/512
                                    double correctionvalue = (Convert.ToDouble(correctionbyte) * 0.001953125) + 0.75;
                                    // now save it into insp_mat at the correct location

                                    byte valuefrominspmat = insp_mat[rt * cols + ct];//readbytefromfile(m_currentfile, GetSymbolAddress(m_symbols, "Insp_mat!") + (rt * cols) + ct);
                                    correctionvalue *= valuefrominspmat;
                                    byte bcorrvalue = Convert.ToByte(correctionvalue);
                                    if (bcorrvalue != valuefrominspmat)
                                    {
                                        //AddToResumeTable("Updating injection table at row " + rt.ToString() + " and column " + ct.ToString() + " seting value: " + correctionvalue.ToString());
                                        insp_mat[(rt * cols) + ct] = bcorrvalue;
                                        //writebyteinfile(m_currentfile, GetSymbolAddress(m_symbols, "Insp_mat!") + (rt * cols) + ct, Convert.ToByte(correctionvalue));
                                    }
                                }
                            }
                        }
                        m_trionicFile.WriteData(insp_mat, (uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetInjectionMap()));
                    }
                    if (frmMergeData.AllowLongTermFuelTrimAdaption)
                    {
                        // adjust long term fuel trim
                        //AddToResumeTable("Overwriting long term fuel trim in binary");

                        byte[] longtermfueltrim = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM("Adapt_injfaktor!"), (uint)m_trionicFileInformation.GetSymbolLength("Adapt_injfaktor!"));
                        m_trionicFile.WriteData(longtermfueltrim, (uint)m_trionicFileInformation.GetSymbolAddressFlash("Adapt_injfaktor!"));
                    }
                    if (frmMergeData.AllowIdleFuelTrimAdaption)
                    {
                        // adjust long term fuel trim
                        //AddToResumeTable("Overwriting idle fuel trim in binary");
                        byte[] idlefueltrim = m_trionicFile.ReadDataFromFile(ofd1.FileName, (uint)m_trionicFileInformation.GetSymbolAddressSRAM("Adapt_inj_imat!"), (uint)m_trionicFileInformation.GetSymbolLength("Adapt_inj_imat!"));
                        m_trionicFile.WriteData(idlefueltrim, (uint)m_trionicFileInformation.GetSymbolAddressFlash("Adapt_inj_imat!"));
                    }
                    if (frmMergeData.AllowIgnitionAdaptionBasedOnKnockInformation)
                    {
                        //AddToResumeTable("Checking knock count map for excessive knock and retarding ignition timing");

                        // read knock map values and adjust timing accordingly
                        int cols = 0;
                        int rows = 0;
                        if (m_trionicFileInformation.isSixteenBitTable("Knock_count_map")) rows /= 2;
                        byte[] ign_map_0 = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash("Ign_map_0!"), (uint)m_trionicFileInformation.GetSymbolLength("Ign_map_0!"));
                        for (int rt = 0; rt < rows; rt++)
                        {
                            for (int ct = 0; ct < cols; ct++)
                            {
                                int iknockcount = ((int)knockcountmap[(rt * cols * 2) + (ct * 2)] * 256) + (int)knockcountmap[(rt * cols * 2) + (ct * 2) + 1];
                                if (iknockcount > 5) // at least 5 knocks
                                {
                                    // retard ignition at this point

                                    int ign_map_0_value = Convert.ToInt32(ign_map_0[(rt * cols * 2) + (ct * 2)]) * 256 + Convert.ToInt32(ign_map_0[(rt * cols * 2) + (ct * 2) + 1]);
                                    //Console.WriteLine("Ignition advance at knocking position is " + ign_map_0_value.ToString());
                                    if (iknockcount < 50)
                                    {
                                        ign_map_0_value -= 5; // decrease by .5 degree
                                        //AddToResumeTable("Decreased ignition timing by 0.5 degrees at row " + rt.ToString() + " and column " + ct.ToString() + ", result = " + ign_map_0_value.ToString());
                                    }
                                    else
                                    {
                                        ign_map_0_value -= 10; // decrease by 1 degree
                                        //AddToResumeTable("Decreased ignition timing by 1.0 degrees at row " + rt.ToString() + " and column " + ct.ToString() + ", result = " + ign_map_0_value.ToString());
                                    }
                                    byte b1 = (byte)(ign_map_0_value / 256);
                                    byte b2 = (byte)(ign_map_0_value - ((int)b1 * 256));
                                    ign_map_0[(rt * cols * 2) + (ct * 2)] = b1;
                                    ign_map_0[(rt * cols * 2) + (ct * 2) + 1] = b2;
                                }
                            }
                        }
                        m_trionicFile.WriteData(ign_map_0, (uint)m_trionicFileInformation.GetSymbolAddressFlash("Ign_map_0!"));
                    }
                    //AddToResumeTable("SRAM merge done.");
                    //TuningReport tuningrep = new TuningReport();
                    //tuningrep.DataSource = resumeTuning;
                    //tuningrep.CreateReport();
                    //tuningrep.ShowPreview(defaultLookAndFeel1.LookAndFeel);
                    frmInfoBox info = new frmInfoBox("Data was imported");
                }
            }
        }
Beispiel #13
0
        private void btnHardcodedRPMLimit_ItemClick(object sender, ItemClickEventArgs e)
        {
            /*bool _writeMapToECU = false;
            byte[] ignitionmap;
            ignitionmap = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetIgnitionMap()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap()));

            for (int i = 0; i < ignitionmap.Length; i += 2)
            {
                // get the value from the map
                int advance = Convert.ToInt32(ignitionmap[i]) * 256 + Convert.ToInt32(ignitionmap[i + 1]);
                if (advance > 32000) advance = -(65535 - advance);
                if (advance > m_appSettings.GlobalMaximumIgnitionAdvance * 10)
                {
                    Console.WriteLine("We need to cap: " + advance.ToString());
                    advance = Convert.ToInt32(m_appSettings.GlobalMaximumIgnitionAdvance * 10);

                    // write into the map and indicate we have to update the map in the ECU
                    byte b1 = (byte)(advance / 256);
                    byte b2 = (byte)(advance - (int)(advance * 256));
                    ignitionmap[i] = b1;
                    ignitionmap[i + 1] = b2;
                    _writeMapToECU = true;
                }
            }
            if (_writeMapToECU)
            {
                // test dump to console
                m_trionicFile.WriteData(ignitionmap, (uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetIgnitionMap()));
            }*/

            // get all files from the library, open them and check hardcoded RPM limit detection algorithm
            /*string libPath = Application.StartupPath + "\\Binaries";

            if (Directory.Exists(libPath))
            {
                string[] filesinLibrary = Directory.GetFiles(libPath, "*.bin");
                foreach (string libFile in filesinLibrary)
                {
                    OpenWorkingFile(libFile);
                    // get hard & soft rpm limit
                    int hardRPMLimit = m_trionicFile.GetHardcodedRPMLimit(m_trionicFileInformation.Filename);
                    int hardRPMLimitTwo = m_trionicFile.GetHardcodedRPMLimitTwo(m_trionicFileInformation.Filename);
                    int softRPMLimit = m_trionicFile.GetSymbolAsInt("Rpm_max!") * 10;
                    Console.WriteLine(Path.GetFileName(libFile) + " softrpm: " + softRPMLimit.ToString() + " hardrpm: " + hardRPMLimit.ToString() + " hardrpm2: " + hardRPMLimitTwo.ToString() + " " + "T55: " + props.IsTrionic55.ToString());
                }
            }*/

            frmRpmLimiterWizard rpmWiz = new frmRpmLimiterWizard();
            if (m_trionicFile != null)
            {
                if (m_trionicFile.Exists())
                {
                    if (props.IsTrionic55)
                    {
                        int hardRPMLimit = m_trionicFile.GetHardcodedRPMLimit(m_trionicFileInformation.Filename);
                        if (hardRPMLimit > 0)
                        {
                            rpmWiz.HardcodedRPMLimit = hardRPMLimit;
                            rpmWiz.SoftwareRPMLimit = m_trionicFile.GetSymbolAsInt("Rpm_max!") * 10;
                            if (rpmWiz.ShowDialog() == DialogResult.OK)
                            {
                                if (rpmWiz.HardcodedRPMLimit > 7500)
                                {
                                    //TODO: <GS-04042011> We should disable diagnostics services when rpm goes as high as this!
                                }
                                m_trionicFile.SetHardcodedRPMLimit(m_trionicFileInformation.Filename, rpmWiz.HardcodedRPMLimit);
                                if (m_trionicFileInformation.GetSymbolAddressFlash("Rpm_max!") > 0)
                                {
                                    byte[] rpmMax = new byte[2];
                                    int rpmLimit = rpmWiz.SoftwareRPMLimit / 10;
                                    int rpm1 = rpmLimit / 256;
                                    int rpm2 = rpmLimit - (rpm1 * 256);
                                    rpmMax.SetValue(Convert.ToByte(rpm1), 0);
                                    rpmMax.SetValue(Convert.ToByte(rpm2), 1);
                                    m_trionicFile.WriteData(rpmMax, (uint)m_trionicFileInformation.GetSymbolAddressFlash("Rpm_max!"));
                                }

                                m_trionicFile.UpdateChecksum();

                                frmInfoBox info = new frmInfoBox("RPM limiters have been changed");

                            }
                        }
                        else
                        {
                            frmInfoBox info = new frmInfoBox("This file is not supported by this wizard");
                        }
                    }
                    else
                    {
                        frmInfoBox info = new frmInfoBox("Trionic 5.2 files are not supported by this wizard");
                    }
                }
            }
        }
Beispiel #14
0
        private void btnFreeTune_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // create a backup!
            // start the parameter screen (user can enter turbo, injector, mapsensor, peak torque and peak power)
            // start the freetune wizard
            frmFreeTuneSettings tunset = new frmFreeTuneSettings();
            Trionic5Properties props = m_trionicFile.GetTrionicProperties();
            tunset.SetMapSensorType(props.MapSensorType);
            tunset.SetInjectorType(props.InjectorType);
            tunset.SetTurboType(props.TurboType);
            ECUFileType fileType = m_trionicFile.DetermineFileType();
            int frek230 = m_trionicFile.GetSymbolAsInt("Frek_230!");
            int frek250 = m_trionicFile.GetSymbolAsInt("Frek_250!");

            int knockTime = m_trionicFile.GetSymbolAsInt("Knock_matrix_time!");
            tunset.SetKnockTime(knockTime);
            int rpmLimit = m_trionicFile.GetSymbolAsInt("Rpm_max!");
            tunset.SetRPMLimiter(rpmLimit);

            if (fileType == ECUFileType.Trionic52File)
            {
                if (frek230 == 728 || frek250 == 935)
                {
                    //dtReport.Rows.Add("APC valve type: Trionic 5");
                    tunset.SetBPCType(BPCType.Trionic5Valve);
                }
                else
                {
                    tunset.SetBPCType(BPCType.Trionic7Valve);
                }
            }
            else if (fileType == ECUFileType.Trionic55File)
            {
                if (frek230 == 90 || frek250 == 70)
                {
                    tunset.SetBPCType(BPCType.Trionic5Valve);
                }
                else
                {
                    tunset.SetBPCType(BPCType.Trionic7Valve);
                }
            }
            if (tunset.ShowDialog() == DialogResult.OK)
            {
                Trionic5Tuner _tuner = new Trionic5Tuner();
                TuningResult res = _tuner.FreeTuneBinary(m_trionicFile, tunset.GetPeakTorque(), tunset.GetPeakBoost(), tunset.IsTorqueBased, tunset.GetMapSensorType(), tunset.GetTurboType(), tunset.GetInjectorType(), tunset.GetBCVType(), tunset.GetRPMLimiter(), tunset.GetKnockTime());
                string text = "Tuning process completed!";
                if (res == TuningResult.TuningFailedAlreadyTuned)
                {
                    text = "Tuning process aborted, file is already tuned!";
                }
                else if (res == TuningResult.TuningFailedThreebarSensor)
                {
                    text = "Tuning process aborted, file was converted to another mapsensor type before!";
                }
                frmInfoBox info = new frmInfoBox(text);
            }
        }
Beispiel #15
0
        private void btnUSBBDMReadECU_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // read the ECU through USB BDM
            bool _continue = true;
            try
            {
                if (!_globalBDMOpened)
                {
                    if (!BdmAdapter_Open())
                    {
                        frmInfoBox info = new frmInfoBox("Could not connect to the BDM adapter");
                        _continue = false;
                    }
                }
                if (_continue)
                {
                    _globalBDMOpened = true;
                    if (BDMversion == 0)
                    {
                        if (!BdmAdapter_GetVersion(ref BDMversion))
                        {
                            frmInfoBox info = new frmInfoBox("BDM adapter is not compatible");
                            _continue = false;
                        }
                    }
                    if (_continue)
                    {
                        // adapter opened and version is compatible
                        //BdmAdapter_GetVerifyFlash();
                        // read ECU through USB BDM
                        frmECUBDMTypeSelection typesel = new frmECUBDMTypeSelection();
                        if (typesel.ShowDialog() == DialogResult.OK)
                        {
                            SaveFileDialog sfd = new SaveFileDialog();
                            sfd.Filter = "Binary files|*.bin";
                            if (sfd.ShowDialog() == DialogResult.OK)
                            {

                                mRecreateAllScriptResources(Path.GetDirectoryName(sfd.FileName));
                                barEditItem1.EditValue = 0;
                                SetStatusText("Dumping ECU");
                                System.Windows.Forms.Application.DoEvents();
                                _globalECUType = typesel.GetECUType();
                                fio_bytes = 0;
                                if (!BdmAdapter_DumpECU(sfd.FileName, typesel.GetECUType()))
                                {
                                    frmInfoBox info = new frmInfoBox("Failed to dump ECU");
                                }
                                DeleteScripts(Path.GetDirectoryName(sfd.FileName));
                            }
                        }
                    }
                }
                SetStatusText("Idle");
                barEditItem1.EditValue = 0;
                System.Windows.Forms.Application.DoEvents();

            }
            catch (Exception BDMException)
            {
                Console.WriteLine("Failed to dump ECU: " + BDMException.Message);
                frmInfoBox info = new frmInfoBox("Failed to download firmware from ECU: " + BDMException.Message);
            }
        }
Beispiel #16
0
 private void btnPeMicroRead_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (m_appSettings.Read_ecubatchfile != string.Empty)
     {
         try
         {
             if (File.Exists(m_appSettings.Read_ecubatchfile))
             {
                 System.Diagnostics.Process process = new System.Diagnostics.Process();
                 process.StartInfo = new System.Diagnostics.ProcessStartInfo(m_appSettings.Read_ecubatchfile);
                 process.Start();
                 process.WaitForExit();
                 // now, import the resulting S19 file
                 string fromfile = Path.GetDirectoryName(m_appSettings.Read_ecubatchfile) + "\\FROM_ECU.S19";
                 string destfile = Path.GetDirectoryName(m_trionicFileInformation.Filename) + "\\FROM_ECU" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".S19";
                 File.Copy(fromfile, destfile, true);
                 if (m_appSettings.TargetECUReadFile != string.Empty)
                 {
                     File.Copy(fromfile, m_appSettings.TargetECUReadFile, true);
                     OpenWorkingFile(m_appSettings.TargetECUReadFile);
                 }
                 else
                 {
                     OpenWorkingFile(destfile);
                 }
             }
             else
             {
                 frmInfoBox info = new frmInfoBox("Batch file not found. Check parameters");
             }
         }
         catch (Exception E)
         {
             MessageBox.Show(E.Message);
         }
     }
 }
Beispiel #17
0
 private void btnUSBBDMWriteECU_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // program ECU through USB BDM
     bool _continue = true;
     try
     {
         if (!_globalBDMOpened)
         {
             if (!BdmAdapter_Open())
             {
                 frmInfoBox info = new frmInfoBox("Could not connect to the BDM adapter");
                 _continue = false;
             }
         }
         if (_continue)
         {
             _globalBDMOpened = true;
             if (BDMversion == 0)
             {
                 if (!BdmAdapter_GetVersion(ref BDMversion))
                 {
                     frmInfoBox info1 = new frmInfoBox("BDM adapter is not compatible");
                     _continue = false;
                 }
             }
             if (_continue)
             {
                 // adapter opened and version is compatible
                 BdmAdapter_GetVerifyFlash();
                 // program ECU through USB BDM
                 frmECUBDMTypeSelection typesel = new frmECUBDMTypeSelection();
                 if (typesel.ShowDialog() == DialogResult.OK)
                 {
                     OpenFileDialog ofd = new OpenFileDialog();
                     ofd.Filter = "Binary files|*.bin";
                     ofd.Multiselect = false;
                     if (ofd.ShowDialog() == DialogResult.OK)
                     {
                         mRecreateAllScriptResources(Path.GetDirectoryName(ofd.FileName));
                         fio_bytes = 0;
                         SetStatusText("Erasing ECU");
                         _globalECUType = typesel.GetECUType();
                         BdmAdapter_EraseECU(typesel.GetECUType());
                         SetStatusText("Flashing ECU");
                         Thread.Sleep(100);
                         BdmAdapter_FlashECU(ofd.FileName, typesel.GetECUType());
                         SetStatusText("Resetting ECU");
                         Thread.Sleep(100);
                         DeleteScripts(Path.GetDirectoryName(ofd.FileName));
                     }
                 }
             }
         }
         SetStatusText("Idle");
         barEditItem1.EditValue = 0;
         System.Windows.Forms.Application.DoEvents();
     }
     catch (Exception BDMException)
     {
         Console.WriteLine("Failed to program ECU: " + BDMException.Message);
         frmInfoBox info= new frmInfoBox("Failed to program ECU: " + BDMException.Message);
     }
 }
Beispiel #18
0
        private void btnSaveAs_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (m_trionicFile != null)
            {
                if (m_trionicFile.Exists())
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.CheckFileExists = false;
                    sfd.CheckPathExists = true;
                    sfd.Filter = "Binary file|*.bin|Motorola S record format|*.S19";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        if (!m_trionicFile.ValidateChecksum()) m_trionicFile.UpdateChecksum();
                        if (sfd.FileName.ToUpper().EndsWith("S19"))
                        {
                            srec2bin convert = new srec2bin();
                            if (!convert.ConvertBinToSrec(m_trionicFileInformation.Filename, sfd.FileName))
                            {
                                frmInfoBox info = new frmInfoBox("Failed to convert file to S19 format");
                            }
                        }
                        else
                        {
                            if (m_trionicFileInformation.Filename != sfd.FileName)
                            {
                                File.Copy(m_trionicFileInformation.Filename, sfd.FileName, true);
                            }

                        }
                    }
                }
            }
        }
Beispiel #19
0
        private void btnViewMatrixFromLog_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            // let the user select x axis, y axis and z axis symbols from the logfile
            //
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Trionic 5 logfiles|*.t5l";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string[] alllines = File.ReadAllLines(ofd.FileName);
                avgTable = null;
                System.Windows.Forms.Application.DoEvents();
                DateTime startDate = DateTime.MaxValue;
                DateTime endDate = DateTime.MinValue;
                Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection();
                try
                {
                    //using (StreamReader sr = new StreamReader(ofd.FileName))

                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            bool sfound = false;
                                            foreach (Trionic5Tools.SymbolHelper sh in sc)
                                            {
                                                if (sh.Varname == varname)
                                                {
                                                    sfound = true;
                                                }
                                            }
                                            Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper();
                                            nsh.Varname = varname;
                                            if (!sfound) sc.Add(nsh);
                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                            }
                        }
                    }
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                }
                frmMatrixSelection sel = new frmMatrixSelection();
                sel.SetSymbolList(sc);
                sel.SetXSelection(m_appSettings.LastXAxisFromMatrix);
                sel.SetYSelection(m_appSettings.LastYAxisFromMatrix);
                sel.SetZSelection(m_appSettings.LastZAxisFromMatrix);
                if (sel.ShowDialog() == DialogResult.OK)
                {
                    // get selected for x, y and z
                    int type = sel.GetViewType(); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
                    string x = sel.GetXAxisSymbol();
                    string y = sel.GetYAxisSymbol();
                    string z = sel.GetZAxisSymbol();
                    m_appSettings.LastXAxisFromMatrix = x;
                    m_appSettings.LastYAxisFromMatrix = y;
                    m_appSettings.LastZAxisFromMatrix = z;
                    double xmin = Double.MaxValue;
                    double xmax = Double.MinValue;
                    double ymin = Double.MaxValue;
                    double ymax = Double.MinValue;
                    double zmin = Double.MaxValue;
                    double zmax = Double.MinValue;
                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));

                                            if (value > 65535) value = 0;
                                            if (value < -65535) value = 0;
                                            if (varname == x)
                                            {
                                                // get max and min

                                                if (value > xmax) xmax = value;
                                                if (value < xmin) xmin = value;
                                            }
                                            else if (varname == y)
                                            {
                                                // get max and min
                                                if (value > ymax) ymax = value;
                                                if (value < ymin) ymin = value;
                                            }
                                            else if (varname == z)
                                            {
                                                // get max and min
                                                if (value > zmax) zmax = value;
                                                if (value < zmin) zmin = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                            }
                        }
                    }
                    // now we have it all
                    if (xmin == xmax || ymin == ymax)
                    {
                        frmInfoBox info = new frmInfoBox("No data to display ... x or y axis contains no differentiated values");
                        return;
                    }
                    frmMatrixResult result = new frmMatrixResult();
                    result.SetViewType(type); // <GS-31032011> 0 = mean values, 1 = minimum values, 2 = maximum values
                    // parse the file again and add the points
                    DataTable dtresult = new DataTable();
                    // xmin = -0.8
                    // xmin = 2.01
                    double[] x_values = new double[16];
                    double[] y_values = new double[16];

                    // fill x and y axis
                    for (int i = 0; i < 16; i++)
                    {

                        double xvalue = xmin;
                        if(i>0) xvalue = xmin + i * ((xmax - xmin) / (15));
                        //Console.WriteLine("Adding: " + xvalue.ToString());
                        dtresult.Columns.Add(xvalue.ToString(), Type.GetType("System.Double"));
                        x_values.SetValue(xvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        //double yvalue = ymin + ((ymax - ymin) / i);
                        double yvalue = ymin;
                        if (i > 0) yvalue = ymin + i * ((ymax - ymin) / (15));
                        y_values.SetValue(yvalue, i); //    test: andersom?
                    }
                    for (int i = 0; i < 16; i++)
                    {
                        dtresult.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                    }
                    // table filled
                    double _lastX = 0;
                    double _lastY = 0;
                    double _lastZ = 0;

                    //using (StreamReader sr = new StreamReader(ofd.FileName))
                    {
                        //string line = string.Empty;
                        char[] sep = new char[1];
                        char[] sep2 = new char[1];
                        //int linecount = 0;
                        sep.SetValue('|', 0);
                        sep2.SetValue('=', 0);
                        //while ((line = sr.ReadLine()) != null)
                        foreach(string line in alllines)
                        {
                            string[] values = line.Split(sep);
                            if (values.Length > 0)
                            {
                                try
                                {
                                    //dd/MM/yyyy HH:mm:ss
                                    //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                    string dtstring = (string)values.GetValue(0);
                                    DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                    if (dt > endDate) endDate = dt;
                                    if (dt < startDate) startDate = dt;
                                    for (int t = 1; t < values.Length; t++)
                                    {
                                        string subvalue = (string)values.GetValue(t);
                                        string[] subvals = subvalue.Split(sep2);
                                        if (subvals.Length == 2)
                                        {
                                            string varname = (string)subvals.GetValue(0);
                                            double value = ConvertToDouble((string)subvals.GetValue(1));
                                            if (varname == x)
                                            {
                                                _lastX = value;
                                            }
                                            else if (varname == y)
                                            {
                                                _lastY = value;
                                            }
                                            else if (varname == z)
                                            {
                                                _lastZ = value;
                                            }

                                        }
                                    }
                                }
                                catch (Exception pE)
                                {
                                    Console.WriteLine(pE.Message);
                                }
                                // add point to the datatable
                                AddPointToDataTable(dtresult, _lastX, _lastY, _lastZ, xmin, xmax, ymin, ymax, zmin, zmax, type);
                            }
                        }
                    }
                    result.MaxValue = zmax;
                    result.MinValue = zmin;
                    result.SetXAxis(x_values);
                    result.SetYAxis(y_values);
                    result.SetXAxisName(x);
                    result.SetYAxisName(y);
                    result.SetZAxisName(z);
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy) result.UseNewMapViewer = true;
                    result.SetTable(dtresult);
                    string typedescr = " (Mean values)";
                    if (type == 1) typedescr = " (Minimum values)";
                    else if (type == 1) typedescr = " (Maximum values)";
                    result.Text = "Matrix [" + x + " : " + y + " : " + z + "]" + typedescr;
                    //result.ShowDialog();
                    byte[] m_map_content = new byte[16 * 16 * 2];
                    int idx = 0;
                    for (int i = 15; i >= 0; i--)
                    {
                        foreach (object o in dtresult.Rows[i].ItemArray)
                        {
                            double value = Convert.ToDouble(o);
                            // now convert to int * 100
                            Int32 ivalue = 0;
                            try
                            {
                                ivalue = Convert.ToInt32(value * 100);
                            }
                            catch (Exception E)
                            {
                                Console.WriteLine("Failed to convert to integer value: " + value.ToString());
                            }
                            byte b1 = 0;
                            byte b2 = 0;
                            try
                            {
                                b1 = Convert.ToByte(ivalue / 256);
                                b2 = Convert.ToByte(ivalue - (int)b1 * 256);
                            }
                            catch (Exception E)
                            {
                                Console.WriteLine("Failed to convert to byte value + " + ivalue.ToString());
                            }

                            m_map_content[idx++] = b1;
                            m_map_content[idx++] = b2;
                        }
                    }
                    //<GS-28102010> for test, start a mapviewer as well
                    result.ShowDialog();
                    //StartResultViewerForMatrix(x_values, y_values, x, y, z, dtresult, m_map_content);
                }
            }
        }
Beispiel #20
0
        private void btnSplitBinaryFiles_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (m_trionicFile.GetFileInfo().Filename != "")
            {
                if (File.Exists(m_trionicFile.GetFileInfo().Filename))
                {
                    string path = Path.GetDirectoryName(m_trionicFile.GetFileInfo().Filename);
                    FileInfo fi = new FileInfo(m_trionicFile.GetFileInfo().Filename);
                    FileStream fs = File.Create(path + "\\chip2.bin");
                    BinaryWriter bw = new BinaryWriter(fs);
                    FileStream fs2 = File.Create(path + "\\chip1.bin");
                    BinaryWriter bw2 = new BinaryWriter(fs2);
                    FileStream fsi1 = File.OpenRead(m_trionicFile.GetFileInfo().Filename);
                    BinaryReader br1 = new BinaryReader(fsi1);
                    bool toggle = false;
                    for (int tel = 0; tel < fi.Length; tel++)
                    {
                        Byte ib1 = br1.ReadByte();
                        if (!toggle)
                        {
                            toggle = true;
                            bw.Write(ib1);
                        }
                        else
                        {
                            toggle = false;
                            bw2.Write(ib1);
                        }
                    }

                    bw.Close();
                    bw2.Close();
                    fs.Close();
                    fs2.Close();
                    fsi1.Close();
                    br1.Close();
                    frmInfoBox info = new frmInfoBox("File split to chip1.bin and chip2.bin");
                }
            }
        }
Beispiel #21
0
        private void ConvertFileToDif(string filename, bool AutoExport)
        {
            System.Windows.Forms.Application.DoEvents();
            DateTime startDate = DateTime.MaxValue;
            DateTime endDate = DateTime.MinValue;
            try
            {
                Trionic5Tools.SymbolCollection sc = new Trionic5Tools.SymbolCollection();
                string[] alllines = File.ReadAllLines(filename);
                //using (StreamReader sr = new StreamReader(filename))
                {
                    //string line = string.Empty;
                    char[] sep = new char[1];
                    char[] sep2 = new char[1];
                    //int linecount = 0;
                    sep.SetValue('|', 0);
                    sep2.SetValue('=', 0);
                    //while ((line = sr.ReadLine()) != null)
                    foreach(string line in alllines)
                    {
                        string[] values = line.Split(sep);
                        if (values.Length > 0)
                        {
                            try
                            {
                                //dd/MM/yyyy HH:mm:ss
                                //string logline = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "|";

                                string dtstring = (string)values.GetValue(0);
                                DateTime dt = new DateTime(Convert.ToInt32(dtstring.Substring(6, 4)), Convert.ToInt32(dtstring.Substring(3, 2)), Convert.ToInt32(dtstring.Substring(0, 2)), Convert.ToInt32(dtstring.Substring(11, 2)), Convert.ToInt32(dtstring.Substring(14, 2)), Convert.ToInt32(dtstring.Substring(17, 2)));
                                if (dt > endDate) endDate = dt;
                                if (dt < startDate) startDate = dt;
                                for (int t = 1; t < values.Length; t++)
                                {
                                    string subvalue = (string)values.GetValue(t);
                                    string[] subvals = subvalue.Split(sep2);
                                    if (subvals.Length == 2)
                                    {
                                        string varname = (string)subvals.GetValue(0);
                                        bool sfound = false;
                                        foreach (Trionic5Tools.SymbolHelper sh in sc)
                                        {
                                            if (sh.Varname == varname)
                                            {
                                                sfound = true;
                                            }
                                        }
                                        Trionic5Tools.SymbolHelper nsh = new Trionic5Tools.SymbolHelper();
                                        nsh.Varname = varname;
                                        if (!sfound) sc.Add(nsh);
                                    }
                                }
                            }
                            catch (Exception pE)
                            {
                                Console.WriteLine(pE.Message);
                            }
                        }
                    }
                }

                if (AutoExport)
                {
                    foreach (Trionic5Tools.SymbolHelper sh in sc)
                    {
                        sh.Color = GetColorFromRegistry(sh.Varname);
                    }
                    DifGenerator difgen = new DifGenerator();

                    difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000;
                    difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000;
                    difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000;
                    difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000;
                    difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol;
                    difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;

                    difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                    System.Windows.Forms.Application.DoEvents();
                    try
                    {
                        difgen.ConvertFileToDif(filename, sc, startDate, endDate, true, true);
                    }
                    catch (Exception expE1)
                    {
                        Console.WriteLine(expE1.Message);
                    }
                }
                else
                {

                    // show selection screen
                    frmPlotSelection plotsel = new frmPlotSelection();
                    foreach (Trionic5Tools.SymbolHelper sh in sc)
                    {
                        if (sh.Varname != "Pgm_status")
                        {
                            plotsel.AddItemToList(sh.Varname);
                        }
                    }
                    plotsel.Startdate = startDate;
                    plotsel.Enddate = endDate;
                    plotsel.SelectAllSymbols();
                    if (plotsel.ShowDialog() == DialogResult.OK)
                    {
                        sc = plotsel.Sc;
                        endDate = plotsel.Enddate;
                        startDate = plotsel.Startdate;
                        DifGenerator difgen = new DifGenerator();
                        LogFilters filterhelper = new LogFilters();
                        difgen.SetFilters(filterhelper.GetFiltersFromRegistry());
                        difgen.LowAFR = m_appSettings.WidebandLowAFR / 1000;
                        difgen.HighAFR = m_appSettings.WidebandHighAFR / 1000;
                        difgen.MaximumVoltageWideband = m_appSettings.WidebandHighVoltage / 1000;
                        difgen.MinimumVoltageWideband = m_appSettings.WidebandLowVoltage / 1000;
                        difgen.WidebandSymbol = m_appSettings.WidebandLambdaSymbol;
                        difgen.UseWidebandInput = m_appSettings.UseWidebandLambdaThroughSymbol;
                        difgen.onExportProgress += new DifGenerator.ExportProgress(difgen_onExportProgress);
                        try
                        {
                            if (difgen.ConvertFileToDif(filename, sc, startDate, endDate, m_appSettings.InterpolateLogWorksTimescale, true))
                            {
                                //difgen.ConvertFileToDif(filename, sc, startDate, endDate, false, false);
                                StartLogWorksWithCurrentFile(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".dif");
                            }
                            else
                            {
                                frmInfoBox info = new frmInfoBox("No data was found to export!");
                            }
                        }
                        catch (Exception expE2)
                        {
                            Console.WriteLine(expE2.Message);
                        }
                    }
                    TimeSpan ts = new TimeSpan(endDate.Ticks - startDate.Ticks);
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
        }
Beispiel #22
0
 private void btnStartManual_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // start the user manual!
     try
     {
         if (File.Exists(System.Windows.Forms.Application.StartupPath + "//T5Suite2 User Manual.pdf"))
         {
             System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "//T5Suite2 User Manual.pdf");
         }
         else
         {
             frmInfoBox info = new frmInfoBox("User manual could not be found or opened!");
         }
     }
     catch (Exception E)
     {
         Console.WriteLine(E.Message);
     }
 }
Beispiel #23
0
 private void DownloadSRAMCANUSB()
 {
     //Download sram snapshot from the ECU
     if (_ecuConnection.Opened)
     {
         if (m_CurrentWorkingProject != "")
         {
             if (!Directory.Exists(m_appSettings.ProjectFolder + "\\" + m_CurrentWorkingProject + "\\Snapshots")) Directory.CreateDirectory(m_appSettings.ProjectFolder + "\\" + m_CurrentWorkingProject + "\\Snapshots");
             string filename = m_appSettings.ProjectFolder + "\\" + m_CurrentWorkingProject + "\\Snapshots\\Snapshot" + DateTime.Now.ToString("MMddyyyyHHmmss") + ".RAM";
             _ecuConnection.DumpSRAM(filename);
         }
         else
         {
             SaveFileDialog sfd = new SaveFileDialog();
             sfd.Filter = "SRAM snapshots|*.ram";
             // set the default filename and directory
             sfd.InitialDirectory = Path.GetDirectoryName(m_trionicFileInformation.Filename);
             sfd.FileName = "Snapshot-" + Path.GetFileNameWithoutExtension(m_trionicFileInformation.Filename) + "-" + DateTime.Now.ToString("MMddyyyyHHmmss") + ".RAM";
             if (sfd.ShowDialog() == DialogResult.OK)
             {
                 _ecuConnection.DumpSRAM(sfd.FileName);
             }
         }
     }
     else
     {
         frmInfoBox info = new frmInfoBox("A canbus connection is needed to create a SRAM snapshot");
     }
 }
Beispiel #24
0
 private void btnStartT5Manual_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     // start the T5 documentation
     try
     {
         if (File.Exists(System.Windows.Forms.Application.StartupPath + "//Trionic 5.pdf"))
         {
             System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "//Trionic 5.pdf");
         }
         else
         {
             frmInfoBox info = new frmInfoBox("Trionic 5 documentation could not be found or opened!");
         }
     }
     catch (Exception E2)
     {
         Console.WriteLine(E2.Message);
     }
 }
Beispiel #25
0
        private void gridViewSymbols_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                // start the selected row
                try
                {
                    int[] selectedrows = gridViewSymbols.GetSelectedRows();
                    int grouplevel = gridViewSymbols.GetRowLevel((int)selectedrows.GetValue(0));
                    if (grouplevel >= gridViewSymbols.GroupCount)
                    {
                        if (gridViewSymbols.GetFocusedRow() is Trionic5Tools.SymbolHelper)
                        {
                            Trionic5Tools.SymbolHelper sh = (Trionic5Tools.SymbolHelper)gridViewSymbols.GetFocusedRow();
                            Console.WriteLine("Symbol:" + sh.Varname);
                            if (!_ecuConnection.Opened && !sh.Varname.Contains("!") && m_trionicFileInformation.SRAMfilename == "")
                            {
                                frmInfoBox info = new frmInfoBox("Symbol resides in SRAM and you are in offline mode. T5Suite is unable to fetch this symboldata in offline mode");
                            }
                            else
                            {
                                StartTableViewer(sh.Varname);
                            }
                        }
                    }
                }
                catch (Exception E)
                {
                    Console.WriteLine(E.Message);
                }

            }
        }
Beispiel #26
0
        private void btnSynchronizeMaps_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_ecuConnection.Opened)
            {
                DateTime dt_ecu = _ecuConnection.GetMemorySyncDate();
                DateTime dt_file = m_trionicFile.GetMemorySyncDate();
                if (dt_ecu > dt_file)
                {
                    // sync ecu to file without changing sync dates
                    SyncMaps(SyncOption.ToFile);
                    m_trionicFile.SetMemorySyncDate(dt_ecu);

                }
                else if (dt_file > dt_ecu)
                {
                    // sync file to ecu without changing sync dates
                    SyncMaps(SyncOption.ToECU);
                    _ecuConnection.SetMemorySyncDate(dt_file);
                }
                else
                {
                    frmInfoBox info = new frmInfoBox("Synchronization not needed");
                }
            }
            else
            {
                    frmInfoBox info = new frmInfoBox("No connection to ECU available");
            }
        }
Beispiel #27
0
 private void ShowChristmasWish()
 {
     int newyear = DateTime.Now.Year + 1;
     frmInfoBox info = new frmInfoBox("Merry christmas and a happy " + newyear.ToString("D4") + "\rDilemma");
 }
Beispiel #28
0
        private void btnTuneToStage3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Trionic5Tuner _tuner = new Trionic5Tuner();
            _tuner.AutoUpdateChecksum = m_appSettings.AutoChecksum;
            frmInfoBox info;
            TuningResult result = _tuner.TuneFileToStage(3, m_trionicFile.GetFileInfo().Filename, m_trionicFile, m_trionicFileInformation, false);
            switch (result)
            {
                case TuningResult.TuningFailed:
                    info = new frmInfoBox("Tuning of the binary file failed!");
                    break;
                case TuningResult.TuningFailedAlreadyTuned:
                    info = new frmInfoBox("Your binary file was already tuned!");
                    break;
                case TuningResult.TuningFailedThreebarSensor:
                    info = new frmInfoBox("Your binary file was already tuned (3 bar sensor)!");
                    break;
                case TuningResult.TuningSuccess:
                    // show report
                    props = m_trionicFile.GetTrionicProperties();
                    //info = new frmInfoBox("Your binary file was succesfully tuned to stage 3");
                    TuningReport tuningrep = new TuningReport();
                    tuningrep.ReportTitle = "Tuning report (stage III)";
                    tuningrep.SetDataSource(_tuner.Resume.ResumeTuning);
                    tuningrep.CreateReport();
                    tuningrep.ShowReportPreview(defaultLookAndFeel1.LookAndFeel);
                    break;
                case TuningResult.TuningCancelled:
                    // show report
                    info = new frmInfoBox("Tuning process cancelled by user");
                    break;

            }
        }
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     // show the details for this transaction (including data, meaning 2 mapviewers showing the details)
     frmInfoBox info = new frmInfoBox("Still needs to be implemented");
 }
Beispiel #30
0
        private void btnConnectECU_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!_ecuConnection.Opened)
            {
                StartECUConnection();

                btnConnectECU.Caption = "Disconnect ECU";
                if (!_ecuConnection.Opened)
                {
                    btnConnectECU.Caption = "Connect ECU";
                    //btnSwitchMode.Caption = "Go online";
                    //barStaticItem5.Caption = "Mode: offline";
                    _ECUmode = OperationMode.ModeOffline;
                    SetOnlineButtons(false);
                    UpdateOnlineOffLineTexts();
                    Application.DoEvents();
                    frmInfoBox info = new frmInfoBox("Failed to open canbus connection!");
                }
            }
            else
            {
                //<GS-25032010>
                if (btnConnectECU.Caption == "Connect ECU")
                {
                    //StartECUConnection();
                    btnConnectECU.Caption = "Disonnect ECU";
                    _ECUmode = OperationMode.ModeOnline;
                    SetOnlineButtons(true);

                    UpdateOnlineOffLineTexts();
                    // switch mode
                }
                else
                {
                    //StopECUConnection();
                    StopOnlineMode();
                    _ECUmode = OperationMode.ModeOffline;
                    SetOnlineButtons(false);
                    UpdateOnlineOffLineTexts();
                    btnConnectECU.Caption = "Connect ECU";
                }
            }
        }