06-04-2012 10:05 AM
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
Solved! Go to Solution.
06-05-2012 10:59 AM
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,
06-05-2012 11:44 AM
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.
06-05-2012 12:22 PM
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!
06-07-2012 12:43 PM
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.
06-07-2012 01:18 PM
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.
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
06-08-2012 02:23 PM - edited 06-08-2012 02:26 PM
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!
06-14-2012 08:49 AM
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?
06-15-2012 09:21 AM
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,