DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient Method to Search for channels in Data Portal

I am looking for an efficient way to search channels in the data portal so that I can perform specific calculations depending on which channel it is

 

I would be able to search by channel name or position.

 

Example

 

If Channel # = 1<>3<>5<>7<>9<>11<>13<>15

Perform A

Else If Channel # = 2<>4<>6<>8<>10<>12<>14<>16

Perform B

Else If Channel # = 17<>19<>21<>23<>25<>27<>29<>31

Perform C

 

etc.

 

I have also looked at just grouping the channels into Array's at the beginning of the script, then performing the correct calculations on each array.

 

I have tried usign the DataFinder, but I can find a way to do it withouth having to load my results into the DataPortal seperately.

0 Kudos
Message 1 of 3
(3,909 Views)

Hi MK,

 

I suggest you build Element List variables.  For the case of channel name finding, there is an awesome function that returns the variable directly.  For the case of channel index finding, you'd just need to build the Element List with the appropriate loop.

 

Set Group = Data.Root.ChannelGroups(1)
jMax = Group.Channels.Count

Set ChannelsNoise = Data.GetChannels(Group.Name & "/Noise_*")
Set ChannelsRes_N = Data.GetChannels(Group.Name & "/Res_Noise_*")
Set ChannelsTemps = Data.GetChannels(Group.Name & "/Temperature_*")

Set ChannelsA = Data.CreateElementList()
FOR j = 1 TO jMax Step 2
  Call ChannelsA.Add(Group.Channels(j))
NEXT ' j

Set ChannelsB = Data.CreateElementList()
FOR j = 2 TO jMax Step 2
  Call ChannelsB.Add(Group.Channels(j))
NEXT ' j

Set ChannelsC = Data.CreateElementList()
FOR j = 17 TO jMax Step 2
  Call ChannelsC.Add(Group.Channels(j))
NEXT ' j

Msg = ""
FOR Each Channel In ChannelsNoise
  Msg = Msg & Channel.Name & vbCRLF
NEXT
MsgBox Msg

Msg = ""
FOR Each Channel In ChannelsA
  Msg = Msg & Channel.Properties("GroupIndex").Value & vbCRLF
NEXT
MsgBox Msg

You can also loop over the ChannelsA variable with a For j = 1 TO ChannelsA.Count construction, and you can reference individual channels in the ChannelsA variable by array index.  There are also many DIAdem commands that directly accept an ElementList variable, such as Data.Remove()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 3
(3,882 Views)

I have created a Community Example Program which performs a filtered group and channel search using dialog:

 

Filtered Data Portal Search with DIAdem Dialog - Discussion Forums - National Instruments

https://forums.ni.com/t5/Example-Program-Drafts/Filtered-Data-Portal-Search-with-DIAdem-Dialog/ta-p/...

 

Filtered_Search.PNG

Eric H.
Applications Engineering
National Instruments
0 Kudos
Message 3 of 3
(2,279 Views)