LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Re-entrant VIs and network streams

Solved!
Go to solution

Can the network stream writer exist within a re-entrant VI and write arrays or strings to the same endpoint from multiple threads?

 

I have a series of VIs which produce data (Flattened to strings) which I would like to send to my host PC via a single network stream.  Basically, the data is just a Channel Number combined with a waveform (Of varying data types).  These are produced from multiple VIs which run asynchronously from each other.

 

What I'd like to see at the reader is a continuous stream of strings, each representing a flattened cluster in the same order they were written.

 

Thanks,

 

XL600

0 Kudos
Message 1 of 8
(3,745 Views)
0 Kudos
Message 2 of 8
(3,733 Views)

I've read through that white paper and wasn't able to gleen from it whether or not the network stream writer was thread safe such that two VIs can write to the same endpoint without conflicting.

0 Kudos
Message 3 of 8
(3,727 Views)

I can't imagine this will work. You need matching endpoints. This is a one way communication path as described in the file in the link above. When you lose one endpoint you have to close the other and recreate to get communications.

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 Kudos
Message 4 of 8
(3,716 Views)

I was thinking I would only create the endpoint in one VI, but have writers in multiple VIs using the same endpoint name.

 

It's sounding like this isn't a recommended approach so I can add a string queue to hold the elements from the multiple sources, then use a single loop to write to the stream (By flushing the queue into the stream periodically).

0 Kudos
Message 5 of 8
(3,710 Views)
Solution
Accepted by topic author xl600

My main RT Project uses 4 Network Streams -- two form a bidirectional Message (as in Queued Message Handler) stream, one sends sampled data (from a single point) to the Host, and the other sends "Event" data, which includes digital I/O level changes, Action Engine transitions, sending and receiving Messages on the Message Streams, etc.  There is a single Event "Sender", fed by a Queue that everyone who needs to send an Event dumps the Event into -- the Event Streamer is basically the Consumer of this Producer/Consumer pattern, sending each Event to the Host as it is dequeued from whatever routine in the RT Target generated it.  This sounds a lot like that you have decided to try -- I can recommend it, as it works well for me.

 

Bob Schor

0 Kudos
Message 6 of 8
(3,691 Views)

Thanks.  That helps to validate the approach.

0 Kudos
Message 7 of 8
(3,684 Views)

"Network streams were designed for lossless, point-to-point communication.  While this works well for data streaming and command based applications, it makes establishing arbitrary N:1 or many to many communication paths very difficult.  This is a requirement that is common for many client/server applications." This was in the section I linked.

 

Using a queue as Bob suggested can help you get around this.  But, Network Streams aren't mean to have N:1 or 1:N configurations.  You'd have to handle that logic in addition to the Network Streams

0 Kudos
Message 8 of 8
(3,660 Views)