Esempio n. 1
0
        public void addCategory(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel, string categoryName)
        {
            S6xNavCategory newNICateg = new S6xNavCategory(categoryName);

            if (categoryLevel == S6xNavCategoryLevel.ONE)
            {
                if (!slLists1[headerCategory].ContainsKey(newNICateg.Key))
                {
                    slLists1[headerCategory].Add(newNICateg.Key, newNICateg);
                }
            }
            else if (categoryLevel == S6xNavCategoryLevel.TWO)
            {
                if (!slLists2[headerCategory].ContainsKey(newNICateg.Key))
                {
                    slLists2[headerCategory].Add(newNICateg.Key, newNICateg);
                }
            }
            else if (categoryLevel == S6xNavCategoryLevel.THREE)
            {
                if (!slLists3[headerCategory].ContainsKey(newNICateg.Key))
                {
                    slLists3[headerCategory].Add(newNICateg.Key, newNICateg);
                }
            }
        }
Esempio n. 2
0
        private void BitFlagsForm_Load(object sender, EventArgs e)
        {
            advElemsTreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(advElemsTreeView_NodeMouseClick);
            advElemsTreeView.AfterSelect    += new TreeViewEventHandler(advElemsTreeView_AfterSelect);

            advElemsContextMenuStrip.Opening += new CancelEventHandler(advElemsContextMenuStrip_Opening);

            bitFlagPositionComboBox.SelectedIndexChanged += new EventHandler(bitFlagPositionComboBox_SelectedIndexChanged);

            sharedIdentificationStatusTrackBar.ValueChanged += new EventHandler(sharedIdentificationStatusTrackBar_ValueChanged);

            S6xNavHeaderCategory headerCateg = S6xNavHeaderCategory.UNDEFINED;

            if (s6xScalar != null)
            {
                advLabelTextBox.Text  = s6xScalar.Label;
                advSLabelTextBox.Text = s6xScalar.UniqueAddressHex;
                headerCateg           = S6xNavHeaderCategory.SCALARS;
            }
            else if (s6xReg != null)
            {
                advLabelTextBox.Text  = s6xReg.Label;
                advSLabelTextBox.Text = s6xReg.Address;
                headerCateg           = S6xNavHeaderCategory.REGISTERS;
            }

            sharedCategComboBox.Items.Clear();
            sharedCategComboBox.Items.Add(new S6xNavCategory(string.Empty));
            foreach (S6xNavCategory navCateg in s6xNavCategories.getCategories(headerCateg, S6xNavCategoryLevel.ONE, true).Values)
            {
                sharedCategComboBox.Items.Add(navCateg);
            }
            sharedCateg2ComboBox.Items.Clear();
            sharedCateg2ComboBox.Items.Add(new S6xNavCategory(string.Empty));
            foreach (S6xNavCategory navCateg in s6xNavCategories.getCategories(headerCateg, S6xNavCategoryLevel.TWO, true).Values)
            {
                sharedCateg2ComboBox.Items.Add(navCateg);
            }
            sharedCateg3ComboBox.Items.Clear();
            sharedCateg3ComboBox.Items.Add(new S6xNavCategory(string.Empty));
            foreach (S6xNavCategory navCateg in s6xNavCategories.getCategories(headerCateg, S6xNavCategoryLevel.THREE, true).Values)
            {
                sharedCateg3ComboBox.Items.Add(navCateg);
            }

            Control.ControlCollection controls = null;
            controls = (Control.ControlCollection)bitFlagTabPage.Controls;
            attachPropertiesEventsControls(ref controls);
            controls = null;

            loadElemsTreeView();
            if (advElemsTreeView.Nodes[TreeRootNodeName].Nodes.Count == 0)
            {
                clearElem();
            }
            else
            {
                advElemsTreeView.SelectedNode = advElemsTreeView.Nodes[TreeRootNodeName].Nodes[0];
            }
        }
Esempio n. 3
0
        public bool addCategory(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel, string categoryName)
        {
            S6xNavCategory newNICateg = new S6xNavCategory(categoryName);

            switch (categoryLevel)
            {
            case S6xNavCategoryLevel.ONE:
                if (slLists1[headerCategory].ContainsKey(newNICateg.Key))
                {
                    return(false);
                }
                slLists1[headerCategory].Add(newNICateg.Key, newNICateg);
                return(true);

            case S6xNavCategoryLevel.TWO:
                if (slLists2[headerCategory].ContainsKey(newNICateg.Key))
                {
                    return(false);
                }
                slLists2[headerCategory].Add(newNICateg.Key, newNICateg);
                return(true);

            case S6xNavCategoryLevel.THREE:
                if (slLists3[headerCategory].ContainsKey(newNICateg.Key))
                {
                    return(false);
                }
                slLists3[headerCategory].Add(newNICateg.Key, newNICateg);
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        public static void s6xNavCategoriesLoad(S6xNavHeaderCategory headerCateg, ComboBox categComboBox, S6xNavCategoryLevel ncLevel, ref S6xNavCategories s6xNavCategories)
        {
            if (categComboBox.Tag != null)
            {
                // No need to reload
                if ((S6xNavHeaderCategory)categComboBox.Tag == headerCateg)
                {
                    return;
                }
            }

            if (s6xNavCategories == null)
            {
                s6xNavCategories = new S6xNavCategories();
            }

            categComboBox.Items.Clear();

            categComboBox.Items.Add(new S6xNavCategory(string.Empty));

            foreach (S6xNavCategory navCateg in s6xNavCategories.getCategories(headerCateg, ncLevel, true).Values)
            {
                categComboBox.Items.Add(navCateg);
            }

            categComboBox.Tag = headerCateg;
        }
Esempio n. 5
0
        public SortedList <string, S6xNavCategory> getCategories(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel, bool globalIncluded)
        {
            if (!globalIncluded)
            {
                if (categoryLevel == S6xNavCategoryLevel.ONE)
                {
                    return(slLists1[headerCategory]);
                }
                else if (categoryLevel == S6xNavCategoryLevel.TWO)
                {
                    return(slLists2[headerCategory]);
                }
                else if (categoryLevel == S6xNavCategoryLevel.THREE)
                {
                    return(slLists3[headerCategory]);
                }
            }

            SortedList <string, S6xNavCategory> slResultList = null;

            if (categoryLevel == S6xNavCategoryLevel.ONE)
            {
                slResultList = new SortedList <string, S6xNavCategory>(slLists1[headerCategory]);
                foreach (S6xNavCategory gbNICateg in slLists1[S6xNavHeaderCategory.UNDEFINED].Values)
                {
                    if (!slResultList.ContainsKey(gbNICateg.Key))
                    {
                        slResultList.Add(gbNICateg.Key, gbNICateg);
                    }
                }
            }
            else if (categoryLevel == S6xNavCategoryLevel.TWO)
            {
                slResultList = new SortedList <string, S6xNavCategory>(slLists2[headerCategory]);
                foreach (S6xNavCategory gbNICateg in slLists2[S6xNavHeaderCategory.UNDEFINED].Values)
                {
                    if (!slResultList.ContainsKey(gbNICateg.Key))
                    {
                        slResultList.Add(gbNICateg.Key, gbNICateg);
                    }
                }
            }
            else if (categoryLevel == S6xNavCategoryLevel.THREE)
            {
                slResultList = new SortedList <string, S6xNavCategory>(slLists3[headerCategory]);
                foreach (S6xNavCategory gbNICateg in slLists3[S6xNavHeaderCategory.UNDEFINED].Values)
                {
                    if (!slResultList.ContainsKey(gbNICateg.Key))
                    {
                        slResultList.Add(gbNICateg.Key, gbNICateg);
                    }
                }
            }
            return(slResultList);
        }
Esempio n. 6
0
 public void resetCategory(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel)
 {
     if (categoryLevel == S6xNavCategoryLevel.ONE)
     {
         slLists1[headerCategory] = new SortedList <string, S6xNavCategory>();
     }
     else if (categoryLevel == S6xNavCategoryLevel.TWO)
     {
         slLists2[headerCategory] = new SortedList <string, S6xNavCategory>();
     }
     else if (categoryLevel == S6xNavCategoryLevel.THREE)
     {
         slLists3[headerCategory] = new SortedList <string, S6xNavCategory>();
     }
 }
Esempio n. 7
0
        public static void s6xNavCategoriesAdd(S6xNavHeaderCategory addHeaderCateg, S6xNavHeaderCategory reloadHeaderCateg, ref ComboBox categComboBox, S6xNavCategoryLevel ncLevel, string newCategory, ref S6xNavCategories s6xNavCategories)
        {
            if (newCategory == null || newCategory == string.Empty)
            {
                return;
            }

            bool addedCategory = s6xNavCategories.addCategory(addHeaderCateg, ncLevel, newCategory);

            if (addedCategory)
            {
                categComboBox.Tag = null;   // To force the reload
                s6xNavCategoriesLoad(reloadHeaderCateg, categComboBox, ncLevel, ref s6xNavCategories);
            }
        }
Esempio n. 8
0
        public S6xNavCategory getCategory(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel, bool globalIncluded, string categoryName)
        {
            if (categoryName == null || categoryName == string.Empty)
            {
                return(null);
            }

            try
            {
                return(getCategories(headerCategory, categoryLevel, globalIncluded)[(new S6xNavCategory(categoryName)).Key]);
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 9
0
        private void showElemData()
        {
            if (sadBin == null || s6xObject == null)
            {
                this.Close();
            }

            S6xNavHeaderCategory headerCategory = S6xNavHeaderCategory.UNDEFINED;

            if (s6xObject.GetType() == typeof(S6xScalar))
            {
                headerCategory          = S6xNavHeaderCategory.SCALARS;
                elemLabelTextBox.Text   = ((S6xScalar)s6xObject).Label;
                elemBankTextBox.Text    = ((S6xScalar)s6xObject).BankNum.ToString();
                elemAddressTextBox.Text = ((S6xScalar)s6xObject).Address;
            }
            else if (s6xObject.GetType() == typeof(S6xFunction))
            {
                headerCategory          = S6xNavHeaderCategory.FUNCTIONS;
                elemLabelTextBox.Text   = ((S6xFunction)s6xObject).Label;
                elemBankTextBox.Text    = ((S6xFunction)s6xObject).BankNum.ToString();
                elemAddressTextBox.Text = ((S6xFunction)s6xObject).Address;
            }
            else if (s6xObject.GetType() == typeof(S6xTable))
            {
                headerCategory          = S6xNavHeaderCategory.TABLES;
                elemLabelTextBox.Text   = ((S6xTable)s6xObject).Label;
                elemBankTextBox.Text    = ((S6xTable)s6xObject).BankNum.ToString();
                elemAddressTextBox.Text = ((S6xTable)s6xObject).Address;
            }
            else if (s6xObject.GetType() == typeof(S6xStructure))
            {
                headerCategory          = S6xNavHeaderCategory.STRUCTURES;
                elemLabelTextBox.Text   = ((S6xStructure)s6xObject).Label;
                elemBankTextBox.Text    = ((S6xStructure)s6xObject).BankNum.ToString();
                elemAddressTextBox.Text = ((S6xStructure)s6xObject).Address;
            }

            if (headerCategory == S6xNavHeaderCategory.UNDEFINED)
            {
                this.Close();
            }

            ToolsElemData.showElemData(ref elemDataGridView, ref sadBin, s6xObject, decimalToolStripMenuItem.Checked, decimalNotConvertedToolStripMenuItem.Checked, reverseOrderToolStripMenuItem.Checked, (RepositoryConversionItem)convertToolStripMenuItem.Tag, (RepositoryConversionItem)convertInputToolStripMenuItem.Tag);
        }
Esempio n. 10
0
        public static string getHeaderCategToolTip(S6xNavHeaderCategory hCateg)
        {
            switch (hCateg)
            {
            case S6xNavHeaderCategory.PROPERTIES:
                return("Properties");

            case S6xNavHeaderCategory.RESERVED:
                return("Reserved Elements");

            case S6xNavHeaderCategory.TABLES:
                return("Tables");

            case S6xNavHeaderCategory.FUNCTIONS:
                return("Functions");

            case S6xNavHeaderCategory.SCALARS:
                return("Scalars");

            case S6xNavHeaderCategory.STRUCTURES:
                return("Structures");

            case S6xNavHeaderCategory.ROUTINES:
                return("Routines");

            case S6xNavHeaderCategory.OPERATIONS:
                return("Operations");

            case S6xNavHeaderCategory.REGISTERS:
                return("Registers");

            case S6xNavHeaderCategory.OTHER:
                return("Other Addresses");

            case S6xNavHeaderCategory.SIGNATURES:
                return("Routines Signatures");

            case S6xNavHeaderCategory.ELEMSSIGNATURES:
                return("Elements Signatures");

            default:
                return(string.Empty);
            }
        }
Esempio n. 11
0
        public int getCategoriesCount(S6xNavHeaderCategory headerCategory, S6xNavCategoryLevel categoryLevel, bool globalIncluded)
        {
            int iCount = 0;

            if (categoryLevel == S6xNavCategoryLevel.ONE)
            {
                iCount = slLists1[headerCategory].Count + (globalIncluded ? slLists1[S6xNavHeaderCategory.UNDEFINED].Count : 0);
            }
            else if (categoryLevel == S6xNavCategoryLevel.TWO)
            {
                iCount = slLists2[headerCategory].Count + (globalIncluded ? slLists2[S6xNavHeaderCategory.UNDEFINED].Count : 0);
            }
            else if (categoryLevel == S6xNavCategoryLevel.THREE)
            {
                iCount = slLists3[headerCategory].Count + (globalIncluded ? slLists3[S6xNavHeaderCategory.UNDEFINED].Count : 0);
            }

            return(iCount);
        }
Esempio n. 12
0
        public static string getS6xNavHeaderCategoryStateImageKey(S6xNavHeaderCategory headerCateg)
        {
            switch (headerCateg)
            {
            case S6xNavHeaderCategory.PROPERTIES:
                return("elemProperty");

            case S6xNavHeaderCategory.RESERVED:
                return("elemReserved");

            case S6xNavHeaderCategory.TABLES:
                return("elemTable");

            case S6xNavHeaderCategory.FUNCTIONS:
                return("elemFunction");

            case S6xNavHeaderCategory.SCALARS:
                return("elemScalar");

            case S6xNavHeaderCategory.STRUCTURES:
                return("elemStructure");

            case S6xNavHeaderCategory.ROUTINES:
                return("elemRoutine");

            case S6xNavHeaderCategory.OPERATIONS:
                return("elemOperation");

            case S6xNavHeaderCategory.REGISTERS:
                return("elemRegister");

            case S6xNavHeaderCategory.OTHER:
                return("elemOther");

            case S6xNavHeaderCategory.SIGNATURES:
                return("elemSignature");

            case S6xNavHeaderCategory.ELEMSSIGNATURES:
                return("elemSignature");
            }

            return(string.Empty);
        }
Esempio n. 13
0
 public static string getHeaderCategName(S6xNavHeaderCategory hCateg)
 {
     return(Enum.GetName(typeof(S6xNavHeaderCategory), hCateg));
 }
Esempio n. 14
0
        public static void s6xNavCategoriesReset(S6xNavHeaderCategory headerCateg, ref S6xNavCategories s6xNavCategories, ref SADBin sadBin, ref SADS6x sadS6x)
        {
            if (s6xNavCategories == null)
            {
                s6xNavCategories = new S6xNavCategories();
            }

            if (headerCateg == S6xNavHeaderCategory.RESERVED && sadBin != null)
            {
                if (sadBin.Bank8 != null)
                {
                    s6xNavCategories.addCategory(headerCateg, S6xNavCategoryLevel.ONE, "Bank 8");
                }
                if (sadBin.Bank1 != null)
                {
                    s6xNavCategories.addCategory(headerCateg, S6xNavCategoryLevel.ONE, "Bank 1");
                }
                if (sadBin.Bank9 != null)
                {
                    s6xNavCategories.addCategory(headerCateg, S6xNavCategoryLevel.ONE, "Bank 9");
                }
                if (sadBin.Bank0 != null)
                {
                    s6xNavCategories.addCategory(headerCateg, S6xNavCategoryLevel.ONE, "Bank 0");
                }
                return;
            }

            if (sadS6x != null)
            {
                s6xNavCategories.resetCategory(headerCateg, S6xNavCategoryLevel.ONE);
                s6xNavCategories.resetCategory(headerCateg, S6xNavCategoryLevel.TWO);
                s6xNavCategories.resetCategory(headerCateg, S6xNavCategoryLevel.THREE);

                string nameOfCategory  = "Category";
                string nameOfCategory2 = "Category2";
                string nameOfCategory3 = "Category3";

                S6xNavHeaderCategory replacedHeaderCateg = S6xNavHeaderCategory.UNDEFINED;

                SortedList slS6xList = null;
                switch (headerCateg)
                {
                case S6xNavHeaderCategory.TABLES:
                    slS6xList = sadS6x.slTables;
                    break;

                case S6xNavHeaderCategory.FUNCTIONS:
                    slS6xList = sadS6x.slFunctions;
                    break;

                case S6xNavHeaderCategory.SCALARS:
                    slS6xList = sadS6x.slScalars;
                    break;

                case S6xNavHeaderCategory.STRUCTURES:
                    slS6xList = sadS6x.slStructures;
                    break;

                case S6xNavHeaderCategory.ROUTINES:
                    slS6xList = sadS6x.slRoutines;
                    break;

                case S6xNavHeaderCategory.OPERATIONS:
                    slS6xList = sadS6x.slOperations;
                    break;

                case S6xNavHeaderCategory.REGISTERS:
                    slS6xList = sadS6x.slRegisters;
                    break;

                case S6xNavHeaderCategory.OTHER:
                    slS6xList = sadS6x.slOtherAddresses;
                    break;

                case S6xNavHeaderCategory.SIGNATURES:
                    slS6xList           = sadS6x.slSignatures;
                    replacedHeaderCateg = headerCateg;
                    nameOfCategory      = "SignatureCategory";
                    nameOfCategory2     = "SignatureCategory2";
                    nameOfCategory3     = "SignatureCategory3";
                    break;

                case S6xNavHeaderCategory.ELEMSSIGNATURES:
                    slS6xList           = sadS6x.slElementsSignatures;
                    replacedHeaderCateg = headerCateg;
                    nameOfCategory      = "SignatureCategory";
                    nameOfCategory2     = "SignatureCategory2";
                    nameOfCategory3     = "SignatureCategory3";
                    break;
                }

                if (slS6xList != null)
                {
                    foreach (object s6xObject in slS6xList.Values)
                    {
                        if (s6xObject == null)
                        {
                            continue;
                        }

                        Type         s6xType = s6xObject.GetType();
                        PropertyInfo piPI    = null;
                        object       oValue  = null;

                        piPI = s6xType.GetProperty(nameOfCategory);
                        if (piPI != null)
                        {
                            oValue = piPI.GetValue(s6xObject, null);
                            if (oValue != null)
                            {
                                s6xNavCategories.addCategory(replacedHeaderCateg, S6xNavCategoryLevel.ONE, (string)oValue);
                            }
                        }
                        piPI = null;

                        piPI = s6xType.GetProperty(nameOfCategory2);
                        if (piPI != null)
                        {
                            oValue = piPI.GetValue(s6xObject, null);
                            if (oValue != null)
                            {
                                s6xNavCategories.addCategory(replacedHeaderCateg, S6xNavCategoryLevel.TWO, (string)oValue);
                            }
                        }
                        piPI = null;

                        piPI = s6xType.GetProperty(nameOfCategory3);
                        if (piPI != null)
                        {
                            oValue = piPI.GetValue(s6xObject, null);
                            if (oValue != null)
                            {
                                s6xNavCategories.addCategory(replacedHeaderCateg, S6xNavCategoryLevel.THREE, (string)oValue);
                            }
                        }
                        piPI = null;
                    }
                }
            }
        }
Esempio n. 15
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);
        }