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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Register Events and Queues

Solved!
Go to solution

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

RegisterEventsQuit.pngRegisterEventsQueue.png

0 Kudos
Message 1 of 8
(3,158 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(3,152 Views)

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

0 Kudos
Message 3 of 8
(3,138 Views)

Open a new project from the Producer/consumer (data)-pattern and you'll see what i mean. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 8
(3,136 Views)

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.

0 Kudos
Message 5 of 8
(3,128 Views)

hello Ravensfan,

 

Your explanation is correct!

Just a simple example below that shows the problem.

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. 😉
Message 6 of 8
(3,093 Views)
Solution
Accepted by topic author ThijsBoeree

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

 

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
Download All
Message 7 of 8
(3,057 Views)

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:

 

PassingMessages.png

 

I derived it from the project maker from labview.

Regards,

Thijs

0 Kudos
Message 8 of 8
(3,019 Views)