コード例 #1
0
ファイル: SADXdf.cs プロジェクト: Stokes1114/SAD806x
        public void Import(S6xScalar s6xScalar, int xdfBaseOffset)
        {
            title       = s6xScalar.Label;
            description = Tools.XDFLabelSLabelComXdfComment(s6xScalar.Label, s6xScalar.ShortLabel, s6xScalar.Comments);

            xdfData.mmedaddress = Tools.xdfAddressFromBinAddress(s6xScalar.AddressBinInt, xdfBaseOffset);
            if (s6xScalar.Signed)
            {
                xdfData.mmedtypeflags = "0x03";
            }
            else
            {
                xdfData.mmedtypeflags = "0x02";
            }
            if (s6xScalar.Byte)
            {
                xdfData.mmedelementsizebits = "8";
            }
            else
            {
                xdfData.mmedelementsizebits = "16";
            }

            units = s6xScalar.Units;

            xdfMath.equation = s6xScalar.ScaleExpression.Trim();
            if (s6xScalar.ScalePrecision >= SADDef.DefaultScaleMinPrecision && s6xScalar.ScalePrecision <= SADDef.DefaultScaleMaxPrecision)
            {
                decimalpl = s6xScalar.ScalePrecision.ToString();
            }
        }
コード例 #2
0
        public BitFlagsForm(ref SADS6x s6x, ref S6xScalar scalar, ref ImageList stateImageList, ref S6xNavCategories navCategories)
        {
            S6x              = s6x;
            s6xScalar        = scalar;
            s6xNavCategories = navCategories;

            slBitFlags = new SortedList();

            if (s6xScalar.BitFlags != null)
            {
                foreach (S6xBitFlag s6xObject in s6xScalar.BitFlags)
                {
                    if (s6xObject != null)
                    {
                        slBitFlags.Add(s6xObject.UniqueKey, s6xObject);
                    }
                }
            }

            try { Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); }
            catch { }

            this.FormClosing += new FormClosingEventHandler(Form_FormClosing);

            InitializeComponent();

            advElemsTreeView.StateImageList = stateImageList;
        }
コード例 #3
0
ファイル: SADXdf.cs プロジェクト: Stokes1114/SAD806x
        public void Import(S6xScalar s6xScalar, S6xBitFlag s6xBitFlag, int xdfBaseOffset)
        {
            title       = s6xBitFlag.Label;
            description = Tools.XDFLabelSLabelComXdfComment(s6xBitFlag.Label, s6xBitFlag.ShortLabel, s6xBitFlag.Comments);

            xdfData.mmedaddress   = Tools.xdfAddressFromBinAddress(s6xScalar.AddressBinInt, xdfBaseOffset);
            xdfData.mmedtypeflags = "0x02";
            if (s6xScalar.Byte)
            {
                xdfData.mmedelementsizebits = "8";
            }
            else
            {
                xdfData.mmedelementsizebits = "16";
            }

            mask = "0x" + string.Format("{0:x4}", (int)Math.Pow(2, s6xBitFlag.Position));
        }
コード例 #4
0
ファイル: SADXls.cs プロジェクト: OpenEEC-Project/SAD806x
        public void Import(S6xScalar s6xScalar, int xlsBaseOffset, SortedList <string, XlsLevel> xlsLevels)
        {
            PID = s6xScalar.ShortLabel;
            Key = s6xScalar.DuplicateNum == 0 ? Key : Key + "_" + s6xScalar.DuplicateNum.ToString();

            Parameter = s6xScalar.Label;
            Comments  = s6xScalar.Comments;

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

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

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

            Units  = s6xScalar.Units;
            Bytes  = s6xScalar.Byte ? 1 : 2;
            Signed = s6xScalar.Signed;

            Equation = s6xScalar.ScaleExpression;
            Digits   = s6xScalar.ScalePrecision;

            Min = Tools.getValidMinMax(s6xScalar.Min);
            Max = Tools.getValidMinMax(s6xScalar.Max);
        }
コード例 #5
0
        private void scalarBitFlagsButton_Click(object sender, EventArgs e)
        {
            string    uniqueAddress = string.Empty;
            S6xScalar tempScalar    = null;
            S6xScalar s6xScalar     = null;

            if (scalarBitFlagsButton.Tag != null)
            {
                s6xScalar = (S6xScalar)scalarBitFlagsButton.Tag;
            }

            if (s6xScalar == null)
            {
                tempScalar = new S6xScalar();
                if (s6xESig.Scalar != null)
                {
                    if (s6xESig.Scalar.BitFlags != null)
                    {
                        tempScalar.BitFlags = (S6xBitFlag[])s6xESig.Scalar.BitFlags.Clone();
                    }
                }
            }
            else
            {
                tempScalar = s6xScalar.Clone();
            }
            s6xScalar = null;

            tempScalar.Label = labelTextBox.Text;
            tempScalar.Byte  = scalarByteCheckBox.Checked;

            BitFlagsForm bitFlagsForm = new BitFlagsForm(ref S6x, ref tempScalar);

            bitFlagsForm.ShowDialog();
            bitFlagsForm = null;

            scalarBitFlagsCheckBox.Checked = tempScalar.isBitFlags;

            // To be reused on Update
            scalarBitFlagsButton.Tag = tempScalar;

            tempScalar = null;
        }
コード例 #6
0
        public BitFlagsForm(ref SADS6x s6x, ref S6xScalar scalar)
        {
            S6x       = s6x;
            s6xScalar = scalar;

            slBitFlags = new SortedList();

            if (s6xScalar.BitFlags != null)
            {
                foreach (S6xBitFlag s6xObject in s6xScalar.BitFlags)
                {
                    if (s6xObject != null)
                    {
                        slBitFlags.Add(s6xObject.UniqueKey, s6xObject);
                    }
                }
            }

            try { Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); }
            catch { }

            InitializeComponent();
        }
コード例 #7
0
 public static void updateScalarBitFlagRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, R_SAD806x_Def_ScalarsBitFlags rRow, S6xScalar s6xObject, S6xBitFlag s6xBitFlag)
 {
     SQLite806xToolsSAD806xV10.updateScalarBitFlagRow(ref db806x, ref sadS6x, rRow, s6xObject, s6xBitFlag);
 }
コード例 #8
0
 public static object addScalarRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_806x_Def_Scalars> rList, S6xScalar s6xObject)
 {
     return(SQLite806xTools806xV10.addScalarRow(ref db806x, ref sadS6x, ref rList, s6xObject));
 }
コード例 #9
0
ファイル: SADFixedScalars.cs プロジェクト: Stokes1114/SAD806x
        public static S6xScalar GetFixedScalarTemplate(FixedScalars fixedScalar)
        {
            S6xScalar oRes = new S6xScalar();

            switch (fixedScalar)
            {
            case FixedScalars.ACTMAX:
                oRes.ShortLabel      = "ACTMAX";
                oRes.Label           = "ACT Max";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nValue at which the eec considers that the sensor has failed open circuit.";
                oRes.ScaleExpression = "X/12800";
                oRes.ScalePrecision  = 2;
                oRes.Units           = "Volts";
                break;

            case FixedScalars.ACTMIN:
                oRes.ShortLabel      = "ACTMIN";
                oRes.Label           = "ACT Min";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nValue at which the eec considers that the sensor has failed short circuit.";
                oRes.ScaleExpression = "X/12800";
                oRes.ScalePrecision  = 2;
                oRes.Units           = "Volts";
                break;

            case FixedScalars.ACTFMM:
                oRes.ShortLabel      = "ACTFMM";
                oRes.Label           = "ACT FMM Default";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nFailed ACT value, should be set to the hottest the engine will run at IAT wise.";
                oRes.ScaleExpression = "X*2";
                oRes.ScalePrecision  = 0;
                oRes.Units           = "°F";
                break;

            case FixedScalars.ECTMAX:
                oRes.ShortLabel      = "ECTMAX";
                oRes.Label           = "ECT Max";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nValue at which the eec considers that the sensor has failed open circuit.";
                oRes.ScaleExpression = "X/12800";
                oRes.ScalePrecision  = 2;
                oRes.Units           = "Volts";
                break;

            case FixedScalars.ECTMIN:
                oRes.ShortLabel      = "ECTMIN";
                oRes.Label           = "ECT Min";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nValue at which the eec considers that the sensor has failed short circuit.";
                oRes.ScaleExpression = "X/12800";
                oRes.ScalePrecision  = 2;
                oRes.Units           = "Volts";
                break;

            case FixedScalars.ECTFMM:
                oRes.ShortLabel      = "ECTFMM";
                oRes.Label           = "ECT FMM Default";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nFailed ECT value, should be set to the hottest the engine will run at ECT wise.";
                oRes.ScaleExpression = "X*2";
                oRes.ScalePrecision  = 0;
                oRes.Units           = "°F";
                break;

            case FixedScalars.NUMEGO:
                oRes.ShortLabel      = "NUMEGO";
                oRes.Label           = "Number of HEGOs";
                oRes.Comments        = oRes.ShortLabel + " - " + oRes.Label;
                oRes.Comments       += "\r\nWhen changing from 2 to 1 the injector output port must be reassigned, all bank2 injectors must be assigned to bank1 otherwise all bank2 injectors will be disabled.";
                oRes.ScaleExpression = "X";
                oRes.ScalePrecision  = 2;
                oRes.Units           = "SW";
                break;

            default:
                oRes.ShortLabel = fixedScalar.ToString();
                oRes.Label      = oRes.ShortLabel;
                break;
            }

            return(oRes);
        }
コード例 #10
0
 public static object addScalarBitFlagRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_SAD806x_Def_ScalarsBitFlags> rList, S6xScalar s6xObject, S6xBitFlag s6xBitFlag)
 {
     return(SQLite806xToolsSAD806xV10.addScalarBitFlagRow(ref db806x, ref sadS6x, ref rList, s6xObject, s6xBitFlag));
 }
コード例 #11
0
        private void updateElem()
        {
            string categ     = string.Empty;
            string uniqueKey = string.Empty;
            string label     = string.Empty;
            string comments  = string.Empty;

            switch (elemTabControl.SelectedTab.Name)
            {
            case "structureTabPage":
                categ = TreeCategStructureNodeName;
                break;

            case "tableTabPage":
                categ = TreeCategTableNodeName;
                break;

            case "functionTabPage":
                categ = TreeCategFunctionNodeName;
                break;

            case "scalarTabPage":
                categ = TreeCategScalarNodeName;
                break;

            default:
                return;
            }

            if (!checkElem(categ))
            {
                MessageBox.Show("Invalid values are present, please correct them to continue.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            s6xESig.for8061    = (for8061ComboBox.SelectedIndex == 0);
            s6xESig.forBankNum = forBankTextBox.Text;

            switch (categ)
            {
            case TreeCategStructureNodeName:
                S6xRoutineInternalStructure sigIntStr = s6xESig.Structure;
                sigIntStr.Number    = Convert.ToInt32(structureNumTextBox.Text);
                sigIntStr.StructDef = structureStructTextBox.Text;

                sigIntStr.ShortLabel     = shortLabelTextBox.Text;
                sigIntStr.Label          = labelTextBox.Text;
                sigIntStr.Comments       = commentsTextBox.Text;
                sigIntStr.OutputComments = outputCommentsCheckBox.Checked;

                uniqueKey = sigIntStr.UniqueKey;
                label     = sigIntStr.Label;
                comments  = sigIntStr.Comments;

                sigIntStr = null;
                break;

            case TreeCategTableNodeName:
                S6xRoutineInternalTable sigIntTbl = s6xESig.Table;
                sigIntTbl.VariableColsNumber   = tableColsTextBox.Text;
                sigIntTbl.CellsUnits           = tableCellsUnitsTextBox.Text;
                sigIntTbl.ColsUnits            = tableColsUnitsTextBox.Text;
                sigIntTbl.RowsNumber           = Convert.ToInt32(tableRowsTextBox.Text);
                sigIntTbl.RowsUnits            = tableRowsUnitsTextBox.Text;
                sigIntTbl.CellsScaleExpression = tableScaleTextBox.Text;
                sigIntTbl.CellsScalePrecision  = (int)tableScalePrecNumericUpDown.Value;
                sigIntTbl.SignedOutput         = tableSignedCheckBox.Checked;
                sigIntTbl.WordOutput           = tableWordCheckBox.Checked;

                sigIntTbl.ShortLabel     = shortLabelTextBox.Text;
                sigIntTbl.Label          = labelTextBox.Text;
                sigIntTbl.Comments       = commentsTextBox.Text;
                sigIntTbl.OutputComments = outputCommentsCheckBox.Checked;

                uniqueKey = sigIntTbl.UniqueKey;
                label     = sigIntTbl.Label;
                comments  = sigIntTbl.Comments;

                sigIntTbl = null;
                break;

            case TreeCategFunctionNodeName:
                S6xRoutineInternalFunction sigIntFunc = s6xESig.Function;
                sigIntFunc.ByteInput             = functionByteCheckBox.Checked;
                sigIntFunc.RowsNumber            = Convert.ToInt32(functionRowsTextBox.Text);
                sigIntFunc.InputScaleExpression  = functionScaleInputTextBox.Text;
                sigIntFunc.OutputScaleExpression = functionScaleOutputTextBox.Text;
                sigIntFunc.InputScalePrecision   = (int)functionScalePrecInputNumericUpDown.Value;
                sigIntFunc.OutputScalePrecision  = (int)functionScalePrecOutputNumericUpDown.Value;
                sigIntFunc.SignedInput           = functionSignedInputCheckBox.Checked;
                sigIntFunc.SignedOutput          = functionSignedOutputCheckBox.Checked;
                sigIntFunc.InputUnits            = functionUnitsInputTextBox.Text;
                sigIntFunc.OutputUnits           = functionUnitsOutputTextBox.Text;

                sigIntFunc.ShortLabel     = shortLabelTextBox.Text;
                sigIntFunc.Label          = labelTextBox.Text;
                sigIntFunc.Comments       = commentsTextBox.Text;
                sigIntFunc.OutputComments = outputCommentsCheckBox.Checked;

                uniqueKey = sigIntFunc.UniqueKey;
                label     = sigIntFunc.Label;
                comments  = sigIntFunc.Comments;

                sigIntFunc = null;
                break;

            case TreeCategScalarNodeName:
                S6xRoutineInternalScalar sigIntScal = s6xESig.Scalar;
                sigIntScal.Byte            = scalarByteCheckBox.Checked;
                sigIntScal.ScaleExpression = scalarScaleTextBox.Text;
                sigIntScal.ScalePrecision  = (int)scalarScalePrecNumericUpDown.Value;
                sigIntScal.Signed          = scalarSignedCheckBox.Checked;
                sigIntScal.Units           = scalarUnitsTextBox.Text;

                sigIntScal.ShortLabel     = shortLabelTextBox.Text;
                sigIntScal.Label          = labelTextBox.Text;
                sigIntScal.Comments       = commentsTextBox.Text;
                sigIntScal.OutputComments = outputCommentsCheckBox.Checked;
                sigIntScal.InlineComments = scalarInlineCommentsCheckBox.Checked;

                uniqueKey = sigIntScal.UniqueKey;
                label     = sigIntScal.Label;
                comments  = sigIntScal.Comments;

                if (scalarBitFlagsButton.Tag != null)
                {
                    S6xScalar s6xScalar = (S6xScalar)scalarBitFlagsButton.Tag;
                    scalarBitFlagsButton.Tag = null;
                    if (s6xScalar.BitFlags != null)
                    {
                        sigIntScal.BitFlags = (S6xBitFlag[])s6xScalar.BitFlags.Clone();
                    }
                    s6xScalar = null;
                }

                sigIntScal = null;
                break;

            default:
                return;
            }
        }
コード例 #12
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);
        }
コード例 #13
0
ファイル: SQLite806xTools.cs プロジェクト: Stokes1114/SAD806x
        public static void addScalarBitFlagRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_806x_Def_ScalarsBitFlags> rList, S6xScalar s6xObject)
        {
            if (db806x == null)
            {
                return;
            }
            if (sadS6x == null)
            {
                return;
            }
            if (rList == null)
            {
                return;
            }
            if (s6xObject == null)
            {
                return;
            }
            if (s6xObject.Skip || !s6xObject.Store)
            {
                return;
            }
            if (!s6xObject.isBitFlags)
            {
                return;
            }
            if (s6xObject.BitFlags == null)
            {
                return;
            }

            foreach (S6xBitFlag s6xBF in s6xObject.BitFlags)
            {
                if (s6xBF.Skip)
                {
                    continue;
                }

                R_806x_Def_ScalarsBitFlags rRow = db806x.newRow <R_806x_Def_ScalarsBitFlags>();
                rRow.ScalarBank.Value          = s6xObject.BankNum;
                rRow.ScalarAddress.Value       = s6xObject.AddressInt;
                rRow.ScalarUniqueAddCode.Value = s6xObject.DuplicateNum;
                rRow.Position.Value            = s6xBF.Position;
                rRow.UniqueAddCode.Value       = 0;
                rRow.Comments.Value            = s6xBF.Comments;
                rRow.Label.Value      = s6xBF.Comments;
                rRow.ShortLabel.Value = s6xBF.Comments;

                rList.Add(rRow);
            }
        }
コード例 #14
0
ファイル: SQLite806xTools.cs プロジェクト: Stokes1114/SAD806x
        public static void addScalarRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, ref List <R_806x_Def_Scalars> rList, S6xScalar 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_Scalars rRow = db806x.newRow <R_806x_Def_Scalars>();

            rRow.Bank.Value            = s6xObject.BankNum;
            rRow.Address.Value         = s6xObject.AddressInt;
            rRow.UniqueAddCode.Value   = s6xObject.DuplicateNum;
            rRow.Byte.Value            = s6xObject.Byte;
            rRow.Comments.Value        = s6xObject.Comments;
            rRow.Label.Value           = s6xObject.Label;
            rRow.ScaleExpression.Value = s6xObject.ScaleExpression;
            rRow.ScalePrecision.Value  = s6xObject.ScalePrecision;
            rRow.ShortLabel.Value      = s6xObject.ShortLabel;
            rRow.Signed.Value          = s6xObject.Signed;
            rRow.Units.Value           = s6xObject.Units;

            rList.Add(rRow);
        }
コード例 #15
0
 public static void updateScalarRow(ref SQLite806xDB db806x, ref SADS6x sadS6x, R_806x_Def_Scalars rRow, S6xScalar s6xObject)
 {
     SQLite806xTools806xV10.updateScalarRow(ref db806x, ref sadS6x, rRow, s6xObject);
 }
コード例 #16
0
ファイル: SADXdf.cs プロジェクト: Stokes1114/SAD806x
 public XdfFlag(S6xScalar s6xScalar, S6xBitFlag s6xBitFlag, int xdfBaseOffset)
 {
     Init();
     Import(s6xScalar, s6xBitFlag, xdfBaseOffset);
 }
コード例 #17
0
ファイル: SADXdf.cs プロジェクト: Stokes1114/SAD806x
 public XdfScalar(S6xScalar s6xScalar, int xdfBaseOffset)
 {
     Init();
     Import(s6xScalar, xdfBaseOffset);
 }