LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
longbow

Bit flags

Status: Declined

Any idea that has received less than 3 kudos within 3 years after posting will be automatically declined.

Testing multiple items one after the other takes a lot of space horizontally.

It would be awesome to have a boolean array input to a "multi-case sturcture" but where 0 or more cases might end up being executed, depending on the boolean entries.

 

An extension to this could be an integer input with bit flag cases (sets of if (x and mask = mask), where x is the input integer, and mask is the case statement.

8 Comments
Philbot
Active Participant

The first part sounds a lot like a case structure inside a for loop with auto indexing.  Did I missunderstand?

Get a life? This IS my life!
ToeCutter
Active Participant

...and the second bit sounds like just a couple of simple LabVIEW primitives bolted on to the first bit.

 

Weighing the simplicity of implementing this in code against the added bloat of having it built in, it's a no goer for me.

longbow
Member

Yes - its basically a space and time saver structure I propose.

You're correct that it could be done with a case structure in a for loop, but would save time to have it.

AristosQueue (NI)
NI Employee (retired)

longbow: Can you give some example code where you would have used this? I could not find any examples in my G code, C# code or C++ code where I would have ever used such a construct.

 

Just to make sure I'm looking for the right thing... you want a wire of some integer type with N bits and a structure node that has N frames and frame 0 executes if the zeroth bit is true, frame 1 executes if the 1th bit is true, etc. Yes? (Please say "yes" if I have the general gist... I realize there are many variations on the theme, like reordering the cases and/or combining the cases for several bits into one frame... I just want to know that I have the basics of your request.)

 

It is the phrase "where 0 or more cases might end up being executed" that is the sticking point. I have plenty of code that would execute *one* frame of a case structure would be executed if a given bit pattern is set, but nothing where multiple frames would execute. I had trouble even coming up with code where that would be useful. The closest I got was some sort of sequencer, where the flags correlate to whether or not to execute a particular step in the sequence, but in the code I looked at, that was either not able to be expressed with a simple bit field OR there were advantages to having each sequence step be its own Case Structure (because it made reordering easier and because I could set a breakpoint in the "false" frame for each step).

 

I'm open to the idea of this structure, but I need example code where it would have helped and some estimation of how frequently it would be useful to you.

GregSands
Active Participant

I guess a Status value from some piece of hardware might set various bits to indicate the current state of the component, so handling that might be one possible use case.  But I can't see the need for a dedicated structure to implement this.

longbow
Member

Hi AristosQueue & GregS

 

Yes - you've got the gist of the idea, together with the combining several bits into one. Maybe for building up a status string, or taking actions based on status bytes.

 

But its a mere nice-to-have structure to save a little time & block-diagram space, and could be done a little more clumsily with for loops and case statements or a set of "equals" operators and true-false cases arranged left-to-right.

AristosQueue (NI)
NI Employee (retired)

Thanks for the clarification.

Darren
Proven Zealot
Status changed to: Declined

Any idea that has received less than 3 kudos within 3 years after posting will be automatically declined.