LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel event structures triggering on the same events

Solved!
Go to solution

Based on information gleaned from this thread [using forked registrations], I think that what I'm trying to do is impossible and intentionally so. But it would be so nice. Here goes:

 

Given one event and two dynamic registrations for that event, is it possible to capture the event simultaneously in two parallel event structures?

 

I understand why this is typically undesirable behavior but it would save me considerable heartache [polling!] if it's possible. Here's what I'm doing [er, trying to do]:

 

I have a set of network-published SVs that are written to by a data acquisition VI. A Web Method VI dynamically registers for the SV events, handles events [sends the new SV values to the HTTP socket], then unregisters before finishing execution. When I execute the web method VI through a URL query, the client sits and waits for a response until the SV is written to, then properly receives the data from the web method VI. So far, so good. However, there are two cases where things go very wrong:

 

1. Multiple clients call the web method

2. A single client calls the web method at a rate faster than the event rate

 

In both cases, multiple instances of the web method are active and waiting for events simultaneously. When a new SV event is generated, only one of these web methods will pick it up. In the first case that means that only a single client will receive the new data. In the second case, no SV events will be detected indefinitely--more and more web method instances pile up. Even if I use a timeout case to kill old instances of the web method, the OLDEST one picks up new events and the client will only recognize a response from the newest instance.

 

I'm anticipating using client polling, though it won't be as pretty as using the event structures. Am I wrong?

 

 

0 Kudos
Message 1 of 32
(4,498 Views)

You can have lots of listeners to an event. For example a quite or abort event it's rather natural. 🙂

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 32
(4,485 Views)

Hmm. I must not be doing it right. Here's my test code:

 

SVEtest.png

If I run 2 of these in parallel and fire off value changes manually, one instance captures the first event then closes and the second waits until the second event, then executes and closes. How would I make them both trigger on the first event?

 

Message 3 of 32
(4,476 Views)

Alright. Clearly multiple subscribers is possible [I misread the linked posts] and I've implemented it with the test code above. I had to use a single Request Value Change Notifications VI and fork the notification refnum in the higher-level VI. Now I have parallel event structures triggering simultaneously on the same SV event. All I'd need to do is pass the notification refnum to each new instance of the web method VI.

0 Kudos
Message 4 of 32
(4,462 Views)

Despite the fact that I was wrong--I can have multiple subscribers to a single event notification--there is still a big challenge for me in using this in the web service. The challenge is this:

 

In my test example, I passed the notification refnum to each parallel loop through wires. However, when each web method instance initializes, it needs to get the refnum. However, when I tried to send the refnum as a variant or flattened string over a shared variable, the SV crashed every time. So how does the web method access the refnum of the event notifications?

0 Kudos
Message 5 of 32
(4,447 Views)

Hey pltrogon,

 

I'm not exactly sure I understand what you are trying to do.  Are you saying that the picture above is the Web Method VI, and it's being called by a Data Acquisition VI?  Is there a way you could either post your code or repost the pictures of the updated versions of them so we can see what is going on? 

 

Regards,

Jake

Regards,
Jake G.
National Instruments
Applications Engineer
0 Kudos
Message 6 of 32
(4,411 Views)

Here's the code I used to prove that I could do this:

 

Top-level VI:

 

SVtop.png

 

SubVI:

SVsub.png

So as long as I use a single notification refnum and generate a new event registration for each parallel even structure, each event fires all structures simultaneously. So this works fine.

 

My question is how to do this when I can't directly wire the notification refnum to each event loop, such as is the case with web method vi's [which are similar to these subVI's]. When I convert the refnum into a variant and try to send it through a shared variable, the SV crashes--probably for very good reason, but I can't put my finger on the reason.

 

Hopefully that's enough information, thanks for the help.

0 Kudos
Message 7 of 32
(4,406 Views)

If I'm understanding correctly, you're trying to pass a user event refnum through a shared variable to a web service VI.  This won't work.  Web services run in a separate application instance, and user event refnums can't be shared between instances.  Consider either putting data directly into a shared variable from the web service VI and handling that new data in your main VI, or using VI server for communication.

0 Kudos
Message 8 of 32
(4,403 Views)

OK, this makes sense: "Web services run in a separate application instance, and user event refnums can't be shared between instances." That's the conclusion I had come to but I wasn't sure.

 

This, however, I don't think helps: "Consider either putting data directly into a shared variable from the web service VI and handling that new data in your main VI." I need the web method VI to trigger on events from the main VI. Data is already shared both ways vi SVs but it's the event handling that is tricky.

 

So, essentially, there is no way to use SV events in web methods if multiple instances of the web methods will be invoked?

 

 

0 Kudos
Message 9 of 32
(4,401 Views)

All the deployed web methods are in the same application instance, right? If I create a notification refnum in the Aux VI upon deployment, I'd like to use that refnum in each web method VI subsequently called. But I can't send a refnum over a SV, even within the same application instance, so is there any way to do this?

0 Kudos
Message 10 of 32
(4,398 Views)