Пример #1
0
        public static IMapViewer Get(T5AppSettings m_appSettings)
        {
            IMapViewer mapviewer;

            if (m_appSettings.MapViewerType == MapviewerType.Fancy)
            {
                mapviewer = new MapViewerEx();
            }
            else if (m_appSettings.MapViewerType == MapviewerType.Normal)
            {
                mapviewer = new MapViewer();
            }
            else
            {
                mapviewer = new SimpleMapViewer();
            }
            mapviewer.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
            mapviewer.DisableColors   = m_appSettings.DisableMapviewerColors;
            mapviewer.GraphVisible    = m_appSettings.ShowGraphs;
            mapviewer.IsRedWhite      = m_appSettings.ShowRedWhite;
            mapviewer.SetViewSize(m_appSettings.DefaultViewSize);
            mapviewer.Viewtype           = m_appSettings.DefaultViewType;
            mapviewer.AutoUpdateChecksum = m_appSettings.AutoChecksum;
            mapviewer.GraphVisible       = m_appSettings.ShowGraphs;

            return(mapviewer);
        }
Пример #2
0
        private void StartTableViewerSRAMFile(string symbolname, string sramfile)
        {
            if (m_trionicFile == null)
            {
                frmInfoBox info = new frmInfoBox("You should open a binary file first");
                return;
            }
            if (!m_trionicFile.HasSymbol(symbolname))
            {
                frmInfoBox info = new frmInfoBox(symbolname + " is not present in the current file");
                return;
            }
            // make it 100% self-defining
            // the application shouldn't have any know how about the details
            // it should only define TUNING-FLOW
            // have this work in online mode as well, this should enable the user to work in online mode in the SRAM
            //itself when it is connected.

            if (!SRAMPanelExists(symbolname, sramfile)/* true*/)
            {

                dockManager1.BeginUpdate();
                DockPanel dp = dockManager1.AddPanel(DockingStyle.Right);
                dp.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel);
                dp.Tag = sramfile;
                IMapViewer mv;
                if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                {
                    mv = new MapViewerEx();
                }
                else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                {
                    mv = new MapViewer();
                }
                else
                {
                    mv = new SimpleMapViewer();
                }
                mv.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                mv.GraphVisible = m_appSettings.ShowGraphs;

                mv.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);

                if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                    }
                }
                //mv.LoadSymbol(symbolname, m_trionicFile);
                mv.LoadSymbol(symbolname, m_trionicFile, sramfile);
                //mv.Map_content = m_trionicFile.ReadDataFromFile(sramfile, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                mv.OnlineMode = true;
                int cols = 1;
                int rows = 1;
                m_trionicFile.GetMapMatrixWitdhByName(symbolname, out cols, out rows);
                mv.ShowTable(cols, m_trionicFile.IsTableSixteenBits(symbolname));
                TryToAddOpenLoopTables(mv);
                mv.InitEditValues();

                mv.Dock = DockStyle.Fill;
                mv.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                // what todo on a save action (sram/binary)?
                mv.onSymbolSave += new IMapViewer.NotifySaveSymbol(mv_onSymbolSave);
                mv.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(mv_onReadFromSRAM);
                mv.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequestedSRAM);
                mv.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                mv.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                mv.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                //
                dp.Width = mv.DetermineWidth();
                dp.Text = "SRAM: " + Path.GetFileName(/*m_trionicFile.GetFileInfo().Filename*/ sramfile) + " [" + symbolname + "]";
                //if (_ecuConnection.Opened) dp.Text += " Online";
                dp.Controls.Add(mv);
                bool isDocked = false;
                if (m_appSettings.AutoDockSameSymbol)
                {
                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                    {
                        if (pnl.Text.Contains("[" + symbolname + "]") && pnl != dp && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                        {
                            dp.DockAsTab(pnl, 0);
                            //pnl.Options.ShowCloseButton = false;
                            isDocked = true;
                            break;
                        }
                    }
                }
                if (!isDocked)
                {
                    if (m_appSettings.AutoDockSameFile)
                    {
                        foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                        {
                            if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dp && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                            {
                                dp.DockAsTab(pnl, 0);
                                //pnl.Options.ShowCloseButton = false;
                                isDocked = true;
                                break;
                            }
                        }
                    }
                }
                dockManager1.EndUpdate();
            }
            else
            {
                BringPanelToForeGround(symbolname);
            }
        }
Пример #3
0
        private void ShowIgnitionMAP(string mapname, int[] lockmap)
        {
            // show seperate mapviewer for AFR target map
            byte[] _data = new byte[lockmap.Length * 2];
            _data = IntArrayToByteArray(lockmap);
            DevExpress.XtraBars.Docking.DockPanel dockPanel;
            bool pnlfound = false;
            string symbolname = mapname;
            try
            {
                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                {
                    if (pnl.Text == "Symbol: " + symbolname + " [" + Path.GetFileName(m_trionicFile.GetFileInfo().Filename) + "]")
                    {
                        dockPanel = pnl;
                        pnlfound = true;
                        dockPanel.Show();
                        // nog data verversen?

                    }
                }
            }
            catch (Exception E)
            {
                Console.WriteLine(E.Message);
            }
            if (!pnlfound)
            {
                dockManager1.BeginUpdate();
                try
                {
                    IMapViewer tabdet;
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                    {
                        tabdet = new MapViewerEx();
                    }
                    else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                    {
                        tabdet = new MapViewer();
                    }
                    else
                    {
                        tabdet = new SimpleMapViewer();
                    }

                    tabdet.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    //TryTpShowTouchScreenInput();

                    tabdet.DirectSRAMWriteOnSymbolChange = false;
                    //tabdet.SetViewSize(m_appSettings.DefaultViewSize);
                    tabdet.Visible = false;
                    tabdet.Filename = m_trionicFile.GetFileInfo().Filename;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                        }
                    }
                    tabdet.DisableColors = m_appSettings.DisableMapviewerColors;
                    tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                    tabdet.IsRedWhite = m_appSettings.ShowRedWhite;
                    tabdet.Map_name = symbolname;
                    tabdet.Map_descr = "Ignition locked map";
                    tabdet.Map_cat = XDFCategories.Sensor;
                    tabdet.X_axisvalues = m_trionicFile.GetMapXaxisValues(m_trionicFileInformation.GetIgnitionMap());
                    tabdet.Y_axisvalues = m_trionicFile.GetMapYaxisValues(m_trionicFileInformation.GetIgnitionMap());
                    System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30));
                    dockPanel = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    dockPanel.Width = 800; // TEST

                    if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                    {
                        int dw = 650;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 400) dw = 400;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 900);
                            tabdet.SetSplitter(0, 0, 280, false, false);

                        }
                        else
                        {
                            dockPanel.FloatSize = new Size(dw, 500);
                        }
                    }
                    else if (m_appSettings.DefaultViewSize == ViewSize.SmallView)
                    {
                        int dw = 550;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 380) dw = 380;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 850);
                            tabdet.SetSplitter(0, 0, 250, false, false);
                            //tabdet.SetSurfaceGraphZoom(0.4);
                        }
                        else
                        {

                            dockPanel.FloatSize = new Size(dw, 450);
                            //dockPanel.FloatSize = new Size(550, 450);
                        }
                    }
                    else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView || m_appSettings.DefaultViewSize == ViewSize.TouchscreenView)
                    {
                        int dw = 550;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 380) dw = 380;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 700);
                            tabdet.SetSplitter(0, 0, 320, false, false);
                            // tabdet.SetSurfaceGraphZoom(0.5);
                        }
                        else
                        {
                            // dockPanel.FloatSize = new Size(450, 450);

                            dockPanel.FloatSize = new Size(dw, 450);
                        }
                        dockPanel.Width = dw;
                    }
                    floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2);
                    while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++;
                    dockPanel.FloatLocation = floatpoint;

                    dockPanel.Tag = m_trionicFile.GetFileInfo().Filename;

                    string xdescr = string.Empty;
                    string ydescr = string.Empty;
                    string zdescr = string.Empty;

                    m_trionicFile.GetMapAxisDescriptions(m_trionicFileInformation.GetIgnitionMap(), out xdescr, out ydescr, out zdescr);
                    tabdet.X_axis_name = xdescr;
                    tabdet.Y_axis_name = ydescr;
                    tabdet.Z_axis_name = zdescr;
                    int columns = 18;
                    int rows = 16;
                    //m_trionicFile.GetMapMatrixWitdhByName(m_trionicFileInformation.GetIgnitionMap(), out columns, out rows);

                    tabdet.Map_address = 0;
                    tabdet.Map_sramaddress = 0;
                    int length = m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap());
                    tabdet.Map_length = length ;
                    byte[] mapdata = _data;// m_AFRMaps.LoadTargetAFRMapInBytes(filename);//TODO: ???
                    tabdet.Map_content = mapdata;

                    tabdet.Correction_factor = 1;
                    tabdet.Correction_offset = 0;
                    tabdet.IsUpsideDown = true;
                    tabdet.ShowTable(columns, true);
                    tabdet.Dock = DockStyle.Fill;
                    tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(ignitionMapClear);
                    //tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(onTargetAFRMapSave);
                    tabdet.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                    tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(ignitionMapRefresh);
                    tabdet.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                    //tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(onIgnitionLockRefresh);
                    dockPanel.Text = "Symbol: " + tabdet.Map_name + " [" + Path.GetFileName(m_trionicFile.GetFileInfo().Filename) + "]";
                    bool isDocked = false;
                    if (!isDocked)
                    {
                        int width = 600;
                        if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                        {
                            width = 600;
                        }
                        if (m_appSettings.AutoSizeNewWindows)
                        {
                            if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                else
                                {
                                    //width = this.Width - dockSymbols.Width - 10;
                                }
                                if (width < 500) width = 500;
                            }
                            else if (m_appSettings.DefaultViewSize == ViewSize.SmallView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                else
                                {
                                    //width = this.Width - dockSymbols.Width - 10;
                                }
                                if (width < 450) width = 450;

                            }
                            else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView || m_appSettings.DefaultViewSize == ViewSize.TouchscreenView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                if (width < 400) width = 400;

                            }
                        }
                        dockPanel.Width = width;
                    }
                    if (dockPanel.Height < 700) tabdet.GraphVisible = false; //<GS-24032010>

                    dockPanel.Controls.Add(tabdet);
                    TryToAddOpenLoopTables(tabdet);
                    tabdet.Visible = true;
                }
                catch (Exception newdockE)
                {
                    Console.WriteLine(newdockE.Message);
                }
                dockManager1.EndUpdate();

            }
            //UpdateFeedbackMaps();

            System.Windows.Forms.Application.DoEvents();
        }
Пример #4
0
        private void StartTableViewer(string symbolname)
        {
            if (m_trionicFile == null)
            {
                frmInfoBox info = new frmInfoBox("You should open a binary file first");
                return;
            }
            if(!m_trionicFile.HasSymbol(symbolname))
            {
                frmInfoBox info = new frmInfoBox(symbolname + " is not present in the current file");
                return;
            }

            // make it 100% self-defining
            // the application shouldn't have any know how about the details
            // it should only define TUNING-FLOW
            // have this work in online mode as well, this should enable the user to work in online mode in the SRAM
            //itself when it is connected.
            if (m_appSettings.ShowAdditionalSymbolInformation)
            {
                ShowContextSensitiveHelpOnSymbol(symbolname);
            }

            if (m_appSettings.AutoHighlightSelectedMap)
            {
                try
                {
                    //gridViewSymbols.ActiveFilter.Clear(); // clear filter
                    if (gridSymbols.DataSource is Trionic5Tools.SymbolCollection)
                    {
                        Trionic5Tools.SymbolCollection dt = (Trionic5Tools.SymbolCollection)gridSymbols.DataSource;
                        int rtel = 0;

                        foreach (Trionic5Tools.SymbolHelper dr in dt)
                        {

                            if (dr.Varname == symbolname)
                            {

                                try
                                {
                                    int rhandle = gridViewSymbols.GetRowHandle(rtel);
                                    gridViewSymbols.OptionsSelection.MultiSelect = true;
                                    gridViewSymbols.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
                                    gridViewSymbols.ClearSelection();
                                    gridViewSymbols.SelectRow(rhandle);
                                    //gridViewSymbols.SelectRows(rhandle, rhandle);
                                    gridViewSymbols.MakeRowVisible(rhandle, true);
                                    gridViewSymbols.FocusedRowHandle = rhandle;
                                    Application.DoEvents(); //<GS-15042010>
                                    if (gridViewSymbols.IsRowVisible(rhandle) == RowVisibleState.Hidden)
                                    {
                                        gridViewSymbols.ActiveFilter.Clear(); // clear filter
                                        //Do again!
                                        Application.DoEvents();
                                        dt = (Trionic5Tools.SymbolCollection)gridSymbols.DataSource;
                                        int rtel2 = 0;

                                        foreach (Trionic5Tools.SymbolHelper dr2 in dt)
                                        {

                                            if (dr2.Varname == symbolname)
                                            {
                                                rhandle = gridViewSymbols.GetRowHandle(rtel2);
                                                gridViewSymbols.OptionsSelection.MultiSelect = true;
                                                gridViewSymbols.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
                                                gridViewSymbols.ClearSelection();
                                                gridViewSymbols.SelectRow(rhandle);
                                                gridViewSymbols.MakeRowVisible(rhandle, true);
                                                gridViewSymbols.FocusedRowHandle = rhandle;
                                            }
                                            rtel2++;
                                        }
                                    }
                                    //gridViewSymbols.SelectRange(rhandle, rhandle);
                                    break;
                                }
                                catch (Exception E)
                                {
                                    MessageBox.Show(E.Message);
                                }
                            }

                            rtel++;
                        }

                    }
                }
                catch (Exception highlightE)
                {
                    Console.WriteLine(highlightE.Message);
                }
            }

            if (symbolname == m_trionicFileInformation.GetProgramModeSymbol())
            {
                //<GS-20042010> make a special viewer for this!
                frmEasyFirmwareInfo info = new frmEasyFirmwareInfo();
                if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline)
                {
                    info.Pgm_mod = _ecuConnection.ReadSymbolData(symbolname, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    info.SetPrimarySourceName("ECU " + Path.GetFileNameWithoutExtension(m_trionicFileInformation.Filename));
                }
                else
                {
                    info.Pgm_mod = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash(m_trionicFileInformation.GetProgramModeSymbol()), (uint)m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetProgramModeSymbol()));
                    info.SetPrimarySourceName("BIN " + Path.GetFileNameWithoutExtension(m_trionicFileInformation.Filename));
                }
                if (m_trionicFileInformation.SRAMfilename != "")
                {
                    info.Pgm_mod2 = m_trionicFile.ReadDataFromFile(m_trionicFileInformation.SRAMfilename, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    info.SetSecondarySourceName("SRAM " + Path.GetFileNameWithoutExtension(m_trionicFileInformation.SRAMfilename));
                }
                else
                {
                    info.DisableSecondarySource();
                }
                info.ShowDialog();
            }
            else if (symbolname == m_trionicFileInformation.GetProgramStatusSymbol())
            {
                //TODO: <GS-20042010> make a special viewer for this!
            }
            else if (!PanelExists(symbolname))
            {
                dockManager1.BeginUpdate();
                DockPanel dp = dockManager1.AddPanel(DockingStyle.Right);
                dp.Tag = m_trionicFileInformation.Filename;
                dp.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel);
                //IMapViewer mv = new MapViewerEx();
                IMapViewer mv;
                if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                {
                    mv = new MapViewerEx();
                }
                else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                {
                    mv = new MapViewer();
                }
                else
                {
                    mv = new SimpleMapViewer();
                }
                mv.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                mv.GraphVisible = m_appSettings.ShowGraphs;
                // set viewsize
                mv.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);
                if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                    }
                }
                mv.LoadSymbol(symbolname, m_trionicFile);
                if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline)
                {
                    mv.Map_content = _ecuConnection.ReadSymbolData(symbolname, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    mv.OnlineMode = true;
                }
                else if (m_trionicFileInformation.SRAMfilename != "" && !symbolname.Contains("!"))
                {
                    mv.Map_content = m_trionicFile.ReadDataFromFile(m_trionicFileInformation.SRAMfilename, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    mv.OnlineMode = true;
                }
                int cols = 1;
                int rows = 1;
                m_trionicFile.GetMapMatrixWitdhByName(symbolname, out cols, out rows);
                TryToAddOpenLoopTables(mv);
                mv.InitEditValues();

                mv.Dock = DockStyle.Fill;
                mv.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                // what todo on a save action (sram/binary)?
                mv.onSymbolSave += new IMapViewer.NotifySaveSymbol(mv_onSymbolSave);
                mv.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(mv_onReadFromSRAM);
                mv.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                mv.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                mv.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                mv.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged);
                mv.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);
                int width = mv.DetermineWidth();
                if (dp.Width != width) dp.Width = width;
                dp.Text = Path.GetFileName(m_trionicFile.GetFileInfo().Filename) + " [" + symbolname + "]";
                //if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline) dp.Text += " Online";
                dp.Controls.Add(mv);

                bool isDocked = false;
                if (m_appSettings.AutoDockSameSymbol)
                {
                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                    {
                        if (pnl.Text.Contains("[" + symbolname + "]") && pnl != dp && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                        {
                            dp.DockAsTab(pnl, 0);
                            //pnl.Options.ShowCloseButton = false;
                            isDocked = true;
                            break;
                        }
                    }
                }
                if (!isDocked)
                {
                    if (m_appSettings.AutoDockSameFile)
                    {
                        foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                        {
                            if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dp && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                            {
                                dp.DockAsTab(pnl, 0);
                                //pnl.Options.ShowCloseButton = false;
                                isDocked = true;
                                break;
                            }
                        }
                    }
                }

                dockManager1.EndUpdate();

            }
            else
            {
                BringPanelToForeGround(symbolname);
            }

            // update all mapviewers with a dummy value for test
            // UpdateMapViewers(3000, 100, 1.6);
        }
Пример #5
0
        // center screen?
        private void StartTableViewerFloating(string symbolname)
        {
            bool _isAdjustmentMap = false;
            if (symbolname == "FuelAdjustmentMap")
            {
                symbolname = m_trionicFileInformation.GetInjectionMap();
                props = m_trionicFile.GetTrionicProperties();
                if (!props.IsTrionic55) symbolname = "Adapt_korr";
                _isAdjustmentMap = true;
                if (m_AFRMaps == null)
                {
                    m_AFRMaps = new AFRMaps();
                    m_AFRMaps.onFuelmapCellChanged += new AFRMaps.FuelmapCellChanged(m_AFRMaps_onFuelmapCellChanged);
                    m_AFRMaps.onIdleFuelmapCellChanged += new AFRMaps.IdleFuelmapCellChanged(m_AFRMaps_onIdleFuelmapCellChanged);
                    m_AFRMaps.onCellLocked += new AFRMaps.CellLocked(m_AFRMaps_onCellLocked);
                    m_AFRMaps.TrionicFile = m_trionicFile;
                    m_AFRMaps.InitializeMaps();
                }
                if (!m_AFRMaps.HasValidFuelmap)
                {
                    // insert the fuel map from SRAM now
                    byte[] fuelmap = _ecuConnection.ReadSymbolData(symbolname, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    m_AFRMaps.SetCurrentFuelMap(fuelmap);
                }

            }
            if (m_trionicFile == null)
            {
                frmInfoBox info = new frmInfoBox("You should open a binary file first");
                return;
            }
            if (!m_trionicFile.HasSymbol(symbolname))
            {
                frmInfoBox info = new frmInfoBox(symbolname + " is not present in the current file");
                return;
            }
            // make it 100% self-defining
            // the application shouldn't have any know how about the details
            // it should only define TUNING-FLOW
            // have this work in online mode as well, this should enable the user to work in online mode in the SRAM
            //itself when it is connected.
            if (!PanelExists(symbolname))
            {

                dockManager1.BeginUpdate();
                /*Rectangle r = Screen.GetWorkingArea(ctrlRealtime1);
                Point p = new Point(r.X + r.Width/2, r.Y + r.Height/2);
                System.Drawing.Point floatpoint = this.PointToScreen(p);*/
                System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30));

                DockPanel dp = dockManager1.AddPanel(floatpoint);
                dp.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel);
                dp.Tag = m_trionicFileInformation.Filename;
                //IMapViewer mv = new MapViewerEx();
                IMapViewer mv;
                if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                {
                    mv = new MapViewerEx();
                }
                else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                {
                    mv = new MapViewer();
                }
                else
                {
                    mv = new SimpleMapViewer();
                }
                mv.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                mv.GraphVisible = m_appSettings.ShowGraphs;
                mv.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);
                if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                    }
                }
                else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                {
                    if (m_appSettings.DefaultViewType == ViewType.Decimal)
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                    }
                    else
                    {
                        mv.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                    }
                }
                mv.LoadSymbol(symbolname, m_trionicFile);

                if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline)
                {
                    if (_isAdjustmentMap)
                    {
                        mv.Map_content = m_AFRMaps.GetCurrentlyMutatedFuelMap();
                    }
                    else
                    {
                        mv.Map_content = _ecuConnection.ReadSymbolData(symbolname, (uint)m_trionicFileInformation.GetSymbolAddressSRAM(symbolname), (uint)m_trionicFileInformation.GetSymbolLength(symbolname));
                    }

                    mv.OnlineMode = true;
                }
                int cols = 1;
                int rows = 1;
                m_trionicFile.GetMapMatrixWitdhByName(symbolname, out cols, out rows);
               /* if (m_trionicFile.GetMapSensorType() == MapSensorType.MapSensor30)
                {
                    mv.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                }*/
                mv.ShowTable(cols, m_trionicFile.IsTableSixteenBits(symbolname));
                mv.Dock = DockStyle.Fill;
                mv.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                // what todo on a save action (sram/binary)
                mv.onSymbolSave += new IMapViewer.NotifySaveSymbol(mv_onSymbolSave);
                mv.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(mv_onReadFromSRAM);
                mv.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                mv.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                mv.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                mv.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                TryToAddOpenLoopTables(mv);
                mv.InitEditValues();

                //
                dp.Width = mv.DetermineWidth();
                dp.Text = Path.GetFileName(m_trionicFile.GetFileInfo().Filename) + " [" + symbolname + "]";
                //if (_ecuConnection.Opened && _APPmode == OperationMode.ModeOnline) dp.Text += " Online";
                dp.Controls.Add(mv);

                mv.GraphVisible = false;
                int dw = 650;
                if (mv.X_axisvalues.Length > 0)
                {
                    dw = 30 + ((mv.X_axisvalues.Length + 1) * 35);
                }
                if (dw < 400) dw = 400;
                dp.FloatSize = new Size(dw, 500);

                // now set it in the center of the screen!
                //int x = Screen.PrimaryScreen.WorkingArea.Width / 2 - dp.FloatSize.Width / 2;
                //int y = Screen.PrimaryScreen.WorkingArea.Height / 2 - dp.FloatSize.Height / 2;
                int x = this.Left + this.Width / 2 - dp.FloatSize.Width / 2;
                int y = this.Top + this.Height / 2 - dp.FloatSize.Height / 2;
                System.Drawing.Point realfloatpoint = new Point(x, y);//this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30));
                dp.FloatLocation = realfloatpoint;

                dockManager1.EndUpdate();
            }
            else
            {
                BringPanelToForeGround(symbolname);
                //TODO: Fuel adjustment map should be data-updated!
                /*if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline)
                {
                    if (_isAdjustmentMap)
                    {
                        mv.Map_content = m_AFRMaps.GetCurrentlyMutatedFuelMap();
                    }
                }*/
            }
            // update all mapviewers with a dummy value for test
            // UpdateMapViewers(3000, 100, 1.6);
        }
Пример #6
0
        private void StartSRAMToFlashCompareDifferenceViewer(string symbolname, string sramfilename, string flashfilename, int length, int sramaddress, int flashaddress)
        {
            DevExpress.XtraBars.Docking.DockPanel dockPanel;
            bool pnlfound = false;
            foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
            {

                if (pnl.Text == "SRAM-Flash symbol difference: " + symbolname + " [" + Path.GetFileName(sramfilename) + " vs " + Path.GetFileName(flashfilename) + "]")
                {
                    dockPanel = pnl;
                    pnlfound = true;
                    dockPanel.Show();
                }
            }
            if (!pnlfound)
            {
                dockManager1.BeginUpdate();
                try
                {
                    dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                    dockPanel.Tag = sramfilename;

                    //IMapViewer mv = new MapViewerEx();
                    IMapViewer mv;
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                    {
                        mv = new MapViewerEx();
                    }
                    else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                    {
                        mv = new MapViewer();
                    }
                    else
                    {
                        mv = new SimpleMapViewer();
                    }
                    mv.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                    mv.IsCompareViewer = true;
                    mv.GraphVisible = m_appSettings.ShowGraphs;
                    //TryTpShowTouchScreenInput();

                    mv.DirectSRAMWriteOnSymbolChange = false;

                    mv.Viewtype = Trionic5Tools.ViewType.Decimal;
                    mv.DisableColors = m_appSettings.DisableMapviewerColors;
                    mv.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                    mv.GraphVisible = m_appSettings.ShowGraphs;
                    mv.IsRedWhite = m_appSettings.ShowRedWhite;
                    mv.Filename = sramfilename;
                    mv.Map_name = symbolname;
                    mv.Map_descr = m_trionicFileInformation.GetSymbolDescription(mv.Map_name);
                    mv.Map_cat = m_trionicFileInformation.GetSymbolCategory(mv.Map_name);
                    mv.X_axisvalues = m_trionicFile.GetMapXaxisValues(mv.Map_name);
                    mv.Y_axisvalues = m_trionicFile.GetMapYaxisValues(mv.Map_name);
                    string xdescr = string.Empty;
                    string ydescr = string.Empty;
                    string zdescr = string.Empty;
                    m_trionicFile.GetMapAxisDescriptions(mv.Map_name, out xdescr, out ydescr, out zdescr);
                    mv.X_axis_name = xdescr;
                    mv.Y_axis_name = ydescr;
                    mv.Z_axis_name = zdescr;

                    //mv.Map_sramaddress = GetSymbolAddressSRAM(SymbolName);
                    int columns = 8;
                    int rows = 8;
                    m_trionicFile.GetMapMatrixWitdhByName(mv.Map_name, out columns, out rows);
                    int tablewidth = columns;
                    //int tablewidth = m_trionicFileInformation.GetTab.GetTableGetTableMatrixWitdhByName(m_trionicFileInformation.Filename, mv.Map_name, out columns, out rows);
                    //int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, mv.Map_name, out columns, out rows);
                    int address = sramaddress;
                    if (address != 0)
                    {
                        while (address > m_trionicFileInformation.Filelength) address -= m_trionicFileInformation.Filelength;
                        mv.Map_address = address;
                        mv.Map_length = length;
                        byte[] mapdata = m_trionicFile.ReadDataFromFile(sramfilename, (uint)sramaddress, (uint)length);
                        byte[] mapdata2 = m_trionicFile.ReadDataFromFile(flashfilename, (uint)flashaddress, (uint)length);
                        byte[] mapdataOri = m_trionicFile.ReadDataFromFile(sramfilename, (uint)sramaddress, (uint)length);
                        mv.Map_original_content = mapdata;
                        mv.Map_compare_content = mapdata2;

                        if (mapdata.Length == mapdata2.Length)
                        {
                            if (m_trionicFile.IsTableSixteenBits(symbolname))
                            {
                                for (int bt = 0; bt < mapdata2.Length; bt += 2)
                                {
                                    int value1 = Convert.ToInt16(mapdata.GetValue(bt)) * 256 + Convert.ToInt16(mapdata.GetValue(bt + 1));
                                    int value2 = Convert.ToInt16(mapdata2.GetValue(bt)) * 256 + Convert.ToInt16(mapdata2.GetValue(bt + 1));

                                    value1 = (int)Math.Abs(value1 - value2);
                                    byte v1 = (byte)(value1 / 256);
                                    byte v2 = (byte)(value1 - (int)v1 * 256);
                                    mapdataOri.SetValue(v1, bt);
                                    mapdataOri.SetValue(v2, bt + 1);
                                }
                            }
                            else
                            {
                                for (int bt = 0; bt < mapdata2.Length; bt++)
                                {
                                    //Console.WriteLine("Byte diff: " + mapdata.GetValue(bt).ToString() + " - " + mapdata2.GetValue(bt).ToString() + " = " + (byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))));
                                    mapdataOri.SetValue((byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt);
                                }
                            }

                            mv.Map_content = mapdataOri;
                            TryToAddOpenLoopTables(mv);
                            // ori and changed

                            mv.Correction_factor = m_trionicFile.GetCorrectionFactorForMap(mv.Map_name);
                            mv.Correction_offset = m_trionicFile.GetOffsetForMap(mv.Map_name);
                            mv.IsUpsideDown = true;// GetMapUpsideDown(mv.Map_name);
                            mv.ShowTable(columns, m_trionicFile.IsTableSixteenBits(symbolname));
                            mv.Dock = DockStyle.Fill;
                            //mv.onSymbolSave += new MapViewer.NotifySaveSymbol(mv_onSymbolSave);
                            mv.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                            mv.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                            //mv.onAxisLock += new MapViewer.NotifyAxisLock(mv_onAxisLock);
                            //mv.onSliderMove += new MapViewer.NotifySliderMove(mv_onSliderMove);
                            mv.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                            mv.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                            mv.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                            //mv.onSplitterMoved += new MapViewer.SplitterMoved(mv_onSplitterMoved);
                            //mv.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged);
                            //mv.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(mv_onGraphSelectionChanged);
                            //mv.onViewTypeChanged += new MapViewer.ViewTypeChanged(mv_onViewTypeChanged);

                            //dockPanel.DockAsTab(dockPanel1);
                            dockPanel.Text = "SRAM-Flash symbol difference: " + symbolname + " [" + Path.GetFileName(sramfilename) + " vs " + Path.GetFileName(flashfilename) + "]";
                            bool isDocked = false;
                            if (m_appSettings.AutoDockSameSymbol)
                            {
                                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                {
                                    if (pnl.Text.StartsWith("SRAM-Flash symbol difference: " + symbolname) && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                    {
                                        dockPanel.DockAsTab(pnl, 0);
                                        pnl.Options.ShowCloseButton = false;
                                        isDocked = true;
                                        break;
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                if (m_appSettings.AutoDockSameFile)
                                {
                                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                    {
                                        if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                        {
                                            dockPanel.DockAsTab(pnl, 0);
                                            pnl.Options.ShowCloseButton = false;
                                            isDocked = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Right, 0);
                                if (m_appSettings.AutoSizeNewWindows)
                                {
                                    if (mv.X_axisvalues.Length > 0)
                                    {
                                        dockPanel.Width = 30 + ((mv.X_axisvalues.Length + 1) * 35);
                                    }
                                    else
                                    {
                                        //dockPanel.Width = this.Width - dockSymbols.Width - 10;

                                    }
                                }
                                if (dockPanel.Width < 400) dockPanel.Width = 400;

                                //                    dockPanel.Width = 400;
                            }
                            dockPanel.Controls.Add(mv);

                        }
                        else
                        {
                            frmInfoBox info = new frmInfoBox("Map lengths don't match...");
                        }
                    }
                }
                catch (Exception E)
                {

                    Console.WriteLine(E.Message);
                }
                dockManager1.EndUpdate();
            }
        }
Пример #7
0
        private void StartResultViewerForMatrix(double[] xaxis, double[]yaxis, string xname, string yname, string zname, DataTable dtdata, byte[] data)
        {
            dockManager1.BeginUpdate();
            DockPanel dp = dockManager1.AddPanel(DockingStyle.Right);
            dp.Tag = m_trionicFileInformation.Filename;
            dp.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel);
            //IMapViewer mv = new MapViewerEx();
            IMapViewer mv;
            if (m_appSettings.MapViewerType == MapviewerType.Fancy)
            {
                mv = new MapViewerEx();
            }
            else if (m_appSettings.MapViewerType == MapviewerType.Normal)
            {
                mv = new MapViewer();
            }
            else
            {
                mv = new SimpleMapViewer();
            }
            mv.AutoUpdateChecksum = false;
            mv.GraphVisible = m_appSettings.ShowGraphs;
            // set viewsize
            mv.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);
            mv.Viewtype = Trionic5Tools.ViewType.Easy;
            mv.Map_content = data;
            int[] ixaxis = new int[xaxis.Length];
            int[] iyaxis = new int[yaxis.Length];
            for(int i = 0; i < xaxis.Length; i ++)
            {
                ixaxis.SetValue(Convert.ToInt32(xaxis.GetValue(i)), i);
            }
            for (int i = 0; i < yaxis.Length; i++)
            {
                iyaxis.SetValue(Convert.ToInt32(yaxis.GetValue(i)), i);
            }
            mv.X_axisvalues = ixaxis;
            mv.Y_axisvalues = iyaxis;
            mv.Map_name = "Matrix [" + xname + " : " + yname + " : " + zname + "]";

            mv.ShowTable(16, true);
            mv.SetDataTable(dtdata);

            int cols = 16;
            int rows = 16;
            TryToAddOpenLoopTables(mv);
            mv.InitEditValues();

            mv.Dock = DockStyle.Fill;
            mv.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
            // what todo on a save action (sram/binary)?
            int width = mv.DetermineWidth();
            if (dp.Width != width) dp.Width = width;
            dp.Text = "Matrix [" + xname + " : " + yname + " : " + zname + "]";
            //if (_ecuConnection.Opened && _ECUmode == OperationMode.ModeOnline) dp.Text += " Online";
            dp.Controls.Add(mv);

            bool isDocked = false;

            dockManager1.EndUpdate();
        }
Пример #8
0
        private void StartCompareMapViewer(string SymbolName, string Filename, int SymbolAddress, int SymbolLength, Trionic5Tools.SymbolCollection curSymbols, AddressLookupCollection curAddresses, Trionic5File curFile, Trionic5FileInformation curFileInfo)
        {
            try
            {
                DevExpress.XtraBars.Docking.DockPanel dockPanel;
                bool pnlfound = false;
                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                {

                    if (pnl.Text == "Symbol: " + SymbolName + " [" + Path.GetFileName(Filename) + "]")
                    {
                        dockPanel = pnl;
                        pnlfound = true;
                        dockPanel.Show();
                        // nog data verversen?
                    }
                }
                if (!pnlfound)
                {
                    dockManager1.BeginUpdate();
                    try
                    {
                        dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                        dockPanel.Tag = Filename;// m_trionicFile.GetFileInfo().Filename; changed 24/01/2008
                        //IMapViewer tabdet = new MapViewerEx();
                        IMapViewer tabdet;

                        if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                        {
                            tabdet = new MapViewerEx();
                        }
                        else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                        {
                            tabdet = new MapViewer();
                        }
                        else
                        {
                            tabdet = new SimpleMapViewer();
                        }
                        tabdet.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                        tabdet.GraphVisible = m_appSettings.ShowGraphs;
                       // TryTpShowTouchScreenInput();

                        //tabdet.DirectSRAMWriteOnSymbolChange = m_appSettings.DirectSRAMWriteOnSymbolChange;
                       // tabdet.SetViewSize(m_appSettings.DefaultViewSize);

                        //tabdet.IsHexMode = barViewInHex.Checked;
                        tabdet.Viewtype = (Trionic5Tools.ViewType)m_appSettings.DefaultViewType;
                        if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                            }
                        }
                        else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                            }
                        }
                        else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                        {
                            if (m_appSettings.DefaultViewType == ViewType.Decimal)
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                            }
                            else
                            {
                                tabdet.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                            }
                        }
                        //tabdet.DisableColors = m_appSettings.DisableMapviewerColors;
                        //tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                        //tabdet.GraphVisible = m_appSettings.ShowGraphs;
                        //tabdet.IsRedWhite = m_appSettings.ShowRedWhite;
                        tabdet.Filename = Filename;
                        tabdet.Map_name = SymbolName;

                        tabdet.Map_descr = m_trionicFileInformation.GetSymbolDescription(tabdet.Map_name);
                        tabdet.Map_cat = m_trionicFileInformation.GetSymbolCategory(tabdet.Map_name);
                        tabdet.X_axisvalues = curFile.GetMapXaxisValues(tabdet.Map_name);
                        tabdet.Y_axisvalues = curFile.GetMapYaxisValues(tabdet.Map_name);
                        string xdescr = string.Empty;
                        string ydescr = string.Empty;
                        string zdescr = string.Empty;
                        // van compare file halen?
                        curFile.GetMapAxisDescriptions(tabdet.Map_name, out xdescr, out ydescr, out zdescr);
                        tabdet.X_axis_name = xdescr;
                        tabdet.Y_axis_name = ydescr;
                        tabdet.Z_axis_name = zdescr;

                        //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName);
                        int columns = 8;
                        int rows = 8;

                        int tablewidth = curFile.GetTableMatrixWitdhByName(Filename, tabdet.Map_name, out columns, out rows);
                        int address = Convert.ToInt32(SymbolAddress);
                        if (address != 0)
                        {
                            while (address > curFileInfo.Filelength) address -= curFileInfo.Filelength;
                            tabdet.Map_address = address;
                            int length = SymbolLength;
                            tabdet.Map_length = length;
                            byte[] mapdata = curFile.ReadData((uint)address, (uint)length);
                            tabdet.Map_content = mapdata;
                            tabdet.Correction_factor = curFile.GetCorrectionFactorForMap(tabdet.Map_name);
                            tabdet.Correction_offset = curFile.GetOffsetForMap(tabdet.Map_name);
                            tabdet.IsUpsideDown = true;
                            tabdet.ShowTable(columns, curFile.GetFileInfo().isSixteenBitTable(SymbolName));
                            tabdet.Dock = DockStyle.Fill;
                            //tabdet.onSymbolSave += new MapViewer.NotifySaveSymbol(tabdet_onSymbolSave);
                            tabdet.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                            tabdet.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                            //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock);
                            //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove);
                            tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                            tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                            tabdet.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                            //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved);
                            //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged);
                            //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged);
                            //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged);

                            tabdet.SetViewSize((Trionic5Tools.ViewSize)m_appSettings.DefaultViewSize);
                            //dockPanel.DockAsTab(dockPanel1);
                            //dockPanel.Text = "Symbol: " + SymbolName + " [" + Filename + "]";
                            dockPanel.Text = Path.GetFileName(Filename) + " [" + SymbolName + "]";

                            bool isDocked = false;
                            if (m_appSettings.AutoDockSameSymbol)
                            {
                                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                {
                                    if (pnl.Text.Contains("[" + SymbolName +"]") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                    {
                                        dockPanel.DockAsTab(pnl, 0);
                                        //pnl.Options.ShowCloseButton = false;
                                        isDocked = true;
                                        break;
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                if (m_appSettings.AutoDockSameFile)
                                {
                                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                    {
                                        if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                        {
                                            dockPanel.DockAsTab(pnl, 0);
                                            //pnl.Options.ShowCloseButton = false;
                                            isDocked = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Right, 0);
                                if (m_appSettings.AutoSizeNewWindows)
                                {
                                    if (tabdet.X_axisvalues.Length > 0)
                                    {
                                        dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                    }
                                    else
                                    {
                                        //dockPanel.Width = this.Width - dockSymbols.Width - 10;

                                    }
                                }
                                if (dockPanel.Width < 400) dockPanel.Width = 400;
                                //                    dockPanel.Width = 400;
                            }
                            tabdet.InitEditValues();
                            dockPanel.Controls.Add(tabdet);

                        }

                    }
                    catch (Exception E)
                    {
                        Console.WriteLine(E.Message);
                    }
                    dockManager1.EndUpdate();
                }

            }
            catch (Exception startnewcompareE)
            {
                Console.WriteLine(startnewcompareE.Message);
            }
        }
Пример #9
0
        private void StartCompareDifferenceViewer(string SymbolName, string Filename, int SymbolAddress, int SymbolLength, Trionic5File curFile, Trionic5FileInformation curInfo)
        {
            DevExpress.XtraBars.Docking.DockPanel dockPanel;
            bool pnlfound = false;
            foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
            {

                if (pnl.Text == "Symbol difference: " + SymbolName + " [" + Path.GetFileName(Filename) + "]")
                {
                    dockPanel = pnl;
                    pnlfound = true;
                    dockPanel.Show();
                    // nog data verversen?
                    foreach (Control c in dockPanel.Controls)
                    {
                        /* if (c is MapViewer)
                         {
                             MapViewer tempviewer = (MapViewer)c;
                             tempviewer.Map_content
                         }*/
                    }
                }
            }
            if (!pnlfound)
            {
                dockManager1.BeginUpdate();
                try
                {
                    dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500));
                    dockPanel.Tag = Filename;
                    //IMapViewer tabdet = new MapViewerEx();
                    IMapViewer tabdet;
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                    {
                        tabdet = new MapViewerEx();
                    }
                    else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                    {
                        tabdet = new MapViewer();
                    }
                    else
                    {
                        tabdet = new SimpleMapViewer();
                    }
                    tabdet.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    tabdet.IsCompareViewer = true;
                    //TryTpShowTouchScreenInput();

                    tabdet.DirectSRAMWriteOnSymbolChange = false;
                    //tabdet.IsHexMode = true; // always in hexmode!
                    if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy;
                        }
                    }
                    else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                        }
                    }
                    else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                        }
                    }
                    else if (curFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                        }
                    }

                    tabdet.DisableColors = m_appSettings.DisableMapviewerColors;
                    tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    tabdet.IsRedWhite = m_appSettings.ShowRedWhite;
                    tabdet.Filename = Filename;
                    tabdet.Map_name = SymbolName;

                    tabdet.Map_descr = m_trionicFileInformation.GetSymbolDescription(tabdet.Map_name);
                    tabdet.Map_cat = m_trionicFileInformation.GetSymbolCategory(tabdet.Map_name);
                    tabdet.X_axisvalues = curFile.GetMapXaxisValues(tabdet.Map_name);
                    tabdet.Y_axisvalues = curFile.GetMapYaxisValues(tabdet.Map_name);
                    string xdescr = string.Empty;
                    string ydescr = string.Empty;
                    string zdescr = string.Empty;
                    // van compare file halen?
                    curFile.GetMapAxisDescriptions(tabdet.Map_name, out xdescr, out ydescr, out zdescr);
                    tabdet.X_axis_name = xdescr;
                    tabdet.Y_axis_name = ydescr;
                    tabdet.Z_axis_name = zdescr;

                    //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName);
                    int columns = 8;
                    int rows = 8;
                    int tablewidth = curFile.GetTableMatrixWitdhByName(Filename, tabdet.Map_name, out columns, out rows);
                    int address = Convert.ToInt32(SymbolAddress);
                    if (address != 0)
                    {
                        while (address > curInfo.Filelength) address -= curInfo.Filelength;
                        tabdet.Map_address = address;
                        int length = SymbolLength;
                        tabdet.Map_length = length;
                        byte[] mapdata = curFile.ReadData((uint)address, (uint)length);
                        byte[] mapdataorig = curFile.ReadData((uint)address, (uint)length);
                        byte[] mapdata2 = m_trionicFile.ReadData((uint)m_trionicFileInformation.GetSymbolAddressFlash(SymbolName), (uint)m_trionicFileInformation.GetSymbolLength(SymbolName));

                        tabdet.Map_original_content = mapdataorig;
                        tabdet.Map_compare_content = mapdata2;

                        if (mapdata.Length == mapdata2.Length)
                        {

                            if (curFile.IsTableSixteenBits(SymbolName))
                            {
                                for (int bt = 0; bt < mapdata2.Length; bt += 2)
                                {
                                    int value1 = Convert.ToInt16(mapdata.GetValue(bt)) * 256 + Convert.ToInt16(mapdata.GetValue(bt + 1));
                                    int value2 = Convert.ToInt16(mapdata2.GetValue(bt)) * 256 + Convert.ToInt16(mapdata2.GetValue(bt + 1));

                                    value1 = (int)Math.Abs(value1 - value2);
                                    //value1 = (int)(value1 - value2);
                                    byte v1 = (byte)(value1 / 256);
                                    byte v2 = (byte)(value1 - (int)v1 * 256);
                                    mapdata.SetValue(v1, bt);
                                    mapdata.SetValue(v2, bt + 1);
                                }
                            }
                            else
                            {
                                for (int bt = 0; bt < mapdata2.Length; bt++)
                                {
                                    //Console.WriteLine("Byte diff: " + mapdata.GetValue(bt).ToString() + " - " + mapdata2.GetValue(bt).ToString() + " = " + (byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))));
                                    mapdata.SetValue((byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt);
                                    //mapdata.SetValue((byte)(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt);
                                }
                            }

                            tabdet.Map_content = mapdata;
                            tabdet.UseNewCompare = true;

                            tabdet.Correction_factor = curFile.GetCorrectionFactorForMap(tabdet.Map_name);
                            tabdet.Correction_offset = curFile.GetOffsetForMap(tabdet.Map_name);
                            tabdet.IsUpsideDown = true;//GetMapUpsideDown(tabdet.Map_name);
                            tabdet.ShowTable(columns, curFile.GetFileInfo().isSixteenBitTable(SymbolName));
                            tabdet.Dock = DockStyle.Fill;
                            //tabdet.onSymbolSave += new MapViewer.NotifySaveSymbol(tabdet_onSymbolSave);
                            tabdet.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                            //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock);
                            //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove);
                            tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged);
                            tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx);
                            tabdet.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                            //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved);
                            //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged);
                            //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged);
                            //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged);
                            tabdet.onAxisEditorRequested += new IMapViewer.AxisEditorRequested(mv_onAxisEditorRequested);
                            //dockPanel.DockAsTab(dockPanel1);
                            dockPanel.Text = "Symbol difference: " + SymbolName + " [" + Path.GetFileName(Filename) + "]";
                            /*bool isDocked = false;
                            if (m_appSettings.AutoDockSameSymbol)
                            {
                                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                {
                                    if (pnl.Text.StartsWith("Symbol difference: " + SymbolName) && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                    {
                                        dockPanel.DockAsTab(pnl, 0);
                                        //pnl.Options.ShowCloseButton = false;
                                        isDocked = true;
                                        break;
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                if (m_appSettings.AutoDockSameFile)
                                {
                                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                    {
                                        if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                        {
                                            dockPanel.DockAsTab(pnl, 0);
                                            //pnl.Options.ShowCloseButton = false;
                                            isDocked = true;
                                            break;
                                        }
                                    }
                                }
                            }*/
                            bool isDocked = false;
                            if (m_appSettings.AutoDockSameSymbol)
                            {
                                foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                {
                                    if (pnl.Text.Contains("[" + SymbolName + "]") && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                    {
                                        dockPanel.DockAsTab(pnl, 0);
                                        //pnl.Options.ShowCloseButton = false;
                                        isDocked = true;
                                        break;
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                if (m_appSettings.AutoDockSameFile)
                                {
                                    foreach (DevExpress.XtraBars.Docking.DockPanel pnl in dockManager1.Panels)
                                    {
                                        if ((string)pnl.Tag == m_trionicFileInformation.Filename && pnl != dockPanel && (pnl.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible))
                                        {
                                            dockPanel.DockAsTab(pnl, 0);
                                            //pnl.Options.ShowCloseButton = false;
                                            isDocked = true;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (!isDocked)
                            {
                                dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Right, 0);
                                if (m_appSettings.AutoSizeNewWindows)
                                {
                                    if (tabdet.X_axisvalues.Length > 0)
                                    {
                                        dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                    }
                                    else
                                    {
                                        //dockPanel.Width = this.Width - dockSymbols.Width - 10;

                                    }
                                }
                                if (dockPanel.Width < 400) dockPanel.Width = 400;

                                //                    dockPanel.Width = 400;
                            }
                            tabdet.InitEditValues();
                            dockPanel.Controls.Add(tabdet);

                        }
                        else
                        {
                            frmInfoBox info = new frmInfoBox("Map lengths don't match...");
                        }
                    }
                }
                catch (Exception E)
                {

                    Console.WriteLine(E.Message);
                }
                dockManager1.EndUpdate();
            }
        }
Пример #10
0
        /// <summary>
        /// shows a mapviewer with the data from a knock counter snapshot
        /// </summary>
        /// <param name="fileToShow"></param>
        private void ShowKnockMap(string fileToShow, byte[] _data, string fileToCompare, byte[] _dataToCompare)
        {
            // show seperate mapviewer for AFR target map
            DevExpress.XtraBars.Docking.DockPanel dockPanel;
            bool pnlfound = false;
            string symbolname = "Knock_count_map";

            if (!pnlfound)
            {
                dockManager1.BeginUpdate();
                try
                {
                    IMapViewer tabdet;
                    if (m_appSettings.MapViewerType == MapviewerType.Fancy)
                    {
                        tabdet = new MapViewerEx();
                    }
                    else if (m_appSettings.MapViewerType == MapviewerType.Normal)
                    {
                        tabdet = new MapViewer();
                    }
                    else
                    {
                        tabdet = new SimpleMapViewer();
                    }

                    if (fileToCompare != string.Empty) tabdet.IsCompareViewer = true;

                    tabdet.AutoUpdateChecksum = m_appSettings.AutoChecksum;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    //TryTpShowTouchScreenInput();

                    tabdet.DirectSRAMWriteOnSymbolChange = false;
                    //tabdet.SetViewSize(m_appSettings.DefaultViewSize);
                    tabdet.Visible = false;
                    tabdet.Filename = m_trionicFile.GetFileInfo().Filename;
                    tabdet.GraphVisible = m_appSettings.ShowGraphs;
                    if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor25)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor30)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal3Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy3Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor35)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal35Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy35Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor40)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal4Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy4Bar;
                        }
                    }
                    else if (m_trionicFile.GetMapSensorType(m_appSettings.AutoDetectMapsensorType) == MapSensorType.MapSensor50)
                    {
                        if (m_appSettings.DefaultViewType == ViewType.Decimal)
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Decimal5Bar;
                        }
                        else
                        {
                            tabdet.Viewtype = Trionic5Tools.ViewType.Easy5Bar;
                        }
                    }
                    tabdet.DisableColors = m_appSettings.DisableMapviewerColors;
                    tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows;
                    tabdet.IsRedWhite = m_appSettings.ShowRedWhite;
                    tabdet.Map_name = symbolname;
                    tabdet.Map_descr = "Knock counter snapshot";
                    tabdet.Map_cat = XDFCategories.Sensor;
                    tabdet.X_axisvalues = m_trionicFile.GetMapXaxisValues(m_trionicFileInformation.GetIgnitionMap());
                    tabdet.Y_axisvalues = m_trionicFile.GetMapYaxisValues(m_trionicFileInformation.GetIgnitionMap());
                    // z, y and z axis to do

                    //<GS-24032010> dock it anyway, so it will fit the screen

                    System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30));

                    //dockPanel = dockManager1.AddPanel(floatpoint);
                    dockPanel = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right);
                    dockPanel.Width = 800; // TEST

                    if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                    {
                        int dw = 650;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 400) dw = 400;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 900);
                            tabdet.SetSplitter(0, 0, 280, false, false);

                        }
                        else
                        {
                            dockPanel.FloatSize = new Size(dw, 500);
                        }
                    }
                    else if (m_appSettings.DefaultViewSize == ViewSize.SmallView)
                    {
                        int dw = 550;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 380) dw = 380;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 850);
                            tabdet.SetSplitter(0, 0, 250, false, false);
                            //tabdet.SetSurfaceGraphZoom(0.4);
                        }
                        else
                        {

                            dockPanel.FloatSize = new Size(dw, 450);
                            //dockPanel.FloatSize = new Size(550, 450);
                        }
                    }
                    else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView || m_appSettings.DefaultViewSize == ViewSize.TouchscreenView)
                    {
                        int dw = 550;
                        if (tabdet.X_axisvalues.Length > 0)
                        {
                            dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                        }
                        if (dw < 380) dw = 380;
                        if (m_appSettings.ShowGraphs)
                        {
                            dockPanel.FloatSize = new Size(dw, 700);
                            tabdet.SetSplitter(0, 0, 320, false, false);
                            // tabdet.SetSurfaceGraphZoom(0.5);
                        }
                        else
                        {
                            // dockPanel.FloatSize = new Size(450, 450);

                            dockPanel.FloatSize = new Size(dw, 450);
                        }
                        dockPanel.Width = dw;
                    }
                    floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2);
                    while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++;
                    dockPanel.FloatLocation = floatpoint;

                    dockPanel.Tag = m_trionicFile.GetFileInfo().Filename;

                    string xdescr = string.Empty;
                    string ydescr = string.Empty;
                    string zdescr = string.Empty;

                    m_trionicFile.GetMapAxisDescriptions(m_trionicFileInformation.GetIgnitionMap(), out xdescr, out ydescr, out zdescr);
                    tabdet.X_axis_name = xdescr;
                    tabdet.Y_axis_name = ydescr;
                    tabdet.Z_axis_name = zdescr;
                    int columns = 8;
                    int rows = 8;
                    m_trionicFile.GetMapMatrixWitdhByName(m_trionicFileInformation.GetIgnitionMap(), out columns, out rows);

                    tabdet.Map_address = 0;
                    tabdet.Map_sramaddress = 0;
                    int length = m_trionicFileInformation.GetSymbolLength(m_trionicFileInformation.GetIgnitionMap());
                    tabdet.Map_length = length;
                    byte[] mapdata = _data;// m_AFRMaps.LoadTargetAFRMapInBytes(filename);//TODO: ???
                    tabdet.Map_content = mapdata;

                    if (fileToCompare != string.Empty)
                    {
                        tabdet.Map_original_content = _data;
                        tabdet.Map_compare_content = _dataToCompare;
                        if (mapdata.Length == _dataToCompare.Length)
                        {

                            if (m_trionicFile.IsTableSixteenBits(symbolname))
                            {
                                for (int bt = 0; bt < _dataToCompare.Length; bt += 2)
                                {
                                    int value1 = Convert.ToInt16(mapdata.GetValue(bt)) * 256 + Convert.ToInt16(mapdata.GetValue(bt + 1));
                                    int value2 = Convert.ToInt16(_dataToCompare.GetValue(bt)) * 256 + Convert.ToInt16(_dataToCompare.GetValue(bt + 1));

                                    value1 = (int)Math.Abs(value1 - value2);
                                    //value1 = (int)(value1 - value2);
                                    byte v1 = (byte)(value1 / 256);
                                    byte v2 = (byte)(value1 - (int)v1 * 256);
                                    mapdata.SetValue(v1, bt);
                                    mapdata.SetValue(v2, bt + 1);
                                }
                            }
                            else
                            {
                                for (int bt = 0; bt < _dataToCompare.Length; bt++)
                                {
                                    //Console.WriteLine("Byte diff: " + mapdata.GetValue(bt).ToString() + " - " + mapdata2.GetValue(bt).ToString() + " = " + (byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))));
                                    mapdata.SetValue((byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)_dataToCompare.GetValue(bt))), bt);
                                    //mapdata.SetValue((byte)(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt);
                                }
                            }
                        }
                    }

                    tabdet.Correction_factor = 1;
                    tabdet.Correction_offset = 0;
                    tabdet.IsUpsideDown = true;

                    tabdet.ShowTable(columns, true);

                    tabdet.Dock = DockStyle.Fill;
                    //tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(onTargetAFRMapSave);
                    tabdet.onClose += new IMapViewer.ViewerClose(OnCloseMapViewer);
                    tabdet.onCellLocked += new IMapViewer.CellLocked(mv_onCellLocked);

                    //tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(onAFRRefresh);
                    dockPanel.Text = "Symbol: " + tabdet.Map_name + " [" + Path.GetFileName(m_trionicFile.GetFileInfo().Filename) + "]";
                    bool isDocked = false;
                    if (!isDocked)
                    {
                        int width = 600;
                        if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                        {
                            width = 600;
                        }
                        if (m_appSettings.AutoSizeNewWindows)
                        {
                            if (m_appSettings.DefaultViewSize == ViewSize.NormalView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                else
                                {
                                    //width = this.Width - dockSymbols.Width - 10;
                                }
                                if (width < 500) width = 500;
                            }
                            else if (m_appSettings.DefaultViewSize == ViewSize.SmallView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                else
                                {
                                    //width = this.Width - dockSymbols.Width - 10;
                                }
                                if (width < 450) width = 450;

                            }
                            else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView || m_appSettings.DefaultViewSize == ViewSize.TouchscreenView)
                            {
                                if (tabdet.X_axisvalues.Length > 0)
                                {
                                    width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35);
                                }
                                if (width < 400) width = 400;

                            }
                        }
                        dockPanel.Width = width;
                    }
                    if (dockPanel.Height < 700) tabdet.GraphVisible = false; //<GS-24032010>

                    dockPanel.Controls.Add(tabdet);
                    TryToAddOpenLoopTables(tabdet);
                    tabdet.Visible = true;
                }
                catch (Exception newdockE)
                {
                    Console.WriteLine(newdockE.Message);
                }
                dockManager1.EndUpdate();

            }
            System.Windows.Forms.Application.DoEvents();
        }