04-03-2023 08:39 AM - edited 04-03-2023 08:40 AM
So I am using the ChnEventFind function to filter out unwanted points in a data set, then average the data at each specified Ton step then store each step in an new channel. But i am struggling on looping the ChnEventFind Function.
TLDR how can get the B to change with iLoop
See code below.
Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim fISM,oResGroup,oResGroupChns,oTon
dim iLoop,iIDx
set oTon =Data.Root.ChannelGroups(1).Channels("Ton")
Set oResGroup=Data.Root.ChannelGroups(1)
set oResGroupChns= oResGroup.Channels
set fISM= oResGroupChns.Add("Filtered Channel",DataTypeChnFloat64)
iIDx=1
For iLoop= oTon.Minimum to oTon.Maximum
ChnEventResultList = Null
ChnEventResultList = ChnEventFind("(A=>29.3 ) AND (A=<32.9) AND (B=iLoop)", Array("A","B"), Array(Data.GetChannel("[1]/[12]"),Data.GetChannel("[1]/[15]")))
fISM.Values(iIDx)= ChnEventStatArithMean("[1]/[17]", ChnEventResultList,1)
iloop= iloop+50
iIDx=iIDx+1
Next
Solved! Go to Solution.
04-04-2023 03:39 PM - edited 04-04-2023 03:40 PM
Maybe like this?
Option Explicit 'Forces the explicit declaration of all the variables in a script.
dim fISM,oResGroup,oResGroupChns,oTon
dim iLoop,iIDx
set oTon =Data.Root.ChannelGroups(1).Channels("Ton")
Set oResGroup=Data.Root.ChannelGroups(1)
set oResGroupChns= oResGroup.Channels
set fISM= oResGroupChns.Add("Filtered Channel",DataTypeChnFloat64)
iIDx=1
For iLoop= oTon.Minimum to oTon.Maximum
ChnEventResultList = Null
ChnEventResultList = ChnEventFind("(A=>29.3 ) AND (A=<32.9) AND (B="& str(iLoop) &")", Array("A","B"),
Array(Data.GetChannel("[1]/[12]"),Data.GetChannel("[1]/[15]")))
fISM.Values(iIDx)= ChnEventStatArithMean("[1]/[17]", ChnEventResultList,1)
iloop= iloop+50
iIDx=iIDx+1
Next