LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequential vi execution on user event

Hi,

 

What I'm trying to establish should be clear from the attachment. Every time a user has pressed a button, the corresponding VI should execute. But there's only one correct sequence.

 

It should be noticed that the VI as in attachment doesn't run properly. The first button lets 'devices' run ok, then the front panel seems to get stuck and pressing the next button 'setup' is not possible.

 

I started with case structures instead of events but then I got stuck with the false case in the first part as wrong data is passed to the next VI.

 

I guess there is a common solution for problems as these but I can't seem to find the right approach so far. If someone could supply me with the correct way of handling this or what I should be looking for in the forum to solve this, that would be great.

0 Kudos
Message 1 of 7
(2,573 Views)

No, no no no no!

 

never use more than 1 event structure per thread.  (LabVIEW will let you put as many chained sequential event structures as you want---but you won't like the results!)

 

You've managed to cross a state machine with a flat sequence structure and gotten pretty much bit.  Since its today and I'm feeling rather generous this snippet contains my template for a QDSM(Events)  For your application you can probably replace the command cluster with a straight typedef'd enum to drive your state machine.

 

PC-template.png

 

With this type on design pattern the user interface is all handled by the event loop and stays nicly ready to deal with the user and pass his instructions down to the worker bees in the state machine


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 7
(2,566 Views)

Jeff is right.  You should really only have 1 event structure per thread.  From what it is you are trying to accomplish, I think that an event based producer/consumer design pattern may get messy without some careful consideratione.

 

My question may be silly but, since you state that there is "only one correct sequence" why do you even have the user pressing the buttons at all?  I'm not sure I understand the purpose of the user clicking on the next button in the sequence when it is the case that they can only move on to the next sequence of your code.  I'd take out the buttons, remove all your event structures and just have a gigantic "GO!" button at top..... maybe I'm missing something.

0 Kudos
Message 3 of 7
(2,564 Views)

allright, that's pretty clear. Totally not the way to go it seems :). thanks for the good advices, just the kind I needed. I'll look deeper into it.

 

I should have clarified a bit more perhaps. It's a really trivial setup: select your devices connected, initialize them and pass the appropriate setup parameters. Then setup sweep settings and afterwards start the sweep.

 

So you can't put in parameters or start a sweep before the correct devices are initialized. But also, it should be possible to restart a (maybe different) sweep without going through all the previous steps. On top, you should be able to reselect different devices and restart the whole thing.

 

That's why there's a sequence, but parts of it should be accessible separately.

0 Kudos
Message 4 of 7
(2,545 Views)

Filip wrote:.
It's a really trivial setup: select your devices connected, initialize them and pass the appropriate setup parameters. Then setup sweep settings and afterwards start the sweep.

 



Well,  You just described the states of your state machine. 

Select

Initialize

Configure

sweep

record results

Clean-up

exit


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(2,525 Views)

Always nice to see a question answered by just writing your question down 🙂

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 6 of 7
(2,510 Views)

Thanks to everyone for the useful hints. It's running very smoothly now 🙂

0 Kudos
Message 7 of 7
(2,488 Views)