11-17-2010 10:54 PM
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 ?
11-17-2010 11:42 PM
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.
11-18-2010 12:34 AM
I agree...state machine is better option than sequence structure
11-18-2010 12:48 AM
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")
11-18-2010 01:17 AM
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
11-18-2010 01:28 AM
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.
11-18-2010 01:35 AM - edited 11-18-2010 01:38 AM
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
11-18-2010 04:48 AM
-------------------------------------------------------------------------------------------
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 ...)
11-18-2010 08:23 AM
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.
11-18-2010 11:54 AM
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.