05-06-2009 01:39 PM
I would like to send a cluster over TCP between two VIs. I looked up and modified the two TCP example files provided by LabView. These examples are found in the help documentation under the title “Creating a TCP Server”.
I modified files (attached to this post) to send a cluster over a TCP server. However, the clusters I will be using in the future are very large and can have several layers of clusters within clusters, as well as various data type controls in the clusters. In the “Simple Data Client_Cluster.vi” block diagram, I would really like to avoid having to define the cluster structure (type) that feeds into the ‘type’ node of the Type Cast Function (which in turn feeds the cluster indicator).
Is there anything I could do to prevent having to recreate this structure (cluster type) on the client side? With large complex structures, you can imagine how inconvenient it would be to have to build this structure during application. Is there any alternative to this solution that would make sending larger clusters over a server easier?
I am relatively new to LabView and I apologize if the answer is very simple and obvious.
Thanks!
Solved! Go to Solution.
05-06-2009 01:50 PM
I have a similar dislike of that approach.
I perfer to use VI Server in situations where I can. VI server "Invoke Node" Call by Reference" will operate across platforms so you can open a reference to the LV instance running on another machine and then open a reference to a VI running in that context. The Call by refeernece will take the values you pass to it, trasfer that data (regardless of the structure), execute the VI you referenced and will move the results back to the machine that invoked the code. It still uses TCP/IP under the hood but LV takes care of all of the data conversions and the lower level stuff. Thies scheme works particularly well when used with Action Engines.
Have fun!
Ben
05-06-2009 02:26 PM
05-06-2009 02:36 PM - edited 05-06-2009 02:44 PM
Ben... Thanks for the response!
I will have to play around with what you said a bit more before i figure it out. Unfortuantely at this point, I learn by example.
05-06-2009 02:45 PM
nathand wrote:
I think you're missing the idea of a type definition, which lets you define the cluster in a single place. You can then create front panel controls and indicators and block diagram constants that are linked to that type definition so that when you update the type definition, all instances of it update as well. Look at the help for creating type definitions. You'll want to take your front panel cluster control, right-click on the border, choose Advanced->Customize, and in the window that appears, change the type from "Control" to "Type Def." or "Strict Type Def." (the difference is cosmetic, see the help for details). Save that control and replace the original cluster with it. Then, in the client VI, replace the cluster constant with an instance of the type definition, which you can drop on the block diagram by choosing Select a VI... and selecting the control you created. Now when you change the cluster it will update in both the server and client at the same time.
YES! I had completely forgotten about the use of Type Def from my labview training. This is probably the best solution to my problem. Thanks for the post.
12-20-2009 08:51 PM
Hi,
I am using the sample VI program as mentioned by the thread starter joe. What i have done is that i had modified it with a DAQ device. Right now i am receiving data from Analog Input channel 0 and 1 from the DAQ hardware. However, i need to sent the data through TCP/IP vi, so that I can sent two data (from 2 channel of DAQ) and receive it as the server terminal.
Currently, i can only think of two methods, combined the datas from 2 channel from DAQ into a string and sent through tcp and convert it back to dbl at the server. Or should i use different port to sent 2 different data?
thks in adv.
12-20-2009 10:09 PM
12-20-2009 11:23 PM
Hi Ravens Fan ,
thk you for sugguesting that. i do agree with you that the 1st method is more fesiable. However, since i have a series of data input from my DAQ card. Therefore i have a wire containing dynamic data form in several channels. I tried to send it the form of string according to the channel order. I manage to send it in a long string in sequece. such as 1st string is data 1, 2nd string is data 2. Can u explain how do I decode at the receiving end?
12-20-2009 11:54 PM
12-21-2009 02:58 AM
Hi raven,
sorry i dun understand what you meant as flatten to string. In my program i convert the dynamic data type to 1D array dbl. After which how can i convert it to string? How can I bundle them into string, so that i can transfer them over thru the TCP? I thks your patience in guiding them.