LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Style: Sequence structure

I was wondering what everybody sees as the greatest drawbacks to using sequence structures. In instances where data flow is not an issue I have found sequence structures to be a handy tool to force the sequence of events (i.e, user prompts at startup, etc.) What are your thoughts on this issue?
0 Kudos
Message 1 of 5
(3,380 Views)
John,

This is a touchy subject, which is sure to start yet another holy-war. But, we must remeber the past or we are doomed to repeat it. So, here is your answer, from a member of NI's LabVIEW Development Team:

At 8:07 PM -0500 6/9/03, stephen.mercer@ni.com wrote:
> Sequence Structures are bad. Their one good
> use is to wrap a single node (and possibly
> constants wired to that node) to provide a way
> to attach arbitrary dataflow -- such as wrapping
> around a Wait primitive.

Want to whole story, do an Info-LabVIEW seach (via http://www.searchview.net/ ) for "Three Button Dialog".

Regards,

-Jim
Message 2 of 5
(3,380 Views)
I think it's best to avoid using Sequence Structures as your primary application framework. There are much better ways to design a program. (State Machines, Producer/Consumer�) Sequence Structures not only hide code (I know, so do Case Structures, but they serve a specific and necessary purpose) but they break the left to right dataflow paradigm when you have to use sequence locals to pass data between frames. You end up with wires running in all directions and keeping track of all of them can be a real pain. The new Flat Sequence in LabVIEW 7 helps some of this, but it�s really only useful for small sequences as an entire program written based on the Flat Sequence would scroll on forever.

I�m in the process now of modifying a program that was based on S
equence Structures. They need to add several new features and it�s going to extremely difficult unless I can convince them to just let me start from scratch. It�s taken me week just to figure out what all the different parts do and label all the wires.

That being said, I agree with Jim and Stephen and you about using them to force dataflow dependency where it is not otherwise possible. But even then, if you have to use more than a single frame, you probably need to rethink what your doing.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 3 of 5
(3,380 Views)
You could say that a simple state machine design - e.g. one with 'initialise', 'run' and 'shutdown' states each of which runs only once - is no different to a sequence structure. What the state machine does give you is the ability to easily add to and extend your program in the future - for example when you find you need to add an error handling state, or you want to go from 'run' back to 'initialise', and so on.
0 Kudos
Message 4 of 5
(3,380 Views)
The greatest drawback with a sequence structure is they are inflexible. Each and every frame must execute through to completion, in the order in which the frames are numbered. If you replace the sequence structure with a state machine (case structure within a while loop with the selector value passed using a shift register), you now have the flexibility to skip to/from any frame, and specify some conditions that will cancel out of the sequence, such as error status or the value of a Quit boolean.
0 Kudos
Message 5 of 5
(3,380 Views)