NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
smoothdurban
Posts: 143
0 Kudos
Accepted Solution

Searching Through Channels and Creating a Channel from Searched Values

Hello,

 

I am trying to generate a script that would allow me to serch throug a channel and compare the values to a number and create another channel with these instances

 

Allow me to elaborate

 

I have the following test data in a TDMS file with a group name of "Monthly Data"  and a Channel name of "Month 2" 

 

Time       Value

1             18000

2             45100

3             59800

4             35500

 

 

What I would like to do is to compare these values to a set of values and record when this values occured in a channel.

 

For eample I am looking for all values above 36000 and 50000

 

So I would end up with a new channel  which would containm the following

 

2         45100

3         59800

 

 

I know that I would have to create an array of values that would hold the comparison data

 

CtrlVals =  Array("", 45000, 50000) 

 

 

and a channel to store the found values in and set it to a default

 

 

 

IF GroupIndexGet("Stored Values") > 0 THEN

             

             groupIndex = GroupIndexGet("Stored Values"

     GroupDel(groupIndex)

 

END IF

 

Call GroupCreate("Stored Values")

 

groupIndex =GroupIndexGet("Stored Values")

 

CallGroupDefaultSet(GroupIndex) 

 

 

And I would have to create the channel I wish to store the data in

 

 

ChArray = ChnAlloc("Instances", iMax) : ChnLength(ChArray(0)) = iMax : CtrlEdgeChX = ChArray(0)

 

 

I guess I am unsure how to insert found data into the created channel.

 

 

 

 

I am using DIAdem 2011

Tim Z
Test Engineer
Magna International
Member
KyleP
Posts: 129
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

Hi smoothdurban,

 

If I understand your question correctly, it sounds like you're looking for the ArrayToChannels function. It seems to me you are able to properly extract the data into an array and create the channel so this should be the next piece of the puzzle.

 

Cheers,

KyleP
Applications Engineer
National Instruments
Member
smoothdurban
Posts: 143
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

Thanks KyleP

 

I will have to try this.  Is there an API which I could reference to assist me in generating scripts?

 

I think it woul;d save me a lot of time if I could reference the API so  I could determine what approach to take to solve future problems.

Tim Z
Test Engineer
Magna International
Member
KyleP
Posts: 129
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

In DIAdem you can navigate to Help ≫ Contents where you will find the Programming Reference. It is pretty well structured but if you cannot find what you're looking for, the Search optioin works great also. I think that should help speed up your development.

 

Good luck!

KyleP
Applications Engineer
National Instruments
Member
smoothdurban
Posts: 143
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

Thanks Again for your help KyleP

 

How would I be bale to determine the length of a channel.  I know this is part of the channel properties I am just unsure how to gain access to it. 

 

I have reviewed the API and there are functions which enable you to set the length but simple want to get the length

 

In most object oriented Languages you would simple code the following

 

int length = channel1.size()

or

 

int length = channel1.length()

 

or something along these lines.

Tim Z
Test Engineer
Magna International
Active Participant
Otmar
Posts: 383
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

Hello SmoothDurban,

 

The variable you're looking for is (this would be for the "Time" channel in group 1 ...

 

Data.Root.ChannelGroups(1).Channels("Time").Properties("length").Value

 

 You can find out the name of any property in DIAdem by dragging it into the Scripte editor from the DataPortal.

 

Dragging properties from the DataPortal to the SCRIPT panel

 

In the example above I simple dragged the maximum property from the Data Portal to the SCRIPT panel, the end resulty being the complete name of the property with channel and group references ...

 

Hope that helps,

 

      Otmar

Otmar D. Foehner
Business Development Manager
DIAdem and Test Data Management
National Instruments
Austin, TX - USA

"For an optimist the glass is half full, for a pessimist it's half empty, and for an engineer is twice bigger than necessary."
Member
smoothdurban
Posts: 143
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

[ Edited ]

Great help Guys!!!  I have continued to build my script and have hit another road block.

 

How do I set units to a channel?  Is this done when I create the channel?

 

 

Never Mind I figured it out!

 

 

Tim Z
Test Engineer
Magna International
Member
smoothdurban
Posts: 143
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

Gentlemen,

 

I have run into another problem.

 

I am trying to find th eavergae of all the values on a curve between two known X values.

 

Any ideas on how to grab all the values between two known X values? 

Tim Z
Test Engineer
Magna International
Member
KyleP
Posts: 129
0 Kudos

Re: Searching Through Channels and Creating a Channel from Searched Values

smoothdurban,

 

One way you can do this is to allow the user to use the band cursor to specify the x points. The attached code achieves this . You can change the x values to something else if you desire, and this should help you out.

 

Regards,

KyleP
Applications Engineer
National Instruments
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page