LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Darren's Weekly Nugget 02/23/2009

This nugget is the first in a series of nuggets on Case structures.   Case structures have been around since LabVIEW 1.0.  They are by far the most commonly-used block diagram object...there are more than twice as many Case Structures as there are For Loops (the 2nd most common object) in all the VIs in the shipping LabVIEW codebase.  A Case structure can accept five different data types at its selector terminal:  Boolean, Numeric, String, Enum, and Error cluster.  Today's nugget will discuss the use of Boolean and Error selectors.

 

Boolean selector

The default data type of a Case Structure selector terminal (i.e. the type it has when you drop it on your diagram) is Boolean.  Thus, a standard Case Structure has a True case and a False case:

 

 

 

 Error selector

You can also wire an error cluster data type to the selector terminal.  In this case, you will have an Error and a No Error case:

 

 

 

 In this situation, the case structure is simply checking the value of the status boolean within the error cluster.  So the following code snippets are equivalent:

 

 

 

As a general rule, if you are writing VIs that have error in/error out terminals, you should wrap the diagram code with an error case so the subVI code can skip execution on an incoming error.  Most of the VIs that ship with LabVIEW use this technique.  There is also a VI Analyzer Toolkit test called "Error Style" that ensures your diagram is wrapped with an error case if there are error terminals on the connector pane.

 

-D

P.S. - Check out past nuggets here

Message Edited by Darren on 02-23-2009 04:29 PM
Download All
Message 1 of 36
(8,709 Views)

The Stop and Select nodes also accept the error cluster following the same logic.

 


 They are by far the most commonly-used block diagram object...there are more than twice as many Case Structures as there are For Loops (the 2nd most common object) in all the VIs in the shipping LabVIEW codebase.


 

Very interesting... Would you come clean if there were a bunch of stacked sequences hiding behind those locked diagrams?  🙂

 

Aside - I've noticed you've turned off "Show dots at wire junctions".  Any reason?  (Am I not in the "club" if I thought "dots" were a great addtion a few releases ago?)

Message Edited by LabBEAN on 02-23-2009 05:55 PM

Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
Message 2 of 36
(8,694 Views)

There are definitely some Stacked Sequence structures lurking in the LabVIEW codebase, although certainly not in any of the VIs I write.  I just did a quick check of the LabVIEW 8.6 core codebase, and I'll just say that for every Stacked Sequence structure with 2 or more frames, there are roughly 150 Case structures.  Do with that ratio what you will.  😉

 

 As for dots at wire junctions, I think they're ugly.  But I also think I'm in the minority with that opinion, so I'm probably the one who's not in the "club".

 

-D

0 Kudos
Message 3 of 36
(8,666 Views)

I'm not keen on the Dots, but my real hate is those Iconize terminals on diagram. Smiley Mad That's the first think I switch off along with making the labels transparent.

 

Regards

Ray Farmer

Regards
Ray Farmer
Message 4 of 36
(8,636 Views)
"Ray Farmer" <x@no.email> wrote in message
news:1235459419707-858847@exchange.ni.com...
> I'm not keen on the Dots, but my real hate is those Iconize terminals on
diagram. Smiley Mad&nbsp;That's the first think I switch off along with
making the labels transparent.&nbsp;RegardsRay Farmer

Ray, we're on the same page with the terminals and dots. I'm not sure if
it's because it's new, or just ugly...I don't care much about those labels
tough...

Another thing I really don't get is that the maximum nuber of undo's is set
to 8 by default... I usually put it to 80 or something...

Regards,

Wiebe.


Message 5 of 36
(8,602 Views)

I personally like the dots and think they help to make the diagram clearer, and I also got used to the transparent labels after switching to 8.6. I don't like the terminals as icons, but I feel that NI is probably correct to have that as the default. In both cases, though, it's just a matter of personal taste. Since the setting is global, debating it is irrelevant.

 

Of course, I can't say the same about the undo. Most people probably have more need to be able to undo a lot than problems with the extra RAM this feature requires. Now, if only we had someone who was in the LabVIEW R&D department and who could push to change this default to a large number...


___________________
Try to take over the world!
Message 6 of 36
(8,587 Views)
I also like the Dots - a relic from my schematic capture days.  I also HATE the Iconized controls - they take up too much realestate  and detract from the otherwise clean code. Other items I turn off is Auto Tool, Auto Wire, Wire Route, Red X's on wires.  Before I start an uproar on the Auto Tool.  I tried it for six months (LabVIEW 8.5) and I can code faster without the tool on.  Most of my LabVIEW career has been without the Auto Tool
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 7 of 36
(8,572 Views)
Well, I love the auto tool!

Let's just say it is great that all those features can be turned on and off!

Regards,

Wiebe.


Message 8 of 36
(8,548 Views)

De gustibus non est disputandum!

 

I learned that phrase in high school Latin class, and it dates from the Romans.  Roughly translated, it means "there is no disputing tastes."  I think we have verified its veracity.

 

That said, I can chime in with my favorite changes:

  • Autowire - off
  • Labels - transparent
  • Structure autogrow - off
  • Autotool - on
  • Automatic error handling - off
  • Number of  undos - maximum
  • Wire dots -On (default now)
  • Coercion dots - orange (default now)
  • Block diagram grid - off
  • Front panel grid - on
  • Snap to front panel grid - off
  • View terminals as icons - off
Message 9 of 36
(8,536 Views)

tst wrote:
Now, if only we had someone who was in the LabVIEW R&D department and who could push to change this default to a large number...

It would not be unreasonable to expect the default value of max undo steps to increase in a future LabVIEW version.

 

-D

 

P.S. - All this talk of LabVIEW preference settings is motivation for me to write my blog entry on my Tools > Options settings.  Maybe I'll get it knocked out sometime this week.

Message Edited by Darren on 02-24-2009 10:13 AM
Message 10 of 36
(8,497 Views)