LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically create Variant Data Socket items with multiple writers

I want to use variant or cluster items with data socket connection. I want to allow multiple writers.

So far I can create these items dynamically but not set them to allow multiple writers.

For numeric, string, and Boolean items I can set these properties by predefining them in the data socket server manager. I could not predefine a variant or cluster in the manager.

I realize I can flatten to string the item needed but would prefer to do this in the cluster or variant formats.

Any suggestions?
0 Kudos
Message 1 of 6
(2,881 Views)
Hi Randall,

Once you have dynamically created the cluster and variant Datasocket data-items, you should be able to have multiple writers for these items. No additional setting is required. Please refer the attached VI (in this VI there are two publishers and only one subscriber for variant and cluster data).

As for predefining variant and cluster datatypes, currently that is not possible without flattening to string first.

Ankita
Message 2 of 6
(2,871 Views)
Ankita:

Thank you for your reply.

This example worked well until I tried to write to the data socket from another P.C.

I then would get a message that it was unable to connect because another connection is made. When I disabled the connections that published in your example on the server, then enabled the connection in the remote PC it worked fine.

Again thanks for the example.

Randall
0 Kudos
Message 3 of 6
(2,860 Views)
Hi Randall,

I apologize for the oversight. You are right. You cannot have multiple writers from two different pcs unless you use predefined data items. But with predefined you cannot use variant/cluster directly.

Ankita
0 Kudos
Message 4 of 6
(2,851 Views)
Could you accomplish this using a functional global architecture??
Message 5 of 6
(2,844 Views)

@unclebump wrote:
Could you accomplish this using a functional global architecture??





An interesting concept which might work and did just open up a new host of possibilities!

When I get the time I might give this a try. I just did a quick test in another program.

Through VI server I opened a reference to a remote machine. I then created strictly typed reference to a “functional global vi” that I knew would be in memory. It reads the functional global just fine!

Thanks for the suggestion.

Here is the work around I used for the data socket program.

Here is the original problem.
I needed to know on the server side when a new value was written to the message cluster, which consisted of a string and a variant. Checking the string portion of the cluster let me know what command to send the device being controlled on the server machine. The variant is used to hold the various parameters that accompanied the command. Since the same command type could be sent several times I needed to reset the string control after the server read the command. This required writing to the data socket from the client & server machine (multiple writers). Also since the client could be any PC in the subnet I needed to allow all these machines to have write access.

I solved this by using a second data socket item for the new message flag. This item is a string value that could be pre-defined and set to allow multiple writers. I then used the cluster item to handle the commands and wrote to the string item a signal that a new command was ready. The server then recognizes a new command is ready, reads the command, and then flags the string message received.

Thanks again for those who took the time to answer this.

Randall
0 Kudos
Message 6 of 6
(2,834 Views)