08-20-2009 06:13 PM
Hello
In a piece of my code I have six controls that control three different bands: A, B and C. My controls are:
A From
A To
B From
B To
C From
C To
Concerning the range of the values, the minimum is always 0, the maximum is adjusted using property nodes and the increment is always 0.01. I need to create a code to verify each band (A, B or C) and avoid that the FROM value overlaps the TO value and vice-versa, within a specific band. Beyond avoiding that they overlaps, the difference between these two values must be kept in, at least, 0.05. One control will "push" the value of other until the maximum or minimum value of the range, keeping always a difference of at least 0.05.
The controls of different bands can present the same value, no problem.
I tryed some codes, but they are too complicated and with a lot of Case Structures (True and False) and are not working properly. Someone have a simple solution for this?
Find attached a simple piece of the code just as an example.
Dan07
08-20-2009 07:02 PM
Use a Value change event case for each of your From/To controls.
When you detect an event for one of those controls, then it can read the corresponding controls that could overlap and change the ranges and value accordingly.
Be sure to work out all of the logic. For instance if C From gets dropped too far, not only could it affect B To, but also B From and A To.
08-20-2009 07:31 PM
I think that your tip to work with one case for each one of the controls will solve my problem. But, there is no problem if a C control drops a lot, it will not affect B and A because there is no problem having values like this:
A from: 1.34 A to: 1.59
B from: 0.74 B to: 1.22
C from: 7.46 C to: 10.42
The controls of different bands can overlap, I am taking care only within the ranges, I don't want values like this:
A from: 1.29 A to: 1.11
B from: 7.34 B to: 2.56
.
.
.
.
Thanks
08-21-2009 05:36 PM - edited 08-21-2009 05:39 PM
I created the code. It is working but I think that it is too complicated. Do you have any suggestion?
There is a problem, if you change the MAXIMUM to 1, the "A To" control goes only until 0.99. I don't know the reason for this.
Find attached the two Vis: Controls.vi and Sub.vi
Thanks
Dan07
08-21-2009 06:13 PM
Easiest would be to just reorder each set so that the smaller of the two occurs first for each set.
Your sequence structure in the subVI has no purpose. Why is it there???
Why do you do all that song and dance with the label text, etc. Just convert the cluster to an array (using cluster to array), reshape the array to a 2x3 2D array, and loop over each row, reshape back to 1D and use array to cluster for the output. It is probably cheaper to always test all sets instead of doing all that work with property nodes.
08-21-2009 11:22 PM
Hello
I forgot the sequence structure there. I was using it to try to find the erros of the code because with it is easier to highlight the code step by step.
I did what you told me and now the code is working well with the N loop. But, I need to keep the label.text because I want that the control "pushes" the value of the other if the difference between then is lower than 0.05. So, the code need to know if I am changing the "from" control or the "to" control to change the comparisions and modify the values. I know that the code is too dirty, but the Label.text help me to know which control I am using. Do you have any sugestion to improve this code?
Find attached the new versions.
Dan07