LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get current sequence in a stacked sequence

Hello,

 

I am trying to implement a progress bar for a stacked sequence; as the sequence increases, the bar increases etc... This may be trivial but I cant figureout how to determine the current sequence number.  There is no property node for a stacked sequence structure...

 

I am using labview 8.5 

 

Regards

hvo

 

0 Kudos
Message 1 of 6
(2,811 Views)

A stacked sequence is just a means to enforce dataflow, and an obsolete one at that.

 

You'd be better off using a state machine architecture.  Every frame of your stacked sequence would become a case in the case structure.  As your program loops, you can use the loop iteration terminal, or some other counter to determine how many cases you have progressed through.

0 Kudos
Message 2 of 6
(2,803 Views)

First, what proces are you doing using teh sequence structure? In general, you should avoid using sequence structures, esspecially stacked sequence structures. I assume you are new to LabVIEW and data flow programming. Take some time to learn how to use data flow programming and you will find you rarely ever need to use sequence structures. There are lots of discussions which cover the negatives about sequence structures.

 

Now, given that you will need to develop your own variable which is used to update the progress bar throughout the sequence. The brute force method would be to wire a value through and use sequence locals. However if you went down this path you will quickly see why sequence structures are not recommended. A more generic method would be to create an Action Engine (search for action engine for lots of explanations on those) which would control the progress bar data. Each frame would need to call the action engine to update the progress bar.

 

Since it sounds like you are writing a fairly complex sequence I would recommend you do one of two things. First and probably the easiest would be to create a subVI for each frame and then simply use dataflow to wire these together in the order you want to execute them. The downside here is that you are creating subVIs which may or may not ever be reused. It is still a valid approach though. The second and more flexible approach would be to use a state machine to control your processing. This is much more flexible and easier to maintain than a stacked sequence.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 6
(2,801 Views)

I have been using the "brute force" method to update my progress bar via a constant in each sequence.  Though this method doesn't make it easy when inserting or deleting a sequence in the middle of the structure since the rest of the constants are off by 1.  I am guessing this is one of the reason why stacked sequence structures are not recommended.   

 

I have not tried the state machine method recommended above but I will look into it.

 

Best Regards.

hvo

0 Kudos
Message 4 of 6
(2,794 Views)

Yes, adding/deleting frames is not very convenient in sequence structures. Passing data through them is a nightmare. Once in it you MUST execute every frame. This can mean that you have nested case statements in later frames simply to avoid executing code due to some upstream condition.

 

State machines are much more flexible and maintainable. You control the execution of the states and can easily reuse a state (not very easy to do with a frame in a sequence), abort execution at any time, reorder execution at runtime based on whatever conditions you desire, as well as having many other benefits. When creating a state machine either use strings or a typedefed ENUM for your state names. They will help to make the code more readable. JKI has a nice state machine template you can start from.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 6
(2,791 Views)

 

Thanks for the suggestions.

 

Best Regards

hvo

0 Kudos
Message 6 of 6
(2,788 Views)