DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Is DataBlDel() the best way to delete channel rows?

Solved!
Go to solution

Hi,

 

I am trying to delete specific rows in a block of channels and am finding that DataBlDel() is extremely slow. Admittedly, my channels are pretty long (~ 36e6 rows), but I am finding it takes hours to delete just a handful of rows. Is there a better way to do this?

 

The code I am using is listed here:

 

Option Explicit

Dim i

i = 1

While i <= Data.Root.ActiveChannelGroup.Channels("Time").Size

  If CHD(i,"[]/Time Delta") < 0 Then
    Call DataBlDel("[]/Time",i,1)
    Call DataBlDel("[]/Time Delta",i,1)
    Call DataBlDel("[]/Force Load Pin (PST_002_FCE)",i,1)
  Else
    i = i + 1
  End If

Wend

 

 

Any is advice much appreciated,

 

PorridgeMan.

0 Kudos
Message 1 of 3
(5,261 Views)
Solution
Accepted by PorridgeMan

Hi PorridgeMan,

 

This task can be made loads faster.  First of all, the DataBlDel() command works on multiple channels and multiple lines at once, so you're calling it many more times than you need to.  If those time<0 rows are contiguous, the ideal approach would be to use the Find() function to get the first row where time>=0 and the use exactly one DataBlDel() call to delete all the invalid rows from the 3 channels.  If the time<0 rows are NOT contiguous, then I'd recommend using the calculator approach, like this:

 

L1 = CNo("/Time")
L2 = CNo("/Time Delta")
L3 = CNo("/Force Load Pin (PST_002_FCE)")
IF L1 > 0 AND L2 > 0 AND L3 > 0 tHEN
  Call FormulaCalc("Ch(L3):= Ch(L3) + NoValue*(Ch(L1)<0)")
  Call FormulaCalc("Ch(L2):= Ch(L2) + NoValue*(Ch(L1)<0)")
  Call FormulaCalc("Ch(L1):= Ch(L1) + NoValue*(Ch(L1)<0)")
  Call ChnNoVHandle(L1, L2 & "," & L3, "Delete", "XY", 1, 0)
END IF 

 

Brad Turpin

DIAdem Product Support Engineer
National Instruments

Message 2 of 3
(5,251 Views)

Hi Brad,

 

Thanks, that was a serious improvement (40 minutes versus about 8 hours).

 

By the way, the script was used to delete non-monotonic data emanating from a Citadel 5 database. I have no idea how that can occur, but if other people have the same problem, here is my final solution:

 

'Calculate the time differences between individual data points.
Call ChnDeltaCalc("[]/Time","/Time Delta")
'Insert zero as the first  change, to align changes with correct time values.
Call DataBlInsertVal("[]/Time Delta",1,1,0,0)

'Replace the non-monotonic time data with NoValue then delete.
'Note L1 - L3 specify freely usable long integer variables.
L1 = CNo("/Time")
L2 = CNo("/Time Delta")
L3 = CNo("/Force Load Pin (PST_002_FCE)")
If L1 > 0 And L2 > 0 And L3 > 0 Then
  Call FormulaCalc("Ch(L1) := Ch(L1) + NoValue * (Ch(L2) < 0)")
  Call FormulaCalc("Ch(L3) := Ch(L3) + NoValue * (Ch(L2) < 0)")
  Call FormulaCalc("Ch(L2) := Ch(L2) + NoValue * (Ch(L2) < 0)")
  Call ChnNoVHandle(L1, L2 & "," & L3, "Delete", "XY", 1, 0)
End If 

 

There was a slight error in your original code, but you basically got me over the line. Many thanks,

 

PorridgeMan.

Message 3 of 3
(5,223 Views)