09-08-2009 02:53 AM
Hello all,
I have an event structure.
I need to make sure that, while an event case block is executing, another can't start being executed until the first one finishes. (So, if events A and B happen almost simultaneously, event case B starts executing only after event case A has completely finished executing).
Since events are not generated only by front panel, the "block front panel activity" option is not enough.
Is there a way to do so?
Many thanks.
09-08-2009 02:57 AM
Use producer/consumer and capture both events by the same event structure. Both events only enqueue a stateinformation which is used in the consumer to execute the "events code".
hope this helps,
Norbert
09-08-2009 03:04 AM
Thanks for replying.
Unfortunately, I believe it's not enough. Inside every case, I need to perform a write&read operation to an external device (via a NI-6251 Daq). If I had only to write, that would have been fine, but the "enqueue" operation allows me only to put data on the write buffer (the consumer loop cannot send back read data to the producer loop).
09-08-2009 03:11 AM
When the write and read are both inside the same event case, other events will queue up until that case has completed.
Felix
09-08-2009 03:15 AM
09-08-2009 03:30 AM
xdaf wrote:
[...]The consumer loop cannot give back results to the producer loop, like as if it was a called sub-vi.
That is only true for the default producer/consumer. BUT you can use custom user events to pass back information or commands to the producer! This is i bit more complex than the default producer/consumer and it heavily depends on the application...so there is (at least as far as i know) no example directly available. Nevertheless, if you are used to work with custom user events, you will be able to implement this very fast and easily.
Another possible solution would be a consumer build as queued state machine. So the consumer can reconfigure/enqueue elements in its very own command queue.
hope this helps,
Norbert
09-08-2009 03:41 AM
09-08-2009 03:42 AM
hi,
Why are you not using STATE MACHINE ARCHITECTURE?..I think it will solve your problem.
09-08-2009 03:49 AM
You also might have a look at the OpenG Message Queue. It uses a notifier to report back.
To install OpenG, you need to download the VI package manager (the community edition is for free).
Felix
09-08-2009 03:56 AM - edited 09-08-2009 03:57 AM
Because I need to collect asynchronous events, each of whom recalls the same sub-vi (with different input data).
I think the producer-consumer structure is mandatory.
I'm working on the custom user event, I think that's the right strategy.
I'll keep you updated, in the meanwhile, thanks a lot!