DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

A way to count occurences

Hello everyone,

I am very new to DIAdem. I am trying to create a template with a list of channels that is essentially standardizd accross the board in terms of the files that will be imported into DIAdem and ultimately analyzed. What I am trying to generate is a simple metric that will go through my list of signals and read the data and if one of the signals fails based on a given condition, I want a counter to add one to the till. So for example, a signal fails: Failed_Signals = Failed_Signals + 1

Once all of the signals have been checked, a view will be presented showing:

Example
Failed Signals: 5



Can someone please get me on the right track and approach here?

Much Appreciated!

0 Kudos
Message 1 of 7
(4,408 Views)

i.e. the condition is <0.6 and you check ch(1)

 

dim i, j
j = 1
for i = 1 to chnlength(1)
  if chdx(i,1) < 0.6 then
    j = j + 1
  end if
next

msgbox("Failed Signals: " & j)

0 Kudos
Message 2 of 7
(4,383 Views)

Hi Kyle,

 

If you have DIAdem 2014 or later, then you could use the ChnEvent...() functions to count such events.  This will run much faster than an explicit VBScript loop.  Of course, if your data channels are small to medium in size, there's nothing wrong with the direct approach Traderhans provided.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 7
(4,371 Views)

This is what I had in mind and the counter process makes sense but how do I reference my channel list so that the signals individuall get checked? My range for failure is betweein -90 and -100 by the way.

Once again, I appreciate the help here.

0 Kudos
Message 4 of 7
(4,342 Views)

Hi Kyle,

 

What DIAdem version are you using?  The syntax is different in 2014 and 2015 and beyond.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 7
(4,305 Views)

It's the 2015 version

0 Kudos
Message 6 of 7
(4,299 Views)

Hi Kyle,

 

If you just want to see if ever a given channel enters the failure range and count the number of such channels in a particular group, here's what I mean:

 

LimLo = -100
LimHi = -90
Set Group = Data.Root.ChannelGroups(1)
FOR Each Channel In Group.Channels EventList = ChnEventDetectionWindow("", Channel, LimLo, LimHi) IF ChnEventCount(EventList) > 0 THEN j = j + 1 : Names = Names & vbCRLF & Channel.Name Next ' Channel MsgBox "Failed Signals = " & j & vbCRLF & String(20, "-") & Names

 

Or you can use the numeric result of the ChnEventCount() fuunction to keep track of how many different times a given channel enters the failure window.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 7
(4,283 Views)