DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Diadem Store Data In Array

Hi everyone, 

 

I've written a diadem script to process some data, the script function is simple, it utilizes the ChnEventDetectionWindow function to find two time stamps where it will then calculate the average value of the signal of interest in between these two timestamps. I'd like to store these timestamps in an array so that later on I can go back and troubleshoot if anything expected happened, for example, I'd like to see a pair of two timestamps for each average value that script calculated. So far, I've not gotten any luck storing the timestamps value in an array.

My script is below: 

'-- Comment:
'-- The ChnEventDetectionWindow function is used to detect events within a specified window condition in a channel. In below script, the function call:
'-- ChnEventList2 = ChnEventDetectionWindow("/TimeStamp", "/" & diffChannelName, -1, 1, 0.5, 0.5)
'-- is used to detect events in the diffChannelName channel where the values fall within the window defined by -1 and 1, with a hysteresis of 0.5.

'-- What ChnEventList2 Contains
'-- ChnEventList2 is a two-dimensional array that stores the results of the event detection.
'-- Each row in the array corresponds to a detected event, and the columns contain information about the event:
'-- Index 0: Start index of the event
'-- Index 1: End index of the event
'-- Index 2: Start value (if an x-channel is specified)
'-- Index 3: End value (if an x-channel is specified)
'-- In the script, ChnEventList2 is used to store the start and end indices of each detected event,
'-- which are then used to calculate the duration and average value of the events.

'----------------------------------------------------------------------------'

Dim channels, i, j, k, channelName, diffChannelName, avgChannelName, eventCount, startIndex, endIndex, avgValue, impedanceValue
Dim dutNumber

' Define the channels to process
channels = Array("L1", "L2", "L3", "LN") ' Add more channels as needed


' Initialize the timeStampsArray with two columns
ReDim timeStampsArray(1, 0)


' Loop through each DUT from DUT1 to DUT6
For k = 1 To 6
dutNumber = "DUT" & k

' Loop through each channel L1, L2, L3, and LN
For i = 0 To UBound(channels)
channelName = channels(i)
diffChannelName = dutNumber & "_" & channelName & "_Differences"
avgChannelName = dutNumber & "_" & channelName & "_mV_averaged"

' Add a new channel for storing differences
Call Data.Root.ChannelGroups(1).Channels.Add(diffChannelName, DataTypeFloat64)

' Calculate differences and detect events
Call ChnDeltaCalc(dutNumber & "_" & channelName & "_mV", diffChannelName)
ChnEventList2 = ChnEventDetectionWindow("[1]/TimeStamp", "[1]/" & diffChannelName, -1, 1, 0.5, 0.5) 'event filter is hard-coded ... need to change
eventCount = ChnEventCount(ChnEventList2)

' Add a new channel for storing average values
Call Data.Root.ChannelGroups(1).Channels.Add(avgChannelName, DataTypeFloat64)

' Create and activate a new channel group for averaged values
Call Data.Root.ChannelGroups.Add(dutNumber & "_" & channelName & "_mV_averaged", 2).Activate()

' Check if any events were detected
If eventCount > 0 Then
' Initialize arrays to store event durations and average values
ReDim durations(eventCount - 1)
ReDim avgValues(eventCount - 1)

' Loop through each detected event
For j = 1 To eventCount
' Calculate the duration of the event
durations(j - 1) = ChnEventDuration(ChnEventList2, j)

' Check if the event duration is within the specified range
If durations(j - 1) > 15 AND durations(j - 1) < 300 Then 'duration range is hard-coded ... need to change
' Get the start and end indices of the event
startIndex = ChnEventList2(j - 1, 0)
endIndex = ChnEventList2(j - 1, 1)

' Calculate the average value of the channel between the start and end indices
avgValue = ChnStatisticsChannelCalc("[1]/" & dutNumber & "_" & channelName & "_mV", eStatsArithmeticMean, startIndex, endIndex, False, True, False, "NameName")


' Store the start and end indices in the timeStampsArray
ReDim Preserve timeStampsArray(1, UBound(timeStampsArray, 2) + 1)
timeStampsArray(0, UBound(timeStampsArray, 2)) = startIndex
timeStampsArray(1, UBound(timeStampsArray, 2)) = endIndex

End If
Next
End If
Next
Next

0 Kudos
Message 1 of 2
(285 Views)

A data set to test your script would be helpful.

DIAdem experience since 1996

Turn-key applications - Remote and on-site trainings - On-the-job training

| müller+krahmer GmbH | Koenitzer Straße 14, 07338 Kaulsdorf / Germany |
| Phone: +49 36733 / 2328 - 6 | Mobile: +49 160 / 287 7294 |
| Email: mueller@mueller-krahmer.de | Web: www.mueller-krahmer.de |
0 Kudos
Message 2 of 2
(246 Views)