DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programatically cut data in view

Hi There,

 

I have a requirement to programatically load data and display the 2-DAxis curve in view. Once the curve is displayed, the user can toggle a band cursor and with its help cut/tuncate data. All this needs to be achieved programatically. I am able to achive until setting the band cursor but could not find a means where to cut the data programatically. Can someone please help me out with the same.

 

Thanks in advance

Priya

0 Kudos
Message 1 of 14
(7,096 Views)

Hi Pria,

 

Are you struggling to get the desired VBScript code to run each time the user moves the band cursor, or will the user click on an icon or select a custom menu to start the code to cut the data?  Do you want to remove those data points from the selected curve only, from all curves, or from all channels in the Data Portal?  Or do you  want to replace those selected values with NoValue so they will act like they've been cut but not mess up row alignment with other channels?

 

Once I'm clear what you need, I can help you with any/all of the above,

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 2 of 14
(7,089 Views)

Hi Brad,

 

I have embedded a SUD Dialog in view pannel, this SUD includes 3 buttons (Button 1 : toggle cursor, Button 2 : Remove data, Button 3: Retain data)

Event click of button 1  - toggles the band cursor

Event click of button 2 - should remove the data points in the selected curve within the band range

Event Click of button 3 - Retain the data values within the band cursor and remove any other data in the curve.

 

Once the band cursor is visible to the user, he can adjust it to select the data points which needs to be removed/retained. The data points has to be cut from the selected curve only and the values needs to be replaced by NoValues.

 

FYI, this curve will resemble like a hystersis curve.... which means the there will be repeatation of the X-Values.

 

Hope I am clear....

 

Thanks

Priya

0 Kudos
Message 3 of 14
(7,081 Views)

Hi Priya,

 

I believe this is what you're describing.

 

OPTION EXPLICIT
Dim Sheet, Cursor, Area, Curve, Xch, Ych, Xmin, Xmax, TempCh, Start, Delta
Set Sheet = View.ActiveSheet
Set Cursor = Sheet.Cursor
Set Area = Sheet.Areas(1)
IF Area.DisplayObjType <> "CurveChart2D" THEN Call AutoQuit("Region clearing only works on 2D graph VIEW Areas")
IF Cursor.Type <> "Band" THEN Call AutoQuit("Region clearing only works with the VIEW band cursor")
IF NOT Area.DisplayObj.Curves.Count > 0 THEN Call AutoQuit("Your 2D graph in VIEW has no curves configured")
Set Curve = Area.DisplayObj.LeadingCurve
Xch = Curve.XChannelName : L1 = CNo(Xch)
Ych = Curve.YChannelName : L2 = CNo(Ych)
Xmin = MinV(Cursor.X1, Cursor.X2) : R1 = Xmin
Xmax = MaxV(Cursor.X1, Cursor.X2) : R2 = Xmax
TempCh = CNo("/TempIndexChannel")
IF TempCh > 0 THEN Call ChnDel(TempCh)
IF Xch = "" THEN
  IF ChnPropValGet(Ych, "waveform") = "Yes" THEN
    Start = ChnPropValGet(Ych, "wf_start_offset")
    Delta = ChnPropValGet(Ych, "wf_increment")
  ELSE
    Start = 1
    Delta = 1
  END IF
  TempCh = ChnLinGenImp("TempIndexChannel", ChnLength(L2), Start, Delta)
  Xch = CStr(TempCh)
  TempCh = "\Delete/"
  L1 = CNo(Xch)
END IF
Call FormulaCalc("Ch(L2):= Ch(L2) + NoValue*((Ch(L1)>=R1) AND (Ch(L1)<=R2))")
IF TempCh = "\Delete/" THEN Call ChnDel(Xch)
Call WndShow("VIEW")

 

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 14
(7,074 Views)

I know this is like 6 years old, and maybe I should have just PM'ed you instead, but I am looking for something very similar. I've only been using DIAdem here and there for a year or so, so I know I have barely only scratched the surface of what the program is capable of.

There might already be an easy way to do this, but what I would like to do is trim data from the 2D viewer plot. There are segments in my plot that I would like to trim from the data, but is much easier to find these segments of unneeded data in the line graph than fishing the data out of the channel's data in the table. Basically I would like to apply a band around a segment of data with a band cursor and then delete that data from the line graph and the channel contents.

 

Thanks,

Zac

0 Kudos
Message 5 of 14
(5,452 Views)

Delete the data, meaning not leave novalues.

And it's not a deal breaker, but if I could still be able to keep the Channel Table visible at the same time as the 2D Axis System, that would be helpful.

 

0 Kudos
Message 6 of 14
(5,451 Views)

Hi Zac,

 

I have code to do that for a waveform channel, integrated as a new icon in the VIEW panel.  There's not reason you can't have the graph and table showing at the same time when you do this.

 

But I want to double-check first, are you plotting XY curves or just Y curves?  If you're plotting XY curves, then we'd need to decide if it's OK to delete the X values as well as the Y values from the original channels.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 14
(5,437 Views)

I've been plotting Y with respects of time, so I'm only providing Y-values. I would like to cut the data out and leave no holes/novalues in the table, like a full data trim.

And I'd also like to trim one value in for the two bounds. So if my bounds were row 1000 and the other was at 1100, I would like to cut 1001 and 1099. If that makes sense. I would like to keep the two rows/data points the bounds are actually on.

0 Kudos
Message 8 of 14
(5,422 Views)

Hi ZacMom,

 

Sorry for the slow answer.  I'll take your statement to mean that you are plotting only Y channels with no X channels configured in any of the curves you want to delete from.  Here are 2 scripts that you should put in the same folder somewhere.  Run the "Waveform Delete Region.VBS" first in the SCRIPT panel, that will add a new icon at the far right of the VIEW panel's top icon bar.  Now any time you have a graph area selected that has waveform plots on it, and any time you also have the band cursor displayed on that graph, then click on the new "Delete Time Region" icon, it will run the "Delete Time Region.VBS" and remove the values in between (but not including) those band cursors.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Download All
0 Kudos
Message 9 of 14
(5,260 Views)

Hi Brad,

 

I ran the script in your reply and I need a similar solution. I don't want to cut out, but keep a selected part of curves, and not just the Leading.Curve, but all of the curves in the diagram.

 

Can you give me some help, how to modify your script to reach this?

 

Thank you:

Daniel

0 Kudos
Message 10 of 14
(4,147 Views)