Пример #1
0
 private void UpdateMapViewer(IMapViewer viewer, int tabwidth, bool sixteenbits)
 {
     viewer.ShowTable(tabwidth, sixteenbits);
 }
Пример #2
0
 private void UpdateViewer(IMapViewer viewer, int tabwidth, bool sixteenbits)
 {
     try
     {
         this.Invoke(m_DelegateUpdateMapViewer, viewer, tabwidth, sixteenbits);
     }
     catch (Exception E)
     {
         logger.Debug(E.Message);
     }
 }
Пример #3
0
        private void TryToAddOpenLoopTables(IMapViewer mv)
        {
            try
            {
                //if (mv.Map_name == "BFuelCal.Map" || mv.Map_name == "IgnNormCal.Map" || mv.Map_name == "TargetAFR" || mv.Map_name == "FeedbackAFR" || mv.Map_name == "FeedbackvsTargetAFR" )
                //{

                    byte[] open_loop = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "LambdaCal.MaxLoadNormTab"), GetSymbolLength(m_symbols, "LambdaCal.MaxLoadNormTab"));
                    if (mv.Map_name == "IgnE85Cal.fi_AbsMap" || mv.Map_name == "BFuelCal.E85Map")
                    {
                        open_loop = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, "LambdaCal.MaxLoadE85Tab"), GetSymbolLength(m_symbols, "LambdaCal.MaxLoadE85Tab"));
                    }
                    mv.Open_loop = open_loop;
                    mv.StandardFill = m_appSettings.StandardFill;
            /*                    byte[] open_loop_knock = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetOpenLoopKnockMap()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetOpenLoopKnockMap()));
                    mv.Open_loop_knock = open_loop_knock;*/
                    //TODO: add counters as well.
                    //mv.Afr_counter = AFRMapCounterInMemory;
                //}
            }
            catch (Exception E)
            {
                logger.Debug(E.Message);
            }
        }
Пример #4
0
 void tuningpackage_onSymbolSave(object sender, IMapViewer.SaveSymbolEventArgs e)
 {
     // mapviewer requested to save data into a tuning package
     // how on earth are we going to refresh the data in the tuning package edit window?
     if (tunpackeditWindow != null)
     {
         // refresh the data in the window to reflect the changes made in the mapviewer
         if (e.Filename == tunpackeditWindow.TuningPackageFilename)
         {
             string symbolData = string.Empty;
             foreach (byte b in e.SymbolDate)
             {
                 symbolData += b.ToString("X2") + ",";
             }
             tunpackeditWindow.SetDataForSymbol(e.SymbolName, symbolData);
         }
     }
 }
Пример #5
0
        void tabdet_onSymbolSave(object sender, IMapViewer.SaveSymbolEventArgs e)
        {
            if (sender is IMapViewer)
            {
                // juiste filename kiezen
                IMapViewer tabdet = (IMapViewer)sender;
               /* if (e.Filename == m_currentfile)
                {
                    MarkSymbolChanged(e.SymbolName);
                }*/

                string note = string.Empty;
                if (m_appSettings.RequestProjectNotes && m_CurrentWorkingProject != "")
                {
                    //request a small note from the user in which he/she can denote a description of the change
                    frmChangeNote changenote = new frmChangeNote();
                    changenote.ShowDialog();
                    note = changenote.Note;
                }

                savedatatobinary(e.SymbolAddress, e.SymbolLength, e.SymbolDate, e.Filename, true, note);
                UpdateChecksum(e.Filename);
                if (!tabdet.IsRAMViewer && m_connectedToECU) // <GS-12102010> don't refresh from binary when in online mode
                {
                    tabdet.Map_content = readdatafromfile(e.Filename, e.SymbolAddress, e.SymbolLength);
                }
            }
        }
Пример #6
0
 void tabdet_onWriteToSRAM(object sender, IMapViewer.WriteToSRAMEventArgs e)
 {
     // write data to SRAM, check for valid connection first
     bool writepossible = false;
     try
     {
         //if (flash != null)
         {
             if (CheckCANConnectivity())
             {
                 writepossible = true;
                 m_prohibitReading = true;
                 try
                 {
                     WriteMapToSRAM(e.Mapname, e.Data, true);
                 }
                 catch (Exception E)
                 {
                     logger.Debug("Failed to write to SRAM: " + E.Message);
                 }
             }
         }
         if (!writepossible)
         {
             frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to write data to the ECU");
         }
     }
     catch (Exception E)
     {
         logger.Debug("Failed to write map to SRAM: " + E.Message);
     }
     m_prohibitReading = false;
 }
Пример #7
0
 void tabdet_onSymbolRead(object sender, IMapViewer.ReadSymbolEventArgs e)
 {
     //<GS-12102010> refresh data from file
     if (sender is IMapViewer)
     {
         IMapViewer mv = (IMapViewer)sender;
         mv.Map_content = readdatafromfile(e.Filename, (int)GetSymbolAddress(m_symbols, e.SymbolName), GetSymbolLength(m_symbols, e.SymbolName));
         int cols = 0;
         int rows = 0;
         GetTableMatrixWitdhByName(e.Filename, m_symbols, e.SymbolName, out cols, out rows);
         mv.IsRAMViewer = false;
         mv.OnlineMode = false;
         mv.ShowTable(cols, isSixteenBitTable(e.SymbolName));
         mv.IsRAMViewer = false;
         mv.OnlineMode = false;
         System.Windows.Forms.Application.DoEvents();
     }
 }
Пример #8
0
 void tabdet_onSelectionChanged(object sender, IMapViewer.CellSelectionChangedEventArgs e)
 {
     //<GS-22042010>
     // sync mapviewers maybe?
     if (m_appSettings.SynchronizeMapviewers)
     {
         // andere cell geselecteerd, doe dat ook bij andere viewers met hetzelfde symbool (mapname)
         foreach (DockPanel pnl in dockManager1.Panels)
         {
             foreach (Control c in pnl.Controls)
             {
                 if (c is IMapViewer)
                 {
                     if (c != sender)
                     {
                         IMapViewer vwr = (IMapViewer)c;
                         if (vwr.Map_name == e.Mapname)
                         {
                             vwr.SelectCell(e.Rowhandle, e.Colindex);
                             vwr.Invalidate();
                         }
                     }
                 }
                 else if (c is DockPanel)
                 {
                     DockPanel tpnl = (DockPanel)c;
                     foreach (Control c2 in tpnl.Controls)
                     {
                         if (c2 is IMapViewer)
                         {
                             if (c2 != sender)
                             {
                                 IMapViewer vwr2 = (IMapViewer)c2;
                                 if (vwr2.Map_name == e.Mapname)
                                 {
                                     vwr2.SelectCell(e.Rowhandle, e.Colindex);
                                     vwr2.Invalidate();
                                 }
                             }
                         }
                     }
                 }
                 else if (c is ControlContainer)
                 {
                     ControlContainer cntr = (ControlContainer)c;
                     foreach (Control c3 in cntr.Controls)
                     {
                         if (c3 is IMapViewer)
                         {
                             if (c3 != sender)
                             {
                                 IMapViewer vwr3 = (IMapViewer)c3;
                                 if (vwr3.Map_name == e.Mapname)
                                 {
                                     vwr3.SelectCell(e.Rowhandle, e.Colindex);
                                     vwr3.Invalidate();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #9
0
        void tabdet_onReadFromSRAM(object sender, IMapViewer.ReadFromSRAMEventArgs e)
        {
            // read data from SRAM through CAN bus and refresh the viewer with it
            bool writepossible = false;
            try
            {
                m_prohibitReading = true;
                //if (flash != null)
                {
                    if (CheckCANConnectivity())
                    {
                        writepossible = true;
                        //T5 byte[] resulttemp = tcan.readRAM((ushort)GetSymbolAddressSRAM(m_symbols, e.Mapname), (uint)GetSymbolLength(m_symbols, e.Mapname) + 1);
                        int symbolindex = GetSymbolNumberFromRealtimeList(GetSymbolNumber(m_symbols, e.Mapname), e.Mapname);
                        if (symbolindex >= 0)
                        {
                            //logger.Debug("Reading " + symbolindex.ToString() + " " + e.Mapname);
                            System.Windows.Forms.Application.DoEvents();
                            foreach (SymbolHelper shs in m_symbols)
                            {
                                if (shs.Varname == e.Mapname || shs.Userdescription == e.Mapname)
                                {
                                    try
                                    {
                                        byte[] result = ReadMapFromSRAM(shs, true);
                                        int rows = 0;
                                        int cols = 0;
                                        foreach (DockPanel pnl in dockManager1.Panels)
                                        {
                                            if (pnl.Text.StartsWith("Symbol: ") || pnl.Text.StartsWith("SRAM"))
                                            {
                                                foreach (Control c in pnl.Controls)
                                                {
                                                    if (c is IMapViewer)
                                                    {
                                                        IMapViewer vwr = (IMapViewer)c;
                                                        if (vwr.Map_name == e.Mapname)
                                                        {
                                                            vwr.Map_content = result;
                                                            GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                                            if ((m_connectedToECU && !m_appSettings.UseNewMapViewer))
                                                            {
                                                                vwr.IsRAMViewer = true;
                                                            }
                                                            else
                                                            {
                                                                vwr.IsRAMViewer = false;
                                                            }

                                                            vwr.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                            if ((m_connectedToECU && m_appSettings.UseNewMapViewer) /*|| m_appSettings.DebugMode*/)
                                                            {
                                                                vwr.OnlineMode = true;
                                                                vwr.IsRAMViewer = true;
                                                            }
                                                            else
                                                            {
                                                                vwr.IsRAMViewer = false;
                                                            }
                                                        }
                                                    }
                                                    else if (c is DockPanel)
                                                    {
                                                        DockPanel tpnl = (DockPanel)c;
                                                        foreach (Control c2 in tpnl.Controls)
                                                        {
                                                            if (c2 is IMapViewer)
                                                            {
                                                                IMapViewer vwr2 = (IMapViewer)c2;
                                                                if (vwr2.Map_name == e.Mapname)
                                                                {
                                                                    vwr2.Map_content = result;
                                                                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                                                    if ((m_connectedToECU && !m_appSettings.UseNewMapViewer))
                                                                    {
                                                                        vwr2.IsRAMViewer = true;
                                                                    }
                                                                    else
                                                                    {
                                                                        vwr2.IsRAMViewer = false;
                                                                    }

                                                                    vwr2.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                                    if ((m_connectedToECU && m_appSettings.UseNewMapViewer) /*|| m_appSettings.DebugMode*/)
                                                                    {
                                                                        vwr2.OnlineMode = true;
                                                                        vwr2.IsRAMViewer = true;
                                                                    }
                                                                    else
                                                                    {
                                                                        vwr2.IsRAMViewer = false;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else if (c is ControlContainer)
                                                    {
                                                        ControlContainer cntr = (ControlContainer)c;
                                                        foreach (Control c3 in cntr.Controls)
                                                        {
                                                            if (c3 is IMapViewer)
                                                            {
                                                                IMapViewer vwr3 = (IMapViewer)c3;
                                                                if (vwr3.Map_name == e.Mapname)
                                                                {
                                                                    vwr3.Map_content = result;
                                                                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                                                    if ((m_connectedToECU && !m_appSettings.UseNewMapViewer))
                                                                    {
                                                                        vwr3.IsRAMViewer = true;
                                                                    }
                                                                    else
                                                                    {
                                                                        vwr3.IsRAMViewer = false;
                                                                    }

                                                                    vwr3.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                                    if ((m_connectedToECU && m_appSettings.UseNewMapViewer) /*|| m_appSettings.DebugMode*/)
                                                                    {
                                                                        vwr3.OnlineMode = true;
                                                                        vwr3.IsRAMViewer = true;
                                                                    }
                                                                    else
                                                                    {
                                                                        vwr3.IsRAMViewer = false;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                            }
                                        }
                                    }
                                    catch (Exception E)
                                    {
                                        logger.Debug("Refresh viewer with SRAM data error: " + E.Message);
                                    }
                                    break;
                                }
                            }

                            /*byte[] result = ReadSymbolFromSRAM((uint)symbolindex);
                            string debugstring = "Data: ";
                            foreach (byte b in result)
                            {
                                debugstring += b.ToString("X2") + " ";
                            }
                            logger.Debug(debugstring);*/
                            //TODO: remove this line
                            //byte[] result = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, e.Mapname), (int)GetSymbolLength(m_symbols, e.Mapname));
                            //TODO: remove this line ^^
                            //MessageBox.Show("Data refreshed for symbol: " + e.Mapname);
                        }
                    }
                    /*else if(m_appSettings.DebugMode)
                    {
                        // only if debug
                        writepossible = true;
                        byte[] result = new byte[GetSymbolLength(m_symbols, e.Mapname)];
                        int rows = 0;
                        int cols = 0;
                        foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                        {
                            if (pnl.Text.StartsWith("Symbol: ") || pnl.Text.StartsWith("SRAM"))
                            {
                                foreach (Control c in pnl.Controls)
                                {
                                    if (c is IMapViewer)
                                    {
                                        IMapViewer vwr = (IMapViewer)c;
                                        if (vwr.Map_name == e.Mapname)
                                        {
                                            vwr.Map_content = result;
                                            GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                            vwr.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                        }
                                    }
                                    else if (c is DevExpress.XtraBars.Docking.DockPanel)
                                    {
                                        DevExpress.XtraBars.Docking.DockPanel tpnl = (DevExpress.XtraBars.Docking.DockPanel)c;
                                        foreach (Control c2 in tpnl.Controls)
                                        {
                                            if (c2 is IMapViewer)
                                            {
                                                IMapViewer vwr2 = (IMapViewer)c2;
                                                if (vwr2.Map_name == e.Mapname)
                                                {
                                                    vwr2.Map_content = result;
                                                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                                    vwr2.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                }
                                            }
                                        }
                                    }
                                    else if (c is DevExpress.XtraBars.Docking.ControlContainer)
                                    {
                                        DevExpress.XtraBars.Docking.ControlContainer cntr = (DevExpress.XtraBars.Docking.ControlContainer)c;
                                        foreach (Control c3 in cntr.Controls)
                                        {
                                            if (c3 is IMapViewer)
                                            {
                                                IMapViewer vwr3 = (IMapViewer)c3;
                                                if (vwr3.Map_name == e.Mapname)
                                                {
                                                    vwr3.Map_content = result;
                                                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, e.Mapname, out cols, out rows);
                                                    vwr3.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                }
                                            }
                                        }
                                    }
                                }

                            }
                        }
                    }*/
                }
                if (!writepossible)
                {
                    frmInfoBox info = new frmInfoBox("An active CAN bus connection is needed to get data from the ECU");
                }
            }
            catch (Exception E)
            {
                logger.Debug("Failed to read MAP from SRAM: " + E.Message);
            }
            m_prohibitReading = false;
        }
Пример #10
0
        void onTargetAFRMapSave(object sender, IMapViewer.SaveSymbolEventArgs e)
        {
            if (sender is IMapViewer)
            {
                IMapViewer tabdet = (IMapViewer)sender;
                // get data from mapviewer

                /*
            if (m_AFRMap != null && m_currentfile != string.Empty)
            {
                int cols = 18;
                int rows = 16;
                string foldername = Path.Combine(Path.GetDirectoryName(m_currentfile), "AFRMaps");
                if (!Directory.Exists(foldername))
                {
                    Directory.CreateDirectory(foldername);
                }
                GetTableMatrixWitdhByName(m_currentfile, m_symbols, "BFuelCal.Map", out cols, out rows);
                m_AFRMap.SaveMap(m_currentfile, cols, rows);
                ShowAfrMAP("TargetAFR", Path.Combine(foldername, Path.GetFileNameWithoutExtension(m_currentfile) + "-targetafr.afr"));
            }                 * */
                if (m_AFRMap != null && m_currentfile != string.Empty)
                {
                    int cols = 18;
                    int rows = 16;
                    string foldername = Path.Combine(Path.GetDirectoryName(m_currentfile), "AFRMaps");
                    if (!Directory.Exists(foldername))
                    {
                        Directory.CreateDirectory(foldername);
                    }
                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, "BFuelCal.Map", out cols, out rows);

                    if (e.SymbolName == "TargetAFR")
                    {
                        // set the new map data
                        m_AFRMap.SaveTargetAFRMap(Path.Combine(foldername, Path.GetFileNameWithoutExtension(m_currentfile) + "-targetafr.afr"), ConvertMapToFloat(e.SymbolDate), cols, rows);
                        m_AFRMap.InitializeMaps(cols * rows, m_currentfile);
                        // reload ... into m_AFRMap structure
                        tabdet.Map_content = m_AFRMap.GetTargetAFRMapinBytes(cols * rows, Path.Combine(foldername, Path.GetFileNameWithoutExtension(m_currentfile) + "-targetafr.afr"));
                    }
                }
                /*
                if (tabdet.Map_name == "FeedbackAFR" || tabdet.Map_name == "FeedbackvsTargetAFR")
                {
                    // only done on clear?
                    if (tabdet.ClearData)
                    {
                        tabdet.ClearData = false;
                        // now clear the entire map
                        string filename = Path.Combine(Path.GetDirectoryName(m_currentfile), Path.GetFileNameWithoutExtension(m_currentfile) + "-AFRFeedbackmap.afr");
                        string filenamecount = Path.Combine(Path.GetDirectoryName(m_currentfile), Path.GetFileNameWithoutExtension(m_currentfile) + "-AFRFeedbackCountermap.afr");
                        if (File.Exists(filename))
                        {
                            File.Delete(filename);
                        }
                        if (File.Exists(filenamecount))
                        {
                            File.Delete(filenamecount);
                        }
                    }
                    // reload data
                    int columns = 0;
                    int rows = 0;
                    GetTableMatrixWitdhByName(m_currentfile, m_symbols, "Insp_mat!", out columns, out rows);
                    AFRMapInMemory = new float[rows * columns];
                    AFRMapCounterInMemory = new int[rows * columns];
                    SaveAFRAndCounterMaps();
                    UpdateFeedbackMaps();
                }*/
            }
        }
Пример #11
0
 void mv_onSurfaceGraphViewChangedEx(object sender, IMapViewer.SurfaceGraphViewChangedEventArgsEx e)
 {
     if (m_appSettings.SynchronizeMapviewers)
     {
         foreach (DockPanel pnl in dockManager1.Panels)
         {
             foreach (Control c in pnl.Controls)
             {
                 if (c is IMapViewer)
                 {
                     if (c != sender)
                     {
                         IMapViewer vwr = (IMapViewer)c;
                         if (vwr.Map_name == e.Mapname)
                         {
                             vwr.SetSurfaceGraphViewEx(e.DepthX, e.DepthY, e.Zoom, e.Rotation, e.Elevation);
                             vwr.Invalidate();
                         }
                     }
                 }
                 else if (c is DockPanel)
                 {
                     DockPanel tpnl = (DockPanel)c;
                     foreach (Control c2 in tpnl.Controls)
                     {
                         if (c2 is IMapViewer)
                         {
                             if (c2 != sender)
                             {
                                 IMapViewer vwr2 = (IMapViewer)c2;
                                 if (vwr2.Map_name == e.Mapname)
                                 {
                                     vwr2.SetSurfaceGraphViewEx(e.DepthX, e.DepthY, e.Zoom, e.Rotation, e.Elevation);
                                     vwr2.Invalidate();
                                 }
                             }
                         }
                     }
                 }
                 else if (c is ControlContainer)
                 {
                     ControlContainer cntr = (ControlContainer)c;
                     foreach (Control c3 in cntr.Controls)
                     {
                         if (c3 is IMapViewer)
                         {
                             if (c3 != sender)
                             {
                                 IMapViewer vwr3 = (IMapViewer)c3;
                                 if (vwr3.Map_name == e.Mapname)
                                 {
                                     vwr3.SetSurfaceGraphViewEx(e.DepthX, e.DepthY, e.Zoom, e.Rotation, e.Elevation);
                                     vwr3.Invalidate();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }