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.
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.
12-17-2015 09:19 AM
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.
12-18-2015 04:28 PM
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
01-05-2016 09:29 AM - edited 01-05-2016 09:30 AM
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.