02-28-2012 04:03 PM
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.
02-28-2012 04:22 PM
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.
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
02-28-2012 04:33 PM
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.
02-29-2012 01:44 AM
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.
02-29-2012 07:33 AM - edited 02-29-2012 07:34 AM
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
03-01-2012 05:39 AM
Always nice to see a question answered by just writing your question down 🙂
03-06-2012 02:12 AM
Thanks to everyone for the useful hints. It's running very smoothly now 🙂