09-28-2021 05:18 PM
I'd like to use the DIAdem VIEW window to set flags that are start and end points. I've used the "Copy Data Points" command, but that saves the Y value of the flag, not the index value. I know I can use that Y value to find the index via script, but is there an easier way to save off the index value instead of datapoint?
Thanks,
Tamer
10-08-2021 05:28 PM - edited 10-08-2021 05:29 PM
Hi TamerZero,
Can you back up a step and please explain what you're wanting to accomplish in DIAdem VIEW? It sounds like you want to set start and end points to a graph of your raw data, but... why? What's the goal here? Maybe setting flags programmatically is the best way forward, but that's actually pretty rare.
I'm happy to help create a solution for you, once I understand what you're after.
Brad Turpin
Principal Technical Support Engineer
NI
10-08-2021 05:40 PM
Hi Brad,
Basically I'm using the VIEW window to manually mark start and end points for my script to average. Each dataset has roughly 30 sections I'm trying to average. Unfortunately writing an algorithm to find and mark those sections would be difficult, so using the flags is the best method I've found. This is the solution I came up with. After I set the flags I export them to X/Y channels, then my code uses the X channel to find the index value. Doesn't feel super efficient, but it works:
Dim iLoop, iValue
For iLoop = 1 to Data.Root.ChannelGroups(1).Channels("CopyXTime Stamp").Properties("Length").Value
Call DataAreaInsertV("[1]/Full",iLoop,1,"[1]/Full",PNo("[1]/Time Stamp", Data.Root.ChannelGroups(1).Channels("CopyXTime Stamp").Values(iLoop)))
Next
Call Data.Root.ChannelGroups(1).Channels.Remove("CopyXTime Stamp")
iLoop = 1
iValue = 1
Do While (iValue < Data.Root.ChannelGroups(1).Channels("Full").Properties("Length").Value)
Call DataAreaInsertV("[1]/Start",iLoop,1,"[1]/Start",Data.Root.ChannelGroups(1).Channels("Full").Values(iValue))
Call DataAreaInsertV("[1]/Finish",iLoop,1,"[1]/Finish",Data.Root.ChannelGroups(1).Channels("Full").Values(iValue+1))
iValue = (iLoop * 2)+1
iLoop = iLoop + 1
Loop
10-12-2021 01:54 PM - edited 10-12-2021 02:05 PM
Hi TamerZero,
When I imagine the user setting all the flags, I imagine a scenario like this repeated 30 or so times:
1) Set the leading band cursor (X1) to the start of the data segment
2) Set the trailing band cursor (X2) to the end of the data segment
3) Click the "Set Flags" icon to flag the data points in this data segment
I assume you want to average each data segment in isolation from the rest of the data segments, right? In that case, part of your processing effort is re-creating those index windows that you created one at a time with steps 1), 2), 3).
In that case, why not instead run a script in step 3) that reads off Cursor.X1 and Cursor.X2 and used the PNo() command to determine the index window for that one data segment and writes the average value to the next row of the result channel? You could embed this step 3) script in a custom icon on the VIEW icon bar so that it would be just as easy for the user to click there as the "Set Flags" icon that I think you're currently using. I can help with the script creation and icon embedding, if you like.
With a contiguous index window, you can call the DIAdem statistics command once for a particular "row range", and get the average value to write to the next result channel row without having to copy the data segment values into a temporary channel. What do you think?
Brad Turpin
Principal Technical Support Engineer
NI
10-12-2021 02:22 PM
Hi Brad,
Thanks for the help. Your method sounds much simpler. If you can help me sort that out I would appreciate it.
Thanks!
Tamer