DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching Through Channels and Creating a Channel from Searched Values

Solved!
Go to solution

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
0 Kudos
Message 1 of 9
(4,846 Views)

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
0 Kudos
Message 2 of 9
(4,821 Views)

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
0 Kudos
Message 3 of 9
(4,816 Views)

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
0 Kudos
Message 4 of 9
(4,814 Views)

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
0 Kudos
Message 5 of 9
(4,791 Views)
Solution
Accepted by topic author smoothdurban

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
0 Kudos
Message 6 of 9
(4,788 Views)

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
0 Kudos
Message 7 of 9
(4,774 Views)

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
0 Kudos
Message 8 of 9
(4,733 Views)

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
0 Kudos
Message 9 of 9
(4,720 Views)