06-09-2023 03:54 AM
Hi All,
I am filtering out transient behavior as result of stepwise(setpoint) measurements. Works OK, with event search difference detection with ChnEventResultAddPrePost command. Characteristic values for events -when chosen-are saved in channels. However, characteristic values are not saved in channels when running the teachin script.
Instead: teachin adds comments to script:
'Dim TotalMin
'TotalMin = ChnEventStatMin("[1]/qm_air", ChnEventList1)
, same for max, mean,sum, stddev and valcnt.
Is this intended behavior, and what is reason/solution to get resultstachannels?
06-12-2023 03:24 AM
To keep the code simple and limited to the essentials, only the main commands are included when using TeachIn.
To achieve the same result via script, you can use the following code, which creates a result channel with the maximum values found by the search and creates a property via the Properties collection. It is up to you, what to do with the statistic values ;-).
ChnEventList1 = ChnEventDetectionWindow("", "[1]/Geschwindigkeit", 0, 50, 0, 0)
Call ChnEventCreateStatusChn("/EventStatus", ChnEventList1, "[1]/Geschwindigkeit", 0, 1)
Dim TotalMax, ResCount
TotalMax = ChnEventStatMax("[1]/Geschwindigkeit", ChnEventList1)
ResCount = ChnEventCount(ChnEventResultList)
Dim oMaxChn
Set oMaxChn = Data.Root.ActiveChannelGroup.Channels.Add("EventMax", DataTypeChnFloat64)
Call oMaxChn.Properties.Add("Result~Event~Max", TotalMax)
Dim i
for i = 1 to ResCount
oMaxChn(i) = ChnEventStatMax("[1]/Geschwindigkeit", ChnEventList1, i)
next