LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why use this construct? Coding Style Issue


@smercurio_fc wrote:

That sounds like someone trying to create a state machine, but not completely understanding the concept. Or perhaps the programmer had read about how sequence frames are "evil" (which they are not, if used correctly), and decided to do it that way instead.


In some cases it may be useful. Just enum, and loop (I prefer while, but may be "for" loop as well) which runs for all values sequentially. It looks like sequence (and act as sequence), but all frames are named - its good for readability and navigation. Kind of "reduced" State Machine, something like that:

 

SM.png

0 Kudos
Message 11 of 15
(648 Views)

... or the orginal develper did not want to use sequence locals in a stacked seq so they invented a stacked quence where they could use SRs instead.

 

Can you share an image of the curiosity?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 15
(645 Views)

I've done this to parse a string into a cluster where the string contained embedded strings preceeded by a string length, so I couldn't use several instances of string subset in parallel.  Each case removes the appropriate length from the beginning of the string, fills in an element of the cluster, and stores the remaining string to a shift register.

0 Kudos
Message 13 of 15
(629 Views)

thanks Nathan!

 

A stacked sequence that can use a SR.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 15
(626 Views)

>Can you share an image...

 

Sorry, can't post any code from the project.  I could recreate the code and post it, however I think I figured it out.  I did look at the code a little more and I'm convinced there is a better way.  The ouput of the case statement goes into a sub-vi that does a "replace array subset" for each interation, Read of Global Array to Write of Global array.

 

As the code is for initialization, I believe that the For Loop and Case can be eliminated and replaced with one instance of  Replace Array Subset.  Replace Array Subset could be expanded to handle all of the 10 indexed items and can be more easily maintained without stacked/flat sequences.

 

Or even better (IMHO)

 

The Global Array could be replaced with a functional global and the functional global would have an initialize function that would take in a 10 element array and perform the "Initialize Array" for size and "Replace Array Subset" for data entry in the Initialization case.

 

What do you think?

0 Kudos
Message 15 of 15
(616 Views)