LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling windows messages within an event structure

Hello all.

I've got an event driven VI which makes use of an event structure. I'd like my VI to be able to respond to some custom windows messages (i.e. WM_USER) sent from a separate process that listens on a telemetry card (sends a message when it receives data).
I have tried modifying the Windows Messaging Queue VI example provided by NI so that the VI will process windows messages during the timeout event in the event structure but this doesn't seem to work.

Any suggestions?

If labview events and windows messages don't mix then I guess I could do away with the event structure and go entirely with windows messages. This could be done by defining some custom messages that replace the labview events (e.g., W
M_STOPBUTTON_PRESSED = stop button, value changed event) and have the VI post these messages using PostMessage from User32.DLL and then catch these messages in the same manner as the NI Windows Messaging Queue VI.

My preference is to make use of the event structure if I can because its more inline with the labview methodology.

This is really interprocess communication question so if there are other ways of achieving the same result (sockets, named pipes, shared memory?) I'm keen to listen.

cheers,
Novak.
0 Kudos
Message 1 of 5
(3,791 Views)
LabVIEW Events and Windows messages don't mix. To implement as such, you would have to do as you describe.

Using sockets as an inter process communication scheme works great. And on a single machine, they dont leave the computer (i.e. no round trip on the network). Also, its cross platform compatable, not to mention it adds the possibility of being able to seperate your processes across several machines. Add to this that sockets are as easy to code as serial communication (with the benefit of "sleeping" waits instead of "serial polling") and you get a solution fits many applications and needs.

Get the idea I am sold on sockets?

Good luck.
0 Kudos
Message 2 of 5
(3,791 Views)
These 'sockets' sound interesting. What exactly are they? Could you direct
me to an example?

Thanks

Denis


"VI Guy" wrote in message
news:5065000000050000000BAF0000-1031838699000@exchange.ni.com...
> LabVIEW Events and Windows messages don't mix. To implement as such,
> you would have to do as you describe.
>
> Using sockets as an inter process communication scheme works great.
> And on a single machine, they dont leave the computer (i.e. no round
> trip on the network). Also, its cross platform compatable, not to
> mention it adds the possibility of being able to seperate your
> processes across several machines. Add to this that sockets are as
> easy to code as serial communication (with the benefit of "sleeping"
> waits instead
of "serial polling") and you get a solution fits many
> applications and needs.
>
> Get the idea I am sold on sockets?
>
> Good luck.
0 Kudos
Message 3 of 5
(3,791 Views)
Basically they are TCP/IP network communication functions, found in the LabVIEW functions palette -> Communications -> TCP or Communications -> UDP. Use the network communication examples supplied with LabVIEW to get you started.

Good luck.
0 Kudos
Message 4 of 5
(3,791 Views)
> do away with the event structure and go entirely with windows messages.
> This could be done by defining some custom messages that replace the labview events (e.g., WM_STOPBUTTON_PRESSED = stop button, value changed event)
> and have the VI post these messages using PostMessage from User32.DLL and then catch these messages in the same manner as the NI Windows Messaging Queue VI.
For some LabVIEW support of standard and custom windows messages (e.g. WM_USER) in a while loop, see Windows Message Queue Library http://zone.ni.com/devzone/cda/epd/p/id/4394
0 Kudos
Message 5 of 5
(3,287 Views)