LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine architecture solution

Hi all !  I'm developing a VI that implements a state machine.

In one specific state, I'd like the VI to start an acquisition loop to plot data in a chart. This loop stops only when a stop button is pressed an the whole VI stops.

I was planning to trigger an event using "value signaling property" to start the loop.

After the loop is started, the state machine have to continue its proccess up to an end state, in parallel with the loop.

I'd like to know if this is the best achitecture solution for this application or if there is something better.

Thanks in advance for the help.

Regards, Roberto.

 

0 Kudos
Message 1 of 10
(3,530 Views)

From advice I've gotten, seems like Producer/Consumer architecture might work best.

0 Kudos
Message 2 of 10
(3,522 Views)

Not very clear what you are proposing.  Do you want a state machine or a state machine in parallel with a loop.

 

Can you describe the application or provide a code sample?

 

 

 

 

-------
Mark Ramsdale
-------
0 Kudos
Message 3 of 10
(3,513 Views)

Hi Mark! I don't have the VI yet!

I'm planning the application first.

In fact, I'd like a state machine in parallel with a loop, but, I'd like the state machine to start a loop not in the first state.

Because of this, I was looking for triggering an event or using a producer/consumer mechanism to start the loop.

Clear now?

Regards, Roberto.

0 Kudos
Message 4 of 10
(3,508 Views)

Not to clear, let me see if I have this.  A state machine in parallel with a loop.   The state machine also starts a loop somewhere, but not in the first state.

 

Technically this is three loops, the state machine loop, the parallel loop, and the loop started by the state machine. 

 

Which loop do you want an event for triggering?

 

A brief description of the type application would be helpful.  While I am willing to believe, I think there may be a better way to accomplish what you really want to do.  

 

Using a P->C architecture involves two loops to begin with.  I think you could probably just use a state machine, that continually loops, and direct it through repeating states, A - B  - C.   Then when you want you can turn off the traverse through any state or turn on new states. 

-------
Mark Ramsdale
-------
0 Kudos
Message 5 of 10
(3,499 Views)

Hi Mark! I think I was not clear enought to explain my necessities.

Let's see.

The main purpose of the application is to start a loop to collect data from an instrument, perform some calculation and plot a chart.

To do the calculation, application needs to get some data from a file. First state.

Then, after getting data from a file, state machine goes to the second state, when it starts the loop, I mensioned above.

And then, lots of othes states are necessary to do other things, i. e., getting other data from a database, waiting user to make options using combo-boxes, and finally, writing some data into a database.

At last, whem the user press stop button, main loop and the whole applicaton end.

That's it!

But I agree with you, I think a state machine with a P-C will be the best architect solution.

Regards, Roberto

0 Kudos
Message 6 of 10
(3,477 Views)

You can have more than one consumer loop if you want to make things parallell.

Just have one queue for each consumer loop. You can add things to queues from multiple places but can only take things off a queue in one place.

Message 7 of 10
(3,461 Views)

OK, that makes a lot more sense. 

 

Does the application need to respond to user actions and transfer data to/from the DB during measurement?  Or does the user sit while the data is measured and then analyzed?

 

I don't need the answers personally, but if this process you are programming fits into the sequence:  Init - read user inputs - measure/analyze - post processing (save files, write to DB) - done.   And if the measurement is not fast, huge, or time consuming, you could get away with just a state machine.  This may just be a fine point to make, P-C would always work where a state machine works.

-------
Mark Ramsdale
-------
0 Kudos
Message 8 of 10
(3,459 Views)

If you do want to "take things off in multiple places" you can use either user events or notifiers. (Not suggesting this is the best way to solve your problem)

 

 

=====================
LabVIEW 2012


0 Kudos
Message 9 of 10
(3,458 Views)

Yes Mark, application need to respond to user actions and data must to be transfered to/from DB.

At any moment, after the loop that collect data and plot chart is started, user can press a button to get data that is being plotted in the chart and put it into a variable.

In a next step, in another state, user can make choices in a combo-box generated with data got from the DB, and then, press another button to write data from the variable into a DB.

That's why I need a state machine.

I'm thinking to use P-C to start the loop to plot the chart.

Finally, the whole application ends when user press a stop button.

Thank you all very much for the help.

Regards, Roberto

0 Kudos
Message 10 of 10
(3,441 Views)