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: 

receiving multiple messages from multiple loops in event structure

Solved!
Go to solution

Hey guys,

 

I have two questions really, first, whats the best way to receive messages in the event structure? I've been looking at user events, and that seems like a good option if I only ever want to send a single message. Ive never found an example where the regester for events has a second event its looking for. I currently use queues from the event structure to my other loops.

 

My second question is do I even want to send messages to the event structure, my current thinking is that it would make things easier to follow if the event structure dispatched all the messages to individual loops. Is is more appropriate to just have one loop talk directly to another through the queues already in place?

 

Im thinking ill set up an user event for handlng errors but im not sure about the other messages.

 

Thanks guys

0 Kudos
Message 1 of 13
(4,200 Views)

You should take a look into Queued Message Handler design (Create Project Wizard).

 

You do know that you can expand the Register Event node just like any property node?

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 13
(4,196 Views)

@pathare535 wrote:
whats the best way to receive messages in the event structure? I've been looking at user events, and that seems like a good option if I only ever want to send a single message. Ive never found an example where the regester for events has a second event its looking for. I currently use queues from the event structure to my other loops.

Definately User Events.  You can drag the Register For Events to have more inputs (like a property node).  Or your can bundle a bunch of registered events together and wire that up to the dynamic event terminal.

 

 


@pathare535 wrote:

My second question is do I even want to send messages to the event structure, my current thinking is that it would make things easier to follow if the event structure dispatched all the messages to individual loops. Is is more appropriate to just have one loop talk directly to another through the queues already in place?


There is nothing wrong with other loops sending messages to the GUI loop.  I do this all the time.  Sometimes purely for display purposes.  Sometimes to let it know that something encountered a critical error and therefore everything must shut down.  There are lots of reasons you would want to get these messages from the other loops.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 13
(4,192 Views)

Yeah, from what I've read I really need to work on adopting that, I looked at it for a minute and had a hard time figuring out how to use it. I probably just need to spend more time with it though.

 

Thanks

0 Kudos
Message 4 of 13
(4,191 Views)

@crossrulz wrote:

@pathare535 wrote:
whats the best way to receive messages in the event structure? I've been looking at user events, and that seems like a good option if I only ever want to send a single message. Ive never found an example where the regester for events has a second event its looking for. I currently use queues from the event structure to my other loops.

Definately User Events.  You can drag the Register For Events to have more inputs (like a property node).  Or your can bundle a bunch of registered events together and wire that up to the dynamic event terminal.


When I do that can I have a new event for each User event or do they all come into the same user event window? Also can the use the same user event reference wire?
0 Kudos
Message 5 of 13
(4,182 Views)
First, event structures can service as many different events as you want. Second, in terms of how and where the events are serviced, that is highly dependent upon the overall structure of the application. In fact, both of these questions lack hard and fast answers because (to paraphrase a famous quote), "...many things are possible, but not all things are helpful..."

For example, while a single event structure can in theory service dozens of different events, in practice ones I create tend to service at most 4 or 5 because of the way I factor applications into functional blocks that run in parallel.

Those same design decisions also obviously impact where the actual processing of a message occurs. Sometimes I do processing in the event loop, but I have also created architectures where processing bandwidth could automatically scale by dynamically launching and stopping data processing loops.

If you want to see examples of how these design decisions effect structure and architecture, check out my blog. The link is in my signature.

It is very good that you are asking these kinds of questions -- keep asking them.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 6 of 13
(4,174 Views)
Solution
Accepted by topic author pathare535

You can get event for individual events. Even better, you can use clusters to group different events together and access them individually (see below).

 

Example_VI_BD.png

Marc Dubois
Message 7 of 13
(4,172 Views)

Oh wow! I read your blog all the time actually, thanks! It almost always comes up when I'm googling questions.

0 Kudos
Message 8 of 13
(4,165 Views)
Marc,

I don't know if you noticed, but there is a subtle naming convention at play in the code you posted. To see what I mean, relabel the "output cluster" constant as "Input 1". Now create and wire a cluster constant for the other group of three events, and label it "Input 2".

Finally create event handlers for all 6 events and note how they are labeled in the event structure.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 9 of 13
(4,141 Views)

Thanks for pointing out the naming convention! Now I can maintian my usual naming convention with my user events.

0 Kudos
Message 10 of 13
(4,111 Views)