DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Looping ChnEventFind Variable

Solved!
Go to solution

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

0 Kudos
Message 1 of 2
(703 Views)
Solution
Accepted by topic author JamieA99

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

Message 2 of 2
(657 Views)