From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-04-2013 04:23 AM - edited 03-04-2013 04:27 AM
Hi,
I am building a User/ Display/ Acquisition program and having dufficulties with the whole register for event stuff. I've attached a simple dummy to show what is going on:
I want to control 2 while loops with external events from one user while loop. But when i press quit, most of the time it will close all 3 loops but sometimes it leaves one running? Also i need to control the playing and stopping, but sometimes it only fires one event to one of the loops.
I think it has to do with the queues, that they are waiting for something. The whole thing is derived from a user consumer structure (this is an abstract (dummy file)).
Best regards,
Thijs
Solved! Go to Solution.
03-04-2013 04:30 AM - edited 03-04-2013 04:31 AM
All event structure need to register for the events, else they wont work correctly.
You shoule unregister events after the structure.
Queues can be handled by destroying the queue after the exiting loop, thus the consumer should stop.
In your case all 3 user events can be made into one by sending a TypeDef'd Enum instead. 🙂
/Y
03-04-2013 05:56 AM
Okay,
I like the typedef enum, so i am going to make that, but the loops don't have to stop allways, when i press play or stop, they have to do other tasks than quiting the loop... thus i can't do it with the error on my queue...
Best regards,
Thijs
03-04-2013 05:59 AM
Open a new project from the Producer/consumer (data)-pattern and you'll see what i mean. 🙂
/Y
03-04-2013 08:10 AM
I think you may need to have each event structure register for an event separately. I think when you split the event registration wire like you did, the two event structures share the same dynamic event queue, so when one queue starts handling the event, the other doesn't receive it. I rtemember reading another message thread about this, but I can't find it at the moment.
03-05-2013 08:21 AM
hello Ravensfan,
Your explanation is correct!
Just a simple example below that shows the problem.
03-05-2013 04:57 PM
Hi Thijs,
Attached are two examples. "mod 1" uses 3 event loops like your version.
"mod 2" simplifies the file saving loop (would work for you if all this loop does is save data).
There is an important caveat with User Events and Timeout:
"Any User Event connected to the Register for Events function will reset the Timeout timer when fired.
(Even if there was no event set up to use the User Event.)"
For example:
If there was a User Event occuring every 100ms and you had set up a 500ms timeout - your timeout would never occur.
This is not an problem with this example, but it is good to know about this issue as your program grows.
One way to limit the impact is to only register events that will be used for a particular loop.
Another way is to use a separate timed loop to generate a User Event timeout.
steve
03-07-2013 08:49 AM
Sorry for my late reaction,
I solved it in a whole other way, now i use one event structure, and pass al my commands with message queues. It's more like a luxury state machine now:
I derived it from the project maker from labview.
Regards,
Thijs