02-08-2012 03:16 PM
I am having some trouble determining how to design multiple programs that can exchange data or events between each other when compiled into separate executables. I will layout the design scenario:
I have two VIs, one called Status and the other Graph. The Status VI displays the serial number and status of each DUT being tested (>50 devices). The Status VI has one timed loop along with a while loop that contains an event structure. If the user clicks on the DUT Status Cluster the event structure needs to pass the serial number to the Graph VI. The Graph VI when called fetches the records for the DUT based on the Serial Number and time frame. This VI is a producer/consumer so the user can change the time frame of the records to display onto the front panel graph.
I have a couple reasons the VIs need to be separated into independent applications. One being the underlying database fetches tends to slow the threads down between the two VIs; the other is that they may be distributed into separate systems (don't consider this in the design criteria).
I have been researching the available methods to pass the serial number to the Graph VI. My initial idea was to us a command line argument, but this does not allow the Status VI to pass another Serial Number to the Graph once it has started (I do not want to allow the user to execute multiple Graph applications because the database query can load down the server).
Is there a program method that I can implement between the two VIs that will allow me to compile them as two executables, and allow the Status program the repeatedly send an updated serial number event to the Graphs program.
I have reviewed many methods; Pipes (oglib_pipe), Action Engine, and Shared Variable. I am not sure which method will give me the ability to use a Event driven structure to inform the Graphs program when to update the serial number. Any suggestions and tutorials or examples would be greatly appreciated.
02-08-2012 03:33 PM
You can do this with an Action Engine and VI Server. In the executable that needs to receive the events, you create a user event, and an action engine that stores that event reference. Make that VI accessible through VI Server. The application that sends the events obtains a reference to the action engine through VI Server and calls it, passing the appropriate data.
02-08-2012 04:02 PM
I have used the Action Engine (aka: functional global) approach for many years and it works well. Something to think about is that if you make the event's datatype a variant the only code that will need to know the actual structure of the event will be the function that needs to respond to it. Hence, a single event can service multiple functions.
Simply create a cluster containing an enum typedef that is a list of the functions that the event will service, and a variant that will be the function event data. From anywhere in the code you can fire the event (via the functional global) by selecting the function from the enum and converting function specific data to a variant. On the receiving end the event handler uses the enum to determine the function that is to get the data and sends the variant to it. The event handler doesn't know or care what the actual event data is so you could in theory add new functions without modifying the event handler.
Mike...
04-27-2012 07:36 PM
mike,
I'm not sure I follow you.
How does the event handler send the data to the appropriate function if all functions are using a single event?
04-27-2012 10:51 PM
GollumGTH wrote:
How does the event handler send the data to the appropriate function if all functions are using a single event?
The event data is a cluster. One of its elements is an enumeration that indicates what event occurred, or what function to execute.