LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Speed up table cell value change

I am trying to display data in a table as it's retrieved into my PC. I am sampling sequential channels and I need the data to be row-wise. Below is a snippit of code from the function that adds the data to the table.

SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow), ATTR_CELL_TYPE,
VAL_CELL_STRING);
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow), ATTR_CTRL_VAL,
pIni->pScanInfo->m_szTime);
nCol++;
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow), ATTR_DATA_TYPE,
VAL_INTEGER);
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow), ATTR_CTRL_VAL,
pIni->pScanInfo->m_nCurrentChannel);

// Then put all the ion currents in to a string
for (i=0; i
pScanInfo->m_nFinalMass - pIni->pScanInfo->m_nInitialMass + 1; i++)
{
nStatus = Fmt(szScan, "%s<%f", pIni->pScanInfo->m_dDataArray[i]);
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
ATTR_DATA_TYPE, VAL_DOUBLE);
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
ATTR_FORMAT, VAL_SCIENTIFIC_FORMAT);
SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow), ATTR_CTRL_VAL,
atof(szScan) );
nCol++;
}

The for {} loop has to put 50-100 items in their cells, incrementing the column after each. I find that the for{} loop alone takes something on the order of 30 seconds to execute. Is there a more efficient way of doing this? Perhaps replacing the MakePoint() functions, which allocate memory each time they are called, with another method would speed things up?

I need this whole function to finish in 1 second or so, not 30 seconds. Is this possible, or is the table going to be forever a time burden on my app
?

Thanks,

Craig
0 Kudos
Message 1 of 4
(3,937 Views)
Hello! It was happened to me too... and
teh best (and simpliest) solution is to put BEFORE your loop the table
in invisibile state with :
SetCtrlAttribute (panelHandle, TAB_TABLE, ATTR_VISIBLE, 0);
end immediately AFTER
SetCtrlAttribute (panelHandle, TAB_TABLE, ATTR_VISIBLE, 1);
Of course the table cannot disappear, simply CVI runtime doesn't refresh
the screen for every attr or value changed. Of course you can't put a
call like ProcessSyestemEvent() or ProcessDrawEvent() in your loop.
Remember that you also optimize speed using functions that affect an
entire range of cells instead one a time like:
SetTableCellRangeAttribute (panelHandle, controlID,MakeRect (2, 3, 5,
5),cellAttribute,attributeValue);

hoping this helps
Ciao
Raf




Craig Leidholm wrote:
> I am trying to display data in a table as it's retrieved into my PC.
> I am sampling sequential channels and I need the data to be row-wise.
> Below is a snippit of code from the function that adds the data to the
> table.
>
> SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
> ATTR_CELL_TYPE,
> VAL_CELL_STRING);
> SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
> ATTR_CTRL_VAL,
> pIni->pScanInfo->m_szTime);
> nCol++;
> SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
> ATTR_DATA_TYPE,
> VAL_INTEGER);
> SetTableCellAttribute (nPanel, nTable, MakePoint(nCol,nRow),
> ATTR_CTRL_VAL,
> pIni->pScanInfo->m_nCurrentChannel);
>
> // Then put all the ion currents in to a string
> for (i=0; ipScanInfo->m_nFinalMass -
> pIni->pScanInfo->m_nInitialMass + 1; i++)
> {
> nStatus = Fmt(szScan, "%s<%f",
> pIni->pScanInfo->m_dDataArray[i]);
> SetTableCellAttribute (nPanel, nTable,
> MakePoint(nCol,nRow),
> ATTR_DATA_TYPE,
> VAL_DOUBLE);
> SetTableCellAttribute (nPanel, nTable,
> MakePoint(nCol,nRow),
> ATTR_FORMAT,
> VAL_SCIENTIFIC_FORMAT);
> SetTableCellAttribute (nPanel, nTable,
> MakePoint(nCol,nRow), ATTR_CTRL_VAL,
> atof(szScan)
> );
> nCol++;
> }
>
> The for {} loop has to put 50-100 items in their cells, incrementing
> the column after each. I find that the for{} loop alone takes
> something on the order of 30 seconds to execute. Is there a more
> efficient way of doing this? Perhaps replacing the MakePoint()
> functions, which allocate memory each time they are called, with
> another method would speed things up?
>
> I need this whole function to finish in 1 second or so, not 30
> seconds. Is this possible, or is the table going to be forever a time
> burden on my app?
>
> Thanks,
>
> Craig
0 Kudos
Message 2 of 4
(3,938 Views)
Thanks for the reply. Shortly after posting, I realized that, since I am using arrays, I could take advantage of the SetTableCellRangeAttribute() function and found that it improved the function time immensely. The 20-30 second update took less than a second.

I still wonder if there is a way to declare a Point variable pointer and use it, to remove the malloc() that must be going on each time you call SetTableCellVal() with the embedded MakePoint().
0 Kudos
Message 3 of 4
(3,937 Views)
Hi,
 
     I am having the same problem in LabVIEW. How can I overcome this. I have displayed a 7000 x 70 string data in table and it is taking much of the memory and time for processing and display. How can I correct this?
 
-Vasanth.
Ya Ya
0 Kudos
Message 4 of 4
(3,741 Views)