09-08-2022 07:59 AM
Hi joshilpa,
The calculation time depends very much on the signal progression and on the number of events found in the signal. The more events are found, the longer the calculation takes. (And of course it also depends on the PC performance).
Here are two optimizations that can speed up the calculation. A test with me with a signal of the length 60 000 000 and approx. 300 000 finding places lasted about 10 minutes.
dd.StopWatchReset(1)
oSourceChn = dd.Data.GetChannel("[1]/signal")
dd.ChnEventList1 = dd.ChnEventDetectionWindow("", oSourceChn, 8, 10, 0, 0)
dd.ChnEventCreateStatusChn("/EventStatus", dd.ChnEventList1, oSourceChn, 0, 1)
iMaxCount = len(dd.ChnEventList1)
oResultChn = dd.Data.Root.ActiveChannelGroup.Channels.Add("Result", dd.DataTypeChnFloat64)
# prepare max channel length
oResultChn[iMaxCount] = dd.NV
# calculate characteristic properties of this channel
dd.ChnCharacter(oSourceChn)
# if the channel contains no NoValues you can work only with the index values for counting
# otherwise there is a NoValue handling which takes time.
if oSourceChn.NoValues == 0:
for iCount in range(1, iMaxCount):
oResultChn[iCount] = dd.ChnEventList1[iCount][1] - dd.ChnEventList1[iCount][0]
else:
for iCount in range(1, iMaxCount + 1):
oResultChn[iCount] = dd.ChnEventStatValueCount(oSourceChn, dd.ChnEventList1, iCount)
dd.ChnCharacter(oResultChn)
dd.MsgBoxDisp(oResultChn.Maximum)
print(iMaxCount)
print(dd.StopWatch(1))
Greetings
Walter