10-20-2017 08:19 AM - edited 10-20-2017 08:20 AM
Can you explain me a little more the []-thing?
You tell me that when I use:
Call ChnFFT1("[1]/Time_RoughRoad", chName)
the ChnFFT1-Sub searches the time-channel in the first group (in my structure it is in the first group).
But I use this code:
Call ChnFFT1("Time_RoughRoad", chName)
And I works as well though the group 1 is not the active group.
10-20-2017 09:52 AM
Hi Space,
I would encourage you to use Channel Objects instead of string references. Here's an example of how to do that with the specific use case you mentioned above. You can index the channel in a group with Group.Channels(j), though in the below code I stayed with the FOR Each construction. I chose to output each FFT to a separate group. This has the advantage that you can drag each group onto a graph, but it has the disadvantage that you end up with lots of groups-- your call. Note the Group.Activate command, which tells the resulting channels from each ChnFFT1() command which group to end up in.
RawGroupName = "3310-LOBSTz" XChannelName = "Time_RoughRoad" Set RawGroup = Data.Root.ChannelGroups(RawGroupName) Set XChannel = RawGroup.Channels(XChannelName) FOR Each RawChannel In RawGroup.Channels IF RawChannel.Name <> XChannel.Name THEN Set FFTGroup = Data.Root.ChannelGroups.Add(RawChannel.Name & " FFT") Call FFTGroup.Activate Call ChnFFT1(XChannel, RawChannel) END IF ' NOT XChannel NEXT ' Channel
Regards,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-20-2017 09:56 AM - edited 10-20-2017 09:58 AM
Hi Space,
If you use a string reference to a channel, then the part of the string to the left of the "/" character is the Group part of the reference, i.e. "Group/Channel". You can refer to the group or channel parts with an index, included within square brackets:
"GroupName/ChannelName"
"[1]/ChannelName"
"GroupName/[2]"
"[1]/[2]"
"/[2]"
"/ChannelName"
"ChannelName"
The "/[2]" and "/ChannelName" strings will refer to the default group, while the "ChannelName" string will refer to the first group that contains that channel. See why I suggest you use Group and Channel objects instead?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-23-2017 01:51 PM
Hi Space,
One more thing. You asked about programmatically opening or closing channel groups in the Data Portal-- you can do this with the Portal object.
Portal.Structure.Collapse(Data.Root) MsgBox "All Closed" Portal.Structure.Expand(Data.Root) MsgBox "All Opened"
Brad Turpin
DIAdem Product Support Engineeer
National Instruments