11-18-2016 11:14 AM
Hello everyone!
Can I please get some recommendations on getting my block diagram a bit tidier? Referring to the VI, a user has a selection of 1-64 of channels to scan. For each channel, I've enlisted a case structure, and have wound up with, you guessed it, 64 case structures. Can I substitute the 64 case structures with something more elegant while maintaining the same layout in the Front Panel? An additional 64 channels is coming to the VI soon and, if possible, I want to avoid another 64 case structures! Any help is greatly appreciated!
11-18-2016 11:42 AM
I did not see 64 case structures, I assume you are talking about event structures. A few suggestions:
mcduff
11-18-2016 11:49 AM
Hi mcduff,
The case structures, I believe, are in the event structure "SCAN". Warning, it's really messy.
11-18-2016 11:58 AM
I still am not seeing the case structures, maybe my monitor is too small. A few things for that case:
mcduff
11-18-2016 12:31 PM
I highly recommend you go and browse through the Rube Goldberg thread. Your code has earned you a place in it.
11-18-2016 01:12 PM
Ouch. Yeah the better way to handle the values, might be to use an array of booleans, and then you can index over each one. You can do this through control references which seems to work alright and will scale with the number of buttons you add. Of course this same technique could be used on an array of booleans, or a listbox with check boxes might be a more intuitive UI design as shown here.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-18-2016 01:15 PM
Replace the 64 booleans with a single boolean and a channel control. Select the desired channel, push the boolean.
11-19-2016 01:56 PM - edited 11-19-2016 02:02 PM
If you really want all these buttons, use 2D array of booleans and numeric and the code will shrink to few % of what you currently have. (Keep them 1D in the code and reshape from/to 2D for the front panel).
But, yes, this code is not maintainable, breaking all rules of plain common sense. There are tons of places where the code could get trapped inside inner loops e.g. if the right response is never received, for example. Event frames should complete quickly and not deal with lenghty code and inner loops.
Sorry, I cannot give more detailed advice, because my monitor is not wall sized and does not have 40 million pixels to efficiently navigate that mess.
If you keep working on this VI, you are just digging yourself deeper into a hole. Do a few simple LabVIEW tutorials, read the entire Rube Goldberg thread (all 1700+ messages!), then start from scratch with scalable code that fits on one screen.
11-19-2016 02:38 PM - edited 11-19-2016 02:42 PM
@altenbach wrote:If you really want all these buttons, use 2D array of booleans and numeric and the code will shrink to few % of what you currently have. (Keep them 1D in the code and reshape from/to 2D for the front panel).
Here's a quick draft of what I had in mind. The code basically fits on a postage stamp! 😄
The main control is a 2D array of clusters, where each element is a channel name string and a boolean. The string is disabled so it cannot be changed by the operator.