08-08-2013 02:21 AM
Hello everyone,
I have a bit of a challenge that I appreciate some help with. I am trying to create a program that synchronises the function of a group of booleans by their names. If the booleans have names bool 1_i, I want them to be synchronised such that when one bool 1_1 for instance is turned on, then all the other bool 1_i are changed to the same state. The group of Booleans bool 1_i will all initially be in the same state but I'm trying to get a program that allows them to work in parallel like that. I have been able to make a 16 by 128 array to work like that, where every row represented the group of bool j_i where i=16 and j=128. Now I want to have the same function only for a stand alone booleans that aren't put into an array by the array function palette. In effect i am trying to get an array of booleans without creating a boolean array in the traditional sense. This is because I want the position to each standalone boolean to be changed while maintaining is synchrony with other booleans linked to it by name. Any help on this would be very much appreciated.
Below are screen shots of the code that I used the 16 y 128 array
Sincerely,
Tebello
Solved! Go to Solution.
08-08-2013 02:41 AM - edited 08-08-2013 03:08 AM
@tebelloq wrote:
I have a bit of a challenge that I appreciate some help with. I am trying to create a program that synchronises the function of a group of booleans by their names. If the booleans have names bool 1_i, I want them to be synchronised such that when one bool 1_1 for instance is turned on, then all the other bool 1_i are changed to the same state. The group of Booleans bool 1_i will all initially be in the same state but I'm trying to get a program that allows them to work in parallel like that. I have been able to make a 16 by 128 array to work like that, where every row represented the group of bool j_i where i=16 and j=128. Now I want to have the same function only for a stand alone booleans that aren't put into an array by the array function palette. In effect i am trying to get an array of booleans without creating a boolean array in the traditional sense. This is because I want the position to each standalone boolean to be changed while maintaining is synchrony with other booleans linked to it by name. Any help on this would be very much appreciated.
Though I'm not able to correlate the screen shots you had shared and the issue you're facing, why don't you use Or Array Elements function.
08-08-2013 03:05 AM
You could use just one boolean instead of a synchronized group and place local variables wherever you need it. I don't think synchronization by names is possible. That is a contradiction to Labview's (and any other programming language's) concept.
Cheers
Edgar
08-08-2013 03:54 AM
Won't this still have the booleans in an array. I want to create standalone booleans which are sychronised instead of having them in a lined array.
I am sorry about the images. I will attach the VIs I created.
One has the function I call on the separate VI.
Thanks in advance.
08-08-2013 04:46 AM
first of all you can change all your local variable for wires. it prevent the race condition in "Binary operater final-1.vi" and eleminates the uses of the frame in the "Binary to Decimal converter Copy 1-1.vi"
second use usesfull names for your vi's.
next the for loop in "Binary to Decimal converter Copy 1-1.vi" can be used with auto index removing most of the code in it. but you can also replace the whole construction with a boolean to (1,0) and a sum array.
sinds the booleans in the same row are all the same (or that it wat i understand out of your story) is it not an idee to just use a single boolean and then if you need to display it set the value of the display to the value of the boolean.
08-08-2013 06:09 AM
Hi,
of course there are ways to switch the Booleans by name if you really want to. I'm not sure it's a good idea however.
Maybe it's time to take a step back and have a look at the big picture. You only told us what you want to do, not why you want to do it.
Your code suggests that you are rather new to LabVIEW, by entering this forum you've come to the right place to start thinking dataflow. We can help.
Tell us what you are up to and we may be able to suggest a design pattern to use for solving your problem.
Regards Florian
08-08-2013 06:19 AM
Florian,
even if it is not a good idea, just for curiosity, how would you switch the variable by name?
Cheers
Edgar
08-08-2013 06:30 AM
First thing that comes to mind (crudely described):
Make an array with references to all your fp elements and a corresponding array with their names,
use an event structure to monitor value change of the Booleans (in a single case),
therein use the element refnum to find out name of the switched Boolean,
use this to filter out names that are identical except for last character,
index those out of your ref array,
use property node to set their values to new value.
Regards Florian
08-08-2013 06:45 AM
well, ok, but this is probably not what the poster has in mind. He doesn't want to use a array.
08-08-2013 06:49 AM
If i got him correctly he doesn't want to use an array of Booleans - he wants separate Booleans.
I don't think he is against using arrays of any kind (refnums and strings in my example).