VAGSuite.XDFWriter.AddTable C# (CSharp) Метод

AddTable() публичный Метод

public AddTable ( string name, string description, XDFCategories category, string xunits, string yunits, string zunits, int rows, int columns, int address, bool issixteenbit, int xaxisaddress, int yaxisaddress, bool isxaxissixteenbit, bool isyaxissixteenbit, float x_correctionfactor, float y_correctionfactor, float z_correctionfactor ) : void
name string
description string
category XDFCategories
xunits string
yunits string
zunits string
rows int
columns int
address int
issixteenbit bool
xaxisaddress int
yaxisaddress int
isxaxissixteenbit bool
isyaxissixteenbit bool
x_correctionfactor float
y_correctionfactor float
z_correctionfactor float
Результат void
        public void AddTable(string name, string description, XDFCategories category, string xunits, string yunits, string zunits, int rows, int columns, int address, bool issixteenbit, int xaxisaddress, int yaxisaddress, bool isxaxissixteenbit, bool isyaxissixteenbit, float x_correctionfactor, float y_correctionfactor, float z_correctionfactor)
        {
            if (sw != null)
            {
                if (name.StartsWith("Driver wish"))
                {
                    bool breakme = true;
                }
                if (description == string.Empty) description = name;
                ConstantID++;
                sw.WriteLine("%%TABLE%%");
                sw.WriteLine("000002 UniqueID         =0x" + ConstantID.ToString("X4"));
                sw.WriteLine("000100 Cat0ID           =0x" + ((int)category).ToString("X2"));
                sw.WriteLine("040005 Title            =\"" + name + "\"");
                sw.WriteLine("040011 DescSize         =0x" + ((int)(name.Length + 1)).ToString("X2"));
                sw.WriteLine("040010 Desc             =\"" + description + "\"");
                sw.WriteLine("040050 SizeInBits       =0x10");
                sw.WriteLine("040100 Address          =0x" + address.ToString("X6"));

                sw.WriteLine("040150 Flags            =0x1"); // 30?
                sw.WriteLine("040200 ZEq              =(X*" + z_correctionfactor.ToString("F1").Replace(",", ".") + ")/10,TH|0|0|0|0|");
                sw.WriteLine("040203 XOutType         =0x4"); // 4?
                sw.WriteLine("040304 YOutType         =0x4"); // 4?
                sw.WriteLine("040205 OutType          =0x3");
                sw.WriteLine("040230 RangeLow         =0.0000");
                sw.WriteLine("040240 RangeHigh        =65535.0000");
                //rows /= 2;
                sw.WriteLine("040300 Rows             =0x" + rows.ToString("X2"));
                sw.WriteLine("040305 Cols             =0x" + columns.ToString("X2"));
                sw.WriteLine("040320 XUnits           =\"" + xunits + "\"");
                sw.WriteLine("040325 YUnits           =\"" + yunits + "\"");
                sw.WriteLine("040330 ZUnits           =\"" + zunits + "\"");
                if (xaxisaddress != 0)
                {
                    string strxlabel = "040350 XLabels          =";
                    for (int ix = 0; ix < columns; ix++) strxlabel += "00,";
                    if (strxlabel.EndsWith(",")) strxlabel = strxlabel.Substring(0, strxlabel.Length - 1);
                    sw.WriteLine(strxlabel);
                }
                else
                {
                    sw.WriteLine("040350 XLabels          =%");
                }
                sw.WriteLine("040352 XLabelType       =0x4"); // 4?
                sw.WriteLine("040354 XEq              =(X*" + x_correctionfactor.ToString("F1").Replace(",", ".") + "),TH|0|0|0|0|");
                string strylabel = "040360 YLabels          =  ";
                for (int ix = 0; ix < columns; ix++)
                {
                    int val = ix*10;
                    strylabel += val.ToString("D2") + ",";
                }
                if (strylabel.EndsWith(",")) strylabel = strylabel.Substring(0, strylabel.Length - 1);
                sw.WriteLine(strylabel);
                if (xaxisaddress != 0 && yaxisaddress != 0)
                {
                    sw.WriteLine("040362 YLabelType       =0x4");
                    sw.WriteLine("040364 YEq              =(X*" + y_correctionfactor.ToString("F1").Replace(",", ".") + "),TH|0|0|0|0|");
                    sw.WriteLine("040505 XLabelSource     =0x1"); // in binary
                    sw.WriteLine("040515 YLabelSource     =0x1");
                    sw.WriteLine("040600 XAddress         =0x" + xaxisaddress.ToString("X6"));
                    if (isxaxissixteenbit)
                    {
                        sw.WriteLine("040620 XAddrStep        =2");
                    }
                    else
                    {
                        sw.WriteLine("040610 XDataSize        =0x1");
                        sw.WriteLine("040620 XAddrStep        =1");
                    }
                }
                else
                {
                    sw.WriteLine("040362 YLabelType       =0x4"); // manual
                    sw.WriteLine("040364 YEq              =(X*" + y_correctionfactor.ToString("F1").Replace(",", ".") + "),TH|0|0|0|0|");
                }
                sw.WriteLine("040660 XAxisMin         =1000.000000");
                sw.WriteLine("040670 XAxisMax         =1000.000000");
                if (xaxisaddress != 0 && yaxisaddress != 0)
                {
                    sw.WriteLine("040700 YAddress         =0x" + yaxisaddress.ToString("X6"));
                    if (isyaxissixteenbit)
                    {
                        sw.WriteLine("040720 YAddrStep        =2");
                    }
                }
                sw.WriteLine("040760 YAxisMin         =1000.000000");
                sw.WriteLine("040770 YAxisMax         =1000.000000");
                sw.WriteLine("%%END%%");
            }
        }

Usage Example

Пример #1
0
        private void btnExportXDF_ItemClick(object sender, ItemClickEventArgs e)
        {
            SaveFileDialog saveFileDialog2 = new SaveFileDialog();
            saveFileDialog2.Filter = "XDF files|*.xdf";
            if (gridControl1.DataSource != null)
            {
                XDFWriter xdf = new XDFWriter();

                string filename = Path.Combine(Path.GetDirectoryName(Tools.Instance.m_currentfile), Path.GetFileNameWithoutExtension(Tools.Instance.m_currentfile));
                saveFileDialog2.FileName = filename;
                if (saveFileDialog2.ShowDialog() == DialogResult.OK)
                {
                    //filename += ".xdf";
                    filename = saveFileDialog2.FileName;

                    xdf.CreateXDF(filename, Tools.Instance.m_currentfile, Tools.Instance.m_currentfilelength, Tools.Instance.m_currentfilelength);
                    foreach (SymbolHelper sh in Tools.Instance.m_symbols)
                    {
                        if (sh.Flash_start_address != 0)
                        {
                            int fileoffset = (int)sh.Flash_start_address;
                            while (fileoffset > Tools.Instance.m_currentfilelength) fileoffset -= Tools.Instance.m_currentfilelength;
                            /*if (sh.Varname == "Pgm_mod!") // VSS vlag
                            {
                                xdf.AddFlag("VSS", sh.Flash_start_address, 0x07);
                            }*/
                            if (sh.Varname.StartsWith("SVBL"))
                            {

                            }
                            else
                            {
                                string xaxis = sh.X_axis_descr;
                                string yaxis = sh.Y_axis_descr;
                                string zaxis = sh.Z_axis_descr;
                                bool m_issixteenbit = true;
                                // special maps are:
                                int xaxisaddress = sh.X_axis_address;
                                int yaxisaddress = sh.Y_axis_address;
                                bool isxaxissixteenbit = true;
                                bool isyaxissixteenbit = true;
                                int columns = sh.X_axis_length;
                                int rows = sh.Y_axis_length;
                                //int tablewidth = GetTableMatrixWitdhByName(Tools.Instance.m_currentfile, Tools.Instance.m_symbols, sh.Varname, out columns, out rows);
                                xdf.AddTable(sh.Varname, sh.Description, XDFCategories.Fuel, xaxis, yaxis, zaxis, columns, rows, fileoffset, m_issixteenbit, xaxisaddress, yaxisaddress, isxaxissixteenbit, isyaxissixteenbit, 1.0F, 1.0F, 1.0F);

                            }
                            /*else
                            {
                                xdf.AddConstant(55, sh.Varname, XDFCategories.Idle, "Aantal", sh.Length, fileoffset, true);
                            }*/
                        }
                    }
                    // add some specific stuff
                    //int fileoffset2 = Tools.Instance.m_currentfile_size - 0x4C;

                    //xdf.AddTable("Vehice Security Code", "VSS code", XDFCategories.Idle, "", "", "", 1, 6, fileoffset2 /*0x3FFB4*/, false, 0, 0, false, false, 1.0F, 1.0F, 1.0F);

                    xdf.CloseFile();
                }
            }
        }