DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Re: VBS script for auto integration for multiple channels

Solved!
Go to solution

Hi brad,

Thanks for the response.

I've attached a sample of the data to be analysed.

Auto steps as follows :

Auto select all channels beginning with 'D' or message box to manually select.

divide channel by 3600000, then Integrate - store result in new channel with original channel name but appended with '_Ah'

Auto maxvalue for each new channel and sum all maxvalues together..

 

I would like to auto select a range of values to be analysed but I will try do this as i learn !

 

Regards

 

AdeK

 

 

 

0 Kudos
Message 1 of 8
(5,488 Views)

Hi AdeK,

 

I don't see the attached data file(s).

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 8
(5,474 Views)

Hi Brad,

I'll try to attach the file again- this time I'll zip it !

Adek

0 Kudos
Message 3 of 8
(5,458 Views)

Hi Brad,

I am continuing to try to understand how to automate the integration calculation. I've tried using the 'for each' loop (for an unknown number of channels), but the integrate function doesn't seem to recognise the variable for the channel ..

Will continue experimenting, but if you can point me in the right direction, maybe all with become clear...

I will await your reply.

AdeK

 

Option

Explicit'Forces the explicit declaration of all the variables in a script.

dim

oMyChannels, oMyChn

Set

oMyChannels = Data.GetChannels("Analogue & HS CAN/D*")

For

Each oMyChn inoMyChannels

 

CallChnIntegrate("[1]/Time (s)","oMyChn","/Integrated") '... XW,Y,ECallChnPropValSet("Integrated","name","Integrated""&oMyChn.Name&")

 

Next

0 Kudos
Message 4 of 8
(5,402 Views)

Hi adek,

 

I apologize for not answering quickly after you posted your data set.  The For Each loop in your posted code looks fine, except that that you have "oMyChn" as the second parameter, when you should have just oMyChn as the second parameter.  If you have an old version of DIAdem, you might have to use oMyChn.Properties("Number").Value instead, but the last several version should accept oMyChn.

 

Let me know if that doesn't clear up the error,

Brad Turpin

DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 5 of 8
(5,396 Views)

Hello Brad,

I have altered the script and now it runs, but the new channels which I thought would be named 'Integrated DF1' upto 'integrated DV_88 etc, are named :

Integrated"&oMyChn.Name&  upto  Integrated"&oMyChn.Name&98 ,therefore the ChnPropValSet is not working correctly..

Can you help with this ?

Thanks again for your help.

AdeK

 

0 Kudos
Message 6 of 8
(5,391 Views)
Solution
Accepted by topic author adek

Hi adek,

 

Here's a VBScript that does what I understood you to be asking for-- it integrates all the "D*" channels, naming the new channels with an "_Ah" suffix and divides them each by 3600000, finally summing all the maxima of the integral channels.  Note that some of the integral channels have a negative maximum, so there's some positive and negative cancelling going on in that summation.

 

Dim Group, Channels, TimeChannel, DataChannel, NewChannel, Sum
Set Group = Data.Root.ChannelGroups(1)
Set TimeChannel = Group.Channels(1)
Set Channels = Data.GetChannels(Group.Name & "/D*")
Call Group.Activate
For Each DataChannel In Channels
  Call ChnIntegrate(TimeChannel, DataChannel, DataChannel.Name & "_Ah")
  Set NewChannel = Group.Channels(DataChannel.Name & "_Ah")
  Call ChnLinScale(NewChannel, NewChannel, 1/3600000, 0)
  Sum = Sum + CMax(NewChannel)
Next ' DataChannel
MsgBox Sum

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 8
(5,389 Views)

Hi Brad,

The code works perfectly, all I need to do now is understand the steps to it's creation !

Thanks again.

AdeK

0 Kudos
Message 8 of 8
(5,380 Views)