LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure mischief.... suggestions?

Solved!
Go to solution

 Hello, 

 

I have been writing my first more "involved" application which will be taking data and controlling some arbitrary number of instruments; my code uses asynchronously called queued message handler-type  VIs and VI Templates to allow for easy reconfiguration before and during runtime. These are dynamically loaded into the front panel of the main VI upon selection, and all control of these VIs happens from that subpanel. 

 

I use event structures and user events to handle front panel events and other data passing within each of these VI, and I am extremely confused about some of the behavior that my event loops are exhibiting. 

 

For example, in some instances a user event generated to stop an event loop will fail to trigger any reaction from said event structure, which would continue to time out. This behavior occurred irregularly, and sometimes my loop terminated fine, which led me to believe that there was a race conditions somewhere in my code. This problem was fixed in each of the culprit VIs by placing the event registration for the user event inside the same initialization subVI which created the event refnum. However, I still have no idea why this fixed the problem, or why it was occuring in the first place. 

 

Currently I am seeing a similar issue where instead of a user event, the event structure fails to respond to value change events in a control.

 

I would attach some code, however I have been unable to reproduce the behavior in any of the test VIs I wrote to probe this behavior, and I don't see how posting any of my asynchronous VIs would be useful unless I posted the entire application. 

 

Please give me suggestions if anything comes to mind!

 

Thanks!

0 Kudos
Message 1 of 23
(4,453 Views)

Try to stay away from multiple event structures in a single VI.  If you feel you need them, there is probably something is wrong with your architecture.  It' is very difficult to use multiple event structures in one VI without problems.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 23
(4,421 Views)

What's causing the value change?  is it your interaction with the front panel or is the VI updating the control elsewhere?  If it's the latter, take a look at the value signaling property node.  That will handle programmatic change of the value.

 

Check this out as well: http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/caveatsrecmndtnsevnts/

0 Kudos
Message 3 of 23
(4,413 Views)
I have multiple event loops but they are all used in different asynchronously called queued message handlers and do not interact as far as I was aware. I thought this was relatively standard but maybe I was wrong.

The value change events in question are a result of front panel interaction and not the VI updating the control. Thank you for the link. The one about event handling with subpanels caught my attention but I will have to look into it more tomorrow.
0 Kudos
Message 4 of 23
(4,391 Views)
Re billko: Could you mayne tell me more about what you mean by having multiple event structures in the same vi, and why this could cause complications? Thanks.
0 Kudos
Message 5 of 23
(4,388 Views)

I would actually direct you to do a search on "multiple event structures".  it gives many topics on why you shouldn't normally have multiple event structures in a VI - BUT there are topics that show you exactly how to do it successfully, too!  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 23
(4,373 Views)

@smallmediumlarge wrote:
Re billko: Could you mayne tell me more about what you mean by having multiple event structures in the same vi, and why this could cause complications? Thanks.

You can have as many event structures as you want, simply make sure they are all reachable at all times via dataflow and reside in their  own loop. (Don't hide event structures inside sequence structures, case structures, or even other event structures, of course.)

Message 7 of 23
(4,361 Views)
Hi altenbach, thanks, I have all of my event structures in their own while loop without any of those caveats.
0 Kudos
Message 8 of 23
(4,354 Views)

@altenbach wrote:

@smallmediumlarge wrote:
Re billko: Could you mayne tell me more about what you mean by having multiple event structures in the same vi, and why this could cause complications? Thanks.

You can have as many event structures as you want, simply make sure they are all reachable at all times via dataflow and reside in their  own loop. (Don't hide event structures inside sequence structures, case structures, or even other event structures, of course.)


That was a nice summary.  I've never heard it said so short and to the point.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 23
(4,332 Views)

@smallmediumlarge wrote:
Re billko: Could you mayne tell me more about what you mean by having multiple event structures in the same vi, and why this could cause complications? Thanks.

Event structures queue events.  This happens to grab events that take place while you're not currently sitting and waiting for an event.  With this, you're able to catch multiple events being triggered at once and andle them in order.

 

This also means having multiple event structures looking for the same event can cause strange behavior.  It also means if your code can't get back to the event structure, you're still queuing up those events.  You want to ensure you handle those.

0 Kudos
Message 10 of 23
(4,308 Views)