06-02-2015 03:04 PM
Hi all,
I've been trying (in vain) to create a good dialogue box that does some bounds checking on user inputs before allowing them to be sent to the main application. Ideally, when an input is out of range, it'll blink until it gets put into range. Generally this means that bounds can only be positive (nonzero, nonnegative numbers) and that VISA resources cannot be left blank. Additionally, the difference between two of them must be bigger than or equal to 40(Range Max - Range Min >= 40). Normally, my code is pretty modular, but I think this being my first real foray into UI design has left me struggling to make things look and work nicely. I've posted the VIs thus far for critique.
I've described how it should work. As to how it's actually working, I've noticed that whenever I have two things that are out of range, and I fix one, the OK button is no longer blocked. I think this may have to do with how my events are set up, but can't be sure. What do you think? How can I make this better? Am I missing something fundamental in my design layout?
thanks,
ijustlovemath
06-02-2015 03:14 PM
It looks very nice and tidy.
But like you said, it has some logic flaws.
I would create a VI that does all the comparisons whenever any of the controls change. (Since it sounds like the controls are inter-related, having condition A be good, but then changing something on B may not make condition A bad.) Have a series of comparisons you could do in a For Loop. Output an boolean True if it passes. At the autoindexing boundary of the For Loop, only enable the OK button if AND ARRAY Elements are all True. Only exit the while loop if AND ARRAY Elements is true AND you've hit OK.
06-02-2015 03:21 PM
So would I pass an autoindexed array of references to the For loop? I think I'd still need to create a testing VI for each condition, right? Then somehow pass an array of those in? How would I do that?
06-02-2015 03:43 PM
Here are some suggestions:
Bob Schor
06-02-2015 03:54 PM
Range Min and Range Max need to be set exactly by the user, so while I do like the idea behind the slider, I think it would just end up cluttering the dialogue while not adding much. Could you explain the "Abort VI" suggestion a little more? Also, what do you mean by using shift registers? Would that be used for just reading new values, or what?
06-02-2015 04:34 PM
@ijustlovemath wrote:
Range Min and Range Max need to be set exactly by the user, so while I do like the idea behind the slider, I think it would just end up cluttering the dialogue while not adding much. Could you explain the "Abort VI" suggestion a little more? Also, what do you mean by using shift registers? Would that be used for just reading new values, or what?
So you make them "Coerced" as well, force them to be done first (by making only Min visible, using Min's value to set the Min for Max, making Max visible, then using Max and Min's value to set the other Range Control and make it Visible). Once you have the range set, make Min and Max invisible. By doing this, you gently lead the user by the nose through the correct steps.
Here is a Snippet of (some of) the rest of your question. This picture can be "dragged" onto a blank Block Diagram and it will magically become LabVIEW code.
Here are points to note:
Bob Schor
06-02-2015 09:05 PM
@ijustlovemath wrote:
So would I pass an autoindexed array of references to the For loop? I think I'd still need to create a testing VI for each condition, right? Then somehow pass an array of those in? How would I do that?
No. An auto-indexed array of booleans. A For Loop that has a case structure tied to the i terminal where each case is the test for a set of conditions. Now you have an array knowing what conditions passed the test and which failed. If you do AND Array Elements and have a True result, you know that all the conditions have passed.
06-02-2015 10:14 PM
Hers is another place you can check for ideas.
http://www.notatamelion.com/2014/12/12/validating-data-input/
This basic idea can be easily expanded to handle arbitrarily complex validation.
Mike...