GregFreeman Posted October 3, 2013 Report Share Posted October 3, 2013 (edited) I have a customer that is writing an application with C# .Net and measurement studio. Can anyone give advice on flattening and sending structures over TCP/IP to LabVIEW, and unflattening them on the other side? Is there a relatively easy way to accomplish this, or will we have to write my own flattening/unflattening methods? I know we can use shared variables with measurement studio, but I don't like the idea of this. Some of the data is config data, and there is a chance it could be overwritten before we read it. That combined with the fact that I've had painful shared variable experiences means this is not really an option. Edited October 3, 2013 by for(imstuck) Quote Link to comment
Rolf Kalbermatter Posted October 3, 2013 Report Share Posted October 3, 2013 It's not really that difficult to stream data over a TCP/IP connection and in fact it is a bit more trivial in LabVIEW than in C(++)(#) but even there it is doable. You need to take care about byte order, which is big endian if you use the native LabVIEW flattening functions and also padding but in general LabVIEW is packing data as much as possible, except for booleans which are sent as byte. So you (or your collegue) will likely want to use some sort of C# library that allows to send data in big endian form over a stream. Most likely you will need to have some specific code on the C# side to flatten and unflatten the structures into and from the stream. Writing a general purpose library that can flatten and unflatten any form of structure into stream is most likely to much of a hassle, also because C# doesn't really know something like a cluster but uses classes for everything. So there is not a strict order in memory like for a structure in C. You could of course use create a library that uses reflection in C# to stream arbitrary structure classes on a wire but you have to be very careful that the order of elements in the class definition would stay consistent with what you use on the LabVIEW side in the cluster. Quote Link to comment
ShaunR Posted October 4, 2013 Report Share Posted October 4, 2013 (edited) I have a customer that is writing an application with C# .Net and measurement studio. Can anyone give advice on flattening and sending structures over TCP/IP to LabVIEW, and unflattening them on the other side? Is there a relatively easy way to accomplish this, or will we have to write my own flattening/unflattening methods? I know we can use shared variables with measurement studio, but I don't like the idea of this. Some of the data is config data, and there is a chance it could be overwritten before we read it. That combined with the fact that I've had painful shared variable experiences means this is not really an option. Flatten to JSON. You'll be able to use clusters on your side and they can use equivalent objects on the other side (within reason) Edited October 4, 2013 by ShaunR Quote Link to comment
GregFreeman Posted October 11, 2013 Author Report Share Posted October 11, 2013 Thanks, I think we are going to go the JSON route, especially since those VIs are now built into LabVIEW 2013. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.