Example #1
0
        private void copyTableData(TableData srcTd, TableData dstTd, ref PcmFile dstPCM)
        {
            frmTableEditor srcTE = new frmTableEditor();

            srcTE.PCM = PCM;
            srcTE.loadTable(srcTd);
            frmTableEditor dstTE = new frmTableEditor();

            dstTE.PCM = dstPCM;
            dstTE.loadTable(dstTd);

            uint srcAddr = (uint)(srcTd.addrInt + srcTd.Offset);
            int  srcStep = getElementSize(srcTd.DataType);
            uint dstAddr = (uint)(dstTd.addrInt + dstTd.Offset);
            int  dstStep = getElementSize(dstTd.DataType);

            for (int r = 0; r < srcTd.Rows; r++)
            {
                for (int c = 0; c < srcTd.Columns; c++)
                {
                    double cellValue = srcTE.getValue(srcAddr, srcTd);
                    dstTE.SaveValue(dstAddr, r, c, dstTd, cellValue);
                    srcAddr += (uint)srcStep;
                    dstAddr += (uint)dstStep;
                }
            }
            dstTE.saveTable();
            dstPCM = dstTE.PCM;
            srcTE.Dispose();
            dstTE.Dispose();
        }
Example #2
0
 private void DataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex > -1)
     {
         int            id       = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["id"].Value);
         int            id2      = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["id2"].Value);
         TableData      td       = pcm1.tableDatas[id];
         frmTableEditor frmT     = new frmTableEditor();
         List <int>     tableIds = new List <int>();
         tableIds.Add(id);
         frmT.prepareTable(pcm1, td, tableIds, "A");
         frmT.addCompareFiletoMenu(pcm2, pcm2.tableDatas[id2], "B:" + pcm2.FileName);
         frmT.Show();
         frmT.loadTable();
     }
 }
Example #3
0
        private void copyTableData(TableData srcTd, TableData dstTd, ref PcmFile dstPCM)
        {
            frmTableEditor srcTE = new frmTableEditor();

            srcTE.prepareTable(PCM, srcTd, null, "A");
            //srcTE.loadTable();
            frmTableEditor dstTE = new frmTableEditor();

            dstTE.prepareTable(dstPCM, dstTd, null, "A");
            //dstTE.loadTable();

            for (int cell = 0; cell < srcTE.compareFiles[0].tableInfos[0].tableCells.Count; cell++)
            {
                TableCell srcTc = srcTE.compareFiles[0].tableInfos[0].tableCells[cell];
                TableCell dstTc = dstTE.compareFiles[0].tableInfos[0].tableCells[cell];
                dstTc.saveValue((double)srcTc.lastValue);
            }

            dstTE.saveTable();
            srcTE.Dispose();
            dstTE.Dispose();
        }
Example #4
0
        private string peekTableValues(int ind, PcmFile peekPCM)
        {
            string retVal = "";

            try
            {
                frmTableEditor frmT = new frmTableEditor();
                frmT.PCM = peekPCM;
                frmT.disableMultiTable = true;
                frmT.loadTable(peekPCM.tableDatas[ind]);
                //txtResult.SelectionFont = new Font(txtResult.Font, FontStyle.Regular);
                //txtResult.SelectionColor = Color.Blue;
                if (peekPCM.tableDatas[ind].Rows == 1 && peekPCM.tableDatas[ind].Columns == 1)
                {
                    double curVal  = frmT.getValue((uint)(peekPCM.tableDatas[ind].addrInt + peekPCM.tableDatas[ind].Offset), peekPCM.tableDatas[ind]);
                    UInt64 rawVal  = frmT.getRawValue((uint)(peekPCM.tableDatas[ind].addrInt + peekPCM.tableDatas[ind].Offset), peekPCM.tableDatas[ind]);
                    string valTxt  = curVal.ToString();
                    string unitTxt = " " + peekPCM.tableDatas[ind].Units;
                    string maskTxt = "";
                    if (peekPCM.tableDatas[ind].OutputType == OutDataType.Flag || peekPCM.tableDatas[ind].Units.ToLower().StartsWith("boolean"))
                    {
                        if (peekPCM.tableDatas[ind].BitMask != null && peekPCM.tableDatas[ind].BitMask.Length > 0)
                        {
                            unitTxt = "";
                            UInt64 maskVal = Convert.ToUInt64(peekPCM.tableDatas[ind].BitMask.Replace("0x", ""), 16);
                            if ((rawVal & maskVal) == maskVal)
                            {
                                valTxt = "Set";
                            }
                            else
                            {
                                valTxt = "Unset";
                            }
                            string maskBits = Convert.ToString((Int64)maskVal, 2);
                            int    bit      = -1;
                            for (int i = 0; 1 <= maskBits.Length; i++)
                            {
                                if (((maskVal & (UInt64)(1 << i)) != 0))
                                {
                                    bit = i + 1;
                                    break;
                                }
                            }
                            if (bit > -1)
                            {
                                string rawBinVal = Convert.ToString((Int64)rawVal, 2);
                                rawBinVal = rawBinVal.PadLeft(getBits(peekPCM.tableDatas[ind].DataType), '0');
                                maskTxt   = " [" + rawBinVal + "], bit $" + bit.ToString();
                            }
                        }
                        else
                        {
                            unitTxt = ", Unset/Set";
                            if (curVal > 0)
                            {
                                valTxt = "Set, " + valTxt;
                            }
                            else
                            {
                                valTxt = "Unset, " + valTxt;
                            }
                        }
                    }
                    else if (peekPCM.tableDatas[ind].Values.StartsWith("Enum: "))
                    {
                        Dictionary <double, string> possibleVals = frmT.parseEnumHeaders(peekPCM.tableDatas[ind].Values.Replace("Enum: ", ""));
                        if (possibleVals.ContainsKey(curVal))
                        {
                            unitTxt = " (" + possibleVals[curVal] + ")";
                        }
                        else
                        {
                            unitTxt = " (Out of range)";
                        }
                    }
                    string formatStr = "X" + (getElementSize(peekPCM.tableDatas[ind].DataType) * 2).ToString();
                    retVal = valTxt + unitTxt + " [" + rawVal.ToString(formatStr) + "]" + maskTxt;
                    //txtResult.AppendText(Environment.NewLine);
                }
                else
                {
                    string tblData = ""; //"Current values: " + Environment.NewLine;
                    uint   addr    = (uint)(peekPCM.tableDatas[ind].addrInt + peekPCM.tableDatas[ind].Offset);
                    if (peekPCM.tableDatas[ind].RowMajor)
                    {
                        for (int r = 0; r < peekPCM.tableDatas[ind].Rows; r++)
                        {
                            for (int c = 0; c < peekPCM.tableDatas[ind].Columns; c++)
                            {
                                double curVal = frmT.getValue(addr, peekPCM.tableDatas[ind]);
                                addr    += (uint)getElementSize(peekPCM.tableDatas[ind].DataType);
                                tblData += "[" + curVal.ToString("#0.0") + "]";
                            }
                            tblData += Environment.NewLine;
                        }
                    }
                    else
                    {
                        List <string> tblRows = new List <string>();
                        for (int r = 0; r < peekPCM.tableDatas[ind].Rows; r++)
                        {
                            tblRows.Add("");
                        }
                        for (int c = 0; c < peekPCM.tableDatas[ind].Columns; c++)
                        {
                            for (int r = 0; r < peekPCM.tableDatas[ind].Rows; r++)
                            {
                                double curVal = frmT.getValue(addr, peekPCM.tableDatas[ind]);
                                addr       += (uint)getElementSize(peekPCM.tableDatas[ind].DataType);
                                tblRows[r] += "[" + curVal.ToString("#0.0") + "]";
                            }
                        }
                        for (int r = 0; r < peekPCM.tableDatas[ind].Rows; r++)
                        {
                            tblData += tblRows[r] + Environment.NewLine;
                        }
                    }
                    retVal = tblData;
                }
            }
            catch (Exception ex)
            {
                LoggerBold(ex.Message);
            }
            return(retVal);
        }