From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From 11:00 PM CDT Friday, May 10 – 02:30 PM CDT Saturday, May 11 (04:00 AM UTC – 07:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
11-20-2008 02:10 PM
I have created a periodic table of elements, using a bunch of boolean switches, color-coded and labeled as shown. Anyone have any suggestions as to the easiest way to create a list of all the elements selected?
The PC-based application will use a touch screen monitor. The general idea is below.
1. Analyst clicks on all of the elements in the sample. (I want to ensure that the array only lists an element once, regardless of whether they click a button multiple times - I may make it so the button is disabled after they press it once
2. On a second tab, there will be a list of all those elements selected on the 1st tab. There will be a keypad here, so that the analyst can enter the percent weight for each element in the sample.
I've attached screen captures of what I have so far (not much). Just looking for some general ideas - not looking for anyone to do my job...
Solved! Go to Solution.
11-20-2008 02:51 PM
First of all, nicely done.
Use switch when pressed for the boolean control.
In that case the selection stays until reset, resetting can be done by pressing it agian or programmatically restting the value to false.
To get the values of all true elements if there on a tab and the onlyu one on a tab.
Use VI server:
Create a reference to the tabcontrol.
Get the array of page references.
Index the page that contains the elements.
Get all control references for that page reference.
Iterate the control references and where value is TRUE get the boolean text and build it into an array.
11-20-2008 03:04 PM - edited 11-20-2008 03:05 PM
My solution would be to wrap up your controls in a cluster (you can make the cluster box invisible so it doesnt take away from your front panel apperance.) Then I would use an event structure to handle "Value Change" for "All Elements" in that Cluster. Then I would convert this cluster to array of booleans and send this to OpenG's "Search Array" which will return an array of indices of all those elements which matched the search value (TRUE in your case.) Once you have this array of indices, and since you know the predefined order of the elements, you can create your list. I think this is probably the cleanest approach but you'll have to use (free) 3rd party VI's for it.
11-20-2008 03:07 PM
The (free) 3rd party VI is not necessary.
Its not hard to create the functionality yourself. Probably faster than finding out how to get the free VI. From openG?
11-20-2008 03:23 PM
11-20-2008 03:55 PM - edited 11-20-2008 03:58 PM
Here's another idea.
Involving several semi-advanced LabVIEW topics: VI server, Event driven programming, Dynamic events.
What it does, is filter all the boolean controls, register for a value change on any of the booleans, upon a value change the list of elements is determined by the booleans which are true.
Ton
11-24-2008 09:36 AM
11-24-2008 09:54 AM - edited 11-24-2008 09:55 AM
You can get the actual clicked button from the left side of the Event structure, which you can convert to a boolean type, than you can read the boolean texts:
Ton
11-24-2008 10:37 AM
Ton, thanks for the feedback. I've tried this:
I added an element (CtlRef) to the event structure
I ran that to the reference iput on a "To More Specific Class" function and wired a boolean constant to the target class input.
I created a Strings (4) Property for the Boolen Class and connected its output to an Index Array function whose output goes to a front panel indicator.
If I interpret this code correctly, it should just look for those boolean controls which are returning a true, grab their string values and build an array of those strings. When I run this as described, I get the following error:
Error 1507 occured at To More Specific Class in
Periodic Table.vi
Possible Reason(s):
LabVIEW: Type mismatch: Object cannot be type casted to the
specified type.
I don't understand why it can't be typecast to a boolean, since it is a boolean control, and I'm confused as to why I'm not using a build array insterad of an index array
11-24-2008 11:00 AM