LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting sequence of operations

Imagine that you have 5 independent measurements using 3 instruments.

 

I have them defined in separate flat sequence structures. Depending on front panel input, I want the ability to run these measurements in a user-defined sequence - say 1,2,3,4,5 or 1,3,5,2,4, or ...

 

How do I do that ?

0 Kudos
Message 1 of 13
(4,490 Views)

I can't imagine why you have them in flat sequnece structures. I would recomend a basic a queue driven state machine where each state is a particular instrument.

Message 2 of 13
(4,484 Views)

I agree...state machine is better option than sequence structure Smiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 3 of 13
(4,474 Views)

What Ben and GAK mentioned is something like this (a simple state machine but the same concept can be done in many ways like for example by making use of "Queues")

 

 

Regards
Guru (CLA)
0 Kudos
Message 4 of 13
(4,469 Views)

The easy solution is to put each sequence in a separate Case structure. Then it's easy to use the front panel to control which to run.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 13
(4,463 Views)

They are in flat sequence structures internally because each measurement requires a certain sequence of internal steps, not all of which can be causally connected using error cluster lines (initialization, trigger set up, measurement, post-processing, etc.). This is the most straightforward way of defining any one of them. Why would I want to bother with anything more complicated ?

 

What I am asking about is how to sequence these measurements (internally defined as flat sequences) according to user input. For purposes of this question, consider each of the measurements to be defined as a sub VI.  Given the large number of possibilities, using a case structure is clearly not the most easy solution to code (as someone suggested).

 

Just count the number of ways in which 1-5 can be arranged.

0 Kudos
Message 6 of 13
(4,459 Views)

You can not decide the sequence in which "Sequence structure" will execute. It will execute as it is arranged. Sequence 1 first...5 last.

You are making it complicated for yourself by not using state machine.

And if you are so willing to use sequence structure then make sub vi for each possible combination. And call these subvis using event structure.

It is going to increase your efforts

 

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 7 of 13
(4,456 Views)

 

-------------------------------------------------------------------------------------------

Why would I want to bother with anything more complicated ?

--------------------------------------------------------------------------------------------

 

Well, its up to you, what sort of application you would like to develop.

 

Quee or state machine will only reduce your effort when the application is going to get bigger.

Or if you are happy with your current approch its absolutly fine.... (since you will be one to change tt later ...)

 

 

 

 

Regards
Guru (CLA)
0 Kudos
Message 8 of 13
(4,440 Views)

I agree with Dennis about the queue-driven state machine. Very powerful and flexible, not only for this type of application, but for general programming as well.

 

As a starter, check out JKI's QSM template, which I often recommend. Using this structured template will keep you from having to start from scratch and reinvent the wheel. There are a million ways to do QSM's, but this is a good start.

Jarrod S.
National Instruments
0 Kudos
Message 9 of 13
(4,424 Views)

I think you are being slightly misunderstood, it seems the Flat Sequences are only used to specify the individual measurements, and not to control the order like some are suggesting.  If that works, and makes you happy, so be it.  I'll take your advice and just consider those to be subVIs, one for each of the 5 measurements.

 

When I want a quick UI like this I reach for an Event Structure, and use the timeout case for the business end.  Inside the timeout case I may put a Queued State Machine or in this case I would just use a simple For Loop.  In the example I create a simple array of enums, with one value for each measurement.  When Go is pressed, the Event Structure timeout is fired, and the array of measurements is autoindexed by a For Loop.  Inside the Loop is a Case Structure to handle the individual measurements, just drop your 'subVIs' in there.

 

Simple and quick, lets you spend more time measuring and less time coding.

0 Kudos
Message 10 of 13
(4,410 Views)