LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I pass data out of an Event Callback vi for use within the main VI structure

I am currently converting from a VI based on a poling architecture to run as event driven. The VI controls a proprietary external hardware module via a CAN Bus Communication COM Object providing an OLE Automation compatible interface. So far I have created a Event Callback VI using the Register Event featue but am unable to pass any data resulting from the processing of the callback for use elsewhere in the VI hierarchy since the Event Callback interface is stricly defined.
 
So my question is >
How can I pass the results of the processing performed within the Event Callback VII to the rest of the program.
 
I anticipate that I am missing something obvious due tomy lack of experience with using Event Driven VI's.
 
Thanking you in andvance for your assistance
 
Best regards
 
Ian Melville 
0 Kudos
Message 1 of 10
(3,435 Views)
I understand you are just creating a sub-vi with the event structure in it?
 
Can you not use the connectors on the SubVI (right click on top right hand corner of the Front Panel and select "show connector", then assign the wiring to the controls/indicators)?
 
Vikas
0 Kudos
Message 2 of 10
(3,433 Views)
Hi Vikas
 
Thanks for the reply.
 
I'm creating a Event Callback VI by right clicking the VI Ref on the Register Event Callback Object and selecting the " Create Callback VI" Option. This creates a VI with a strict interface which does not seem to allow any changes or provide any method for passing data out of the created VI. Or am I missing something?
 
Ian
 
  
0 Kudos
Message 3 of 10
(3,428 Views)
In the main, create a user event, and put the reference in a buffer VI. In
the Event Callback VI, use the reference from the buffer to trigger the user
event. In the main, register for the user event, and react to it.

Instead of a buffer with a user event reference, a normal buffer might be
sufficient. E.g. Put or add the data in the buffer in the Event Callback vi,
and read it when you need it in the main vi.

Regards,

Wiebe.


0 Kudos
Message 4 of 10
(3,406 Views)
I had a similar issue, I ended up using named queues to throw the data around.  The Event Callback VI (I had three in my case) enqueues the data, and I  had a separate handler VI deal with it.  You just have to be careful where you close the queue.
0 Kudos
Message 5 of 10
(3,398 Views)

Hi Britoa

Thanks for the information. This may be what I'm looking for. Will look into this again monday.  

 

0 Kudos
Message 6 of 10
(3,393 Views)

Thanks  Wiebe.

I'll lookm into this option on monday.

 

 

 

0 Kudos
Message 7 of 10
(3,392 Views)
User events have a lot in common with queues. I usually prefer UE because
the can be integrated in my UI loop, that is build around an event
structure. You have to make a seperate loop that polls the queue for new
messages. I know others prefer to use queues.

Regards,

Wiebe.


0 Kudos
Message 8 of 10
(3,383 Views)

 I'm sorry for recovering this old post, but I thought it would be better than starting a new one. I have a similar situation: I need some data to be sent from the Callback VI to the Main VI.

 I guess both the queue or the event buffer ideas would solve my . The problem is that I tried but couldn't succeed in implementing these solutions. I could not figure, for an example, how I was suposed to wire the blocks in order to trhow the data out of the callback using a queue. Actualy, I'm using LabView 7.1.

 Could anyone guide me through the implementaion of one of these?

 

Thanks so much!

 

Leo

0 Kudos
Message 9 of 10
(3,041 Views)

Just to report, I finally realized that I just need to define 2 queues, one in the Callback and one in the main VI and connect the same names to both "Obtain Queue" blocks!

 

 That's it!

 

Leo

Message 10 of 10
(3,007 Views)