Пример #1
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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #2
0
        void tabdet_onSymbolSave(object sender, IMapViewer.SaveSymbolEventArgs e)
        {
            if (sender is IMapViewer)
            {
                // juiste filename kiezen
                IMapViewer tabdet = (IMapViewer)sender;

                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, true);
                //tabdet.Map_content = readdatafromfile(e.Filename, e.SymbolAddress, e.SymbolLength);
            }
        }
Пример #3
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 (m_connectedToECU)
                    {
                        writepossible = true;
                        m_prohibitReading = true;
                        try
                        {

                            WriteMapToSRAM(e.Mapname, e.Data);
                        }
                        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;
        }
Пример #4
0
        void tabdet_onSymbolRead(object sender, IMapViewer.ReadSymbolEventArgs e)
        {
            // reload data from the file
            IMapViewer tabdet = (IMapViewer)sender;
            tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, tabdet.Map_name);
            tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, tabdet.Map_name);
            Int64 symaddress = GetSymbolAddress(m_symbols, tabdet.Map_name);
            int symlen = GetSymbolLength(m_symbols, tabdet.Map_name);
            int columns = 8;
            int rows = 8;
            int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, tabdet.Map_name, out columns, out rows);
            int address = Convert.ToInt32(symaddress);

            if (tabdet.X_axisvalues.Length > 1) columns = tabdet.X_axisvalues.Length;
            if (tabdet.Y_axisvalues.Length > 1) rows = tabdet.Y_axisvalues.Length;
            tablewidth = columns;

            int sramaddress = 0;// Convert.ToInt32(dr.Row["SRAMADDRESS"].ToString());
            if (address != 0)
            {

                while (address > m_currentfile_size) address -= m_currentfile_size;
                tabdet.Map_address = address;
                tabdet.Map_sramaddress = sramaddress;
                int length = Convert.ToInt32(symlen);
                tabdet.Map_length = length;
                byte[] mapdata = readdatafromfile(m_currentfile, address, length);
                tabdet.Map_content = mapdata;
                tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name);
                tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name);
                tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name);
                tabdet.ShowTable(tablewidth, isSixteenBitTable(tabdet.Map_name));
            }
        }
Пример #5
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();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #6
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 (m_connectedToECU)
                    {
                        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)
                                {
                                    try
                                    {
                                        byte[] result = ReadMapFromSRAM(shs);
                                        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);
                                                            vwr.IsRAMViewer = false;
                                                            vwr.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                            if ((m_connectedToECU) /*|| 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);
                                                                    vwr2.IsRAMViewer = false;
                                                                    vwr2.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                                    if ((m_connectedToECU) /*|| 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);
                                                                    vwr3.IsRAMViewer = false;
                                                                    vwr3.ShowTable(cols, isSixteenBitTable(e.Mapname));
                                                                    if ((m_connectedToECU) /*|| 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;
                                }
                            }

                        }
                    }
                }
                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;
        }
Пример #7
0
 void tabdet_onAxisEditorRequested(object sender, IMapViewer.ReadSymbolEventArgs e)
 {
     StartTableViewer(e.SymbolName);
 }
Пример #8
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);
         }
     }
 }