Ejemplo n.º 1
0
        public void Import(S6xTable s6xTable, int xlsBaseOffset, SortedList <string, XlsLevel> xlsLevels)
        {
            PID = s6xTable.ShortLabel;
            Key = s6xTable.DuplicateNum == 0 ? Key : Key + "_" + s6xTable.DuplicateNum.ToString();

            Title    = s6xTable.Label;
            Comments = s6xTable.Comments;

            if (s6xTable.Category != null && s6xTable.Category != string.Empty)
            {
                foreach (XlsLevel xlsLevel in xlsLevels.Values)
                {
                    if (xlsLevel.Label.ToUpper() == s6xTable.Category.ToUpper())
                    {
                        Level = xlsLevel;
                        break;
                    }
                }
            }

            if (s6xTable.Category2 != null && s6xTable.Category2 != string.Empty)
            {
                foreach (XlsLevel xlsLevel in xlsLevels.Values)
                {
                    if (xlsLevel.Label.ToUpper() == s6xTable.Category2.ToUpper())
                    {
                        Level2 = xlsLevel;
                        break;
                    }
                }
            }

            AddressInt = Tools.xlsAddressFromBinAddress(s6xTable.AddressBinInt, xlsBaseOffset);

            Cols   = s6xTable.ColsNumber;
            Rows   = s6xTable.RowsNumber;
            Bytes  = s6xTable.WordOutput ? 2 : 1;
            Signed = s6xTable.SignedOutput;

            Equation = s6xTable.CellsScaleExpression;
            Digits   = s6xTable.CellsScalePrecision;
            Units    = s6xTable.CellsUnits;

            Min = Tools.getValidMinMax(s6xTable.CellsMin);
            Max = Tools.getValidMinMax(s6xTable.CellsMax);

            XUnits = s6xTable.ColsUnits;
            if ((XUnits == null || XUnits == string.Empty) && XFunction != null)
            {
                XUnits = XFunction.XUnits;
            }
            YUnits = s6xTable.RowsUnits;
            if ((YUnits == null || YUnits == string.Empty) && YFunction != null)
            {
                YUnits = YFunction.XUnits;
            }
        }
Ejemplo n.º 2
0
        public static S6xTable GetFixedTableTemplate(FixedTables fixedTable)
        {
            S6xTable oRes = new S6xTable();

            switch (fixedTable)
            {
            default:
                oRes.ShortLabel = fixedTable.ToString();
                oRes.Label      = oRes.ShortLabel;
                break;
            }

            return(oRes);
        }
 public static void updateTableRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, R_SAD806x_Def_Tables rRow, S6xTable s6xObject)
 {
     SQLite806xToolsSAD806xV10.updateTableRow(ref db806x, ref sadS6x, rRow, s6xObject);
 }
 public static object addTableRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_SAD806x_Def_Tables> rList, S6xTable s6xObject)
 {
     return(SQLite806xToolsSAD806xV10.addTableRow(ref db806x, ref sadS6x, ref rList, s6xObject));
 }
Ejemplo n.º 5
0
        public static void addTableRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_806x_Def_Tables> rList, S6xTable s6xObject)
        {
            if (db806x == null)
            {
                return;
            }
            if (sadS6x == null)
            {
                return;
            }
            if (rList == null)
            {
                return;
            }
            if (s6xObject == null)
            {
                return;
            }
            if (s6xObject.Skip || !s6xObject.Store)
            {
                return;
            }

            R_806x_Def_Tables rRow = db806x.newRow <R_806x_Def_Tables>();

            rRow.Bank.Value                 = s6xObject.BankNum;
            rRow.Address.Value              = s6xObject.AddressInt;
            rRow.UniqueAddCode.Value        = s6xObject.DuplicateNum;
            rRow.Byte.Value                 = !s6xObject.WordOutput;
            rRow.CellsScaleExpression.Value = s6xObject.CellsScaleExpression;
            rRow.CellsScalePrecision.Value  = s6xObject.CellsScalePrecision;
            rRow.CellsUnits.Value           = s6xObject.CellsUnits;
            rRow.Columns.Value              = s6xObject.ColsNumber;
            rRow.ColumnsUnits.Value         = s6xObject.ColsUnits;
            rRow.Comments.Value             = s6xObject.Comments;
            rRow.Label.Value                = s6xObject.Label;
            rRow.Rows.Value                 = s6xObject.RowsNumber;
            rRow.RowsUnits.Value            = s6xObject.RowsUnits;
            rRow.ShortLabel.Value           = s6xObject.ShortLabel;
            rRow.Signed.Value               = s6xObject.SignedOutput;

            S6xFunction s6xScaler = null;

            if (s6xObject.ColsScalerAddress != null && s6xObject.ColsScalerAddress != string.Empty)
            {
                s6xScaler = (S6xFunction)sadS6x.slFunctions[s6xObject.ColsScalerAddress];
                if (s6xScaler == null)
                {
                    s6xScaler = (S6xFunction)sadS6x.slDupFunctions[s6xObject.ColsScalerAddress];
                }

                if (s6xScaler != null)
                {
                    rRow.ColumnsScalerBank.Value          = s6xScaler.BankNum;
                    rRow.ColumnsScalerAddress.Value       = s6xScaler.AddressInt;
                    rRow.ColumnsScalerUniqueAddCode.Value = (s6xScaler.DuplicateAddress == null || s6xScaler.DuplicateAddress == string.Empty) ? 0.ToString() : s6xScaler.DuplicateNum.ToString();
                }
            }
            if (s6xObject.RowsScalerAddress != null && s6xObject.RowsScalerAddress != string.Empty)
            {
                s6xScaler = (S6xFunction)sadS6x.slFunctions[s6xObject.RowsScalerAddress];
                if (s6xScaler == null)
                {
                    s6xScaler = (S6xFunction)sadS6x.slDupFunctions[s6xObject.RowsScalerAddress];
                }

                if (s6xScaler != null)
                {
                    rRow.RowsScalerBank.Value          = s6xScaler.BankNum;
                    rRow.RowsScalerAddress.Value       = s6xScaler.AddressInt;
                    rRow.RowsScalerUniqueAddCode.Value = (s6xScaler.DuplicateAddress == null || s6xScaler.DuplicateAddress == string.Empty) ? 0.ToString() : s6xScaler.DuplicateNum.ToString();
                }
            }

            rList.Add(rRow);
        }
Ejemplo n.º 6
0
        private void calibChart_MouseClick(object sender, MouseEventArgs e)
        {
            Chart  cChart = (Chart)sender;
            Axis   xAxis  = cChart.ChartAreas[0].AxisX;
            double pPos   = (int)xAxis.PixelPositionToValue(e.Location.X);

            foreach (CustomLabel cLabel in xAxis.CustomLabels)
            {
                if (pPos >= cLabel.FromPosition && pPos <= cLabel.ToPosition)
                {
                    if (cLabel.Tag == null)
                    {
                        return;
                    }
                    if (cLabel.Tag.GetType() == typeof(S6xTable))
                    {
                        try
                        {
                            S6xTable s6xTable = (S6xTable)cLabel.Tag;
                            mainToolTip.SetToolTip((Control)sender, s6xTable.Label + "\r\n" + s6xTable.UniqueAddressHex + "\r\n" + s6xTable.ShortLabel + "\r\n\r\n" + s6xTable.Comments);
                            if (cChart == calibCurrentChart)
                            {
                                S6xNavInfo niMFHeaderCateg = new S6xNavInfo(elemsTreeView.Nodes[S6xNav.getHeaderCategName(S6xNavHeaderCategory.TABLES)]);
                                if (niMFHeaderCateg.isValid)
                                {
                                    TreeNode tnMFNode = niMFHeaderCateg.FindElement(s6xTable.UniqueAddress);
                                    if (tnMFNode != null)
                                    {
                                        elemsTreeView.SelectedNode = tnMFNode;
                                    }
                                    tnMFNode = null;
                                }
                                niMFHeaderCateg = null;
                            }
                        }
                        catch { }
                    }
                    else if (cLabel.Tag.GetType() == typeof(S6xFunction))
                    {
                        try
                        {
                            S6xFunction s6xFunction = (S6xFunction)cLabel.Tag;
                            mainToolTip.SetToolTip((Control)sender, s6xFunction.Label + "\r\n" + s6xFunction.UniqueAddressHex + "\r\n" + s6xFunction.ShortLabel + "\r\n\r\n" + s6xFunction.Comments);
                            if (cChart == calibCurrentChart)
                            {
                                S6xNavInfo niMFHeaderCateg = new S6xNavInfo(elemsTreeView.Nodes[S6xNav.getHeaderCategName(S6xNavHeaderCategory.FUNCTIONS)]);
                                if (niMFHeaderCateg.isValid)
                                {
                                    TreeNode tnMFNode = niMFHeaderCateg.FindElement(s6xFunction.UniqueAddress);
                                    if (tnMFNode != null)
                                    {
                                        elemsTreeView.SelectedNode = tnMFNode;
                                    }
                                    tnMFNode = null;
                                }
                                niMFHeaderCateg = null;
                            }
                        }
                        catch { }
                    }
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        public void Import(S6xTable s6xTable, int xdfBaseOffset)
        {
            title       = s6xTable.Label;
            description = Tools.XDFLabelSLabelComXdfComment(s6xTable.Label, s6xTable.ShortLabel, s6xTable.Comments);

            xdfAxis[0].units      = s6xTable.ColsUnits;
            xdfAxis[0].indexcount = s6xTable.ColsNumber.ToString();

            if (s6xTable.ColsScalerXdfUniqueId == null && s6xTable.ColsScalerXdfUniqueId == string.Empty)
            {
                xdfAxis[0].xdfInfo = null;
            }
            else
            {
                if (xdfAxis[0].xdfInfo == null)
                {
                    xdfAxis[0].xdfInfo           = new XdfInfo();
                    xdfAxis[0].xdfInfo.type      = "2";
                    xdfAxis[0].xdfInfo.linkobjid = s6xTable.ColsScalerXdfUniqueId;
                }
                else
                {
                    xdfAxis[0].xdfInfo.linkobjid = s6xTable.ColsScalerXdfUniqueId;
                }
            }

            xdfAxis[1].units      = s6xTable.RowsUnits;
            xdfAxis[1].indexcount = s6xTable.RowsNumber.ToString();
            if (s6xTable.RowsScalerXdfUniqueId == null && s6xTable.RowsScalerXdfUniqueId == string.Empty)
            {
                xdfAxis[1].xdfInfo = null;
            }
            else
            {
                if (xdfAxis[1].xdfInfo == null)
                {
                    xdfAxis[1].xdfInfo           = new XdfInfo();
                    xdfAxis[1].xdfInfo.type      = "2";
                    xdfAxis[1].xdfInfo.linkobjid = s6xTable.RowsScalerXdfUniqueId;
                }
                else
                {
                    xdfAxis[1].xdfInfo.linkobjid = s6xTable.RowsScalerXdfUniqueId;
                }
            }

            xdfAxis[2].xdfData.mmedaddress = Tools.xdfAddressFromBinAddress(s6xTable.AddressBinInt, xdfBaseOffset);
            if (s6xTable.WordOutput)
            {
                xdfAxis[2].xdfData.mmedelementsizebits = "16";
            }
            else
            {
                xdfAxis[2].xdfData.mmedelementsizebits = "8";
            }
            if (s6xTable.SignedOutput)
            {
                xdfAxis[2].xdfData.mmedtypeflags = "0x03";
            }
            else
            {
                xdfAxis[2].xdfData.mmedtypeflags = "0x02";
            }
            xdfAxis[2].xdfData.mmedrowcount = s6xTable.RowsNumber.ToString();
            xdfAxis[2].xdfData.mmedcolcount = s6xTable.ColsNumber.ToString();

            xdfAxis[2].units            = s6xTable.CellsUnits;
            xdfAxis[2].xdfMath.equation = s6xTable.CellsScaleExpression.Trim();
            if (s6xTable.CellsScalePrecision >= SADDef.DefaultScaleMinPrecision && s6xTable.CellsScalePrecision <= SADDef.DefaultScaleMaxPrecision)
            {
                xdfAxis[2].decimalpl = s6xTable.CellsScalePrecision.ToString();
            }
        }
Ejemplo n.º 8
0
 public XdfTable(S6xTable s6xTable, int xdfBaseOffset)
 {
     Init();
     Import(s6xTable, xdfBaseOffset);
 }
Ejemplo n.º 9
0
        public static bool showElemData(ref DataGridView elemDataGridView, ref SADBin sadBin, object s6xObject, bool dataDecimal, bool ignoreDefinedConversion, bool dataReversed, RepositoryConversionItem rcOutput, RepositoryConversionItem rcInput)
        {
            S6xScalar    s6xScalar   = null;
            S6xFunction  s6xFunction = null;
            S6xTable     s6xTable    = null;
            S6xStructure s6xStruct   = null;
            DataTable    dtTable     = null;
            Type         dataType    = null;
            string       sValue      = string.Empty;
            int          iValue      = 0;
            int          iAddress    = 0;

            string[] arrBytes       = null;
            string[] arrCols        = null;
            object[] arrRows        = null;
            object[] arrRowsHeaders = null;
            object[] arrRow         = null;
            bool     failedScale    = false;
            int      iBfTop         = -1;

            if (elemDataGridView == null)
            {
                return(false);
            }
            if (sadBin == null)
            {
                return(false);
            }
            if (s6xObject == null)
            {
                return(false);
            }

            if (dataDecimal)
            {
                dataType = typeof(double);
            }
            else
            {
                dataType = typeof(string);
            }

            elemDataGridView.DataSource = null;

            S6xNavHeaderCategory headerCategory = S6xNavHeaderCategory.UNDEFINED;

            if (s6xObject.GetType() == typeof(S6xScalar))
            {
                headerCategory = S6xNavHeaderCategory.SCALARS;
            }
            else if (s6xObject.GetType() == typeof(S6xFunction))
            {
                headerCategory = S6xNavHeaderCategory.FUNCTIONS;
            }
            else if (s6xObject.GetType() == typeof(S6xTable))
            {
                headerCategory = S6xNavHeaderCategory.TABLES;
            }
            else if (s6xObject.GetType() == typeof(S6xStructure))
            {
                headerCategory = S6xNavHeaderCategory.STRUCTURES;
            }

            switch (headerCategory)
            {
            case S6xNavHeaderCategory.SCALARS:
                s6xScalar = (S6xScalar)s6xObject;

                elemDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

                s6xScalar.AddressBinInt = Tools.binAddressCorrected(s6xScalar.BankNum, s6xScalar.AddressInt, ref sadBin, s6xScalar.AddressBinInt);

                if (s6xScalar.isBitFlags)
                {
                    dataType = typeof(string);
                    arrCols  = null;
                    if (s6xScalar.BitFlags != null)
                    {
                        if (s6xScalar.BitFlags.Length > 0)
                        {
                            arrCols = new string[s6xScalar.BitFlags.Length + 1];
                            for (int iCol = 1; iCol < arrCols.Length; iCol++)
                            {
                                arrCols[iCol] = s6xScalar.BitFlags[arrCols.Length - iCol - 1].ShortLabel;
                            }
                        }
                    }
                    // Default BitFlags
                    if (arrCols == null)
                    {
                        iBfTop = 15;
                        if (s6xScalar.Byte)
                        {
                            iBfTop = 7;
                        }

                        for (int iBf = iBfTop; iBf >= 0; iBf--)
                        {
                            arrCols = new string[iBfTop + 2];
                            for (int iCol = 1; iCol < arrCols.Length; iCol++)
                            {
                                arrCols[iCol] = "B" + iBf.ToString();
                            }
                        }
                    }
                    // For better output
                    if (arrCols != null)
                    {
                        for (int iCol = 1; iCol < arrCols.Length; iCol++)
                        {
                            arrCols[iCol] = OutputTools.GetSpacesCenteredString(arrCols[iCol], 20);
                        }
                    }
                }
                else
                {
                    arrCols = new string[1];
                }
                if (s6xScalar.Byte)
                {
                    arrCols[0] = "Byte";
                    arrBytes   = sadBin.getBytesArray(s6xScalar.AddressBinInt, 1);
                    try
                    {
                        sValue = arrBytes[0];
                        iValue = Tools.getByteInt(sValue, s6xScalar.Signed);
                    }
                    catch
                    {
                        sValue = string.Empty;
                        iValue = 0;
                    }
                }
                else
                {
                    arrCols[0] = "Word";
                    arrBytes   = sadBin.getBytesArray(s6xScalar.AddressBinInt, 2);
                    try
                    {
                        sValue = Tools.LsbFirst(arrBytes);
                        iValue = Tools.getWordInt(sValue, s6xScalar.Signed);
                    }
                    catch
                    {
                        sValue = string.Empty;
                        iValue = 0;
                    }
                }
                // For better output
                if (arrCols.Length == 1)
                {
                    arrCols[0] = OutputTools.GetSpacesCenteredString(arrCols[0], 100);
                }
                else
                {
                    arrCols[0] = OutputTools.GetSpacesCenteredString(arrCols[0], 50);
                }

                arrRow = new object[arrCols.Length];
                if (s6xScalar.isBitFlags)
                {
                    BitArray arrBit = new BitArray(new int[] { iValue });
                    for (int iCol = 1; iCol < arrRow.Length; iCol++)
                    {
                        if (arrBit[s6xScalar.BitFlags[arrRow.Length - iCol - 1].Position])
                        {
                            arrRow[iCol] = s6xScalar.BitFlags[arrRow.Length - iCol - 1].SetValue;
                        }
                        else
                        {
                            arrRow[iCol] = s6xScalar.BitFlags[arrRow.Length - iCol - 1].NotSetValue;
                        }
                    }
                }
                if (dataDecimal)
                {
                    if (failedScale)
                    {
                        arrRow[0] = iValue;
                    }
                    else
                    {
                        try
                        {
                            if (ignoreDefinedConversion)
                            {
                                if (rcOutput == null)
                                {
                                    arrRow[0] = iValue;
                                }
                                else
                                {
                                    arrRow[0] = Tools.ScaleValue(iValue, rcOutput.InternalFormula, 0, true);
                                }
                            }
                            else
                            {
                                if (rcOutput == null)
                                {
                                    arrRow[0] = Tools.ScaleValue(iValue, s6xScalar.ScaleExpression, s6xScalar.ScalePrecision, true);
                                }
                                else
                                {
                                    arrRow[0] = Tools.ScaleValue(iValue, rcOutput.InternalFormula.ToUpper().Replace("X", "(" + s6xScalar.ScaleExpression + ")"), s6xScalar.ScalePrecision, true);
                                }
                            }
                        }
                        catch
                        {
                            failedScale = true;
                            arrRow[0]   = iValue;
                        }
                    }
                }
                else
                {
                    arrRow[0] = sValue.ToUpper();
                }

                arrRows = new object[] { arrRow };

                s6xScalar = null;
                break;

            case S6xNavHeaderCategory.FUNCTIONS:
                s6xFunction = (S6xFunction)s6xObject;

                elemDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                s6xFunction.AddressBinInt = Tools.binAddressCorrected(s6xFunction.BankNum, s6xFunction.AddressInt, ref sadBin, s6xFunction.AddressBinInt);

                arrCols    = new string[2];
                arrCols[0] = "Word Input";
                iValue     = 2;
                if (s6xFunction.ByteInput)
                {
                    arrCols[0] = "Byte Input";
                    iValue--;
                }
                arrCols[1] = "Word Output";
                iValue    += 2;
                if (s6xFunction.ByteOutput)
                {
                    arrCols[1] = "Byte Output";
                    iValue--;
                }
                arrCols[0] = OutputTools.GetSpacesCenteredString(arrCols[0], 50);       // For better output
                arrCols[1] = OutputTools.GetSpacesCenteredString(arrCols[1], 50);       // For better output

                if (s6xFunction.RowsNumber <= 0)
                {
                    arrRows = new object[] { };
                }
                else
                {
                    arrRows  = new object[s6xFunction.RowsNumber];
                    arrBytes = sadBin.getBytesArray(s6xFunction.AddressBinInt, iValue * arrRows.Length);
                    iAddress = 0;
                    for (int iRow = 0; iRow < arrRows.Length; iRow++)
                    {
                        arrRow = new object[arrCols.Length];
                        for (int iCol = 0; iCol < arrRow.Length; iCol++)
                        {
                            if (iCol % 2 == 0)
                            {
                                if (s6xFunction.ByteInput)
                                {
                                    try
                                    {
                                        sValue = arrBytes[iAddress];
                                        iValue = Tools.getByteInt(sValue, s6xFunction.SignedInput);
                                    }
                                    catch
                                    {
                                        sValue = string.Empty;
                                        iValue = 0;
                                    }
                                    iAddress++;
                                }
                                else
                                {
                                    try
                                    {
                                        sValue = arrBytes[iAddress + 1] + arrBytes[iAddress];
                                        iValue = Tools.getWordInt(sValue, s6xFunction.SignedInput);
                                    }
                                    catch
                                    {
                                        sValue = string.Empty;
                                        iValue = 0;
                                    }
                                    iAddress += 2;
                                }
                                if (dataDecimal)
                                {
                                    if (failedScale)
                                    {
                                        arrRow[iCol] = iValue;
                                    }
                                    else
                                    {
                                        try
                                        {
                                            if (ignoreDefinedConversion)
                                            {
                                                if (rcInput == null)
                                                {
                                                    arrRow[iCol] = iValue;
                                                }
                                                else
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, rcInput.InternalFormula, 0, true);
                                                }
                                            }
                                            else
                                            {
                                                if (rcInput == null)
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, s6xFunction.InputScaleExpression, s6xFunction.InputScalePrecision, true);
                                                }
                                                else
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, rcInput.InternalFormula.ToUpper().Replace("X", "(" + s6xFunction.InputScaleExpression + ")"), s6xFunction.InputScalePrecision, true);
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            failedScale  = true;
                                            arrRow[iCol] = iValue;
                                        }
                                    }
                                }
                                else
                                {
                                    arrRow[iCol] = sValue.ToUpper();
                                }
                            }
                            else
                            {
                                if (s6xFunction.ByteOutput)
                                {
                                    try
                                    {
                                        sValue = arrBytes[iAddress];
                                        iValue = Tools.getByteInt(sValue, s6xFunction.SignedOutput);
                                    }
                                    catch
                                    {
                                        sValue = string.Empty;
                                        iValue = 0;
                                    }
                                    iAddress++;
                                }
                                else
                                {
                                    try
                                    {
                                        sValue = arrBytes[iAddress + 1] + arrBytes[iAddress];
                                        iValue = Tools.getWordInt(sValue, s6xFunction.SignedOutput);
                                    }
                                    catch
                                    {
                                        sValue = string.Empty;
                                        iValue = 0;
                                    }
                                    iAddress += 2;
                                }
                                if (dataDecimal)
                                {
                                    if (failedScale)
                                    {
                                        arrRow[iCol] = iValue;
                                    }
                                    else
                                    {
                                        try
                                        {
                                            if (ignoreDefinedConversion)
                                            {
                                                if (rcOutput == null)
                                                {
                                                    arrRow[iCol] = iValue;
                                                }
                                                else
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, rcOutput.InternalFormula, 0, true);
                                                }
                                            }
                                            else
                                            {
                                                if (rcOutput == null)
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, s6xFunction.OutputScaleExpression, s6xFunction.OutputScalePrecision, true);
                                                }
                                                else
                                                {
                                                    arrRow[iCol] = Tools.ScaleValue(iValue, rcOutput.InternalFormula.ToUpper().Replace("X", "(" + s6xFunction.OutputScaleExpression + ")"), s6xFunction.OutputScalePrecision, true);
                                                }
                                            }
                                        }
                                        catch
                                        {
                                            failedScale  = true;
                                            arrRow[iCol] = iValue;
                                        }
                                    }
                                }
                                else
                                {
                                    arrRow[iCol] = sValue.ToUpper();
                                }
                            }
                        }
                        arrRows[iRow] = arrRow;
                    }
                }
                s6xFunction = null;
                break;

            case S6xNavHeaderCategory.TABLES:
                s6xTable = (S6xTable)s6xObject;
                if (s6xTable.ColsNumber <= 0)
                {
                    return(false);
                }

                elemDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                s6xTable.AddressBinInt = Tools.binAddressCorrected(s6xTable.BankNum, s6xTable.AddressInt, ref sadBin, s6xTable.AddressBinInt);

                //arrCols = new string[s6xTable.ColsNumber];
                //for (int iCol = 0; iCol < arrCols.Length; iCol++) arrCols[iCol] = (iCol + 1).ToString();
                arrCols = getTableElemDataScale(ref sadBin, s6xTable.ColsScalerAddress, s6xTable.ColsNumber);

                // For better output
                if (arrCols != null)
                {
                    for (int iCol = 0; iCol < arrCols.Length; iCol++)
                    {
                        arrCols[iCol] = OutputTools.GetSpacesCenteredString(arrCols[iCol], 10);
                    }
                }

                if (s6xTable.RowsNumber <= 0)
                {
                    arrRows = new object[] { };
                }
                else
                {
                    arrRows        = new object[s6xTable.RowsNumber];
                    arrRowsHeaders = getTableElemDataScale(ref sadBin, s6xTable.RowsScalerAddress, s6xTable.RowsNumber);
                    if (s6xTable.WordOutput)
                    {
                        arrBytes = sadBin.getBytesArray(s6xTable.AddressBinInt, arrCols.Length * arrRows.Length * 2);
                    }
                    else
                    {
                        arrBytes = sadBin.getBytesArray(s6xTable.AddressBinInt, arrCols.Length * arrRows.Length);
                    }
                    iAddress = 0;
                    for (int iRow = 0; iRow < arrRows.Length; iRow++)
                    {
                        arrRow = new object[arrCols.Length];
                        for (int iCol = 0; iCol < arrRow.Length; iCol++)
                        {
                            try
                            {
                                if (s6xTable.WordOutput)
                                {
                                    sValue = arrBytes[iAddress + 1] + arrBytes[iAddress];
                                    iValue = Tools.getWordInt(sValue, s6xTable.SignedOutput);
                                }
                                else
                                {
                                    sValue = arrBytes[iAddress];
                                    iValue = Tools.getByteInt(sValue, s6xTable.SignedOutput);
                                }
                            }
                            catch
                            {
                                sValue = string.Empty;
                                iValue = 0;
                            }
                            iAddress++;
                            if (s6xTable.WordOutput)
                            {
                                iAddress++;
                            }

                            if (dataDecimal)
                            {
                                if (failedScale)
                                {
                                    arrRow[iCol] = iValue;
                                }
                                else
                                {
                                    try
                                    {
                                        if (ignoreDefinedConversion)
                                        {
                                            if (rcOutput == null)
                                            {
                                                arrRow[iCol] = iValue;
                                            }
                                            else
                                            {
                                                arrRow[iCol] = Tools.ScaleValue(iValue, rcOutput.InternalFormula, 0, true);
                                            }
                                        }
                                        else
                                        {
                                            if (rcOutput == null)
                                            {
                                                arrRow[iCol] = Tools.ScaleValue(iValue, s6xTable.CellsScaleExpression, s6xTable.CellsScalePrecision, true);
                                            }
                                            else
                                            {
                                                arrRow[iCol] = Tools.ScaleValue(iValue, rcOutput.InternalFormula.ToUpper().Replace("X", "(" + s6xTable.CellsScaleExpression + ")"), s6xTable.CellsScalePrecision, true);
                                            }
                                        }
                                    }
                                    catch
                                    {
                                        failedScale  = true;
                                        arrRow[iCol] = iValue;
                                    }
                                }
                            }
                            else
                            {
                                arrRow[iCol] = sValue.ToUpper();
                            }
                        }
                        arrRows[iRow] = arrRow;
                    }
                }
                s6xTable = null;
                break;

            case S6xNavHeaderCategory.STRUCTURES:
                s6xStruct = (S6xStructure)s6xObject;
                if (s6xStruct.Number <= 0)
                {
                    return(false);
                }

                s6xStruct.Structure = new Structure(s6xStruct);
                if (!s6xStruct.Structure.isValid)
                {
                    return(false);
                }
                if (s6xStruct.Structure.isEmpty)
                {
                    return(false);
                }

                elemDataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                s6xStruct.Structure.AddressBinInt = Tools.binAddressCorrected(s6xStruct.Structure.BankNum, s6xStruct.Structure.AddressInt, ref sadBin, s6xStruct.Structure.AddressBinInt);

                arrBytes = sadBin.getBytesArray(s6xStruct.Structure.AddressBinInt, s6xStruct.Structure.MaxSizeSingle * s6xStruct.Number);
                s6xStruct.Structure.Read(ref arrBytes, s6xStruct.Number);
                arrBytes = null;

                arrCols = new string[s6xStruct.Structure.MaxLineItemsNum];
                for (int iCol = 0; iCol < arrCols.Length; iCol++)
                {
                    arrCols[iCol] = (iCol + 1).ToString();
                }

                // For better output
                for (int iCol = 0; iCol < arrCols.Length; iCol++)
                {
                    arrCols[iCol] = OutputTools.GetSpacesCenteredString(arrCols[iCol], 10);
                }

                dataType = typeof(string);

                if (s6xStruct.Structure.Lines.Count <= 0)
                {
                    arrRows = new object[] { };
                }
                else
                {
                    arrRows        = new object[s6xStruct.Structure.Lines.Count];
                    arrRowsHeaders = new object[s6xStruct.Structure.Lines.Count];
                    int iRow = 0;
                    foreach (StructureLine structLine in s6xStruct.Structure.Lines)
                    {
                        arrRowsHeaders[iRow] = structLine.NumberInStructure.ToString();
                        arrRow = new object[arrCols.Length];
                        for (int iCol = 0; iCol < structLine.Items.Count; iCol++)
                        {
                            arrRow[iCol] = ((StructureItem)structLine.Items[iCol]).Value(structLine.NumberInStructure);
                        }
                        arrRows[iRow] = arrRow;
                        iRow++;
                    }
                }
                s6xStruct = null;
                break;

            default:
                return(false);
            }

            if (arrCols == null)
            {
                return(false);
            }

            if (dataReversed)
            {
                object[] arrReversedRows = new object[arrRows.Length];
                for (int iRow = 0; iRow < arrReversedRows.Length; iRow++)
                {
                    arrReversedRows[arrReversedRows.Length - 1 - iRow] = arrRows[iRow];
                }
                arrRows         = arrReversedRows;
                arrReversedRows = null;

                if (arrRowsHeaders != null)
                {
                    arrReversedRows = new object[arrRowsHeaders.Length];
                    for (int iRow = 0; iRow < arrReversedRows.Length; iRow++)
                    {
                        arrReversedRows[arrReversedRows.Length - 1 - iRow] = arrRowsHeaders[iRow];
                    }
                    arrRowsHeaders  = arrReversedRows;
                    arrReversedRows = null;
                }
            }

            dtTable = new DataTable();
            //foreach (string colLabel in arrCols) dtTable.Columns.Add(new DataColumn(colLabel, dataType));
            for (int iCol = 0; iCol < arrCols.Length; iCol++)
            {
                DataColumn dcDC = new DataColumn(iCol.ToString(), dataType);
                dcDC.Caption = arrCols[iCol];
                dtTable.Columns.Add(dcDC);
            }

            foreach (object[] oRow in arrRows)
            {
                dtTable.Rows.Add(oRow);
            }
            arrRows = null;

            elemDataGridView.Tag = new object[] { arrCols, arrRowsHeaders };

            // For Speed purpose
            elemDataGridView.AutoSizeColumnsMode     = DataGridViewAutoSizeColumnsMode.None;
            elemDataGridView.AutoSizeRowsMode        = DataGridViewAutoSizeRowsMode.None;
            elemDataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;

            try { elemDataGridView.DataSource = dtTable; }
            catch { return(false); }

            // For Speed purpose
            switch (headerCategory)
            {
            case S6xNavHeaderCategory.SCALARS:
            case S6xNavHeaderCategory.FUNCTIONS:
                elemDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                break;

            case S6xNavHeaderCategory.TABLES:
            case S6xNavHeaderCategory.STRUCTURES:
                //elemDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
                elemDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                break;
            }

            elemDataGridView.AutoSizeRowsMode        = DataGridViewAutoSizeRowsMode.None;
            elemDataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;

            dtTable        = null;
            arrCols        = null;
            arrRowsHeaders = null;

            elemDataGridView.Visible = true;

            return(true);
        }