LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Managing USER EVENTS in large projects

Hello Sebastian,

 

as far as I can see you have an architectorial problem. There are a lot of events generated in different parts of the program (the created user-events wires go to various subVIs, which seem to "live" with their own loops) and there are a lot of event registrations going to several event cases. I think, your first task should be to condense these Many-to-Many to a simpler Producer-Consumer-pattern. That means, loops with an event structure (consumer) should be able to receive more than only one type of event.

Since the controls defining the name of an event are unlabled it is hard to guess what purpose these events have, but I suppose a lot of events can be handled by the same loop. For instance a "disconnect event" and the "TCPWrite Cluster event" can surely be handled by the same consumer, since this sounds both like handling the TCP interface (There is another problem with the "TCP Stop"- global in the "TCP write"- loop, this is only handled when there is an event raised twice after the global bool went to TRUE).

I like to use user events with a cluster of a typedefed Enum and a variant. This gives me the chance to send any kind of data, but allocated and described by the enum. So one consumer can receive events and data from various senders with different kinds of signals.

 

The other problem is the lack of clarity. Wires are going around and it is hard to tell who talks to whom. As a first approach you could put all "Create User Event" nodes into a SubVI, bundle all references into a cluster (don't forget to typedef) and feed this cluster to all the SubVIs, registering the appropriate events iside them.

But this won't help you understand the program, so it is better to analyze first what producer- and consumer- loops can be reduced to one loop.

And you have to understand, that it is better to see, where a wire is leading to and which part of the program is is using the wire than using "obtain something with a global name", since this is harder to understand, which part of the program is having access to your ressource.

 

Greets, Dave
0 Kudos
Message 11 of 12
(133 Views)

Some suggestions to help manage and understand things:

 

When creating/initializing the user event, give the datatype a unique and descriptive name. That way you can use ctrl + f to search for text and find all the locations where the user event is registered to an event structure.  ctrl + g to quickly cycle through the search results.

 

If a user event is registered to multiple Event Structures across a project, I like to drop static VI references connected to the locations where they are used. That way you can quickly hop from where events are initialized to where they are registered. You could also use View >> Bookmark Manager in a similar fashion.

 

In case you were not aware, you can right click on an Event Structure >> Event Inspection Window. This will show an events list specific to that Event Structure as they are received. Useful for debugging and gaining insight into an application's operation.

 

For something more advanced, you could make a kind of application-wide event status monitor using the following:

https://forums.ni.com/t5/You-May-Not-Know/Programmatically-Inspect-Event-Queues/ba-p/3549367

 

0 Kudos
Message 12 of 12
(125 Views)