From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I construct a ChannelList/ElementList for use in the CALCYChn arg of the ChnNovHandle function?

I'm trying to maximize the speed of my script that has to separate a contiguous group into multiple groups based on a "cycle counter" channel:

 

dim sFormula, aSymbols, aValues 
redim aSymbols(4), aValues(4)
aSymbols(0) = "a"
aSymbols(1) = "b"
aSymbols(2) = "c"
aSymbols(3) = "d"
aValues(2) = sGroupPattern & "/numCyclesCompleted"
dim intLoop, chnCount, chnIdx
dim oChns

for i = 0 to cycleMax sNewGrpName = "Cycle " & i set oNewGrp = CreateNewGroup(sNewGrpName) oNewGrp.Activate
sFormula = "Ch(a) = Ch(b) + CTNV(Ch(c) <> d)" aValues(3) = i call LoopInit() chnCount = data.Root.ChannelGroups(sGroupPattern).Channels.Count chnIdx = 0 call msglinedisp("Processing Cycle " & i) set oChns = data.CreateElementList for each oChn in data.Root.ChannelGroups(sGroupPattern).Channels chnIdx = chnIdx + 1 LoopInc(int((chnIdx/chnCount) * 100)) set oNewChn = oNewGrp.Channels.AddChannel(oChn) if oNewChn.Name <> "DateTime" then oChns.Add(oNewChn) end if next aValues(0) = oNewGrp.Name & "/DateTime" aValues(1) = sGroupPattern & "/DateTime" call calculate(sFormula, aSymbols, aValues) call ChnNovHandle(oNewGrp.Name & "/DateTime",oChns,"Delete","XY",true,true) call LoopDeInit() next

However,. the ChnNovHandle() call is not doing anything to the channels in each cycle group, only the DateTime channel.  I have checked the size and contents of the oChns ElementList object, and it has formed how I expect.  ChnNovHandle() says that the CALCYChn argument can take a "ChannelList Variable", and goes on to explain that a Channel List object fits this bill, which is returned from Data.CreateElementList as an ElementList.

 

Am I missing something simple?  I've searched around the help docs for quite a while and I can't seem to figure out where I'm going wrong.  My alternative to the above is to use CTNV and ChnNovHandle on every channel, but that is many, many times slower than doing each only once per group, since my groups contain >250 channels apiece.

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

Hi jack,

 

The second to last parameter in the ChnNovHandle() function needs to be FALSE, not TRUE.  Otherwise I don't see anything wrong with your code.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

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

 The second to last parameter in the ChnNovHandle() function needs to be FALSE, not TRUE.  


That... would make a lot of sense, since that's the single/multiple channel flag...

 

Whoops.  Thank you!  I'll give that a shot and mark your post as a solution if that proves to be where I made the mistake.

0 Kudos
Message 3 of 3
(3,737 Views)