02-05-2014 09:30 AM
Hi,
I've got an event structure with events reading all my inputs, and one dynanmic event running every 10 ms. The dynamic event is a pretty heavy piece of code.
It works swell, except that sometimes the events generated by inputs from the front panel are ignored. Is there a way around this? A screen shot of my code is attached.
Thank you!
Christopher
02-05-2014 09:49 AM - edited 02-05-2014 09:50 AM
You could try moving all of the processing in your dynamic event case (not sure what your subVI is doing) to Loop2.
02-05-2014 09:52 AM
I'd rather not, loop 2 is only running every 250ms. And all the data from the engine is coming from the inputs in the other events.
I thought of putting this event in its own while loop, but then I would need a notifier to send it the data and a notifier to send it back after it had been modified in the subvi.
Any other ideas? Thank you!
Christopher
02-05-2014 09:59 AM
The event structure dynamic case is busy processing your subVI hence it is missing your front panel activity. You have to move your processing to a woker loop such as Loop 2
Also, you are generating a notification in your dynamic event case (every 10ms, from your previous post) so by waiting for 250ms in Loop2, you are overwriting 25notifications? Is this by design?
02-05-2014 10:01 AM
What is your definition of a "heavy piece of code"? Could it be that it takes longer than 10ms to execute causing an large accumulation of events in the queue?
02-05-2014 10:01 AM
Yes, in the subvi I'm writing data to a DAQ (critical), in loop 2 I'm writing other info to the front panel (not critical).
There is no way to make the event structure store up events and execute them when it is not busy?
Thanks!
Christopher
02-05-2014 10:03 AM
No, it takes less than 10ms (I guess that was a misleading comment, sorry), but when it is running I can't register any other events.
Is there a way to que them, or do I need to just live with missing them occasionally?
Thanks!
Christopher
02-05-2014 10:04 AM
Use queues (not lossy) instead of notifiers (lossy) and dequeue it in a separate loop, this is a much better solution and there are plenty of examples around. Search for producer / consumer (Events) examples.
02-05-2014 10:07 AM
Thats an idea.. but the notifier will only come when a value changes on the front panel. Then my code will sit idle until a front panel value has changed and sends the next notifier.. or is there a way to run without a notification?
02-05-2014 10:17 AM - edited 02-05-2014 10:23 AM
This suggestion is based on partial information and a picture so apologies if this is not relavent.
I would change your structure with queues, it looks like you generate a notification every 10ms. You could replace all of this with a single consumer loop which essentially is a dequeue loop with a 10ms timeout and do all of the dynamic event processing when the dequeue times out. You can also enqueue any front panel activity to the same queue in the event structure. Look for producer consumer examples, it is very elegent